@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(); } } } }
HankBulkResponse result = client.getBulk(domainId, keys); if (result.is_set_xception()) { throw new IOException("Server failed to execute GET BULK: " + result.get_xception());
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(); } }
HankResponse result = client.get(domainId, key); if (result.is_set_xception()) { throw new IOException("Server failed to execute GET: " + result.get_xception());
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."); } }
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 void send_getBulk(int domain_id, List<ByteBuffer> keys) throws org.apache.thrift.TException { getBulk_args args = new getBulk_args(); args.set_domain_id(domain_id); args.set_keys(keys); sendBase("getBulk", args); }
public HankResponse recv_get() throws org.apache.thrift.TException { get_result result = new get_result(); receiveBase(result, "get"); if (result.is_set_success()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "get failed: unknown result"); }
public void send_get(int domain_id, ByteBuffer key) throws org.apache.thrift.TException { get_args args = new get_args(); args.set_domain_id(domain_id); args.set_key(key); sendBase("get", args); }
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 HankBulkResponse getBulk(int domain_id, List<ByteBuffer> keys) throws org.apache.thrift.TException { send_getBulk(domain_id, keys); return recv_getBulk(); }
public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { return new Client(iprot, oprot); } }
public HankBulkResponse recv_getBulk() throws org.apache.thrift.TException { getBulk_result result = new getBulk_result(); receiveBase(result, "getBulk"); if (result.is_set_success()) { return result.success; } throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getBulk failed: unknown result"); }