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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations