/** Wait for service to finish. (Normally, it runs forever.) */ public void join() { try { rpcServer.join(); } catch (InterruptedException ie) { LOG.info("Caught interrupted exception ", ie); } }
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; }
/** 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()); } }
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"); } }
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(); }
/** @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; }
/** @return NameNode RPC address in "host:port" string form */ public String getNameNodeAddressHostPortString() { return NetUtils.getHostPortString(rpcServer.getRpcAddress()); }
/** @return NameNode RPC address */ public InetSocketAddress getNameNodeAddress() { return rpcServer.getRpcAddress(); }