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


Java RpcRequestHeaderProto.getCallId方法代码示例

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


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

示例1: processOneRpc

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入方法依赖的package包/类
/**
 * Process one RPC Request from buffer read from socket stream 
 *  - decode rpc in a rpc-Call
 *  - handle out-of-band RPC requests such as the initial connectionContext
 *  - A successfully decoded RpcCall will be deposited in RPC-Q and
 *    its response will be sent later when the request is processed.
 * 
 * Prior to this call the connectionHeader ("hrpc...") has been handled and
 * if SASL then SASL has been established and the buf we are passed
 * has been unwrapped from SASL.
 * 
 * @param buf - contains the RPC request header and the rpc request
 * @throws IOException - internal error that should not be returned to
 *         client, typically failure to respond to client
 * @throws WrappedRpcServerException - an exception that is sent back to the
 *         client in this method and does not require verbose logging by the
 *         Listener thread
 * @throws InterruptedException
 */    
private void processOneRpc(byte[] buf)
    throws IOException, WrappedRpcServerException, InterruptedException {
  int callId = -1;
  int retry = RpcConstants.INVALID_RETRY_COUNT;
  try {
    final DataInputStream dis =
        new DataInputStream(new ByteArrayInputStream(buf));
    final RpcRequestHeaderProto header =
        decodeProtobufFromStream(RpcRequestHeaderProto.newBuilder(), dis);
    callId = header.getCallId();
    retry = header.getRetryCount();
    if (LOG.isDebugEnabled()) {
      LOG.debug(" got #" + callId);
    }
    checkRpcHeaders(header);
    
    if (callId < 0) { // callIds typically used during connection setup
      processRpcOutOfBandRequest(header, dis);
    } else if (!connectionContextRead) {
      throw new WrappedRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "Connection context not established");
    } else {
      processRpcRequest(header, dis);
    }
  } catch (WrappedRpcServerException wrse) { // inform client of error
    Throwable ioe = wrse.getCause();
    final Call call = new Call(callId, retry, null, this);
    setupResponse(authFailedResponse, call,
        RpcStatusProto.FATAL, wrse.getRpcErrorCodeProto(), null,
        ioe.getClass().getName(), ioe.getMessage());
    call.sendResponse();
    throw wrse;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:55,代码来源:Server.java

示例2: processRpcOutOfBandRequest

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入方法依赖的package包/类
/**
 * Establish RPC connection setup by negotiating SASL if required, then
 * reading and authorizing the connection header
 * @param header - RPC header
 * @param dis - stream to request payload
 * @throws WrappedRpcServerException - setup failed due to SASL
 *         negotiation failure, premature or invalid connection context,
 *         or other state errors. This exception needs to be sent to the 
 *         client.
 * @throws IOException - failed to send a response back to the client
 * @throws InterruptedException
 */
private void processRpcOutOfBandRequest(RpcRequestHeaderProto header,
    DataInputStream dis) throws WrappedRpcServerException, IOException,
    InterruptedException {
  final int callId = header.getCallId();
  if (callId == CONNECTION_CONTEXT_CALL_ID) {
    // SASL must be established prior to connection context
    if (authProtocol == AuthProtocol.SASL && !saslContextEstablished) {
      throw new WrappedRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "Connection header sent during SASL negotiation");
    }
    // read and authorize the user
    processConnectionContext(dis);
  } else if (callId == AuthProtocol.SASL.callId) {
    // if client was switched to simple, ignore first SASL message
    if (authProtocol != AuthProtocol.SASL) {
      throw new WrappedRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "SASL protocol not requested by client");
    }
    saslReadAndProcess(dis);
  } else if (callId == PING_CALL_ID) {
    LOG.debug("Received ping message");
  } else {
    throw new WrappedRpcServerException(
        RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
        "Unknown out of band call #" + callId);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:42,代码来源:Server.java

示例3: processOneRpc

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入方法依赖的package包/类
/**
 * Process an RPC Request - handle connection setup and decoding of
 * request into a Call
 * @param buf - contains the RPC request header and the rpc request
 * @throws IOException - internal error that should not be returned to
 *         client, typically failure to respond to client
 * @throws WrappedRpcServerException - an exception to be sent back to
 *         the client that does not require verbose logging by the
 *         Listener thread
 * @throws InterruptedException
 */    
private void processOneRpc(byte[] buf)
    throws IOException, WrappedRpcServerException, InterruptedException {
  int callId = -1;
  int retry = RpcConstants.INVALID_RETRY_COUNT;
  try {
    final DataInputStream dis =
        new DataInputStream(new ByteArrayInputStream(buf));
    final RpcRequestHeaderProto header =
        decodeProtobufFromStream(RpcRequestHeaderProto.newBuilder(), dis);
    callId = header.getCallId();
    retry = header.getRetryCount();
    if (LOG.isDebugEnabled()) {
      LOG.debug(" got #" + callId);
    }
    checkRpcHeaders(header);
    
    if (callId < 0) { // callIds typically used during connection setup
      processRpcOutOfBandRequest(header, dis);
    } else if (!connectionContextRead) {
      throw new WrappedRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "Connection context not established");
    } else {
      processRpcRequest(header, dis);
    }
  } catch (WrappedRpcServerException wrse) { // inform client of error
    Throwable ioe = wrse.getCause();
    final Call call = new Call(callId, retry, null, this);
    setupResponse(authFailedResponse, call,
        RpcStatusProto.FATAL, wrse.getRpcErrorCodeProto(), null,
        ioe.getClass().getName(), ioe.getMessage());
    responder.doRespond(call);
    throw wrse;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:Server.java

示例4: processRpcOutOfBandRequest

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入方法依赖的package包/类
/**
 * Establish RPC connection setup by negotiating SASL if required, then
 * reading and authorizing the connection header
 * @param header - RPC header
 * @param dis - stream to request payload
 * @throws WrappedRpcServerException - setup failed due to SASL
 *         negotiation failure, premature or invalid connection context,
 *         or other state errors 
 * @throws IOException - failed to send a response back to the client
 * @throws InterruptedException
 */
private void processRpcOutOfBandRequest(RpcRequestHeaderProto header,
    DataInputStream dis) throws WrappedRpcServerException, IOException,
    InterruptedException {
  final int callId = header.getCallId();
  if (callId == CONNECTION_CONTEXT_CALL_ID) {
    // SASL must be established prior to connection context
    if (authProtocol == AuthProtocol.SASL && !saslContextEstablished) {
      throw new WrappedRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "Connection header sent during SASL negotiation");
    }
    // read and authorize the user
    processConnectionContext(dis);
  } else if (callId == AuthProtocol.SASL.callId) {
    // if client was switched to simple, ignore first SASL message
    if (authProtocol != AuthProtocol.SASL) {
      throw new WrappedRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "SASL protocol not requested by client");
    }
    saslReadAndProcess(dis);
  } else if (callId == PING_CALL_ID) {
    LOG.debug("Received ping message");
  } else {
    throw new WrappedRpcServerException(
        RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
        "Unknown out of band call #" + callId);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:41,代码来源:Server.java

示例5: processRpcOutOfBandRequest

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入方法依赖的package包/类
/**
 * Establish RPC connection setup by negotiating SASL if required, then
 * reading and authorizing the connection header
 * @param header - RPC header
 * @param buffer - stream to request payload
 * @throws RpcServerException - setup failed due to SASL
 *         negotiation failure, premature or invalid connection context,
 *         or other state errors 
 * @throws IOException - failed to send a response back to the client
 * @throws InterruptedException
 */
private void processRpcOutOfBandRequest(RpcRequestHeaderProto header,
    RpcWritable.Buffer buffer) throws RpcServerException,
        IOException, InterruptedException {
  final int callId = header.getCallId();
  if (callId == CONNECTION_CONTEXT_CALL_ID) {
    // SASL must be established prior to connection context
    if (authProtocol == AuthProtocol.SASL && !saslContextEstablished) {
      throw new FatalRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "Connection header sent during SASL negotiation");
    }
    // read and authorize the user
    processConnectionContext(buffer);
  } else if (callId == AuthProtocol.SASL.callId) {
    // if client was switched to simple, ignore first SASL message
    if (authProtocol != AuthProtocol.SASL) {
      throw new FatalRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "SASL protocol not requested by client");
    }
    saslReadAndProcess(buffer);
  } else if (callId == PING_CALL_ID) {
    LOG.debug("Received ping message");
  } else {
    throw new FatalRpcServerException(
        RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
        "Unknown out of band call #" + callId);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:41,代码来源:Server.java

示例6: processOneRpc

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入方法依赖的package包/类
/**
 * Process one RPC Request from buffer read from socket stream 
 *  - decode rpc in a rpc-Call
 *  - handle out-of-band RPC requests such as the initial connectionContext
 *  - A successfully decoded RpcCall will be deposited in RPC-Q and
 *    its response will be sent later when the request is processed.
 * 
 * Prior to this call the connectionHeader ("hrpc...") has been handled and
 * if SASL then SASL has been established and the buf we are passed
 * has been unwrapped from SASL.
 * 
 * @param bb - contains the RPC request header and the rpc request
 * @throws IOException - internal error that should not be returned to
 *         client, typically failure to respond to client
 * @throws InterruptedException
 */
private void processOneRpc(ByteBuffer bb)
    throws IOException, InterruptedException {
  // exceptions that escape this method are fatal to the connection.
  // setupResponse will use the rpc status to determine if the connection
  // should be closed.
  int callId = -1;
  int retry = RpcConstants.INVALID_RETRY_COUNT;
  try {
    final RpcWritable.Buffer buffer = RpcWritable.Buffer.wrap(bb);
    final RpcRequestHeaderProto header =
        getMessage(RpcRequestHeaderProto.getDefaultInstance(), buffer);
    callId = header.getCallId();
    retry = header.getRetryCount();
    if (LOG.isDebugEnabled()) {
      LOG.debug(" got #" + callId);
    }
    checkRpcHeaders(header);

    if (callId < 0) { // callIds typically used during connection setup
      processRpcOutOfBandRequest(header, buffer);
    } else if (!connectionContextRead) {
      throw new FatalRpcServerException(
          RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
          "Connection context not established");
    } else {
      processRpcRequest(header, buffer);
    }
  } catch (RpcServerException rse) {
    // inform client of error, but do not rethrow else non-fatal
    // exceptions will close connection!
    if (LOG.isDebugEnabled()) {
      LOG.debug(Thread.currentThread().getName() +
          ": processOneRpc from client " + this +
          " threw exception [" + rse + "]");
    }
    // use the wrapped exception if there is one.
    Throwable t = (rse.getCause() != null) ? rse.getCause() : rse;
    final RpcCall call = new RpcCall(this, callId, retry);
    setupResponse(call,
        rse.getRpcStatusProto(), rse.getRpcErrorCodeProto(), null,
        t.getClass().getName(), t.getMessage());
    sendResponse(call);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:61,代码来源:Server.java


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