use of org.apache.accumulo.core.util.HostAndPort in project accumulo by apache.
the class InstanceOperationsImpl method getActiveCompactions.
@Override
public List<ActiveCompaction> getActiveCompactions(String tserver) throws AccumuloException, AccumuloSecurityException {
final HostAndPort parsedTserver = HostAndPort.fromString(tserver);
Client client = null;
try {
client = ThriftUtil.getTServerClient(parsedTserver, context);
List<ActiveCompaction> as = new ArrayList<>();
for (org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction activeCompaction : client.getActiveCompactions(Tracer.traceInfo(), context.rpcCreds())) {
as.add(new ActiveCompactionImpl(context.getInstance(), activeCompaction));
}
return as;
} catch (TTransportException e) {
throw new AccumuloException(e);
} catch (ThriftSecurityException e) {
throw new AccumuloSecurityException(e.user, e.code, e);
} catch (TException e) {
throw new AccumuloException(e);
} finally {
if (client != null)
ThriftUtil.returnClient(client);
}
}
use of org.apache.accumulo.core.util.HostAndPort in project accumulo by apache.
the class InstanceOperationsImpl method getActiveScans.
@Override
public List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException {
final HostAndPort parsedTserver = HostAndPort.fromString(tserver);
Client client = null;
try {
client = ThriftUtil.getTServerClient(parsedTserver, context);
List<ActiveScan> as = new ArrayList<>();
for (org.apache.accumulo.core.tabletserver.thrift.ActiveScan activeScan : client.getActiveScans(Tracer.traceInfo(), context.rpcCreds())) {
try {
as.add(new ActiveScanImpl(context.getInstance(), activeScan));
} catch (TableNotFoundException e) {
throw new AccumuloException(e);
}
}
return as;
} catch (TTransportException e) {
throw new AccumuloException(e);
} catch (ThriftSecurityException e) {
throw new AccumuloSecurityException(e.user, e.code, e);
} catch (TException e) {
throw new AccumuloException(e);
} finally {
if (client != null)
ThriftUtil.returnClient(client);
}
}
use of org.apache.accumulo.core.util.HostAndPort in project accumulo by apache.
the class MasterClient method getConnection.
public static MasterClientService.Client getConnection(ClientContext context) {
checkArgument(context != null, "context is null");
List<String> locations = context.getInstance().getMasterLocations();
if (locations.size() == 0) {
log.debug("No masters...");
return null;
}
HostAndPort master = HostAndPort.fromString(locations.get(0));
if (0 == master.getPort())
return null;
try {
// Master requests can take a long time: don't ever time out
MasterClientService.Client client = ThriftUtil.getClientNoTimeout(new MasterClientService.Client.Factory(), master, context);
return client;
} catch (TTransportException tte) {
Throwable cause = tte.getCause();
if (null != cause && cause instanceof UnknownHostException) {
// do not expect to recover from this
throw new RuntimeException(tte);
}
log.debug("Failed to connect to master=" + master + ", will retry... ", tte);
return null;
}
}
Aggregations