Use fewer simultaneous connections to Directory API

Ten turns out to have been set too high; that will occasionally throw
500 Backend errors from the API (presumably having to do with
rate-limiting).
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=117549363
This commit is contained in:
mcilwain 2016-03-18 08:28:27 -07:00 committed by Justine Tunney
parent 68c0f4647f
commit 9f548674b7

View file

@ -50,6 +50,7 @@ public class CreateGroupsAction implements Runnable {
public static final String CLIENT_ID_PARAM = "clientId"; public static final String CLIENT_ID_PARAM = "clientId";
private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass(); private static final FormattingLogger logger = FormattingLogger.getLoggerForCallerClass();
private static final int NUM_SIMULTANEOUS_CONNECTIONS = 5;
@Inject GroupsConnection groupsConnection; @Inject GroupsConnection groupsConnection;
@Inject Response response; @Inject Response response;
@ -66,7 +67,9 @@ public class CreateGroupsAction implements Runnable {
List<RegistrarContact.Type> types = asList(RegistrarContact.Type.values()); List<RegistrarContact.Type> types = asList(RegistrarContact.Type.values());
// Concurrently create the groups for each RegistrarContact.Type, collecting the results from // Concurrently create the groups for each RegistrarContact.Type, collecting the results from
// each call (which are either an Exception if it failed, or absent() if it succeeded). // each call (which are either an Exception if it failed, or absent() if it succeeded).
List<Optional<Exception>> results = Concurrent.transform(types, List<Optional<Exception>> results = Concurrent.transform(
types,
NUM_SIMULTANEOUS_CONNECTIONS,
new Function<RegistrarContact.Type, Optional<Exception>>() { new Function<RegistrarContact.Type, Optional<Exception>>() {
@Override @Override
public Optional<Exception> apply(Type type) { public Optional<Exception> apply(Type type) {