Java Code Examples for org.apache.thrift.protocol.TProtocol#readI64()
The following examples show how to use
org.apache.thrift.protocol.TProtocol#readI64() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiServiceProcessor.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Override public boolean process(TProtocol in, TProtocol out) throws TException { short magic = in.readI16(); if (magic != ThriftCodec.MAGIC) { logger.error("Unsupported magic " + magic); 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("Could not find processor for service " + serviceName); 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; }
Example 2
Source File: MultiServiceProcessor.java From dubbox with Apache License 2.0 | 4 votes |
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; }
Example 3
Source File: MultiServiceProcessor.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
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; }
Example 4
Source File: MultiServiceProcessor.java From dubbox with Apache License 2.0 | 4 votes |
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; }
Example 5
Source File: TypeAdapter.java From Firefly with Apache License 2.0 | 4 votes |
@Override public Long read(TProtocol protocol) throws TException { return protocol.readI64(); }
Example 6
Source File: MultiServiceProcessor.java From dubbox with Apache License 2.0 | 4 votes |
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; }
Example 7
Source File: BufferedProtocolReadToWrite.java From parquet-mr with Apache License 2.0 | 4 votes |
/** * @return true when all value is consumed, false when some values is ignored due to the field is not defined in expectedType * @throws TException */ private boolean readOneValue(TProtocol in, byte type, List<Action> buffer, ThriftType expectedType) throws TException { if (expectedType != null && expectedType.getType().getSerializedThriftType() != type) { throw new DecodingSchemaMismatchException("the data type does not match the expected thrift structure: expected " + expectedType + " got " + typeName(type)); } boolean hasFieldsIgnored = false; switch (type) { case TType.LIST: hasFieldsIgnored = readOneList(in, buffer, (ListType)expectedType); break; case TType.MAP: hasFieldsIgnored = readOneMap(in, buffer, (MapType)expectedType); break; case TType.SET: hasFieldsIgnored = readOneSet(in, buffer, (SetType)expectedType); break; case TType.STRUCT: hasFieldsIgnored = readOneStruct(in, buffer, (StructType)expectedType); break; case TType.STOP: break; case TType.BOOL: final boolean bool = in.readBool(); writeBoolAction(buffer, bool); break; case TType.BYTE: final byte b = in.readByte(); writeByteAction(buffer, b); break; case TType.DOUBLE: final double d = in.readDouble(); writeDoubleAction(buffer, d); break; case TType.I16: final short s = in.readI16(); writeShortAction(buffer, s); break; case TType.ENUM: // same as i32 => actually never seen in the protocol layer as enums are written as a i32 field case TType.I32: final int i = in.readI32(); checkEnum(expectedType,i); writeIntAction(buffer, i); break; case TType.I64: final long l = in.readI64(); writeLongAction(buffer, l); break; case TType.STRING: final ByteBuffer bin = in.readBinary(); writeStringAction(buffer, bin); break; case TType.VOID: break; default: throw new TException("Unknown type: " + type); } return hasFieldsIgnored; }