org.apache.hadoop.ipc.ProtobufRpcEngine Java Examples

The following examples show how to use org.apache.hadoop.ipc.ProtobufRpcEngine. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DummyHAService.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private InetSocketAddress startAndGetRPCServerAddress(InetSocketAddress serverAddress) {
  Configuration conf = new Configuration();

  try {
    RPC.setProtocolEngine(conf,
        HAServiceProtocolPB.class, ProtobufRpcEngine.class);
    HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator =
        new HAServiceProtocolServerSideTranslatorPB(new MockHAProtocolImpl());
    BlockingService haPbService = HAServiceProtocolService
        .newReflectiveBlockingService(haServiceProtocolXlator);

    Server server = new RPC.Builder(conf)
        .setProtocol(HAServiceProtocolPB.class)
        .setInstance(haPbService)
        .setBindAddress(serverAddress.getHostName())
        .setPort(serverAddress.getPort()).build();
    server.start();
    return NetUtils.getConnectAddress(server);
  } catch (IOException e) {
    return null;
  }
}
 
Example #2
Source File: ContainerTestUtils.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an Endpoint class for testing purpose.
 *
 * @param conf - Conf
 * @param address - InetAddres
 * @param rpcTimeout - rpcTimeOut
 * @return EndPoint
 * @throws Exception
 */
public static EndpointStateMachine createEndpoint(Configuration conf,
    InetSocketAddress address, int rpcTimeout) throws Exception {
  RPC.setProtocolEngine(conf, StorageContainerDatanodeProtocolPB.class,
      ProtobufRpcEngine.class);
  long version =
      RPC.getProtocolVersion(StorageContainerDatanodeProtocolPB.class);

  StorageContainerDatanodeProtocolPB rpcProxy = RPC.getProtocolProxy(
      StorageContainerDatanodeProtocolPB.class, version,
      address, UserGroupInformation.getCurrentUser(), conf,
      NetUtils.getDefaultSocketFactory(conf), rpcTimeout,
      RetryPolicies.TRY_ONCE_THEN_FAIL).getProxy();

  StorageContainerDatanodeProtocolClientSideTranslatorPB rpcClient =
      new StorageContainerDatanodeProtocolClientSideTranslatorPB(rpcProxy);
  return new EndpointStateMachine(address, rpcClient,
      new LegacyHadoopConfigurationSource(conf));
}
 
Example #3
Source File: HddsServerUtil.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Create a scm security client.
 * @param conf    - Ozone configuration.
 *
 * @return {@link SCMSecurityProtocol}
 * @throws IOException
 */
public static SCMSecurityProtocolClientSideTranslatorPB getScmSecurityClient(
    OzoneConfiguration conf) throws IOException {
  RPC.setProtocolEngine(conf, SCMSecurityProtocolPB.class,
      ProtobufRpcEngine.class);
  long scmVersion =
      RPC.getProtocolVersion(ScmBlockLocationProtocolPB.class);
  InetSocketAddress address =
      getScmAddressForSecurityProtocol(conf);
  RetryPolicy retryPolicy =
      RetryPolicies.retryForeverWithFixedSleep(
          1000, TimeUnit.MILLISECONDS);
  return new SCMSecurityProtocolClientSideTranslatorPB(
      RPC.getProtocolProxy(SCMSecurityProtocolPB.class, scmVersion,
          address, UserGroupInformation.getCurrentUser(),
          conf, NetUtils.getDefaultSocketFactory(conf),
          Client.getRpcTimeout(conf), retryPolicy).getProxy());
}
 
Example #4
Source File: SCMTestUtils.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Start Datanode RPC server.
 */
public static RPC.Server startScmRpcServer(ConfigurationSource configuration,
    StorageContainerDatanodeProtocol server,
    InetSocketAddress rpcServerAddresss, int handlerCount) throws
    IOException {

  Configuration hadoopConfig =
      LegacyHadoopConfigurationSource.asHadoopConfiguration(configuration);
  RPC.setProtocolEngine(hadoopConfig,
      StorageContainerDatanodeProtocolPB.class,
      ProtobufRpcEngine.class);

  BlockingService scmDatanodeService =
      StorageContainerDatanodeProtocolService.
          newReflectiveBlockingService(
              new StorageContainerDatanodeProtocolServerSideTranslatorPB(
                  server, Mockito.mock(ProtocolMessageMetrics.class)));

  RPC.Server scmServer = startRpcServer(hadoopConfig, rpcServerAddresss,
      StorageContainerDatanodeProtocolPB.class, scmDatanodeService,
      handlerCount);

  scmServer.start();
  return scmServer;
}
 
