当前位置: 首页>>代码示例>>Java>>正文


Java TMemoryBuffer.length方法代码示例

本文整理汇总了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();
    }
     
             
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:26,代码来源:Httpd.java

示例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();
    }
     
             
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:26,代码来源:Httpd.java

示例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);
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:16,代码来源:TAsyncMethodCall.java

示例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());
}
 
开发者ID:line,项目名称:armeria,代码行数:7,代码来源:ThriftStructuredLogJsonFormat.java


注:本文中的org.apache.thrift.transport.TMemoryBuffer.length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。