當前位置: 首頁>>代碼示例>>Java>>正文


Java TProtocol.readMessageEnd方法代碼示例

本文整理匯總了Java中org.apache.thrift.protocol.TProtocol.readMessageEnd方法的典型用法代碼示例。如果您正苦於以下問題:Java TProtocol.readMessageEnd方法的具體用法?Java TProtocol.readMessageEnd怎麽用?Java TProtocol.readMessageEnd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.thrift.protocol.TProtocol的用法示例。


在下文中一共展示了TProtocol.readMessageEnd方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: process

import org.apache.thrift.protocol.TProtocol; //導入方法依賴的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.TProtocol; //導入方法依賴的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.TProtocol; //導入方法依賴的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

示例4: tryDecodeUnframedMessage

import org.apache.thrift.protocol.TProtocol; //導入方法依賴的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


注:本文中的org.apache.thrift.protocol.TProtocol.readMessageEnd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。