Skip to content

Commit

Permalink
Add backoff and rety to GCP directory listings. (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnrengelman authored and Travis Tomsu committed Oct 31, 2017
1 parent 75c950b commit ac964c1
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
import com.google.api.client.googleapis.batch.BatchRequest;
import com.google.api.client.googleapis.batch.json.JsonBatchCallback;
import com.google.api.client.googleapis.json.GoogleJsonError;
import com.google.api.client.googleapis.json.GoogleJsonErrorContainer;
import com.google.api.client.http.HttpBackOffUnsuccessfulResponseHandler;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.util.ExponentialBackOff;
import com.google.api.services.admin.directory.Directory;
import com.google.api.services.admin.directory.DirectoryScopes;
import com.google.api.services.admin.directory.model.Group;
Expand Down Expand Up @@ -114,11 +118,14 @@ public Map<String, Collection<Role>> multiLoadRoles(Collection<String> userEmail
try {
GroupBatchCallback callback = new GroupBatchCallback().setEmailGroupsMap(emailGroupsMap)
.setEmail(email);
service.groups()
HttpRequest request = service.groups()
.list()
.setDomain(config.getDomain())
.setUserKey(email)
.queue(batch, callback);
.buildHttpRequest();
request.setUnsuccessfulResponseHandler(new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()));
batch.queue(request, Groups.class, GoogleJsonErrorContainer.class, callback);

} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
Expand Down

0 comments on commit ac964c1

Please sign in to comment.