Example #5
Source File: IPCLoggerChannel.java    From big-c with Apache License 2.0 6 votes vote down vote up
protected QJournalProtocol createProxy() throws IOException {
  final Configuration confCopy = new Configuration(conf);
  
  // Need to set NODELAY or else batches larger than MTU can trigger 
  // 40ms nagling delays.
  confCopy.setBoolean(
      CommonConfigurationKeysPublic.IPC_CLIENT_TCPNODELAY_KEY,
      true);
  
  RPC.setProtocolEngine(confCopy,
      QJournalProtocolPB.class, ProtobufRpcEngine.class);
  return SecurityUtil.doAsLoginUser(
      new PrivilegedExceptionAction<QJournalProtocol>() {
        @Override
        public QJournalProtocol run() throws IOException {
          RPC.setProtocolEngine(confCopy,
              QJournalProtocolPB.class, ProtobufRpcEngine.class);
          QJournalProtocolPB pbproxy = RPC.getProxy(
              QJournalProtocolPB.class,
              RPC.getProtocolVersion(QJournalProtocolPB.class),
              addr, confCopy);
          return new QJournalProtocolTranslatorPB(pbproxy);
        }
      });
}
 
Example #6
Source File: ContainerOperationClient.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
public static StorageContainerLocationProtocol newContainerRpcClient(
    ConfigurationSource configSource) throws IOException {

  Class<StorageContainerLocationProtocolPB> protocol =
      StorageContainerLocationProtocolPB.class;
  Configuration conf =
      LegacyHadoopConfigurationSource.asHadoopConfiguration(configSource);
  RPC.setProtocolEngine(conf, protocol, ProtobufRpcEngine.class);
  long version = RPC.getProtocolVersion(protocol);
  InetSocketAddress scmAddress = getScmAddressForClients(configSource);
  UserGroupInformation user = UserGroupInformation.getCurrentUser();
  SocketFactory socketFactory = NetUtils.getDefaultSocketFactory(conf);
  int rpcTimeOut = Client.getRpcTimeout(conf);

  StorageContainerLocationProtocolPB rpcProxy =
      RPC.getProxy(protocol, version, scmAddress, user, conf,
          socketFactory, rpcTimeOut);

  StorageContainerLocationProtocolClientSideTranslatorPB client =
      new StorageContainerLocationProtocolClientSideTranslatorPB(rpcProxy);
  return TracingUtil.createProxy(
      client, StorageContainerLocationProtocol.class, configSource);
}
 
Example #7
Source File: ZKFCRpcServer.java    From big-c with Apache License 2.0 6 votes vote down vote up
ZKFCRpcServer(Configuration conf,
    InetSocketAddress bindAddr,
    ZKFailoverController zkfc,
    PolicyProvider policy) throws IOException {
  this.zkfc = zkfc;
  
  RPC.setProtocolEngine(conf, ZKFCProtocolPB.class,
      ProtobufRpcEngine.class);
  ZKFCProtocolServerSideTranslatorPB translator =
      new ZKFCProtocolServerSideTranslatorPB(this);
  BlockingService service = ZKFCProtocolService
      .newReflectiveBlockingService(translator);
  this.server = new RPC.Builder(conf).setProtocol(ZKFCProtocolPB.class)
      .setInstance(service).setBindAddress(bindAddr.getHostName())
      .setPort(bindAddr.getPort()).setNumHandlers(HANDLER_COUNT)
      .setVerbose(false).build();
  
  // set service-level authorization security policy
  if (conf.getBoolean(
      CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, false)) {
    server.refreshServiceAcl(conf, policy);
  }

}
 
