Exemple #1
0
 /**
  * Refresh the includes/excludes information.
  *
  * @throws IOException
  */
 public synchronized void refreshNodes() throws IOException {
   hostsReader.refresh();
   LOG.info(
       "After refresh Included hosts: "
           + hostsReader.getHostNames().size()
           + " Excluded hosts: "
           + hostsReader.getExcludedHosts().size());
   Set<String> newHosts = hostsReader.getHostNames();
   Set<String> newExcludes = hostsReader.getExcludedHosts();
   Set<ClusterNode> hostsToExclude = new HashSet<ClusterNode>();
   for (ClusterNode tmpNode : nameToNode.values()) {
     String host = tmpNode.getHost();
     // Check if not included or explicitly excluded.
     if (!newHosts.contains(host) || newExcludes.contains(host)) {
       hostsToExclude.add(tmpNode);
     }
   }
   for (ClusterNode node : hostsToExclude) {
     synchronized (node) {
       for (Map.Entry<ResourceType, RunnableIndices> entry : typeToIndices.entrySet()) {
         ResourceType type = entry.getKey();
         RunnableIndices r = entry.getValue();
         if (r.hasRunnable(node)) {
           LOG.info(
               "Node "
                   + node.getName()
                   + " is no longer "
                   + type
                   + " runnable because it is excluded");
           r.deleteRunnable(node);
         }
       }
     }
   }
 }
Exemple #2
0
 /**
  * NodeManager constructor given a cluster manager and a {@link HostsFileReader} for
  * includes/excludes lists
  *
  * @param clusterManager the cluster manager
  * @param hostsReader the host reader for includes/excludes
  */
 public NodeManager(ClusterManager clusterManager, HostsFileReader hostsReader) {
   this.hostsReader = hostsReader;
   LOG.info(
       "Included hosts: "
           + hostsReader.getHostNames().size()
           + " Excluded hosts: "
           + hostsReader.getExcludedHosts().size());
   this.clusterManager = clusterManager;
   this.expireNodesThread = new Thread(this.expireNodes, "expireNodes");
   this.expireNodesThread.setDaemon(true);
   this.expireNodesThread.start();
   this.faultManager = new FaultManager(this);
 }
Exemple #3
0
 /** Update metrics for alive/dead nodes. */
 private void setAliveDeadMetrics() {
   clusterManager.getMetrics().setAliveNodes(nameToNode.size());
   int totalHosts = hostsReader.getHosts().size();
   if (totalHosts > 0) {
     clusterManager.getMetrics().setDeadNodes(totalHosts - nameToNode.size());
   }
 }
Exemple #4
0
 /**
  * Checks if a host is allowed to communicate with the cluster manager.
  *
  * @param host The host
  * @return a boolean indicating if the host is allowed.
  */
 private boolean canAllowNode(String host) {
   return hostsReader.isAllowedHost(host);
 }
Exemple #5
0
 /** @return The excluded hosts. */
 public Set<String> getExcludedNodes() {
   return hostsReader.getExcludedHosts();
 }
Exemple #6
0
 /** @return The number of excluded hosts. */
 public int getExcludedNodeCount() {
   return hostsReader.getExcludedHosts().size();
 }
Exemple #7
0
 /** @return All the configured hosts. */
 public Set<String> getAllNodes() {
   return hostsReader.getHostNames();
 }
Exemple #8
0
 /** @return The total number of configured hosts. */
 public int getTotalNodeCount() {
   return hostsReader.getHosts().size();
 }