Refine search
public void 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); (new Client(prot)).recv_updateAllOutput(); } }
@Override public byte[] getBuffer() { return in.getBuffer(); }
@Test public void testMultipleInheritance() throws Exception { final NameService.Client client1 = new NameService.Client.Factory().getClient(inProto, outProto); client1.send_removeMiddle(new Name(BAZ, BAR, FOO)); assertThat(out.length()).isGreaterThan(0); final HttpData req1 = HttpData.of(out.getArray(), 0, out.length()); out = new TMemoryBuffer(128); outProto = ThriftProtocolFactories.get(defaultSerializationFormat).getProtocol(out); final NameSortService.Client client2 = new NameSortService.Client.Factory().getClient(inProto, outProto); client2.send_sort(Arrays.asList(NAME_C, NAME_B, NAME_A)); assertThat(out.length()).isGreaterThan(0); final HttpData req2 = HttpData.of(out.getArray(), 0, out.length()); final THttpService service = THttpService.of( (UberNameService) (names, callback) -> callback.onComplete( names.stream().sorted().collect(toImmutableList())), defaultSerializationFormat); invoke0(service, req1, promise); invoke0(service, req2, promise2); final HttpData res1 = promise.get(); final HttpData res2 = promise2.get(); in.reset(res1.array(), res1.offset(), res1.length()); assertThat(client1.recv_removeMiddle()).isEqualTo(new Name(BAZ, null, FOO)); in.reset(res2.array(), res2.offset(), res2.length()); assertThat(client2.recv_sort()).containsExactly(NAME_A, NAME_B, NAME_C); }
private static void eagerlyCleanupReadBuffersFromIdleConnection(CassandraClient idleClient, InetSocketAddress host) { // eagerly cleanup idle-connection read buffer to keep a smaller memory footprint try { TTransport transport = idleClient.getInputProtocol().getTransport(); if (transport instanceof TFramedTransport) { Field readBuffer = ((TFramedTransport) transport).getClass().getDeclaredField("readBuffer_"); readBuffer.setAccessible(true); TMemoryInputTransport memoryInputTransport = (TMemoryInputTransport) readBuffer.get(transport); byte[] underlyingBuffer = memoryInputTransport.getBuffer(); if (underlyingBuffer != null && memoryInputTransport.getBytesRemainingInBuffer() == 0) { log.debug("During {} check-in, cleaned up a read buffer of {} bytes of host {}", UnsafeArg.of("pool", idleClient), SafeArg.of("bufferLength", underlyingBuffer.length), SafeArg.of("host", CassandraLogHelper.host(host))); memoryInputTransport.reset(PtBytes.EMPTY_BYTE_ARRAY); } } } catch (Exception e) { log.debug("Couldn't clean up read buffers on pool check-in.", e); } }
public TMemoryInputTransport(byte[] buf) { reset(buf); }
/** * Deserialize the Thrift object from a byte array. * * @param base The object to read into * @param bytes The array to read from * @param offset The offset into {@code bytes} * @param length The length to read from {@code bytes} */ public void deserialize(TBase base, byte[] bytes, int offset, int length) throws TException { try { trans_.reset(bytes, offset, length); base.read(protocol_); } finally { trans_.clear(); protocol_.reset(); } }
private static void eagerlyCleanupReadBuffersFromIdleConnection(CassandraClient idleClient, InetSocketAddress host) { // eagerly cleanup idle-connection read buffer to keep a smaller memory footprint try { TTransport transport = idleClient.getInputProtocol().getTransport(); if (transport instanceof TFramedTransport) { Field readBuffer = ((TFramedTransport) transport).getClass().getDeclaredField("readBuffer_"); readBuffer.setAccessible(true); TMemoryInputTransport memoryInputTransport = (TMemoryInputTransport) readBuffer.get(transport); byte[] underlyingBuffer = memoryInputTransport.getBuffer(); if (underlyingBuffer != null && memoryInputTransport.getBytesRemainingInBuffer() == 0) { log.debug("During {} check-in, cleaned up a read buffer of {} bytes of host {}", UnsafeArg.of("pool", idleClient), SafeArg.of("bufferLength", underlyingBuffer.length), SafeArg.of("host", CassandraLogHelper.host(host))); memoryInputTransport.reset(PtBytes.EMPTY_BYTE_ARRAY); } } } catch (Exception e) { log.debug("Couldn't clean up read buffers on pool check-in.", e); } }
public TMemoryInputTransport(byte[] buf, int offset, int length) { reset(buf, offset, length); }
public void 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); (new Client(prot)).recv_removeAngularObject(); } }
public void reset(byte[] buf) { reset(buf, 0, buf.length); }
@Override public byte[] getBuffer() { return readBuffer_.getBuffer(); }
public ByteBuffer 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_invokeMethod(); } }
private void invoke(THttpService service) throws Exception { invoke0(service, HttpData.of(out.getArray(), 0, out.length()), promise); final HttpData res = promise.get(); in.reset(res.array(), res.offset(), res.length()); }
@Override public byte[] getBuffer() { return readBuffer_.getBuffer(); }
public int 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_getProgress(); } }
private TField locateField(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException { trans_.reset(bytes);
@Override public byte[] getBuffer() { return readBuffer_.getBuffer(); }
public String 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_getFormType(); } }
public void invoke() { frameTrans_.reset(buffer_.array()); response_.reset(); try { if (eventHandler_ != null) { eventHandler_.processContext(context_, inTrans_, outTrans_); } ((TAsyncProcessor)processorFactory_.getProcessor(inTrans_)).process(this); return; } catch (TException te) { LOGGER.warn("Exception while invoking!", te); } catch (Throwable t) { LOGGER.error("Unexpected throwable while invoking!", t); } // This will only be reached when there is a throwable. state_ = FrameBufferState.AWAITING_CLOSE; requestSelectInterestChange(); } }
public List<InterpreterCompletion> 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_completion(); } }