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


Java HAServiceProtocolPB类代码示例

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


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

示例1: startAndGetRPCServerAddress

import org.apache.hadoop.ha.protocolPB.HAServiceProtocolPB; //导入依赖的package包/类
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;
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:23,代码来源:DummyHAService.java

示例2: startServer

import org.apache.hadoop.ha.protocolPB.HAServiceProtocolPB; //导入依赖的package包/类
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());
}
 
开发者ID:naver,项目名称:hadoop,代码行数:39,代码来源:AdminService.java

示例3: startServer

import org.apache.hadoop.ha.protocolPB.HAServiceProtocolPB; //导入依赖的package包/类
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());
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:37,代码来源:AdminService.java

示例4: start

import org.apache.hadoop.ha.protocolPB.HAServiceProtocolPB; //导入依赖的package包/类
public void start() throws IOException {

    Configuration jtConf = new Configuration(conf);
    String logicalName = HAUtil.getLogicalName(jtConf);
    String jtId = HAUtil.getJobTrackerId(jtConf);
    HAUtil.setGenericConf(jtConf, logicalName, jtId, HAUtil.JOB_TRACKER_SPECIFIC_KEYS);

    // Login HA daemon, if auth is not kerberos login() is a NOP
    InetSocketAddress addr = HAUtil.getJtHaRpcAddress(conf, jtId);
    String localMachine = addr.getHostName();
    UserGroupInformation.setConfiguration(conf);
    SecurityUtil.login(conf, JobTracker.JT_KEYTAB_FILE, JobTracker.JT_USER_NAME, localMachine);
    
    // To avoid the JT from doing a new login() as re-login seems to be destructive
    JobTracker.loggedIn = true;
    
    //Using a thread outside of all login context to start/stop the JT
    //otherwise the credentials of the UGI making the RPC call to activate
    //get in the way breaking things.
    jtRunner = new JobTrackerRunner();
    jtRunner.start();
            
    this.proto = new JobTrackerHAServiceProtocol(jtConf, jtRunner);
    
    RPC.setProtocolEngine(conf, HAServiceProtocolPB.class,
        ProtobufRpcEngine.class);
    
    HAServiceProtocolServerSideTranslatorPB haServiceProtocolXlator = 
      new HAServiceProtocolServerSideTranslatorPB(proto);
    BlockingService haPbService = HAServiceProtocolService
        .newReflectiveBlockingService(haServiceProtocolXlator);
    
    WritableRpcEngine.ensureInitialized();
    
    InetSocketAddress rpcAddr = HAUtil.getJtHaRpcAddress(conf);

    this.rpcServer = RPC.getServer(HAServiceProtocolPB.class, haPbService,
        rpcAddr.getHostName(), rpcAddr.getPort(), conf);

    // set service-level authorization security policy
    if (conf.getBoolean(
        CommonConfigurationKeys.HADOOP_SECURITY_AUTHORIZATION, false)) {
      rpcServer.refreshServiceAcl(conf, new MapReducePolicyProvider());
    }

    this.rpcServer.start();
    
    // set port in config
    int port = rpcServer.getListenerAddress().getPort();
    HAUtil.setJtHaRpcAddress(conf, rpcAddr.getHostName() + ":" + port);
    LOG.info("Started " + getClass().getSimpleName() + " on port " + port);
  }
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:53,代码来源:JobTrackerHADaemon.java


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