Example #8
Source File: TestBlockToken.java    From big-c with Apache License 2.0 6 votes vote down vote up
private static Server createMockDatanode(BlockTokenSecretManager sm,
    Token<BlockTokenIdentifier> token, Configuration conf)
    throws IOException, ServiceException {
  ClientDatanodeProtocolPB mockDN = mock(ClientDatanodeProtocolPB.class);

  BlockTokenIdentifier id = sm.createIdentifier();
  id.readFields(new DataInputStream(new ByteArrayInputStream(token
      .getIdentifier())));
  
  doAnswer(new GetLengthAnswer(sm, id)).when(mockDN)
      .getReplicaVisibleLength(any(RpcController.class),
          any(GetReplicaVisibleLengthRequestProto.class));

  RPC.setProtocolEngine(conf, ClientDatanodeProtocolPB.class,
      ProtobufRpcEngine.class);
  BlockingService service = ClientDatanodeProtocolService
      .newReflectiveBlockingService(mockDN);
  return new RPC.Builder(conf).setProtocol(ClientDatanodeProtocolPB.class)
      .setInstance(service).setBindAddress(ADDRESS).setPort(0)
      .setNumHandlers(5).setVerbose(true).setSecretManager(sm).build();
}
 
Example #9
Source File: BaseFreonGenerator.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
public StorageContainerLocationProtocol createStorageContainerLocationClient(
    OzoneConfiguration ozoneConf)
    throws IOException {

  long version = RPC.getProtocolVersion(
      StorageContainerLocationProtocolPB.class);
  InetSocketAddress scmAddress =
      getScmAddressForClients(ozoneConf);

  RPC.setProtocolEngine(ozoneConf, StorageContainerLocationProtocolPB.class,
      ProtobufRpcEngine.class);
  StorageContainerLocationProtocol client =
      TracingUtil.createProxy(
          new StorageContainerLocationProtocolClientSideTranslatorPB(
              RPC.getProxy(StorageContainerLocationProtocolPB.class, version,
                  scmAddress, UserGroupInformation.getCurrentUser(),
                  ozoneConf,
                  NetUtils.getDefaultSocketFactory(ozoneConf),
                  Client.getRpcTimeout(ozoneConf))),
          StorageContainerLocationProtocol.class, ozoneConf);
  return client;
}
 
Example #10
Source File: OMClientRequest.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Get User information which needs to be set in the OMRequest object.
 * @return User Info.
 */
public OzoneManagerProtocolProtos.UserInfo getUserInfo() {
  UserGroupInformation user = ProtobufRpcEngine.Server.getRemoteUser();
  InetAddress remoteAddress = ProtobufRpcEngine.Server.getRemoteIp();
  OzoneManagerProtocolProtos.UserInfo.Builder userInfo =
      OzoneManagerProtocolProtos.UserInfo.newBuilder();

  // Added not null checks, as in UT's these values might be null.
  if (user != null) {
    userInfo.setUserName(user.getUserName());
  }

  if (remoteAddress != null) {
    userInfo.setHostName(remoteAddress.getHostName());
    userInfo.setRemoteAddress(remoteAddress.getHostAddress()).build();
  }

  return userInfo.build();
}
 
Example #11
Source File: Hadoop3OmTransport.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
public Hadoop3OmTransport(ConfigurationSource conf,
    UserGroupInformation ugi, String omServiceId) throws IOException {

  RPC.setProtocolEngine(OzoneConfiguration.of(conf),
      OzoneManagerProtocolPB.class,
      ProtobufRpcEngine.class);

  this.omFailoverProxyProvider = new OMFailoverProxyProvider(conf, ugi,
      omServiceId);

  int maxFailovers = conf.getInt(
      OzoneConfigKeys.OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS_KEY,
      OzoneConfigKeys.OZONE_CLIENT_FAILOVER_MAX_ATTEMPTS_DEFAULT);

  this.rpcProxy = createRetryProxy(omFailoverProxyProvider, maxFailovers);
}
 
Example #12
Source File: OzoneManager.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Create a scm block client, used by putKey() and getKey().
 *
 * @return {@link ScmBlockLocationProtocol}
 * @throws IOException
 */
