Called when worker is taking too long to disconnect

@private
@param worker
@param cluster
517190
function disconnectTimeoutHandler(worker, cluster) {
    verbose('worker %d is stuck in disconnect', worker.process.pid);

    // if this is not a suicide we need to preserve that as worker.kill() will make this a suicide
    if (!worker.suicide) {
      master.suicideOverrides[worker.id] = worker.id;
    }

    master.isRunning(worker, function(running) {
      if (!running) {
        return;
      }

      try {
        debug('sending SIGKILL to worker %d', worker.process.pid);
        process.kill(worker.process.pid, 'SIGKILL');
      } catch (e) {
        // this can happen.  don't crash!!
      }
    });
  }
1325922
function WorkerFn(root) {
  var timers = {};

  root.onmessage = function (event) {
    switch (event.data.type) {
      case 'ping':
        root.postMessage({ type: 'pong' });
        break;

      case 'set_timeout':
        timers[event.data.id] = setTimeout(function () {
          root.postMessage({ type: 'tick', id: event.data.id });
        }, event.data.delay);
        break;

      case 'clear_timeout':
        clearTimeout(timers[event.data.id]);
        break;

      case 'set_interval':
        timers[event.data.id] = setInterval(function () {
          root.postMessage({ type: 'tick', id: event.data.id });
        }, event.data.interval);
        break;

      case 'clear_interval':
        clearInterval(timers[event.data.id]);
        break;
    }
  };
}
722230
private void handleClusterEvent(ClusterMembershipEvent event) {
    raft.getThreadContext().execute(() -> {
      if (event.type() == ClusterMembershipEvent.Type.MEMBER_REMOVED) {
        log.debug("Node {} deactivated", event.subject().id());
        raft.getSessions().getSessions().stream()
            .filter(session -> session.memberId().equals(event.subject().id()))
            .forEach(this::expireSession);
      }
    });
  }
752951
public void locateCluster(String cluster, Handler<AsyncResult<String>> doneHandler) {
    Set<String> registry = vertx.sharedData().getSet(cluster);
    synchronized (registry) {
      if (!registry.isEmpty()) {
        locateNode(cluster, new HashSet<>(registry), doneHandler);
      }
    }
  }
1372947
private void proxyPause() {
        logger.info("Pausing after cluster state has changed to allow proxy bridges to be established. "
                    + "Will start rebalancing work on servers in "
                    + proxyPauseSec
                    + " seconds.");
        try {
            Thread.sleep(TimeUnit.SECONDS.toMillis(proxyPauseSec));
        } catch(InterruptedException e) {
            logger.warn("Sleep interrupted in proxy pause.");
        }
    }
35037
function (clusterTimeout) {
        clearReconnectInterval();

        if (isConnecting) {
            delegateExceptionCallback(ortc, 'Unable to connect...');
            disconnectSocket();
        }

        isConnecting = true;

        delegateReconnectingCallback(ortc);

        reconnectStartedAt = new Date().getTime();

        if (clusterUrl && clusterUrl != null) {
            clusterConnection(clusterTimeout);
        }
        else {
            ortc.sockjs = createSocketConnection(url);
        }

        if (!ortc.reconnectTimeoutlId) {
            // Timeout to reconnect
            ortc.reconnectTimeoutlId = setTimeout(function () {
                if (!isConnected) {
                    reconnectSocket(ortc.getConnectionTimeout());
                }
            }, ortc.getConnectionTimeout());
        }
    }
506853
private Runnable shutdownAfterHandoff(final String workUnit)
    {
        final Cluster cluster = this.cluster;
        final Logger log = LOG;
        return new Runnable() {
            @Override
            public void run() {
                String str = cluster.getHandoffResult(workUnit);
                log.info("Shutting down {} following handoff to {}.",
                        workUnit, (str == null) ? "(None)" : str);
                cluster.shutdownWork(workUnit, /*doLog =*/ false);

                if (cluster.hasState(NodeState.Draining) && cluster.myWorkUnits.isEmpty()) {
                    cluster.shutdown();
                }
            }
        };
    }
720036
def do_stop_cluster(self, cluster):
        
        try:
            cluster = api.get_cluster(cluster)
            cluster.stop()
            print("Stopping Cluster")
        except ApiException:
            print("Cluster not found")
            return None
988615
function handleWorkerRestart(worker, code, signal) {
		delete self.workers[worker.id];
		if (self.reviveWorkers) {
			var zombie = cluster.fork({
				config: JSON.stringify(self.config)
			});
			self.workers[zombie.id] = zombie;
		}
	}
86847
private void disconnect(final Handler<AsyncResult<Void>> doneHandler) {
    eventBus.sendWithTimeout(inAddress, new JsonObject().putString("action", "disconnect"), 5000, new Handler<AsyncResult<Message<Boolean>>>() {
      @Override
      public void handle(AsyncResult<Message<Boolean>> result) {
        if (result.failed()) {
          ReplyException failure = (ReplyException) result.cause();
          if (failure.failureType().equals(ReplyFailure.RECIPIENT_FAILURE)) {
            log.warn(String.format("%s - Failed to disconnect from %s", DefaultOutputConnection.this, context.target()), result.cause());
            new DefaultFutureResult<Void>(failure).setHandler(doneHandler);
          } else if (failure.failureType().equals(ReplyFailure.NO_HANDLERS)) {
            log.info(String.format("%s - Disconnected from %s", DefaultOutputConnection.this, context.target()));
            new DefaultFutureResult<Void>((Void) null).setHandler(doneHandler);
          } else {
            log.debug(String.format("%s - Disconnection from %s failed, retrying", DefaultOutputConnection.this, context.target()));
            disconnect(doneHandler);
          }
        } else if (result.result().body()) {
          log.info(String.format("%s - Disconnected from %s", DefaultOutputConnection.this, context.target()));
          open = false;
          new DefaultFutureResult<Void>((Void) null).setHandler(doneHandler);
        } else {
          log.debug(String.format("%s - Disconnection from %s failed, retrying", DefaultOutputConnection.this, context.target()));
          vertx.setTimer(500, new Handler<Long>() {
            @Override
            public void handle(Long timerID) {
              disconnect(doneHandler);
            }
          });
        }
      }
    });
  }
