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


Java HAServiceProtocolService.newReflectiveBlockingService方法代码示例

本文整理汇总了Java中org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceProtocolService.newReflectiveBlockingService方法的典型用法代码示例。如果您正苦于以下问题:Java HAServiceProtocolService.newReflectiveBlockingService方法的具体用法?Java HAServiceProtocolService.newReflectiveBlockingService怎么用?Java HAServiceProtocolService.newReflectiveBlockingService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceProtocolService的用法示例。


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

示例1: startAndGetRPCServerAddress

import org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceProtocolService; //导入方法依赖的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: start

import org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceProtocolService; //导入方法依赖的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.proto.HAServiceProtocolProtos.HAServiceProtocolService.newReflectiveBlockingService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。