private static ScmBlockLocationProtocol getScmBlockClient(
    OzoneConfiguration conf) throws IOException {
  RPC.setProtocolEngine(conf, ScmBlockLocationProtocolPB.class,
      ProtobufRpcEngine.class);
  long scmVersion =
      RPC.getProtocolVersion(ScmBlockLocationProtocolPB.class);
  InetSocketAddress scmBlockAddress =
      getScmAddressForBlockClients(conf);
  ScmBlockLocationProtocolClientSideTranslatorPB scmBlockLocationClient =
      new ScmBlockLocationProtocolClientSideTranslatorPB(
          RPC.getProxy(ScmBlockLocationProtocolPB.class, scmVersion,
              scmBlockAddress, UserGroupInformation.getCurrentUser(), conf,
              NetUtils.getDefaultSocketFactory(conf),
              Client.getRpcTimeout(conf)));
  return TracingUtil
      .createProxy(scmBlockLocationClient, ScmBlockLocationProtocol.class,
          conf);
}
 
Example #13
Source File: OzoneManager.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Returns a scm container client.
 *
 * @return {@link StorageContainerLocationProtocol}
 * @throws IOException
 */
private static StorageContainerLocationProtocol getScmContainerClient(
    OzoneConfiguration conf) throws IOException {
  RPC.setProtocolEngine(conf, StorageContainerLocationProtocolPB.class,
      ProtobufRpcEngine.class);
  long scmVersion =
      RPC.getProtocolVersion(StorageContainerLocationProtocolPB.class);
  InetSocketAddress scmAddr = getScmAddressForClients(
      conf);
  StorageContainerLocationProtocol scmContainerClient =
      TracingUtil.createProxy(
          new StorageContainerLocationProtocolClientSideTranslatorPB(
              RPC.getProxy(StorageContainerLocationProtocolPB.class,
                  scmVersion,
                  scmAddr, UserGroupInformation.getCurrentUser(), conf,
                  NetUtils.getDefaultSocketFactory(conf),
                  Client.getRpcTimeout(conf))),
          StorageContainerLocationProtocol.class, conf);
  return scmContainerClient;
}
 
Example #14
Source File: TestBlockToken.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private static Server createMockDatanode(BlockTokenSecretManager sm,
    Token<BlockTokenIdentifier> token, Configuration conf)
    throws IOException, ServiceException {
  ClientDatanodeProtocolPB mockDN = mock(ClientDatanodeProtocolPB.class);

  BlockTokenIdentifier id = sm.createIdentifier();
  id.readFields(new DataInputStream(new ByteArrayInputStream(token
      .getIdentifier())));
  
  doAnswer(new GetLengthAnswer(sm, id)).when(mockDN)
      .getReplicaVisibleLength(any(RpcController.class),
          any(GetReplicaVisibleLengthRequestProto.class));

  RPC.setProtocolEngine(conf, ClientDatanodeProtocolPB.class,
      ProtobufRpcEngine.class);
  BlockingService service = ClientDatanodeProtocolService
      .newReflectiveBlockingService(mockDN);
  return new RPC.Builder(conf).setProtocol(ClientDatanodeProtocolPB.class)
      .setInstance(service).setBindAddress(ADDRESS).setPort(0)
      .setNumHandlers(5).setVerbose(true).setSecretManager(sm).build();
}
 
Example #15
Source File: HadoopRpcService.java    From incubator-ratis with Apache License 2.0 6 votes vote down vote up
private static RPC.Server newRpcServer(
    RaftServerProtocol serverProtocol, final Configuration conf)
    throws IOException {
  final int handlerCount = HadoopConfigKeys.Ipc.handlers(conf);
  final InetSocketAddress address = HadoopConfigKeys.Ipc.address(conf);

  final BlockingService service
      = RaftServerProtocolService.newReflectiveBlockingService(
          new RaftServerProtocolServerSideTranslatorPB(serverProtocol));
  RPC.setProtocolEngine(conf, RaftServerProtocolPB.class, ProtobufRpcEngine.class);
  return new RPC.Builder(conf)
      .setProtocol(RaftServerProtocolPB.class)
      .setInstance(service)
      .setBindAddress(address.getHostName())
      .setPort(address.getPort())
      .setNumHandlers(handlerCount)
      .setVerbose(false)
      .build();
}
 
Example #16
Source File: OzoneManager.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance of rpc server. If an earlier instance is already
 * running then returns the same.
 */
