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


Java RpcResponseHeaderProto.newBuilder方法代码示例

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


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

示例1: readNextRpcPacket

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcResponseHeaderProto; //导入方法依赖的package包/类
private void readNextRpcPacket() throws IOException {
  LOG.debug("reading next wrapped RPC packet");
  DataInputStream dis = new DataInputStream(in);
  int rpcLen = dis.readInt();
  byte[] rpcBuf = new byte[rpcLen];
  dis.readFully(rpcBuf);

  // decode the RPC header
  ByteArrayInputStream bis = new ByteArrayInputStream(rpcBuf);
  RpcResponseHeaderProto.Builder headerBuilder =
      RpcResponseHeaderProto.newBuilder();
  headerBuilder.mergeDelimitedFrom(bis);

  boolean isWrapped = false;
  // Must be SASL wrapped, verify and decode.
  if (headerBuilder.getCallId() == AuthProtocol.SASL.callId) {
    RpcSaslProto.Builder saslMessage = RpcSaslProto.newBuilder();
    saslMessage.mergeDelimitedFrom(bis);
    if (saslMessage.getState() == SaslState.WRAP) {
      isWrapped = true;
      byte[] token = saslMessage.getToken().toByteArray();
      if (LOG.isDebugEnabled()) {
        LOG.debug("unwrapping token of length:" + token.length);
      }
      token = saslClient.unwrap(token, 0, token.length);
      unwrappedRpcBuffer = ByteBuffer.wrap(token);
    }
  }
  if (!isWrapped) {
    throw new SaslException("Server sent non-wrapped response");
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:33,代码来源:SaslRpcClient.java

示例2: readNextRpcPacket

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcResponseHeaderProto; //导入方法依赖的package包/类
private void readNextRpcPacket() throws IOException {
  LOG.debug("reading next wrapped RPC packet");
  DataInputStream dis = new DataInputStream(in);
  int rpcLen = dis.readInt();
  byte[] rpcBuf = new byte[rpcLen];
  dis.readFully(rpcBuf);
  
  // decode the RPC header
  ByteArrayInputStream bis = new ByteArrayInputStream(rpcBuf);
  RpcResponseHeaderProto.Builder headerBuilder =
      RpcResponseHeaderProto.newBuilder();
  headerBuilder.mergeDelimitedFrom(bis);
  
  boolean isWrapped = false;
  // Must be SASL wrapped, verify and decode.
  if (headerBuilder.getCallId() == AuthProtocol.SASL.callId) {
    RpcSaslProto.Builder saslMessage = RpcSaslProto.newBuilder();
    saslMessage.mergeDelimitedFrom(bis);
    if (saslMessage.getState() == SaslState.WRAP) {
      isWrapped = true;
      byte[] token = saslMessage.getToken().toByteArray();
      if (LOG.isDebugEnabled()) {
        LOG.debug("unwrapping token of length:" + token.length);
      }
      token = saslClient.unwrap(token, 0, token.length);
      unwrappedRpcBuffer = ByteBuffer.wrap(token);
    }
  }
  if (!isWrapped) {
    throw new SaslException("Server sent non-wrapped response");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:33,代码来源:SaslRpcClient.java

示例3: setupResponse

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcResponseHeaderProto; //导入方法依赖的package包/类
/**
 * Setup response for the IPC Call.
 * 
 * @param responseBuf buffer to serialize the response into
 * @param call {@link Call} to which we are setting up the response
 * @param status of the IPC call
 * @param rv return value for the IPC Call, if the call was successful
 * @param errorClass error class, if the the call failed
 * @param error error message, if the call failed
 * @throws IOException
 */
private void setupResponse(
    RpcCall call, RpcStatusProto status, RpcErrorCodeProto erCode,
    Writable rv, String errorClass, String error)
        throws IOException {
  // fatal responses will cause the reader to close the connection.
  if (status == RpcStatusProto.FATAL) {
    call.connection.setShouldClose();
  }
  RpcResponseHeaderProto.Builder headerBuilder =
      RpcResponseHeaderProto.newBuilder();
  headerBuilder.setClientId(ByteString.copyFrom(call.clientId));
  headerBuilder.setCallId(call.callId);
  headerBuilder.setRetryCount(call.retryCount);
  headerBuilder.setStatus(status);
  headerBuilder.setServerIpcVersionNum(CURRENT_VERSION);

  if (status == RpcStatusProto.SUCCESS) {
    RpcResponseHeaderProto header = headerBuilder.build();
    try {
      setupResponse(call, header, rv);
    } catch (Throwable t) {
      LOG.warn("Error serializing call response for call " + call, t);
      // Call back to same function - this is OK since the
      // buffer is reset at the top, and since status is changed
      // to ERROR it won't infinite loop.
      setupResponse(call, RpcStatusProto.ERROR,
          RpcErrorCodeProto.ERROR_SERIALIZING_RESPONSE,
          null, t.getClass().getName(),
          StringUtils.stringifyException(t));
      return;
    }
  } else { // Rpc Failure
    headerBuilder.setExceptionClassName(errorClass);
    headerBuilder.setErrorMsg(error);
    headerBuilder.setErrorDetail(erCode);
    setupResponse(call, headerBuilder.build(), null);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:50,代码来源:Server.java


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