use of org.apache.thrift.transport.TSocket in project eiger by wlloyd.
the class ClientOnlyExample method createConnection.
private static Cassandra.Client createConnection(String host, Integer port, boolean framed) throws TTransportException {
TSocket socket = new TSocket(host, port);
TTransport trans = framed ? new TFramedTransport(socket) : socket;
trans.open();
TProtocol protocol = new TBinaryProtocol(trans);
return new Cassandra.Client(protocol);
}
use of org.apache.thrift.transport.TSocket in project eiger by wlloyd.
the class TestRingCache method setup.
private void setup(String server, int port) throws Exception {
/* Establish a thrift connection to the cassandra instance */
TSocket socket = new TSocket(server, port);
System.out.println(" connected to " + server + ":" + port + ".");
TBinaryProtocol binaryProtocol = new TBinaryProtocol(new TFramedTransport(socket));
Cassandra.Client cassandraClient = new Cassandra.Client(binaryProtocol);
socket.open();
thriftClient = cassandraClient;
String seed = DatabaseDescriptor.getSeeds().iterator().next().getHostAddress();
conf = new Configuration();
ConfigHelper.setOutputPartitioner(conf, DatabaseDescriptor.getPartitioner().getClass().getName());
ConfigHelper.setOutputInitialAddress(conf, seed);
ConfigHelper.setOutputRpcPort(conf, Integer.toString(DatabaseDescriptor.getRpcPort()));
}
use of org.apache.thrift.transport.TSocket in project eiger by wlloyd.
the class ConfigHelper method createConnection.
public static Cassandra.Client createConnection(String host, Integer port, boolean framed) throws IOException {
TSocket socket = new TSocket(host, port);
TTransport trans = framed ? new TFramedTransport(socket) : socket;
try {
trans.open();
} catch (TTransportException e) {
throw new IOException("unable to connect to server", e);
}
return new Cassandra.Client(new TBinaryProtocol(trans));
}
use of org.apache.thrift.transport.TSocket in project eiger by wlloyd.
the class EmbeddedCassandraServiceTest method getClient.
/**
* Gets a connection to the localhost client
*
* @return
* @throws TTransportException
*/
private Cassandra.Client getClient() throws TTransportException {
TTransport tr = new TFramedTransport(new TSocket("localhost", DatabaseDescriptor.getRpcPort()));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
return client;
}
use of org.apache.thrift.transport.TSocket in project presto by prestodb.
the class Transport method createRaw.
private static TTransport createRaw(String host, int port, HostAndPort socksProxy, int timeoutMillis) throws TTransportException {
if (socksProxy == null) {
return new TSocket(host, port, timeoutMillis);
}
Socket socks = createSocksSocket(socksProxy);
try {
try {
socks.connect(InetSocketAddress.createUnresolved(host, port), timeoutMillis);
socks.setSoTimeout(timeoutMillis);
return new TSocket(socks);
} catch (Throwable t) {
closeQuietly(socks);
throw t;
}
} catch (IOException e) {
throw new TTransportException(e);
}
}
Aggregations