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


Java ProtoUtil类代码示例

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


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

示例1: writeConnectionContext

import org.apache.hadoop.util.ProtoUtil; //导入依赖的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.util.ProtoUtil; //导入依赖的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: getRpcRequestWrapper

import org.apache.hadoop.util.ProtoUtil; //导入依赖的package包/类
public Class<? extends Writable> getRpcRequestWrapper(
    RpcKindProto rpcKind) {
  if (rpcRequestClass != null)
     return rpcRequestClass;
  RpcKindMapValue val = rpcKindMap.get(ProtoUtil.convert(rpcKind));
  return (val == null) ? null : val.rpcRequestWrapperClass; 
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:8,代码来源:Server.java

示例4: processConnectionContext

import org.apache.hadoop.util.ProtoUtil; //导入依赖的package包/类
/** Reads the connection context following the connection header
 * @param dis - DataInputStream from which to read the header 
 * @throws WrappedRpcServerException - if the header cannot be
 *         deserialized, or the user is not authorized
 */ 
private void processConnectionContext(DataInputStream dis)
    throws WrappedRpcServerException {
  // allow only one connection context during a session
  if (connectionContextRead) {
    throw new WrappedRpcServerException(
        RpcErrorCodeProto.FATAL_INVALID_RPC_HEADER,
        "Connection context already processed");
  }
  connectionContext = decodeProtobufFromStream(
      IpcConnectionContextProto.newBuilder(), dis);
  protocolName = connectionContext.hasProtocol() ? connectionContext
      .getProtocol() : null;

  UserGroupInformation protocolUser = ProtoUtil.getUgi(connectionContext);
  if (saslServer == null) {
    user = protocolUser;
  } else {
    // user is authenticated
    user.setAuthenticationMethod(authMethod);
    //Now we check if this is a proxy user case. If the protocol user is
    //different from the 'user', it is a proxy user scenario. However, 
    //this is not allowed if user authenticated with DIGEST.
    if ((protocolUser != null)
        && (!protocolUser.getUserName().equals(user.getUserName()))) {
      if (authMethod == AuthMethod.TOKEN) {
        // Not allowed to doAs if token authentication is used
        throw new WrappedRpcServerException(
            RpcErrorCodeProto.FATAL_UNAUTHORIZED,
            new AccessControlException("Authenticated user (" + user
                + ") doesn't match what the client claims to be ("
                + protocolUser + ")"));
      } else {
        // Effective user can be different from authenticated user
        // for simple auth or kerberos auth
        // The user is the real user. Now we create a proxy user
        UserGroupInformation realUser = user;
        user = UserGroupInformation.createProxyUser(protocolUser
            .getUserName(), realUser);
      }
    }
  }
  authorizeConnection();
  // don't set until after authz because connection isn't established
  connectionContextRead = true;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:51,代码来源:Server.java

示例5: readVarintBytes

import org.apache.hadoop.util.ProtoUtil; //导入依赖的package包/类
private static byte[] readVarintBytes(DataInput in) throws IOException {
  final int length = ProtoUtil.readRawVarint32(in);
  final byte[] bytes = new byte[length];
  in.readFully(bytes);
  return bytes;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:7,代码来源:ProtobufRpcEngine.java

示例6: readFields

import org.apache.hadoop.util.ProtoUtil; //导入依赖的package包/类
@Override
public void readFields(DataInput in) throws IOException {
  int length = ProtoUtil.readRawVarint32(in);
  theResponseRead = new byte[length];
  in.readFully(theResponseRead);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:7,代码来源:ProtobufRpcEngine.java

示例7: Connection

import org.apache.hadoop.util.ProtoUtil; //导入依赖的package包/类
public Connection(ConnectionId remoteId, int serviceClass) throws IOException {
  this.remoteId = remoteId;
  this.server = remoteId.getAddress();
  if (server.isUnresolved()) {
    throw NetUtils.wrapException(server.getHostName(),
        server.getPort(),
        null,
        0,
        new UnknownHostException());
  }
  this.rpcTimeout = remoteId.getRpcTimeout();
  this.maxIdleTime = remoteId.getMaxIdleTime();
  this.connectionRetryPolicy = remoteId.connectionRetryPolicy;
  this.maxRetriesOnSasl = remoteId.getMaxRetriesOnSasl();
  this.maxRetriesOnSocketTimeouts = remoteId.getMaxRetriesOnSocketTimeouts();
  this.tcpNoDelay = remoteId.getTcpNoDelay();
  this.tcpLowLatency = remoteId.getTcpLowLatency();
  this.doPing = remoteId.getDoPing();
  if (doPing) {
    // construct a RPC header with the callId as the ping callId
    pingRequest = new ByteArrayOutputStream();
    RpcRequestHeaderProto pingHeader = ProtoUtil
        .makeRpcRequestHeader(RpcKind.RPC_PROTOCOL_BUFFER,
            OperationProto.RPC_FINAL_PACKET, PING_CALL_ID,
            RpcConstants.INVALID_RETRY_COUNT, clientId);
    pingHeader.writeDelimitedTo(pingRequest);
  }
  this.pingInterval = remoteId.getPingInterval();
  this.serviceClass = serviceClass;
  if (LOG.isDebugEnabled()) {
    LOG.debug("The ping interval is " + this.pingInterval + " ms.");
  }

  UserGroupInformation ticket = remoteId.getTicket();
  // try SASL if security is enabled or if the ugi contains tokens.
  // this causes a SIMPLE client with tokens to attempt SASL
  boolean trySasl = UserGroupInformation.isSecurityEnabled() ||
                    (ticket != null && !ticket.getTokens().isEmpty());
  this.authProtocol = trySasl ? AuthProtocol.SASL : AuthProtocol.NONE;
  
  this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +
      server.toString() +
      " from " + ((ticket==null)?"an unknown user":ticket.getUserName()));
  this.setDaemon(true);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:46,代码来源:Client.java

示例8: Connection

import org.apache.hadoop.util.ProtoUtil; //导入依赖的package包/类
public Connection(ConnectionId remoteId, int serviceClass) throws IOException {
  this.remoteId = remoteId;
  this.server = remoteId.getAddress();
  if (server.isUnresolved()) {
    throw NetUtils.wrapException(server.getHostName(),
        server.getPort(),
        null,
        0,
        new UnknownHostException());
  }
  this.rpcTimeout = remoteId.getRpcTimeout();
  this.maxIdleTime = remoteId.getMaxIdleTime();
  this.connectionRetryPolicy = remoteId.connectionRetryPolicy;
  this.maxRetriesOnSasl = remoteId.getMaxRetriesOnSasl();
  this.maxRetriesOnSocketTimeouts = remoteId.getMaxRetriesOnSocketTimeouts();
  this.tcpNoDelay = remoteId.getTcpNoDelay();
  this.doPing = remoteId.getDoPing();
  if (doPing) {
    // construct a RPC header with the callId as the ping callId
    pingRequest = new ByteArrayOutputStream();
    RpcRequestHeaderProto pingHeader = ProtoUtil
        .makeRpcRequestHeader(RpcKind.RPC_PROTOCOL_BUFFER,
            OperationProto.RPC_FINAL_PACKET, PING_CALL_ID,
            RpcConstants.INVALID_RETRY_COUNT, clientId);
    pingHeader.writeDelimitedTo(pingRequest);
  }
  this.pingInterval = remoteId.getPingInterval();
  this.serviceClass = serviceClass;
  if (LOG.isDebugEnabled()) {
    LOG.debug("The ping interval is " + this.pingInterval + " ms.");
  }

  UserGroupInformation ticket = remoteId.getTicket();
  // try SASL if security is enabled or if the ugi contains tokens.
  // this causes a SIMPLE client with tokens to attempt SASL
  boolean trySasl = UserGroupInformation.isSecurityEnabled() ||
                    (ticket != null && !ticket.getTokens().isEmpty());
  this.authProtocol = trySasl ? AuthProtocol.SASL : AuthProtocol.NONE;
  
  this.setName("IPC Client (" + socketFactory.hashCode() +") connection to " +
      server.toString() +
      " from " + ((ticket==null)?"an unknown user":ticket.getUserName()));
  this.setDaemon(true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:45,代码来源:Client.java


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