private RPC.Server getRpcServer(OzoneConfiguration conf) throws IOException {
  if (isOmRpcServerRunning) {
    return omRpcServer;
  }

  InetSocketAddress omNodeRpcAddr = OmUtils.getOmAddress(conf);

  final int handlerCount = conf.getInt(OZONE_OM_HANDLER_COUNT_KEY,
      OZONE_OM_HANDLER_COUNT_DEFAULT);
  RPC.setProtocolEngine(configuration, OzoneManagerProtocolPB.class,
      ProtobufRpcEngine.class);
  this.omServerProtocol = new OzoneManagerProtocolServerSideTranslatorPB(
      this, omRatisServer, omClientProtocolMetrics, isRatisEnabled);

  BlockingService omService = newReflectiveBlockingService(omServerProtocol);

  return startRpcServer(configuration, omNodeRpcAddr,
      OzoneManagerProtocolPB.class, omService,
      handlerCount);
}
 
Example #17
Source File: DummyHAService.java    From big-c with Apache License 2.0 6 votes vote down vote up
private InetSocketAddress startAndGetRPCServerAddress(InetSocketAddress serverAddress) {
  Configuration conf = new Configuration();

  try {
    RPC.setProtocolEngine(conf,
        HAServiceProtocolPB.class, ProtobufRpcEngine.class);
    HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator =
        new HAServiceProtocolServerSideTranslatorPB(new MockHAProtocolImpl());
    BlockingService haPbService = HAServiceProtocolService
        .newReflectiveBlockingService(haServiceProtocolXlator);

    Server server = new RPC.Builder(conf)
        .setProtocol(HAServiceProtocolPB.class)
        .setInstance(haPbService)
        .setBindAddress(serverAddress.getHostName())
        .setPort(serverAddress.getPort()).build();
    server.start();
    return NetUtils.getConnectAddress(server);
  } catch (IOException e) {
    return null;
  }
}
 
Example #18
Source File: ClientDatanodeProtocolTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #19
Source File: NameNodeProxies.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #20
Source File: NameNodeProxies.java    From hadoop with Apache License 2.0 5 votes vote down vote up
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, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_ENABLED_KEY, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_ENABLED_DEFAULT, 
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_SPEC_KEY,
          DFSConfigKeys.DFS_CLIENT_RETRY_POLICY_SPEC_DEFAULT,
          SafeModeException.class);
  
  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);
  }
}
 
Example #21
Source File: DatanodeProtocolClientSideTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public DatanodeProtocolClientSideTranslatorPB(InetSocketAddress nameNodeAddr,
    Configuration conf) throws IOException {
  RPC.setProtocolEngine(conf, DatanodeProtocolPB.class,
      ProtobufRpcEngine.class);
  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
  rpcProxy = createNamenode(nameNodeAddr, conf, ugi);
}
 
Example #22
Source File: HAServiceProtocolClientSideTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public HAServiceProtocolClientSideTranslatorPB(
    InetSocketAddress addr, Configuration conf,
    SocketFactory socketFactory, int timeout) throws IOException {
  RPC.setProtocolEngine(conf, HAServiceProtocolPB.class,
      ProtobufRpcEngine.class);
  rpcProxy = RPC.getProxy(HAServiceProtocolPB.class,
      RPC.getProtocolVersion(HAServiceProtocolPB.class), addr,
      UserGroupInformation.getCurrentUser(), conf, socketFactory, timeout);
}
 
Example #23
Source File: AdminService.java    From hadoop with Apache License 2.0 5 votes vote down vote up
protected void startServer() throws Exception {
  Configuration conf = getConfig();
  YarnRPC rpc = YarnRPC.create(conf);
  this.server = (Server) rpc.getServer(
      ResourceManagerAdministrationProtocol.class, this, masterServiceBindAddress,
      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_BIND_HOST,
                         YarnConfiguration.RM_ADMIN_ADDRESS,
                         YarnConfiguration.DEFAULT_RM_ADMIN_ADDRESS,
                         server.getListenerAddress());
}
 
