예제 #1
0
 private void initProtocolMetaInfo(Configuration conf) {
   RPC.setProtocolEngine(conf, ProtocolMetaInfoPB.class, ProtobufRpcEngine.class);
   ProtocolMetaInfoServerSideTranslatorPB xlator =
       new ProtocolMetaInfoServerSideTranslatorPB(this);
   BlockingService protocolInfoBlockingService =
       ProtocolInfoService.newReflectiveBlockingService(xlator);
   addProtocol(
       RpcKind.RPC_PROTOCOL_BUFFER, ProtocolMetaInfoPB.class, protocolInfoBlockingService);
 }
예제 #2
0
 private static Object createNameNodeProxy(
     InetSocketAddress address, Configuration conf, UserGroupInformation ugi, Class<?> xface)
     throws IOException {
   RPC.setProtocolEngine(conf, xface, ProtobufRpcEngine.class);
   Object proxy =
       RPC.getProxy(
           xface,
           RPC.getProtocolVersion(xface),
           address,
           ugi,
           conf,
           NetUtils.getDefaultSocketFactory(conf));
   return proxy;
 }
예제 #3
0
  private static ClientProtocol createNNProxyWithClientProtocol(
      InetSocketAddress address,
      Configuration conf,
      UserGroupInformation ugi,
      boolean withRetries,
      AtomicBoolean fallbackToSimpleAuth)
      throws IOException {
    RPC.setProtocolEngine(conf, ClientNamenodeProtocolPB.class, ProtobufRpcEngine.class);

    final RetryPolicy defaultPolicy =
        RetryUtils.getDefaultRetryPolicy(
            conf,
            HdfsClientConfigKeys.Retry.POLICY_ENABLED_KEY,
            HdfsClientConfigKeys.Retry.POLICY_ENABLED_DEFAULT,
            HdfsClientConfigKeys.Retry.POLICY_SPEC_KEY,
            HdfsClientConfigKeys.Retry.POLICY_SPEC_DEFAULT,
            SafeModeException.class.getName());

    final long version = RPC.getProtocolVersion(ClientNamenodeProtocolPB.class);
    ClientNamenodeProtocolPB proxy =
        RPC.getProtocolProxy(
                ClientNamenodeProtocolPB.class,
                version,
                address,
                ugi,
                conf,
                NetUtils.getDefaultSocketFactory(conf),
                org.apache.hadoop.ipc.Client.getTimeout(conf),
                defaultPolicy,
                fallbackToSimpleAuth)
            .getProxy();

    if (withRetries) { // create the proxy with retries

      Map<String, RetryPolicy> methodNameToPolicyMap = new HashMap<String, RetryPolicy>();
      ClientProtocol translatorProxy = new ClientNamenodeProtocolTranslatorPB(proxy);
      return (ClientProtocol)
          RetryProxy.create(
              ClientProtocol.class,
              new DefaultFailoverProxyProvider<ClientProtocol>(
                  ClientProtocol.class, translatorProxy),
              methodNameToPolicyMap,
              defaultPolicy);
    } else {
      return new ClientNamenodeProtocolTranslatorPB(proxy);
    }
  }
 static ClientDatanodeProtocolPB createClientDatanodeProtocolProxy(
     InetSocketAddress addr,
     UserGroupInformation ticket,
     Configuration conf,
     SocketFactory factory,
     int socketTimeout)
     throws IOException {
   RPC.setProtocolEngine(conf, ClientDatanodeProtocolPB.class, ProtobufRpcEngine.class);
   return RPC.getProxy(
       ClientDatanodeProtocolPB.class,
       RPC.getProtocolVersion(ClientDatanodeProtocolPB.class),
       addr,
       ticket,
       conf,
       factory,
       socketTimeout);
 }
