Java Code Examples for org.apache.thrift.protocol.TProtocolUtil#skip()
The following examples show how to use
org.apache.thrift.protocol.TProtocolUtil#skip() .
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: TProtobufProcessor.java From jigsaw-payment with Apache License 2.0 | 6 votes |
@Override public boolean process(TProtocol in, TProtocol out) throws TException { TMessage msg = in.readMessageBegin(); Controller<?, ?> fn = (Controller<?, ?>) this.beanFactory .getBean(msg.name); if (fn == null) { if (LOGGER.isWarnEnabled()) { LOGGER.warn("Invalid request: failed to find interface=" + msg.name + ", from: " + getInetAddress(in)); } TProtocolUtil.skip(in, TType.STRUCT); in.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.UNKNOWN_METHOD, "Invalid method name: '" + msg.name + "'"); out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(out); out.writeMessageEnd(); out.getTransport().flush(); return true; } process(msg.seqid, msg.name, in, out, fn); return true; }
Example 2
Source File: LocatorServiceImpl.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
@Override public final boolean process(final TProtocol in, final TProtocol out) throws TException { final TMessage msg = in.readMessageBegin(); final ProcessFunction<LocatorServiceImpl, ?> fn = this.fnMap .get(msg.name); if (fn != null) { fn.process(msg.seqid, in, out, this.inst); // terminate connection on receiving closeConnection // direct class comparison should be the fastest way return fn.getClass() != LocatorService.Processor.closeConnection.class; } else { TProtocolUtil.skip(in, TType.STRUCT); in.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.UNKNOWN_METHOD, "Invalid method name: '" + msg.name + "'"); out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(out); out.writeMessageEnd(); out.getTransport().flush(); return true; } }
Example 3
Source File: LocatorServiceImpl.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
@Override public final boolean process(final TProtocol in, final TProtocol out) throws TException { final TMessage msg = in.readMessageBegin(); final ProcessFunction<LocatorServiceImpl, ?> fn = this.fnMap .get(msg.name); if (fn != null) { fn.process(msg.seqid, in, out, this.inst); // terminate connection on receiving closeConnection // direct class comparison should be the fastest way return fn.getClass() != LocatorService.Processor.closeConnection.class; } else { TProtocolUtil.skip(in, TType.STRUCT); in.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.UNKNOWN_METHOD, "Invalid method name: '" + msg.name + "'"); out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(out); out.writeMessageEnd(); out.getTransport().flush(); return true; } }
Example 4
Source File: GFXDServiceImpl.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Override public final boolean process(final TProtocol in, final TProtocol out) throws TException { final TMessage msg = in.readMessageBegin(); final ProcessFunction<GFXDServiceImpl, ?> fn = this.fnMap.get(msg.name); if (fn != null) { fn.process(msg.seqid, in, out, this.inst); // terminate connection on receiving closeConnection // direct class comparison should be the fastest way // TODO: SW: also need to clean up connection artifacts in the case of // client connection failure (ConnectionListener does get a notification // but how to tie the socket/connectionNumber to the connectionID?) return fn.getClass() != GFXDService.Processor.closeConnection.class; } else { TProtocolUtil.skip(in, TType.STRUCT); in.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.UNKNOWN_METHOD, "Invalid method name: '" + msg.name + "'"); out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(out); out.writeMessageEnd(); out.getTransport().flush(); return true; } }
Example 5
Source File: ThriftFrameDecoder.java From ikasoa with MIT License | 5 votes |
protected ChannelBuffer tryDecodeUnframedMessage(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, TProtocolFactory inputProtocolFactory) throws TException { int messageLength = 0; int messageStartReaderIndex = buffer.readerIndex(); try { TNettyTransport decodeAttemptTransport = new TNettyTransport(channel, buffer, TNettyTransportType.UNFRAMED); int initialReadBytes = decodeAttemptTransport.getReadByteCount(); TProtocol inputProtocol = inputProtocolFactory.getProtocol(decodeAttemptTransport); inputProtocol.readMessageBegin(); TProtocolUtil.skip(inputProtocol, TType.STRUCT); inputProtocol.readMessageEnd(); messageLength = decodeAttemptTransport.getReadByteCount() - initialReadBytes; } catch (TTransportException | IndexOutOfBoundsException e) { return null; } finally { if (buffer.readerIndex() - messageStartReaderIndex > maxFrameSize) Channels.fireExceptionCaught(ctx, new TooLongFrameException(String.format("Maximum frame size of %d exceeded .", maxFrameSize))); buffer.readerIndex(messageStartReaderIndex); } if (messageLength <= 0) return null; ChannelBuffer messageBuffer = extractFrame(buffer, messageStartReaderIndex, messageLength); buffer.readerIndex(messageStartReaderIndex + messageLength); return messageBuffer; }
Example 6
Source File: InternalScribeCodec.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
static boolean parseResponse(TBinaryProtocol iprot) throws TException { Boolean result = null; iprot.readStructBegin(); TField schemeField; while ((schemeField = iprot.readFieldBegin()).type != TType.STOP) { if (schemeField.id == 0 /* SUCCESS */ && schemeField.type == TType.I32) { result = iprot.readI32() == 0; } else { TProtocolUtil.skip(iprot, schemeField.type); } } iprot.readStructEnd(); if (result != null) return result; throw new TApplicationException(MISSING_RESULT, "Log failed: unknown result"); }
Example 7
Source File: GFXDServiceImpl.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
@Override public final boolean process(final TProtocol in, final TProtocol out) throws TException { final TMessage msg = in.readMessageBegin(); final ProcessFunction<GFXDServiceImpl, ?> fn = this.fnMap.get(msg.name); if (fn != null) { fn.process(msg.seqid, in, out, this.inst); // terminate connection on receiving closeConnection // direct class comparison should be the fastest way // TODO: SW: also need to clean up connection artifacts in the case of // client connection failure (ConnectionListener does get a notification // but how to tie the socket/connectionNumber to the connectionID?) return fn.getClass() != GFXDService.Processor.closeConnection.class; } else { TProtocolUtil.skip(in, TType.STRUCT); in.readMessageEnd(); TApplicationException x = new TApplicationException( TApplicationException.UNKNOWN_METHOD, "Invalid method name: '" + msg.name + "'"); out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid)); x.write(out); out.writeMessageEnd(); out.getTransport().flush(); return true; } }
Example 8
Source File: TApplicationExceptions.java From armeria with Apache License 2.0 | 5 votes |
/** * Reads a {@link TApplicationException} from the specified {@link TProtocol}. * * <p>Note: This has been copied from {@link TApplicationException#read(TProtocol)} due to API differences * between libthrift 0.9.x and 0.10.x. */ public static TApplicationException read(TProtocol iprot) throws TException { TField field; iprot.readStructBegin(); String message = null; int type = TApplicationException.UNKNOWN; while (true) { field = iprot.readFieldBegin(); if (field.type == TType.STOP) { break; } switch (field.id) { case 1: if (field.type == TType.STRING) { message = iprot.readString(); } else { TProtocolUtil.skip(iprot, field.type); } break; case 2: if (field.type == TType.I32) { type = iprot.readI32(); } else { TProtocolUtil.skip(iprot, field.type); } break; default: TProtocolUtil.skip(iprot, field.type); break; } iprot.readFieldEnd(); } iprot.readStructEnd(); return new TApplicationException(type, message); }
Example 9
Source File: BinFileRead.java From ThriftBook with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws TException { TTransport trans = new TSimpleFileTransport("data", true, false); TProtocol proto = new TBinaryProtocol(trans); Trade trade_read = new Trade(); TField field = new TField(); TStruct struct_obj = proto.readStructBegin(); while(true) { field = proto.readFieldBegin(); if (field.id == TType.STOP) { break; } switch(field.id) { case 1: trade_read.symbol = proto.readString(); break; case 2: trade_read.price = proto.readDouble(); break; case 3: trade_read.size = proto.readI32(); break; default: TProtocolUtil.skip(proto,field.type); break; } proto.readFieldEnd(); } proto.readStructEnd(); System.out.println("Trade: " + trade_read.symbol + " " + trade_read.size + " @ " + trade_read.price); }
Example 10
Source File: Consumers.java From parquet-format with Apache License 2.0 | 4 votes |
@Override public void consumeField(TProtocol protocol, EventBasedThriftReader reader, short id, byte type) throws TException { TProtocolUtil.skip(protocol, type); }
Example 11
Source File: Consumers.java From parquet-mr with Apache License 2.0 | 4 votes |
@Override public void consumeField(TProtocol protocol, EventBasedThriftReader reader, short id, byte type) throws TException { TProtocolUtil.skip(protocol, type); }