Search in sources :

Example 36 with HostAndPort

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);
    }
}
Also used : ActiveCompaction(org.apache.accumulo.core.client.admin.ActiveCompaction) TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ArrayList(java.util.ArrayList) TTransportException(org.apache.thrift.transport.TTransportException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) HostAndPort(org.apache.accumulo.core.util.HostAndPort) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) Client(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client)

Example 37 with HostAndPort

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);
    }
}
Also used : TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ActiveScan(org.apache.accumulo.core.client.admin.ActiveScan) ArrayList(java.util.ArrayList) TTransportException(org.apache.thrift.transport.TTransportException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) HostAndPort(org.apache.accumulo.core.util.HostAndPort) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) Client(org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client)

Example 38 with HostAndPort

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;
    }
}
Also used : HostAndPort(org.apache.accumulo.core.util.HostAndPort) UnknownHostException(java.net.UnknownHostException) MasterClientService(org.apache.accumulo.core.master.thrift.MasterClientService) TTransportException(org.apache.thrift.transport.TTransportException) TServiceClient(org.apache.thrift.TServiceClient)

Aggregations

HostAndPort (org.apache.accumulo.core.util.HostAndPort)38 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)12 ArrayList (java.util.ArrayList)11 TTransportException (org.apache.thrift.transport.TTransportException)10 AccumuloException (org.apache.accumulo.core.client.AccumuloException)8 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)8 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)8 TException (org.apache.thrift.TException)8 UnknownHostException (java.net.UnknownHostException)7 IOException (java.io.IOException)6 Instance (org.apache.accumulo.core.client.Instance)6 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)6 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)6 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)6 KeeperException (org.apache.zookeeper.KeeperException)6 Test (org.junit.Test)6 Connector (org.apache.accumulo.core.client.Connector)5 Client (org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client)5 MasterClient (org.apache.accumulo.core.client.impl.MasterClient)4 Text (org.apache.hadoop.io.Text)4