本文整理汇总了Java中org.apache.thrift.transport.TMemoryBuffer.length方法的典型用法代码示例。如果您正苦于以下问题:Java TMemoryBuffer.length方法的具体用法?Java TMemoryBuffer.length怎么用?Java TMemoryBuffer.length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.thrift.transport.TMemoryBuffer
的用法示例。
在下文中一共展示了TMemoryBuffer.length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: thriftRequest
import org.apache.thrift.transport.TMemoryBuffer; //导入方法依赖的package包/类
private String thriftRequest(byte[] input){
try{
//Input
TMemoryBuffer inbuffer = new TMemoryBuffer(input.length);
inbuffer.write(input);
TProtocol inprotocol = new TJSONProtocol(inbuffer);
//Output
TMemoryBuffer outbuffer = new TMemoryBuffer(100);
TProtocol outprotocol = new TJSONProtocol(outbuffer);
TProcessor processor = new Calculator.Processor(new CalculatorHandler());
processor.process(inprotocol, outprotocol);
byte[] output = new byte[outbuffer.length()];
outbuffer.readAll(output, 0, output.length);
return new String(output,"UTF-8");
}catch(Throwable t){
return "Error:"+t.getMessage();
}
}
示例2: thriftRequest
import org.apache.thrift.transport.TMemoryBuffer; //导入方法依赖的package包/类
private String thriftRequest(byte[] input){
try{
//Input
TMemoryBuffer inbuffer = new TMemoryBuffer(input.length);
inbuffer.write(input);
TProtocol inprotocol = new TJSONProtocol(inbuffer);
//Output
TMemoryBuffer outbuffer = new TMemoryBuffer(100);
TProtocol outprotocol = new TJSONProtocol(outbuffer);
TProcessor processor = new ThriftTest.Processor(new TestHandler());
processor.process(inprotocol, outprotocol);
byte[] output = new byte[outbuffer.length()];
outbuffer.readAll(output, 0, output.length);
return new String(output,"UTF-8");
}catch(Throwable t){
return "Error:"+t.getMessage();
}
}
示例3: prepareMethodCall
import org.apache.thrift.transport.TMemoryBuffer; //导入方法依赖的package包/类
/**
* 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);
}
示例4: writeThriftObjectAsTText
import org.apache.thrift.transport.TMemoryBuffer; //导入方法依赖的package包/类
private static String writeThriftObjectAsTText(Consumer<TProtocol> writer) {
TMemoryBuffer buffer = new TMemoryBuffer(1024);
TProtocol protocol = new TTextProtocol.Factory().getProtocol(buffer);
writer.accept(protocol);
return new String(buffer.getArray(), 0, buffer.length());
}