Search in sources :

Example 1 with ReplicationCoordinatorException

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

the class MasterReplicationCoordinator method getServicerAddress.

@Override
public String getServicerAddress(String remoteTableId, TCredentials creds) throws ReplicationCoordinatorException, TException {
    try {
        security.authenticateUser(master.rpcCreds(), creds);
    } catch (ThriftSecurityException e) {
        log.error("{} failed to authenticate for replication to {}", creds.getPrincipal(), remoteTableId);
        throw new ReplicationCoordinatorException(ReplicationCoordinatorErrorCode.CANNOT_AUTHENTICATE, "Could not authenticate " + creds.getPrincipal());
    }
    Set<TServerInstance> tservers = master.onlineTabletServers();
    if (tservers.isEmpty()) {
        throw new ReplicationCoordinatorException(ReplicationCoordinatorErrorCode.NO_AVAILABLE_SERVERS, "No tservers are available for replication");
    }
    TServerInstance tserver = getRandomTServer(tservers, rand.nextInt(tservers.size()));
    String replServiceAddr;
    try {
        replServiceAddr = new String(reader.getData(ZooUtil.getRoot(inst) + ReplicationConstants.ZOO_TSERVERS + "/" + tserver.hostPort(), null), UTF_8);
    } catch (KeeperException | InterruptedException e) {
        log.error("Could not fetch repliation service port for tserver", e);
        throw new ReplicationCoordinatorException(ReplicationCoordinatorErrorCode.SERVICE_CONFIGURATION_UNAVAILABLE, "Could not determine port for replication service running at " + tserver.hostPort());
    }
    return replServiceAddr;
}
Also used : ReplicationCoordinatorException(org.apache.accumulo.core.replication.thrift.ReplicationCoordinatorException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)1 ReplicationCoordinatorException (org.apache.accumulo.core.replication.thrift.ReplicationCoordinatorException)1 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)1 KeeperException (org.apache.zookeeper.KeeperException)1