130201
function workerProbe () {
  Object.keys(cluster.workers).forEach(function (id) {
    cluster.workers[id].send(['trans'])
  })
}
396328
function Worker() {
    this.config = JSON.parse(process.env.WORKER_CONFIG);
    if (typeof this.config !== 'object') {
      throw new Error('WORKER_CONFIG is missing');
    }
    process.title = process.variousCluster = this.config.title;
  }
1259559
def _do_timeout_for_leave(self, timeout, datapath, dst, in_port):
        """"""
        parser = datapath.ofproto_parser
        dpid = datapath.id

        hub.sleep(timeout)
        outport = self._to_querier[dpid]['port']

        if self._to_hosts[dpid][dst]['ports'][in_port]['out']:
            return

        del self._to_hosts[dpid][dst]['ports'][in_port]
        self._del_flow_entry(datapath, in_port, dst)
        actions = []
        ports = []
        for port in self._to_hosts[dpid][dst]['ports']:
            actions.append(parser.OFPActionOutput(port))
            ports.append(port)

        if len(actions):
            self._send_event(
                EventMulticastGroupStateChanged(
                    MG_MEMBER_CHANGED, dst, outport, ports))
            self._set_flow_entry(
                datapath, actions, outport, dst)
            self._to_hosts[dpid][dst]['leave'] = None
        else:
            self._remove_multicast_group(datapath, outport, dst)
            del self._to_hosts[dpid][dst]
1149303
function(signal)
    {
        return new Promise( resolve =>
        {
            for (let uniqueID in cluster.workers)
            {
                if (cluster.workers.hasOwnProperty(uniqueID))
                {
                    const worker = cluster.workers[uniqueID];

                    worker.kill(signal);
                }
            }

            resolve();
        });
    }
292320
def cluster_meet(self, ip, port):
        """"""
        fut = self.execute(b'CLUSTER', b'MEET', ip, port)
        return wait_ok(fut)
93245
function(pool) {
    if (
      !connectionInCreation &&
      pool.idleConnections() < opts.minimumIdle &&
      pool.totalConnections() < opts.connectionLimit &&
      !closed
    ) {
      connectionInCreation = true;
      process.nextTick(() => {
        const timeoutEnd = Date.now() + opts.initializationTimeout;
        if (!closed) {
          connectionCreationLoop(pool, 0, timeoutEnd)
            .then(conn => {
              if (closed) {
                return conn.forceEnd().catch(err => {});
              }
              addPoolConnection(pool, conn);
            })
            .catch(err => {
              if (pool.totalConnections() === 0) {
                const task = taskQueue.shift();
                if (task) {
                  firstTaskTimeout = clearTimeout(firstTaskTimeout);
                  process.nextTick(task.reject, err);
                  resetTimeoutToNextTask();
                }
              } else if (!closed) {
                console.error(
                  `pool fail to create connection (${err.message})`
                );
              }

              //delay next try
              setTimeout(() => {
                connectionInCreation = false;
                if (taskQueue.size() > 0) {
                  ensurePoolSize(pool);
                }
              }, 500);
            });
        }
      });
    }
  }
195910
function Cluster(data) {
  var self = this;
  self.data = data;

  if (cluster.isMaster) {
    if (data.pid) {
      fs.writeFileSync(data.pid, process.pid);
    }
    let numCPUs = 1;
    if (data.count) {
      numCPUs = data.count;
    } else {
      numCPUs = require('os').cpus().length;
    }

    self.debug.log('Starting up %s workers.', numCPUs);
    for (var i = 0; i < numCPUs; i++) {
      cluster.fork();
    }

    cluster.on('online', function(worker) {
      self.debug.log('Worker %s is online', worker.process.pid);
    });

    cluster.on('exit', function(worker, code, signal) {
      self.debug.log('Worker %s died. code %s signal %s', worker.process.pid, code, signal);
      self.debug.log('Starting a new worker');
      cluster.fork();
    });

    cluster.on('listening', function(worker, address) {
      if (self.data.callbacks['init']) {
        self.data.callbacks['init'](cluster, worker, address);
      }
    });

    process.on('SIGINT', function() {
      self.debug.log('Caught interrupt signal');
      if (data.pid) {
        fs.unlinkSync(data.pid);
      }
      process.exit();
    });
  } else {
    var webServer = new WebHttp(self.data);

    process.on('SIGINT', function() {
      self.debug.worker('Caught interrupt signal');
      webServer.stop();
    });

    process.on('SIGTERM', function() {
        self.debug.worker('Caught termination signal');
        webServer.stop();
      }
    );
  }
  return cluster;
}