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


Java TProtocolUtil.skip方法代码示例

本文整理汇总了Java中org.apache.thrift.protocol.TProtocolUtil.skip方法的典型用法代码示例。如果您正苦于以下问题:Java TProtocolUtil.skip方法的具体用法?Java TProtocolUtil.skip怎么用?Java TProtocolUtil.skip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.thrift.protocol.TProtocolUtil的用法示例。


在下文中一共展示了TProtocolUtil.skip方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
@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;
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:27,代码来源:TProtobufProcessor.java

示例2: process

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
@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;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:27,代码来源:LocatorServiceImpl.java

示例3: process

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
@Override
public boolean process(TProtocol in, TProtocol out) throws TException {
  TMessage msg = in.readMessageBegin();
  ProcessFunction fn = processMap.get(msg.name);
  if (fn == null) {
    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;
  }
  fn.process(msg.seqid, in, out, iface);
  return true;
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:18,代码来源:TBaseProcessor.java

示例4: process

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
public boolean process(TProtocol in, TProtocol out) throws TException {
  TMessage msg = in.readMessageBegin();
  ProcessFunction fn = processMap.get(msg.name);
  if (fn == null) {
    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;
  }
  fn.process(msg.seqid, in, out, iface);
  return true;
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:17,代码来源:TBaseProcessor.java

示例5: process

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
@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;
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:29,代码来源:GFXDServiceImpl.java

示例6: locateField

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
private TField locateField(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
  trans_.reset(bytes);

  TFieldIdEnum[] fieldIdPath= new TFieldIdEnum[fieldIdPathRest.length + 1];
  fieldIdPath[0] = fieldIdPathFirst;
  for (int i = 0; i < fieldIdPathRest.length; i++){
    fieldIdPath[i + 1] = fieldIdPathRest[i];
  }

  // index into field ID path being currently searched for
  int curPathIndex = 0;

  // this will be the located field, or null if it is not located
  TField field = null;

  protocol_.readStructBegin();

  while (curPathIndex < fieldIdPath.length) {
    field = protocol_.readFieldBegin();
    // we can stop searching if we either see a stop or we go past the field
    // id we're looking for (since fields should now be serialized in asc
    // order).
    if (field.type == TType.STOP || field.id > fieldIdPath[curPathIndex].getThriftFieldId()) {
      return null;
    }

    if (field.id != fieldIdPath[curPathIndex].getThriftFieldId()) {
      // Not the field we're looking for. Skip field.
      TProtocolUtil.skip(protocol_, field.type);
      protocol_.readFieldEnd();
    } else {
      // This field is the next step in the path. Step into field.
      curPathIndex++;
      if (curPathIndex < fieldIdPath.length) {
        protocol_.readStructBegin();
      }
    }
  }
  return field;
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:41,代码来源:TDeserializer.java

示例7: read

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
public static TApplicationException read(TProtocol iprot) throws TException {
  TField field;
  iprot.readStructBegin();

  String message = null;
  int type = 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);
}
 
开发者ID:adityayadav76,项目名称:internet_of_things_simulator,代码行数:38,代码来源:TApplicationException.java

示例8: read

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:line,项目名称:armeria,代码行数:44,代码来源:TApplicationExceptions.java

示例9: tryDecodeUnframedMessage

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
private TTransport tryDecodeUnframedMessage(ChannelHandlerContext ctx, ByteBuf buffer) throws TException {
	// Perform a trial decode, skipping through
	// the fields, to see whether we have an entire message available.

	int messageLength = 0;
	int messageStartReaderIndex = buffer.readerIndex();

	try {
		TNiftyTransport decodeAttemptTransport = new TNiftyTransport(ctx.channel(), buffer);
		TProtocol inputProtocol = this.inputProtocolFactory.getProtocol(decodeAttemptTransport);

		// Skip through the message
		inputProtocol.readMessageBegin();
		TProtocolUtil.skip(inputProtocol, TType.STRUCT);
		inputProtocol.readMessageEnd();

		messageLength = buffer.readerIndex() - messageStartReaderIndex;
	} catch (IndexOutOfBoundsException e) {
		// No complete message was decoded: ran out of bytes
		return null;
	} finally {
		if (buffer.readerIndex() - messageStartReaderIndex > maxFrameSize) {
			ctx.fireExceptionCaught(new TooLongFrameException("Maximum frame size of " + maxFrameSize + " exceeded"));
		}

		buffer.readerIndex(messageStartReaderIndex);
	}

	if (messageLength <= 0) {
		return null;
	}

	// We have a full message in the read buffer, slice it off
	ByteBuf messageBuffer = extractFrame(buffer, messageStartReaderIndex, messageLength);
	ThriftMessage message = new ThriftMessage(messageBuffer, ThriftTransportType.UNFRAMED);
	buffer.readerIndex(messageStartReaderIndex + messageLength);
	return new TNiftyTransport(ctx.channel(), message);
}
 
开发者ID:smallmiro,项目名称:NettyThrift,代码行数:39,代码来源:ThriftFrameDecoder.java

示例10: main

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
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);
}
 
