本文整理汇总了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;
}
示例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;
}
}
示例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;
}
}
示例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;
}