示例#1
0
文件: NameNode.java 项目: imace/hops
 /** Wait for service to finish. (Normally, it runs forever.) */
 public void join() {
   try {
     rpcServer.join();
   } catch (InterruptedException ie) {
     LOG.info("Caught interrupted exception ", ie);
   }
 }
示例#2
0
文件: NameNode.java 项目: imace/hops
 NamenodeRegistration setRegistration() throws IOException {
   nodeRegistration =
       new NamenodeRegistration(
           NetUtils.getHostPortString(rpcServer.getRpcAddress()),
           NetUtils.getHostPortString(getHttpAddress()),
           StorageInfo.getStorageInfoFromDB(),
           getRole()); // HOP change. previous code was getFSImage().getStorage()
   return nodeRegistration;
 }
示例#3
0
文件: NameNode.java 项目: imace/hops
  /** Start the services common to active and standby states */
  private void startCommonServices(Configuration conf) throws IOException {
    startHttpServer(conf);

    startLeaderElectionService();

    namesystem.startCommonServices(conf);

    rpcServer.start();
    plugins = conf.getInstances(DFS_NAMENODE_PLUGINS_KEY, ServicePlugin.class);
    for (ServicePlugin p : plugins) {
      try {
        p.start(this);
      } catch (Throwable t) {
        LOG.warn("ServicePlugin " + p + " could not be started", t);
      }
    }
    LOG.info(getRole() + " RPC up at: " + rpcServer.getRpcAddress());
    if (rpcServer.getServiceRpcAddress() != null) {
      LOG.info(getRole() + " service RPC up at: " + rpcServer.getServiceRpcAddress());
    }
  }
示例#4
0
文件: NameNode.java 项目: imace/hops
  private void startLeaderElectionService() throws IOException {
    // Initialize the leader election algorithm (only once rpc server is
    // created and httpserver is started)
    long leadercheckInterval =
        conf.getInt(
            DFSConfigKeys.DFS_LEADER_CHECK_INTERVAL_IN_MS_KEY,
            DFSConfigKeys.DFS_LEADER_CHECK_INTERVAL_IN_MS_DEFAULT);
    int missedHeartBeatThreshold =
        conf.getInt(
            DFSConfigKeys.DFS_LEADER_MISSED_HB_THRESHOLD_KEY,
            DFSConfigKeys.DFS_LEADER_MISSED_HB_THRESHOLD_DEFAULT);
    int leIncrement =
        conf.getInt(
            DFSConfigKeys.DFS_LEADER_TP_INCREMENT_KEY,
            DFSConfigKeys.DFS_LEADER_TP_INCREMENT_DEFAULT);

    leaderElection =
        new LeaderElection(
            new HdfsLeDescriptorFactory(),
            leadercheckInterval,
            missedHeartBeatThreshold,
            leIncrement,
            httpServer.getHttpAddress().getAddress().getHostAddress()
                + ":"
                + httpServer.getHttpAddress().getPort(),
            rpcServer.getRpcAddress().getAddress().getHostAddress()
                + ":"
                + rpcServer.getRpcAddress().getPort());
    leaderElection.start();

    try {
      leaderElection.waitActive();
    } catch (InterruptedException e) {
      LOG.warn("NN was interrupted");
    }
  }
示例#5
0
文件: NameNode.java 项目: imace/hops
 private void stopCommonServices() {
   if (namesystem != null) {
     namesystem.close();
   }
   if (rpcServer != null) {
     rpcServer.stop();
   }
   if (leaderElection != null && leaderElection.isRunning()) {
     leaderElection.stopElectionThread();
   }
   if (plugins != null) {
     for (ServicePlugin p : plugins) {
       try {
         p.stop();
       } catch (Throwable t) {
         LOG.warn("ServicePlugin " + p + " could not be stopped", t);
       }
     }
   }
   stopHttpServer();
 }
示例#6
0
文件: NameNode.java 项目: imace/hops
 /** @return NameNode service RPC address if configured, the NameNode RPC address otherwise */
 public InetSocketAddress getServiceRpcAddress() {
   final InetSocketAddress serviceAddr = rpcServer.getServiceRpcAddress();
   return serviceAddr == null ? rpcServer.getRpcAddress() : serviceAddr;
 }
示例#7
0
文件: NameNode.java 项目: imace/hops
 /** @return NameNode RPC address in "host:port" string form */
 public String getNameNodeAddressHostPortString() {
   return NetUtils.getHostPortString(rpcServer.getRpcAddress());
 }
示例#8
0
文件: NameNode.java 项目: imace/hops
 /** @return NameNode RPC address */
 public InetSocketAddress getNameNodeAddress() {
   return rpcServer.getRpcAddress();
 }