• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RpcRequestHeaderProto类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



RpcRequestHeaderProto类属于org.apache.hadoop.ipc.protobuf.RpcHeaderProtos包,在下文中一共展示了RpcRequestHeaderProto类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeConnectionContext

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入依赖的package包/类
private void writeConnectionContext(ConnectionId remoteId,
                                    AuthMethod authMethod)
                                        throws IOException {
  // Write out the ConnectionHeader
  IpcConnectionContextProto message = ProtoUtil.makeIpcConnectionContext(
      RPC.getProtocolName(remoteId.getProtocol()),
      remoteId.getTicket(),
      authMethod);
  RpcRequestHeaderProto connectionContextHeader = ProtoUtil
      .makeRpcRequestHeader(RpcKind.RPC_PROTOCOL_BUFFER,
          OperationProto.RPC_FINAL_PACKET, CONNECTION_CONTEXT_CALL_ID,
          RpcConstants.INVALID_RETRY_COUNT, clientId);
  RpcRequestMessageWrapper request =
      new RpcRequestMessageWrapper(connectionContextHeader, message);
  
  // Write out the packet length
  out.writeInt(request.getLength());
  request.write(out);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:20,代码来源:Client.java


示例2: writeConnectionContext

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入依赖的package包/类
private void writeConnectionContext(ConnectionId remoteId,
                                    AuthMethod authMethod)
                                        throws IOException {
  // Write out the ConnectionHeader
  IpcConnectionContextProto message = ProtoUtil.makeIpcConnectionContext(
      RPC.getProtocolName(remoteId.getProtocol()),
      remoteId.getTicket(),
      authMethod);
  RpcRequestHeaderProto connectionContextHeader = ProtoUtil
      .makeRpcRequestHeader(RpcKind.RPC_PROTOCOL_BUFFER,
          OperationProto.RPC_FINAL_PACKET, CONNECTION_CONTEXT_CALL_ID,
          RpcConstants.INVALID_RETRY_COUNT, clientId);
  // do not flush.  the context and first ipc call request must be sent
  // together to avoid possibility of broken pipes upon authz failure.
  // see writeConnectionHeader
  final ResponseBuffer buf = new ResponseBuffer();
  connectionContextHeader.writeDelimitedTo(buf);
  message.writeDelimitedTo(buf);
  synchronized (ipcStreams.out) {
    ipcStreams.sendRequest(buf.toByteArray());
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:23,代码来源:Client.java


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


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


示例5: testRpcClientId

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入依赖的package包/类
@Test
public void testRpcClientId() {
  byte[] uuid = ClientId.getClientId();
  RpcRequestHeaderProto header = ProtoUtil.makeRpcRequestHeader(
      RpcKind.RPC_PROTOCOL_BUFFER, OperationProto.RPC_FINAL_PACKET, 0,
      RpcConstants.INVALID_RETRY_COUNT, uuid);
  assertTrue(Arrays.equals(uuid, header.getClientId().toByteArray()));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:9,代码来源:TestProtoUtil.java


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


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


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


示例9: RpcRequestMessageWrapper

import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RpcRequestHeaderProto; //导入依赖的package包/类
public RpcRequestMessageWrapper(
    RpcRequestHeaderProto requestHeader, Message theRequest) {
  super(requestHeader, theRequest);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:5,代码来源:ProtobufRpcEngine.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FindProperty类代码示例发布时间:2022-05-22
下一篇:
Java EllipseMapObject类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap