Search in sources :

Example 91 with TTransportException

use of org.apache.thrift.transport.TTransportException in project brisk by riptano.

the class BriskTool method getConnection.

private Brisk.Iface getConnection() throws IOException {
    TTransport trans = new TFramedTransport(new TSocket(host, port));
    try {
        trans.open();
    } catch (TTransportException e) {
        throw new IOException("unable to connect to brisk server");
    }
    Brisk.Iface client = new Brisk.Client(new TBinaryProtocol(trans));
    return client;
}
Also used : TBinaryProtocol(org.apache.cassandra.thrift.TBinaryProtocol) TFramedTransport(org.apache.thrift.transport.TFramedTransport) Brisk(org.apache.cassandra.thrift.Brisk) Iface(org.apache.cassandra.thrift.Brisk.Iface) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) IOException(java.io.IOException) TSocket(org.apache.thrift.transport.TSocket)

Example 92 with TTransportException

use of org.apache.thrift.transport.TTransportException in project presto by prestodb.

the class MockHiveMetastoreClientFactory method create.

@Override
public HiveMetastoreClient create(String host, int port) throws TTransportException {
    checkState(!clients.isEmpty(), "mock not given enough clients");
    HiveMetastoreClient client = clients.remove(0);
    if (client == null) {
        throw new TTransportException(TTransportException.TIMED_OUT);
    }
    return client;
}
Also used : TTransportException(org.apache.thrift.transport.TTransportException) HiveMetastoreClient(com.facebook.presto.hive.metastore.HiveMetastoreClient)

Example 93 with TTransportException

use of org.apache.thrift.transport.TTransportException in project presto by prestodb.

the class StaticHiveCluster method createMetastoreClient.

/**
     * Create a metastore client connected to the Hive metastore.
     * <p>
     * As per Hive HA metastore behavior, return the first metastore in the list
     * list of available metastores (i.e. the default metastore) if a connection
     * can be made, else try another of the metastores at random, until either a
     * connection succeeds or there are no more fallback metastores.
     */
@Override
public HiveMetastoreClient createMetastoreClient() {
    List<HostAndPort> metastores = new ArrayList<>(addresses);
    Collections.shuffle(metastores.subList(1, metastores.size()));
    TTransportException lastException = null;
    for (HostAndPort metastore : metastores) {
        try {
            return clientFactory.create(metastore.getHostText(), metastore.getPort());
        } catch (TTransportException e) {
            lastException = e;
        }
    }
    throw new PrestoException(HIVE_METASTORE_ERROR, "Failed connecting to Hive metastore: " + addresses, lastException);
}
Also used : HostAndPort(com.google.common.net.HostAndPort) ArrayList(java.util.ArrayList) TTransportException(org.apache.thrift.transport.TTransportException) PrestoException(com.facebook.presto.spi.PrestoException)

Example 94 with TTransportException

use of org.apache.thrift.transport.TTransportException in project akela by mozilla-metrics.

the class ClusterHealth method testThrift.

private static boolean testThrift(String host) {
    boolean ret = false;
    TTransport transport = null;
    try {
        transport = new TSocket(host, 9090, 3000);
        Hbase.Client client = new Hbase.Client(new TBinaryProtocol(transport));
        transport.open();
        client.getColumnDescriptors(ByteBuffer.wrap(META_TABLE_NAME));
        System.out.println(String.format("%s ThriftServer - [ ALIVE ]", new Object[] { host }));
        ret = true;
    } catch (TTransportException e) {
        System.out.println(String.format("%s ThriftServer - [ DEAD ] - %s", new Object[] { host, e.getMessage() }));
    } catch (IOError e) {
        System.out.println(String.format("%s ThriftServer - [ DEAD ] - %s", new Object[] { host, e.getMessage() }));
    } catch (TException e) {
        System.out.println(String.format("%s ThriftServer - [ DEAD ] - %s", new Object[] { host, e.getMessage() }));
    } finally {
        if (transport != null) {
            transport.close();
        }
    }
    return ret;
}
Also used : TException(org.apache.thrift.TException) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) IOError(org.apache.hadoop.hbase.thrift.generated.IOError) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) DFSClient(org.apache.hadoop.hdfs.DFSClient) Hbase(org.apache.hadoop.hbase.thrift.generated.Hbase) TSocket(org.apache.thrift.transport.TSocket)

Example 95 with TTransportException

use of org.apache.thrift.transport.TTransportException in project alluxio by Alluxio.

the class BlockWorkerClientAuthenticationIntegrationTest method customAuthenticationDenyConnect.

@Test(timeout = 10000)
@LocalAlluxioClusterResource.Config(confParams = { PropertyKey.Name.SECURITY_AUTHENTICATION_TYPE, "CUSTOM", PropertyKey.Name.SECURITY_AUTHENTICATION_CUSTOM_PROVIDER_CLASS, NameMatchAuthenticationProvider.FULL_CLASS_NAME, PropertyKey.Name.SECURITY_LOGIN_USERNAME, "alluxio", PropertyKey.Name.USER_RPC_RETRY_MAX_NUM_RETRY, "1" })
public void customAuthenticationDenyConnect() throws Exception {
    boolean failedToConnect = false;
    // Using no-alluxio as loginUser to connect to Worker, the IOException will be thrown
    LoginUserTestUtils.resetLoginUser("no-alluxio");
    try (BlockWorkerClient blockWorkerClient = FileSystemContext.INSTANCE.createBlockWorkerClient(mLocalAlluxioClusterResource.get().getWorkerAddress(), (long) 1)) {
        // Just to supress the "Empty try block" warning in CheckStyle.
        failedToConnect = false;
    } catch (IOException e) {
        if (e.getCause() instanceof TTransportException) {
            failedToConnect = true;
        }
    } finally {
        ClientTestUtils.resetClient();
    }
    Assert.assertTrue(failedToConnect);
}
Also used : TTransportException(org.apache.thrift.transport.TTransportException) BlockWorkerClient(alluxio.client.block.BlockWorkerClient) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

TTransportException (org.apache.thrift.transport.TTransportException)165 TTransport (org.apache.thrift.transport.TTransport)43 TException (org.apache.thrift.TException)42 Test (org.junit.Test)39 IOException (java.io.IOException)38 TSocket (org.apache.thrift.transport.TSocket)38 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)29 TProtocol (org.apache.thrift.protocol.TProtocol)26 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)24 TServerSocket (org.apache.thrift.transport.TServerSocket)15 ArrayList (java.util.ArrayList)13 TFramedTransport (org.apache.thrift.transport.TFramedTransport)13 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)11 HostAndPort (org.apache.accumulo.core.util.HostAndPort)10 InetSocketAddress (java.net.InetSocketAddress)9 AccumuloException (org.apache.accumulo.core.client.AccumuloException)9 Function (org.apache.hadoop.hive.metastore.api.Function)9 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)8 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)8 Partition (org.apache.hadoop.hive.metastore.api.Partition)8