本文整理汇总了Java中org.apache.thrift.protocol.TProtocol.readI64方法的典型用法代码示例。如果您正苦于以下问题:Java TProtocol.readI64方法的具体用法?Java TProtocol.readI64怎么用?Java TProtocol.readI64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.thrift.protocol.TProtocol
的用法示例。
在下文中一共展示了TProtocol.readI64方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.thrift.protocol.TProtocol; //导入方法依赖的package包/类
public boolean process( TProtocol in, TProtocol out ) throws TException {
short magic = in.readI16();
if ( magic != ThriftCodec.MAGIC ) {
logger.error(
new StringBuilder( 24 )
.append( "Unsupported magic " )
.append( magic ).toString() );
return false;
}
in.readI32();
in.readI16();
byte version = in.readByte();
String serviceName = in.readString();
long id = in.readI64();
ByteArrayOutputStream bos = new ByteArrayOutputStream( 1024 );
TIOStreamTransport transport = new TIOStreamTransport( bos );
TProtocol protocol = protocolFactory.getProtocol( transport );
TProcessor processor = processorMap.get( serviceName );
if ( processor == null ) {
logger.error(
new StringBuilder( 32 )
.append( "Could not find processor for service " )
.append( serviceName )
.toString() );
return false;
}
// todo if exception
boolean result = processor.process( in, protocol );
ByteArrayOutputStream header = new ByteArrayOutputStream( 512 );
TIOStreamTransport headerTransport = new TIOStreamTransport( header );
TProtocol headerProtocol = protocolFactory.getProtocol( headerTransport );
headerProtocol.writeI16( magic );
headerProtocol.writeI32( Integer.MAX_VALUE );
headerProtocol.writeI16( Short.MAX_VALUE );
headerProtocol.writeByte( version );
headerProtocol.writeString( serviceName );
headerProtocol.writeI64( id );
headerProtocol.getTransport().flush();
out.writeI16( magic );
out.writeI32( bos.size() + header.size() );
out.writeI16( ( short ) ( 0xffff & header.size() ) );
out.writeByte( version );
out.writeString( serviceName );
out.writeI64( id );
out.getTransport().write( bos.toByteArray() );
out.getTransport().flush();
return result;
}