Example #24
Source File: JournalNodeRpcServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
JournalNodeRpcServer(Configuration conf, JournalNode jn) throws IOException {
  this.jn = jn;
  
  Configuration confCopy = new Configuration(conf);
  
  // Ensure that nagling doesn't kick in, which could cause latency issues.
  confCopy.setBoolean(
      CommonConfigurationKeysPublic.IPC_SERVER_TCPNODELAY_KEY,
      true);
  
  InetSocketAddress addr = getAddress(confCopy);
  RPC.setProtocolEngine(confCopy, QJournalProtocolPB.class,
      ProtobufRpcEngine.class);
  QJournalProtocolServerSideTranslatorPB translator =
      new QJournalProtocolServerSideTranslatorPB(this);
  BlockingService service = QJournalProtocolService
      .newReflectiveBlockingService(translator);
  
  this.server = new RPC.Builder(confCopy)
    .setProtocol(QJournalProtocolPB.class)
    .setInstance(service)
    .setBindAddress(addr.getHostName())
    .setPort(addr.getPort())
    .setNumHandlers(HANDLER_COUNT)
    .setVerbose(false)
    .build();

  // set service-level authorization security policy
  if (confCopy.getBoolean(
    CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, false)) {
        server.refreshServiceAcl(confCopy, new HDFSPolicyProvider());
  }
}
 
Example #25
Source File: ClientDatanodeProtocolTranslatorPB.java    From big-c with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #26
Source File: SCMUploaderProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public SCMUploaderProtocolPBClientImpl(long clientVersion,
    InetSocketAddress addr, Configuration conf) throws IOException {
  RPC.setProtocolEngine(conf, SCMUploaderProtocolPB.class,
    ProtobufRpcEngine.class);
  proxy =
      RPC.getProxy(SCMUploaderProtocolPB.class, clientVersion, addr, conf);
}
 
Example #27
Source File: HadoopRpcService.java    From incubator-ratis with Apache License 2.0 5 votes vote down vote up
private void addRaftClientProtocol(RaftServer server, Configuration conf) {
  final Class<?> protocol = CombinedClientProtocolPB.class;
  RPC.setProtocolEngine(conf, protocol, ProtobufRpcEngine.class);

  final BlockingService service = CombinedClientProtocolService.newReflectiveBlockingService(
      new CombinedClientProtocolServerSideTranslatorPB(server));
  ipcServer.addProtocol(RPC.RpcKind.RPC_PROTOCOL_BUFFER, protocol, service);
}
 
Example #28
Source File: RpcServerFactoryPBImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private Server createServer(Class<?> pbProtocol, InetSocketAddress addr, Configuration conf, 
    SecretManager<? extends TokenIdentifier> secretManager, int numHandlers, 
    BlockingService blockingService, String portRangeConfig) throws IOException {
  RPC.setProtocolEngine(conf, pbProtocol, ProtobufRpcEngine.class);
  RPC.Server server = new RPC.Builder(conf).setProtocol(pbProtocol)
      .setInstance(blockingService).setBindAddress(addr.getHostName())
      .setPort(addr.getPort()).setNumHandlers(numHandlers).setVerbose(false)
      .setSecretManager(secretManager).setPortRangeConfig(portRangeConfig)
      .build();
  LOG.info("Adding protocol "+pbProtocol.getCanonicalName()+" to the server");
  server.addProtocol(RPC.RpcKind.RPC_PROTOCOL_BUFFER, pbProtocol, blockingService);
  return server;
}
 
Example #29
Source File: ResourceManagerAdministrationProtocolPBClientImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public ResourceManagerAdministrationProtocolPBClientImpl(long clientVersion, InetSocketAddress addr, 
    Configuration conf) throws IOException {
  RPC.setProtocolEngine(conf, ResourceManagerAdministrationProtocolPB.class, 
      ProtobufRpcEngine.class);
  proxy = (ResourceManagerAdministrationProtocolPB)RPC.getProxy(
      ResourceManagerAdministrationProtocolPB.class, clientVersion, addr, conf);
}
 
Example #30
Source File: HAServiceProtocolClientSideTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public HAServiceProtocolClientSideTranslatorPB(InetSocketAddress addr,
    Configuration conf) throws IOException {
  RPC.setProtocolEngine(conf, HAServiceProtocolPB.class,
      ProtobufRpcEngine.class);
  rpcProxy = RPC.getProxy(HAServiceProtocolPB.class,
      RPC.getProtocolVersion(HAServiceProtocolPB.class), addr, conf);
}