@Override public TTransport getTransport(TTransport base) { return new TFramedTransport(base, maxLength_); } }
private void doReadingResponseSize() throws IOException { if (transport.read(sizeBuffer) < 0) { throw new IOException("Read call frame size failed"); } if (sizeBuffer.remaining() == 0) { state = State.READING_RESPONSE_BODY; frameBuffer = ByteBuffer.allocate(TFramedTransport.decodeFrameSize(sizeBufferArray)); } }
/** * Write the given integer as 4 bytes to the underlying transport. * * @param length * The length prefix of the next SASL message to write. * @throws TTransportException * Thrown if writing to the underlying transport fails. */ protected void writeLength(int length) throws TTransportException { byte[] lenBuf = new byte[4]; TFramedTransport.encodeFrameSize(length, lenBuf); underlyingTransport.write(lenBuf); }
public int read(byte[] buf, int off, int len) throws TTransportException { if (readBuffer_ != null) { int got = readBuffer_.read(buf, off, len); if (got > 0) { return got; } } // Read another frame of data readFrame(); return readBuffer_.read(buf, off, len); }
public int read(byte[] buf, int off, int len) throws TTransportException { if (readBuffer_ != null) { int got = readBuffer_.read(buf, off, len); if (got > 0) { return got; } } // Read another frame of data readFrame(); return readBuffer_.read(buf, off, len); }
@Override public TTransport getTransport(TTransport base) { return new TFramedTransport(base, maxLength_); } }
/** * Write the given integer as 4 bytes to the underlying transport. * * @param length * The length prefix of the next SASL message to write. * @throws TTransportException * Thrown if writing to the underlying transport fails. */ protected void writeLength(int length) throws TTransportException { byte[] lenBuf = new byte[4]; TFramedTransport.encodeFrameSize(length, lenBuf); underlyingTransport.write(lenBuf); }
private void doReadingResponseSize() throws IOException { if (transport.read(sizeBuffer) < 0) { throw new IOException("Read call frame size failed"); } if (sizeBuffer.remaining() == 0) { state = State.READING_RESPONSE_BODY; frameBuffer = ByteBuffer.allocate(TFramedTransport.decodeFrameSize(sizeBufferArray)); } }
private LCSThriftService.Client createLCSThriftClient() { TSocket socket = new TSocket( lcsAgentHostname, lcsAgentPort, 4096 * 512); TTransport transport = new TFramedTransport(socket); try { transport.open(); } catch (TTransportException e) { logger.info("Failed to create client for LCSAgent: " + lcsAgentHostname + ":" + lcsAgentPort, e); return null; } TProtocol protocol = new TCompactProtocol(transport); return new LCSThriftService.Client(protocol); } }
/** * Initialize buffers. * @throws TException if buffer initialization fails */ protected void prepareMethodCall() throws TException { TMemoryBuffer memoryBuffer = new TMemoryBuffer(INITIAL_MEMORY_BUFFER_SIZE); TProtocol protocol = protocolFactory.getProtocol(memoryBuffer); write_args(protocol); int length = memoryBuffer.length(); frameBuffer = ByteBuffer.wrap(memoryBuffer.getArray(), 0, length); TFramedTransport.encodeFrameSize(length, sizeBufferArray); sizeBuffer = ByteBuffer.wrap(sizeBufferArray); }
private void readFrame() throws TTransportException { underlying.readAll(i32buf , 0, 4); int size = TFramedTransport.decodeFrameSize(i32buf); if (size < 0) { throw new TTransportException("Read a negative frame size (" + size + ")!"); } if (size > maxLength) { throw new TTransportException("Frame size (" + size + ") larger than max length (" + maxLength + ")!"); } readBuffer.fill(underlying, size); }
/** * Initialize buffers. * @throws TException if buffer initialization fails */ protected void prepareMethodCall() throws TException { TMemoryBuffer memoryBuffer = new TMemoryBuffer(INITIAL_MEMORY_BUFFER_SIZE); TProtocol protocol = protocolFactory.getProtocol(memoryBuffer); write_args(protocol); int length = memoryBuffer.length(); frameBuffer = ByteBuffer.wrap(memoryBuffer.getArray(), 0, length); TFramedTransport.encodeFrameSize(length, sizeBufferArray); sizeBuffer = ByteBuffer.wrap(sizeBufferArray); }
private void readFrame() throws TTransportException { underlying.readAll(i32buf , 0, 4); int size = TFramedTransport.decodeFrameSize(i32buf); if (size < 0) { throw new TTransportException("Read a negative frame size (" + size + ")!"); } if (size > maxLength) { throw new TTransportException("Frame size (" + size + ") larger than max length (" + maxLength + ")!"); } readBuffer.fill(underlying, size); }
@Override public void flush() throws TTransportException { byte[] buf = writeBuffer_.get(); int len = writeBuffer_.len(); writeBuffer_.reset(); encodeFrameSize(len, i32buf); transport_.write(i32buf, 0, 4); transport_.write(buf, 0, len); transport_.flush(); }
private void readFrame() throws TTransportException { transport_.readAll(i32buf, 0, 4); int size = decodeFrameSize(i32buf); if (size < 0) { throw new TTransportException("Read a negative frame size (" + size + ")!"); } if (size > maxLength_) { throw new TTransportException("Frame size (" + size + ") larger than max length (" + maxLength_ + ")!"); } byte[] buff = new byte[size]; transport_.readAll(buff, 0, size); readBuffer_.reset(buff); }
@Override public void flush() throws TTransportException { byte[] buf = writeBuffer_.get(); int len = writeBuffer_.len(); writeBuffer_.reset(); encodeFrameSize(len, i32buf); transport_.write(i32buf, 0, 4); transport_.write(buf, 0, len); transport_.flush(); }
private void readFrame() throws TTransportException { transport_.readAll(i32buf, 0, 4); int size = decodeFrameSize(i32buf); if (size < 0) { throw new TTransportException("Read a negative frame size (" + size + ")!"); } if (size > maxLength_) { throw new TTransportException("Frame size (" + size + ") larger than max length (" + maxLength_ + ")!"); } byte[] buff = new byte[size]; transport_.readAll(buff, 0, size); readBuffer_.reset(buff); }
@Override public void flush() throws TTransportException { int length = writeBuffer.getPos(); TFramedTransport.encodeFrameSize(length, i32buf); underlying.write(i32buf, 0, 4); underlying.write(writeBuffer.getBuf().array(), 0, length); writeBuffer.reset(); underlying.flush(); }
@Override public void flush() throws TTransportException { int length = writeBuffer.getPos(); TFramedTransport.encodeFrameSize(length, i32buf); underlying.write(i32buf, 0, 4); underlying.write(writeBuffer.getBuf().array(), 0, length); writeBuffer.reset(); underlying.flush(); }