This runs on each node in the cluster.
485533
@Override public void setupLocal() {
    int idx = H2O.SELF.index();
    _result = new NodeProfile[H2O.CLOUD.size()];

    Map<String, Integer> countedStackTraces = new HashMap<>();

    final int repeats = 100;
    for (int i=0; i<repeats; ++i) {
      Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
      for (Map.Entry<Thread, StackTraceElement[]> el : allStackTraces.entrySet()) {
        StringBuilder sb = new StringBuilder();
        int j=0;
        for (StackTraceElement ste : el.getValue()) {
          String val = ste.toString();
          // filter out unimportant stuff
          if( j==0 && (   val.equals("sun.misc.Unsafe.park(Native Method)")
                  || val.equals("java.lang.Object.wait(Native Method)")
                  || val.equals("java.lang.Thread.sleep(Native Method)")
                  || val.equals("java.lang.Thread.yield(Native Method)")
                  || val.equals("java.net.PlainSocketImpl.socketAccept(Native Method)")
                  || val.equals("sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)")
                  || val.equals("sun.nio.ch.DatagramChannelImpl.receive0(Native Method)")
                  || val.equals("java.lang.Thread.dumpThreads(Native Method)")
          ) ) { break; }

          sb.append(ste.toString());
          sb.append("\n");
          j++;
          if (j==_stack_depth) break;
        }
        String st = sb.toString();
        boolean found = false;
        for (Map.Entry<String, Integer> entry : countedStackTraces.entrySet()) {
          if (entry.getKey().equals(st)) {
            entry.setValue(entry.getValue() + 1);
            found = true;
            break;
          }
        }
        if (!found) countedStackTraces.put(st, 1);
      }
      try {
        Thread.sleep(1);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }

    int i=0;
    _result[idx] = new NodeProfile(countedStackTraces.size());
    _result[idx].node_name = H2O.getIpPortString();
    _result[idx].timestamp = System.currentTimeMillis();
    for (Map.Entry<String, Integer> entry : countedStackTraces.entrySet()) {
      _result[idx].stacktraces[i] = entry.getKey();
      _result[idx].counts[i] = entry.getValue();
      i++;
    }

    // sort it
    Map<Integer, String> sorted = new TreeMap<>(Collections.reverseOrder());
    for (int j=0; j<_result[idx].counts.length; ++j) {
      if (_result[idx].stacktraces[j] != null && _result[idx].stacktraces[j].length() > 0)
        sorted.put(_result[idx].counts[j], _result[idx].stacktraces[j]);
    }

    // overwrite results
    String[] sorted_stacktraces = new String[sorted.entrySet().size()];
    int[] sorted_counts = new int[sorted.entrySet().size()];
    i=0;
    for (Map.Entry<Integer, String> e : sorted.entrySet()) {
      sorted_stacktraces[i] = e.getValue();
      sorted_counts[i] = e.getKey();
      i++;
    }
    _result[idx].stacktraces = sorted_stacktraces;
    _result[idx].counts = sorted_counts;
  }
1005969
@Override
  public void run() {
    try {
      startCleanupThreads();
      try {
        while (running && !shuttingDown) {
          try {
            heartbeatToClusterManager();
          } catch (IOException e) {
            LOG.error("Error initializing heartbeat to Cluster Manager", e);
            try {
              Thread.sleep(5000L);
            } catch (InterruptedException ie) {
            }
          }
          if (shuttingDown) {
            return;
          }
        }
      } finally {
        shutdown();
      }
    } catch (IOException iex) {
      LOG.error("Got fatal exception while initializing TaskTracker", iex);
      return;
    }
  }
242496
private void run() throws IOException, RepositoryException
   {
      // UUIDs of multiple nodes in the index
      Set<String> multipleEntries = new HashSet<String>();
      // collect all documents UUIDs
      documentUUIDs = new HashSet<String>();
      CachingMultiIndexReader reader = index.getIndexReader();
      try
      {
         for (int i = 0; i < reader.maxDoc(); i++)
         {
            if (i > 10 && i % (reader.maxDoc() / 5) == 0)
            {
               long progress = Math.round((100.0 * i) / (reader.maxDoc() * 2f));
               log.info("progress: " + progress + "%");
            }
            if (reader.isDeleted(i))
            {
               continue;
            }
            final int currentIndex = i;
            Document d = reader.document(currentIndex, FieldSelectors.UUID);
            String uuid = d.get(FieldNames.UUID);
            if (stateMgr.getItemData(uuid) != null)
            {
               if (!documentUUIDs.add(uuid))
               {
                  multipleEntries.add(uuid);
               }
            }
            else
            {
               errors.add(new NodeDeleted(uuid));
            }
         }
      }
      finally
      {
         reader.release();
      }

      // create multiple entries errors
      for (Iterator<String> it = multipleEntries.iterator(); it.hasNext();)
      {
         errors.add(new MultipleEntries(it.next()));
      }

      reader = index.getIndexReader();
      try
      {
         // run through documents again and check parent
         for (int i = 0; i < reader.maxDoc(); i++)
         {
            if (i > 10 && i % (reader.maxDoc() / 5) == 0)
            {
               long progress = Math.round((100.0 * i) / (reader.maxDoc() * 2f));
               log.info("progress: " + (progress + 50) + "%");
            }
            if (reader.isDeleted(i))
            {
               continue;
            }
            final int currentIndex = i;
            Document d = reader.document(currentIndex, FieldSelectors.UUID_AND_PARENT);
            String uuid = d.get(FieldNames.UUID);
            String parentUUIDString = d.get(FieldNames.PARENT);

            if (parentUUIDString == null || documentUUIDs.contains(parentUUIDString))
            {
               continue;
            }

            // parent is missing
            //NodeId parentId = new NodeId(parentUUID);
            if (stateMgr.getItemData(parentUUIDString) != null)
            {
               errors.add(new MissingAncestor(uuid, parentUUIDString));
            }
            else
            {
               errors.add(new UnknownParent(uuid, parentUUIDString));
            }
         }
      }
      finally
      {
         reader.release();
      }
   }
938951
public void process(Clustering<?> result1, Clustering<?> result2) {
    // Get the clusters
    final List<? extends Cluster<?>> cs1 = result1.getAllClusters();
    final List<? extends Cluster<?>> cs2 = result2.getAllClusters();

    // Initialize
    size1 = cs1.size();
    size2 = cs2.size();
    contingency = new int[size1 + 2][size2 + 2];
    noise1 = BitsUtil.zero(size1);
    noise2 = BitsUtil.zero(size2);

    // Fill main part of matrix
    {
      final Iterator<? extends Cluster<?>> it2 = cs2.iterator();
      for(int i2 = 0; it2.hasNext(); i2++) {
        final Cluster<?> c2 = it2.next();
        if(c2.isNoise()) {
          BitsUtil.setI(noise2, i2);
        }
        contingency[size1 + 1][i2] = c2.size();
        contingency[size1 + 1][size2] += c2.size();
      }
    }
    final Iterator<? extends Cluster<?>> it1 = cs1.iterator();
    for(int i1 = 0; it1.hasNext(); i1++) {
      final Cluster<?> c1 = it1.next();
      if(c1.isNoise()) {
        BitsUtil.setI(noise1, i1);
      }
      final DBIDs ids = DBIDUtil.ensureSet(c1.getIDs());
      contingency[i1][size2 + 1] = c1.size();
      contingency[size1][size2 + 1] += c1.size();

      final Iterator<? extends Cluster<?>> it2 = cs2.iterator();
      for(int i2 = 0; it2.hasNext(); i2++) {
        final Cluster<?> c2 = it2.next();
        int count = DBIDUtil.intersectionSize(ids, c2.getIDs());
        contingency[i1][i2] = count;
        contingency[i1][size2] += count;
        contingency[size1][i2] += count;
        contingency[size1][size2] += count;
      }
    }
  }
881985
protected void findClusters() {

		for (int i = 0; i < nodes.size(); i++) {
			SquareNode n = nodes.get(i);

			if( n.graph < 0 ) {
				n.graph = clusters.size();
				List<SquareNode> graph = clusters.grow();
				graph.add(n);
				addToCluster(n, graph);
			}
		}
	}
1237937
public void setNodes(final @Nonnull Collection<? extends Node> nodes) throws IOException {
        Queue.withLock(new Runnable() {
            @Override
            public void run() {
                Set<String> toRemove = new HashSet<>(Nodes.this.nodes.keySet());
                for (Node n : nodes) {
                    final String name = n.getNodeName();
                    toRemove.remove(name);
                    Nodes.this.nodes.put(name, n);
                }
                Nodes.this.nodes.keySet().removeAll(toRemove); // directory clean up will be handled by save
                jenkins.updateComputerList();
                jenkins.trimLabels();
            }
        });
        save();
    }
815666
public void run() {
        System.out.print(HORIZONTAL_RULE);
        System.out.println(" Starting Processing");
        System.out.println(HORIZONTAL_RULE);

        // Print periodic stats/analysis to the console
        scheduler.scheduleWithFixedDelay(reporter,
                config.displayinterval,
                config.displayinterval,
                TimeUnit.SECONDS);

        // Update the partition key set, row counts and redundancy level 4 times per second
        scheduler.scheduleWithFixedDelay(partitionTracker,
                0,
                250,
                TimeUnit.MILLISECONDS);

        // Start tracking changes to the maximum value after a 5 second delay to
        // let things settle a bit. Then check up to 100 times per second.
        scheduler.scheduleWithFixedDelay(maxTracker,
                5000,
                10,
                TimeUnit.MILLISECONDS);

        // Run the benchmark loop for the requested duration
        // The throughput may be throttled depending on client configuration
        inserter.run();

        System.out.print(HORIZONTAL_RULE);
        System.out.println(" Processing Complete");
        System.out.println(HORIZONTAL_RULE);

        shutdown();
    }
319119
protected void rebuild() {
		// Checks if the number of nodes in the tree exceeds the maximum number
		while (this.rootCount > this.maxNumClusterFeatures) {
			// Doubles the global threshold
			this.T *= 2.0;
			this.root.setThreshold(calcRSquared(1));
			// Adds all nodes to the ClusteringFeature tree again
			Queue<ClusteringTreeNode> Q = new LinkedList<ClusteringTreeNode>();
			Q.addAll(this.root.getChildren());
			this.root.clearChildren();
			this.rootCount = 0;
			while (!Q.isEmpty()) {
				ClusteringTreeNode x = Q.element();
				Q.addAll(x.getChildren());
				x.clearChildren();
				bicoCFUpdate(x);
				Q.remove();
			}
		}
	}
502619
public function run(): void
    {
        foreach ($this->seed as $key => $value) {
            $this->call($this->each, $value, $key);
        }
    }
74240
public void init(Cluster cluster, Map<String, Node> nodeIdToNode) {
        _cluster = cluster;
        _nodeIdToNode = nodeIdToNode;
    }
834860
def run(cluster, started_by: nil, **args)
      overrides_json = json_generator.generate_override_json(**args)
      info = Ecs.run_task(cluster.name, register,
                          started_by: started_by,
                          overrides_json: overrides_json)
      info.fetch("tasks")[0].fetch("taskArn")
    end
1028909
@Override
    public void run() {
        while (true) {
            if (countObservers() == 0) {
                try {
                    Thread.sleep(Long.MAX_VALUE);
                } catch (InterruptedException e) {
                }
            } else {
                startWatching();
                while (countObservers() > 0) {
                    getNewLines();
                    try {
                        Thread.sleep(getDelay());
                    } catch (InterruptedException e) {
                    }
                }
            }
        }
    }
655670
public Map<GraphObject, Integer> run()
	{
		initMaps();

		// Add all source nodes to the queue if traversal is needed

		if (limit > 0)
		{
			queue.addAll(sourceSet);
		}

		// Initialize dist and color of source set

		for (Node source : sourceSet)
		{
			setLabel(source, 0);
			setColor(source, GRAY);

			labelEquivRecursive(source, UPWARD, 0, true, false);
			labelEquivRecursive(source, DOWNWARD, 0, true, false);
		}

		// Process the queue

		while (!queue.isEmpty())
		{
			Node current = queue.remove(0);

			processNode(current);

			// Current node is processed
			setColor(current, BLACK);
		}

		return dist;
	}
168970
public void each(Each<Props> each) {

        for (Map.Entry<String, Props> entry : pathMap.entrySet()) {
            Props props = entry.getValue();

            each.execute(props);
        }
    }
758810
private synchronized void doNodeLeft(final String nodeID) {
    log.info(String.format("%s - %s left the cluster", this, nodeID));
    context.run(new Runnable() {
      @Override
      public void run() {
        // Redeploy any failed deployments.
        synchronized (deployments) {
          Collection<String> sdeploymentsInfo = deployments.get(group);
          for (final String sdeploymentInfo : sdeploymentsInfo) {
            final JsonObject deploymentInfo = new JsonObject(sdeploymentInfo);
            // If the deployment node is equal to the node that left the cluster then
            // remove the deployment from the deployments list and attempt to redeploy it.
            if (deploymentInfo.getString("node").equals(nodeID)) {
              // If the deployment is an HA deployment then attempt to redeploy it on this node.
              if (deployments.remove(group, sdeploymentInfo) && deploymentInfo.getBoolean("ha", false)) {
                doRedeploy(deploymentInfo);
              }
            }
          }
        }
      }
    });
  }
639988
def cluster(&block)
      cluster = Cluster.new(self, :logger => logger)
      block ? block.call(cluster) : cluster
    end
1276787
def run(self):
        """"""
        while self.keep_listening:
            for interface in self.node.interfaces:
                try:
                    self.recv(self.node.inq[interface].get(timeout=0), interface)
                except Empty:
                    sleep(0.01)