use of org.apache.thrift.protocol.TBinaryProtocol in project logprocessing by cloudian.
the class CassandraClient method open.
public void open() throws IOException {
try {
this.currentServer = this.serverSet.get();
} catch (ServerSet.NoServersAvailableException e) {
throw new IOException("No Cassandra servers available.");
}
int splitIndex = this.currentServer.indexOf(':');
if (splitIndex == -1) {
throw new IOException("Bad host:port pair: " + this.currentServer);
}
String host = this.currentServer.substring(0, splitIndex);
int port = Integer.parseInt(this.currentServer.substring(splitIndex + 1));
TSocket sock = new TSocket(host, port);
this.transport = new TFramedTransport(sock);
TProtocol protocol = new TBinaryProtocol(transport);
this.client = new Cassandra.Client(protocol);
try {
this.transport.open();
this.client.set_keyspace(this.keyspace);
} catch (TException texc) {
throw new IOException(texc.getMessage());
} catch (InvalidRequestException exc) {
throw new IOException(exc.getMessage());
}
}
use of org.apache.thrift.protocol.TBinaryProtocol in project commons by twitter.
the class PingPongClient method run.
@Override
public void run() {
TTransport transport = new TSocket("localhost", THRIFT_PORT.get());
try {
transport.open();
} catch (TTransportException e) {
throw new RuntimeException(e);
}
TProtocol protocol = new TBinaryProtocol(transport);
PingPong.Client client = new PingPong.Client(protocol);
try {
LOG.info("Pinging...");
LOG.info(client.ping());
} catch (TException e) {
throw new RuntimeException(e);
}
}
use of org.apache.thrift.protocol.TBinaryProtocol in project distributedlog by twitter.
the class Utils method parseMessage.
public static Message parseMessage(byte[] data) throws TException {
Message msg = new Message();
TMemoryInputTransport transport = new TMemoryInputTransport(data);
TBinaryProtocol protocol = new TBinaryProtocol(transport);
msg.read(protocol);
return msg;
}
use of org.apache.thrift.protocol.TBinaryProtocol 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.protocol.TBinaryProtocol 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);
}
Aggregations