Search in sources :

Example 1 with ReplicationCoordinator

use of org.apache.accumulo.core.replication.thrift.ReplicationCoordinator in project accumulo by apache.

the class ReplicationClient method getCoordinatorConnectionWithRetry.

/**
 * @param context
 *          the client session for the peer replicant
 * @return Client to the ReplicationCoordinator service
 */
public static ReplicationCoordinator.Client getCoordinatorConnectionWithRetry(ClientContext context) throws AccumuloException {
    requireNonNull(context);
    Instance instance = context.getInstance();
    for (int attempts = 1; attempts <= 10; attempts++) {
        ReplicationCoordinator.Client result = getCoordinatorConnection(context);
        if (result != null)
            return result;
        log.debug("Could not get ReplicationCoordinator connection to {}, will retry", instance.getInstanceName());
        try {
            Thread.sleep(attempts * 250);
        } catch (InterruptedException e) {
            throw new AccumuloException(e);
        }
    }
    throw new AccumuloException("Timed out trying to communicate with master from " + instance.getInstanceName());
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) Instance(org.apache.accumulo.core.client.Instance) ReplicationCoordinator(org.apache.accumulo.core.replication.thrift.ReplicationCoordinator)

Aggregations

AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 Instance (org.apache.accumulo.core.client.Instance)1 ReplicationCoordinator (org.apache.accumulo.core.replication.thrift.ReplicationCoordinator)1