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


Java TProtocol.writeMessageBegin方法代碼示例

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


在下文中一共展示了TProtocol.writeMessageBegin方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: encodeRequest

import org.apache.thrift.protocol.TProtocol; //導入方法依賴的package包/類
protected void encodeRequest(Channel channel, ChannelBuffer buffer, Request request)
    throws IOException {
    Invocation invocation = (Invocation) request.getData();
    TProtocol protocol = newProtocol(channel.getUrl(), buffer);
    try {
        protocol.writeMessageBegin(new TMessage(
            invocation.getMethodName(), TMessageType.CALL, 
            thriftSeq.getAndIncrement()));
        protocol.writeStructBegin(new TStruct(invocation.getMethodName() + "_args"));
        for(int i = 0; i < invocation.getParameterTypes().length; i++) {
            Class<?> type = invocation.getParameterTypes()[i];

        }
    } catch (TException e) {
        throw new IOException(e.getMessage(), e);
    }

}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:19,代碼來源:ThriftNativeCodec.java

示例3: writeRequest

import org.apache.thrift.protocol.TProtocol; //導入方法依賴的package包/類
private static void writeRequest(MethodMetadata method, List<Object> parameters, TProtocol protocol)
        throws Exception
{
    TMessage requestMessage = new TMessage(method.getName(), CALL, SEQUENCE_ID);
    protocol.writeMessageBegin(requestMessage);

    // write the parameters
    ProtocolWriter writer = new ProtocolWriter(new ThriftToDriftProtocolWriter(protocol));
    writer.writeStructBegin(method.getName() + "_args");
    for (int i = 0; i < parameters.size(); i++) {
        Object value = parameters.get(i);
        ParameterMetadata parameter = method.getParameters().get(i);
        writer.writeField(parameter.getName(), parameter.getId(), parameter.getCodec(), value);
    }
    writer.writeStructEnd();

    protocol.writeMessageEnd();
    protocol.getTransport().flush();
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:20,代碼來源:ApacheThriftMethodInvoker.java

示例4: writeResult

import org.apache.thrift.protocol.TProtocol; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void writeResult(final TProtocol out, final TMessage msg, final WriterHandler onComplete, TBase args,
		final TBase result) {
	try {
		onComplete.beforeWrite(msg, args, result);
		// if (!isOneway()) {
		out.writeMessageBegin(new TMessage(msg.name, TMessageType.REPLY, msg.seqid));
		if (result != null) {
			result.write(out);
		} else {
			out.writeStructBegin(null);
			out.writeFieldStop();
			out.writeStructEnd();
		}
		out.writeMessageEnd();
		out.getTransport().flush();
		// }
		onComplete.afterWrite(msg, null, TMessageType.REPLY, args, result);
	} catch (Throwable e) {
		onComplete.afterWrite(msg, e, TMessageType.EXCEPTION, args, result);
	}
}
 
開發者ID:houkx,項目名稱:nettythrift,代碼行數:23,代碼來源:DefaultNettyProcessor.java

示例5: 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

示例6: writeException

import org.apache.thrift.protocol.TProtocol; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes" })
private void writeException(final TProtocol out, final TMessage msg, final WriterHandler onComplete,
		final TApplicationException x, TBase args) {
	Throwable cause = null;
	try {
		onComplete.beforeWrite(msg, args, null);
		out.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));
		x.write(out);
		out.writeMessageEnd();
		out.getTransport().flush();
	} catch (Throwable e) {
		cause = e;
	}
	onComplete.afterWrite(msg, cause, TMessageType.EXCEPTION, args, null);
}
 
開發者ID:houkx,項目名稱:nettythrift,代碼行數:16,代碼來源:DefaultNettyProcessor.java

示例7: 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

示例8: write_args

import org.apache.thrift.protocol.TProtocol; //導入方法依賴的package包/類
public void write_args(TProtocol prot) throws TException {
	prot.writeMessageBegin(new TMessage(Processor.FUNCTION_NAME, TMessageType.CALL, 0));
	ArgsThriftBase args = new ArgsThriftBase();
	args.setFieldValue(AbstractThriftBase.FieldsEnum.VALUE, arg);
	args.write(prot);
	prot.writeMessageEnd();
}
 
開發者ID:venwyhk,項目名稱:ikasoa,代碼行數:8,代碼來源:CallBack.java


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