예제 #5
0
  protected void startServer() throws Exception {
    Configuration conf = getConfig();
    YarnRPC rpc = YarnRPC.create(conf);
    this.server =
        (Server)
            rpc.getServer(
                ResourceManagerAdministrationProtocol.class,
                this,
                masterServiceAddress,
                conf,
                null,
                conf.getInt(
                    YarnConfiguration.RM_ADMIN_CLIENT_THREAD_COUNT,
                    YarnConfiguration.DEFAULT_RM_ADMIN_CLIENT_THREAD_COUNT));

    // Enable service authorization?
    if (conf.getBoolean(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, false)) {
      refreshServiceAcls(
          getConfiguration(conf, YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE),
          RMPolicyProvider.getInstance());
    }

    if (rmContext.isHAEnabled()) {
      RPC.setProtocolEngine(conf, HAServiceProtocolPB.class, ProtobufRpcEngine.class);

      HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator =
          new HAServiceProtocolServerSideTranslatorPB(this);
      BlockingService haPbService =
          HAServiceProtocolProtos.HAServiceProtocolService.newReflectiveBlockingService(
              haServiceProtocolXlator);
      server.addProtocol(RPC.RpcKind.RPC_PROTOCOL_BUFFER, HAServiceProtocol.class, haPbService);
    }

    this.server.start();
    conf.updateConnectAddr(YarnConfiguration.RM_ADMIN_ADDRESS, server.getListenerAddress());
  }
  public NameNodeRpcServer(Configuration conf, NameNode nn) throws IOException {
    this.nn = nn;
    this.namesystem = nn.getNamesystem();
    this.metrics = NameNode.getNameNodeMetrics();

    int handlerCount =
        conf.getInt(DFS_NAMENODE_HANDLER_COUNT_KEY, DFS_NAMENODE_HANDLER_COUNT_DEFAULT);
    InetSocketAddress socAddr = nn.getRpcServerAddress(conf);
    RPC.setProtocolEngine(conf, ClientNamenodeProtocolPB.class, ProtobufRpcEngine.class);
    ClientNamenodeProtocolServerSideTranslatorPB clientProtocolServerTranslator =
        new ClientNamenodeProtocolServerSideTranslatorPB(this);
    BlockingService clientNNPbService =
        ClientNamenodeProtocol.newReflectiveBlockingService(clientProtocolServerTranslator);

    DatanodeProtocolServerSideTranslatorPB dnProtoPbTranslator =
        new DatanodeProtocolServerSideTranslatorPB(this);
    BlockingService dnProtoPbService =
        DatanodeProtocolService.newReflectiveBlockingService(dnProtoPbTranslator);

    NamenodeProtocolServerSideTranslatorPB namenodeProtocolXlator =
        new NamenodeProtocolServerSideTranslatorPB(this);
    BlockingService NNPbService =
        NamenodeProtocolService.newReflectiveBlockingService(namenodeProtocolXlator);

    RefreshAuthorizationPolicyProtocolServerSideTranslatorPB refreshAuthPolicyXlator =
        new RefreshAuthorizationPolicyProtocolServerSideTranslatorPB(this);
    BlockingService refreshAuthService =
        RefreshAuthorizationPolicyProtocolService.newReflectiveBlockingService(
            refreshAuthPolicyXlator);

    RefreshUserMappingsProtocolServerSideTranslatorPB refreshUserMappingXlator =
        new RefreshUserMappingsProtocolServerSideTranslatorPB(this);
    BlockingService refreshUserMappingService =
        RefreshUserMappingsProtocolService.newReflectiveBlockingService(refreshUserMappingXlator);

    GetUserMappingsProtocolServerSideTranslatorPB getUserMappingXlator =
        new GetUserMappingsProtocolServerSideTranslatorPB(this);
    BlockingService getUserMappingService =
        GetUserMappingsProtocolService.newReflectiveBlockingService(getUserMappingXlator);

    HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator =
        new HAServiceProtocolServerSideTranslatorPB(this);
    BlockingService haPbService =
        HAServiceProtocolService.newReflectiveBlockingService(haServiceProtocolXlator);

    WritableRpcEngine.ensureInitialized();

    InetSocketAddress dnSocketAddr = nn.getServiceRpcServerAddress(conf);
    if (dnSocketAddr != null) {
      int serviceHandlerCount =
          conf.getInt(
              DFS_NAMENODE_SERVICE_HANDLER_COUNT_KEY, DFS_NAMENODE_SERVICE_HANDLER_COUNT_DEFAULT);
      // Add all the RPC protocols that the namenode implements
      this.serviceRpcServer =
          RPC.getServer(
              org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB.class,
              clientNNPbService,
              dnSocketAddr.getHostName(),
              dnSocketAddr.getPort(),
              serviceHandlerCount,
              false,
              conf,
              namesystem.getDelegationTokenSecretManager());
      DFSUtil.addPBProtocol(conf, HAServiceProtocolPB.class, haPbService, serviceRpcServer);
      DFSUtil.addPBProtocol(conf, NamenodeProtocolPB.class, NNPbService, serviceRpcServer);
      DFSUtil.addPBProtocol(conf, DatanodeProtocolPB.class, dnProtoPbService, serviceRpcServer);
      DFSUtil.addPBProtocol(
          conf, RefreshAuthorizationPolicyProtocolPB.class, refreshAuthService, serviceRpcServer);
      DFSUtil.addPBProtocol(
          conf, RefreshUserMappingsProtocolPB.class, refreshUserMappingService, serviceRpcServer);
      DFSUtil.addPBProtocol(
          conf, GetUserMappingsProtocolPB.class, getUserMappingService, serviceRpcServer);

      this.serviceRPCAddress = this.serviceRpcServer.getListenerAddress();
      nn.setRpcServiceServerAddress(conf, serviceRPCAddress);
    } else {
      serviceRpcServer = null;
      serviceRPCAddress = null;
    }
    // Add all the RPC protocols that the namenode implements
    this.clientRpcServer =
        RPC.getServer(
            org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolPB.class,
            clientNNPbService,
            socAddr.getHostName(),
            socAddr.getPort(),
            handlerCount,
            false,
            conf,
            namesystem.getDelegationTokenSecretManager());
    DFSUtil.addPBProtocol(conf, HAServiceProtocolPB.class, haPbService, clientRpcServer);
    DFSUtil.addPBProtocol(conf, NamenodeProtocolPB.class, NNPbService, clientRpcServer);
    DFSUtil.addPBProtocol(conf, DatanodeProtocolPB.class, dnProtoPbService, clientRpcServer);
    DFSUtil.addPBProtocol(
        conf, RefreshAuthorizationPolicyProtocolPB.class, refreshAuthService, clientRpcServer);
    DFSUtil.addPBProtocol(
        conf, RefreshUserMappingsProtocolPB.class, refreshUserMappingService, clientRpcServer);
    DFSUtil.addPBProtocol(
        conf, GetUserMappingsProtocolPB.class, getUserMappingService, clientRpcServer);

    // set service-level authorization security policy
    if (serviceAuthEnabled =
        conf.getBoolean(CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, false)) {
      this.clientRpcServer.refreshServiceAcl(conf, new HDFSPolicyProvider());
      if (this.serviceRpcServer != null) {
        this.serviceRpcServer.refreshServiceAcl(conf, new HDFSPolicyProvider());
      }
    }

    // The rpc-server port can be ephemeral... ensure we have the correct info
    this.clientRpcAddress = this.clientRpcServer.getListenerAddress();
    nn.setRpcServerAddress(conf, clientRpcAddress);

    this.minimumDataNodeVersion =
        conf.get(
            DFSConfigKeys.DFS_NAMENODE_MIN_SUPPORTED_DATANODE_VERSION_KEY,
            DFSConfigKeys.DFS_NAMENODE_MIN_SUPPORTED_DATANODE_VERSION_DEFAULT);
  }