开发者ID:RandyAbernethy,项目名称:ThriftBook,代码行数:35,代码来源:BinFileRead.java

示例11: read

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
public void read(TProtocol iprot, Log_result struct) throws TException {
  org.apache.thrift.protocol.TField schemeField;
  iprot.readStructBegin();
  while (true)
  {
    schemeField = iprot.readFieldBegin();
    if (schemeField.type == TType.STOP) { 
      break;
    }
    switch (schemeField.id) {
      case 0: // SUCCESS
        if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
          struct.success = ResultCode.findByValue(iprot.readI32());
          struct.setSuccessIsSet(true);
        } else { 
          TProtocolUtil.skip(iprot, schemeField.type);
        }
        break;
      default:
        TProtocolUtil.skip(iprot, schemeField.type);
    }
    iprot.readFieldEnd();
  }
  iprot.readStructEnd();

  // check for required fields of primitive type, which can't be checked in the validate method
  struct.validate();
}
 
开发者ID:DemandCube,项目名称:NeverwinterDP-Commons,代码行数:29,代码来源:scribe.java

示例12: tryDecodeUnframedMessage

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
protected ByteBuf tryDecodeUnframedMessage(ChannelHandlerContext ctx,
                                                 Channel channel,
                                                 ByteBuf buffer,
                                                 TProtocolFactory inputProtocolFactory)
        throws TException {
    // Perform a trial decode, skipping through
    // the fields, to see whether we have an entire message available.

    int messageLength = 0;
    int messageStartReaderIndex = buffer.readerIndex();

    try {
        TNiftyTransport decodeAttemptTransport =
                new TNiftyTransport(channel, buffer, ThriftTransportType.UNFRAMED);
        int initialReadBytes = decodeAttemptTransport.getReadByteCount();
        TProtocol inputProtocol =
                inputProtocolFactory.getProtocol(decodeAttemptTransport);

        // Skip through the message
        inputProtocol.readMessageBegin();
        TProtocolUtil.skip(inputProtocol, TType.STRUCT);
        inputProtocol.readMessageEnd();

        messageLength = decodeAttemptTransport.getReadByteCount() - initialReadBytes;
    } catch (TTransportException | IndexOutOfBoundsException e) {
        // No complete message was decoded: ran out of bytes
        return null;
    } finally {
        if (buffer.readerIndex() - messageStartReaderIndex > maxFrameSize) {
                throw new  TooLongFrameException("Maximum frame size of " + maxFrameSize + " exceeded");
        }

        buffer.readerIndex(messageStartReaderIndex);
    }

    if (messageLength <= 0) {
        return null;
    }

    // We have a full message in the read buffer, slice it off
    ByteBuf messageBuffer =
            extractFrame(buffer, messageStartReaderIndex, messageLength);
    buffer.readerIndex(messageStartReaderIndex + messageLength);
    return messageBuffer;
}
 
开发者ID:paullyphang,项目名称:nebo,代码行数:46,代码来源:DefaultThriftFrameDecoder.java

示例13: readMessage

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
private <Message extends PMessage<Message, Field>, Field extends PField>
Message readMessage(TProtocol protocol, PMessageDescriptor<Message, Field> descriptor)
        throws SerializerException, TException {
    TField f;

    PMessageBuilder<Message, Field> builder = descriptor.builder();
    protocol.readStructBegin();  // ignored.
    while ((f = protocol.readFieldBegin()) != null) {
        if (f.type == BinaryType.STOP) {
            break;
        }

        PField field;
        // f.name is never fulled out, rely on f.id being correct.
        field = descriptor.findFieldById(f.id);
        if (field != null) {
            if (f.type != forType(field.getDescriptor().getType())) {
                throw new SerializerException("Incompatible serialized type " + asString(f.type) +
                                              " for field " + field.getName() +
                                              ", expected " + asString(forType(field.getDescriptor().getType())));
            }

            Object value = readTypedValue(f.type, field.getDescriptor(), protocol, true);
            if (value != null) {
                builder.set(field.getId(), value);
            }
        } else {
            TProtocolUtil.skip(protocol, f.type);
        }

        protocol.readFieldEnd();
    }
    protocol.readStructEnd();

    if (readStrict) {
        try {
            builder.validate();
        } catch (IllegalStateException e) {
            throw new SerializerException(e, e.getMessage());
        }
    }

    return builder.build();
}
 
开发者ID:morimekta,项目名称:providence,代码行数:45,代码来源:TProtocolSerializer.java

示例14: consumeField

import org.apache.thrift.protocol.TProtocolUtil; //导入方法依赖的package包/类
@Override
public void consumeField(TProtocol protocol, EventBasedThriftReader reader, short id, byte type) throws TException {
  TProtocolUtil.skip(protocol, type);
}
 
开发者ID:apache,项目名称:parquet-format,代码行数:5,代码来源:Consumers.java


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