private void connect() throws IOException { if (LOG.isTraceEnabled()) { LOG.trace("Trying to connect to " + host.getAddress()); } // Use connection timeout to connect socket = new TSocket(host.getAddress().getHostName(), host.getAddress().getPortNumber(), establishConnectionTimeoutMs); transport = new TFramedTransport(socket); try { transport.open(); // Set socket timeout to regular mode setSocketTimeout(queryTimeoutMs); } catch (TTransportException e) { LOG.error("Failed to establish connection to host " + host.getAddress(), e); disconnect(); throw new IOException("Failed to establish connection to host " + host.getAddress(), e); } TProtocol proto = new TCompactProtocol(transport); client = new PartitionServer.Client(proto); if (LOG.isTraceEnabled()) { LOG.trace("Connection to " + host.getAddress() + " opened."); } }
@Override public void run() { TSocket socket = null; TFramedTransport transport = null; try { socket = new TSocket(host.getAddress().getHostName(), host.getAddress().getPortNumber(), 0); transport = new TFramedTransport(socket); transport.open(); TProtocol proto = new TCompactProtocol(transport); com.liveramp.hank.generated.PartitionServer.Client client = new com.liveramp.hank.generated.PartitionServer.Client(proto); // Perform queries for (int i = 0; i < NUM_WARMUP_QUERIES_PER_THREAD; i++) { client.get(0, ByteBuffer.wrap(new byte[0])); } } catch (TException e) { LOG.error("Failed to warm up data server", e); throw new RuntimeException("Failed to warm up data server", e); } finally { if (transport != null) { transport.close(); } if (socket != null) { socket.close(); } } } }
public HankResponse getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_get(); } }
public Client getClient(org.apache.thrift.protocol.TProtocol prot) { return new Client(prot); } public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
public HankBulkResponse getResult() throws org.apache.thrift.TException { if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { throw new IllegalStateException("Method call not finished!"); } org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); return (new Client(prot)).recv_getBulk(); } }
public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { return new Client(iprot, oprot); } }