Pause all cluster nodes - ensure that we store data so that in
        the future the nodes can be restarted.

        :return: int - number of failures.
1017
def _pause_all_nodes(self, max_thread_pool_size=0):
        
        failed = 0

        def _pause_specific_node(node):
            if not node.instance_id:
                log.warning("Node `%s` has no instance id."
                            " It is either already stopped, or"
                            " never created properly.  Not attempting"
                            " to stop it again.", node.name)
                return None
            try:
                return node.pause()
            except Exception as err:
                log.error(
                    "Could not stop node `%s` (instance ID `%s`): %s %s",
                    node.name, node.instance_id, err, err.__class__)
                node.update_ips()
                return None

        nodes = self.get_all_nodes()
        thread_pool = self._make_thread_pool(max_thread_pool_size)
        for node, state in zip(nodes, thread_pool.map(_pause_specific_node, nodes)):
            if state is None:
                failed += 1
            else:
                self.paused_nodes[node.name] = state

        return failed
1305742
def _start_nodes_parallel(self, nodes, max_thread_pool_size):
        
        # Create one thread for each node to start
        thread_pool_size = min(len(nodes), max_thread_pool_size)
        thread_pool = Pool(processes=thread_pool_size)
        log.debug("Created pool of %d threads", thread_pool_size)

        # pressing Ctrl+C flips this flag, which in turn stops the main loop
        # down below
        keep_running = True

        def sigint_handler(signal, frame):
            """
            Makes sure the cluster is saved, before the sigint results in
            exiting during node startup.
            """
            log.error(
                "Interrupted: will save cluster state and exit"
                " after all nodes have started.")
            keep_running = False

        # intercept Ctrl+C
        with sighandler(signal.SIGINT, sigint_handler):
            result = thread_pool.map_async(self._start_node, nodes)
            while not result.ready():
                result.wait(1)
                # check if Ctrl+C was pressed
                if not keep_running:
                    log.error("Aborting upon user interruption ...")
                    # FIXME: `.close()` will keep the pool running until all
                    # nodes have been started; should we use `.terminate()`
                    # instead to interrupt node creation as soon as possible?
                    thread_pool.close()
                    thread_pool.join()
                    self.repository.save_or_update(self)
                    # FIXME: should raise an exception instead!
                    sys.exit(1)

            # keep only nodes that were successfully started
            return set(node for node, ok
                       in itertools.izip(nodes, result.get()) if ok)
1056712
def stop(self):
        
        self._stopped = True
        for result in self._results:
            result._set_result(Failure(ReactorStopped()))
239571
def pause(self):
        """"""
        yield from self.manager.query("POST", "containers/{}/pause".format(self._cid))
        self.status = "suspended"
        log.info("Docker container '{name}' [{image}] paused".format(name=self._name, image=self._image))
919015
def atlas_node_stop( atlas_state ):
    
    for component in atlas_state.keys():
        log.debug("Stopping Atlas component '%s'" % component)
        atlas_state[component].ask_join()
        atlas_state[component].join()

    return True
862157
def recursively_pause_states(self):
        
        super(ContainerState, self).recursively_pause_states()
        for state in self.states.values():
            state.recursively_pause_states()
831660
def stop(self):
        
        stopped = []
        for host, _ in self.host_cores:
            if self.status(host)[0][1] == 'not-running':
                print('%s not running' % host)
                continue
            ctrl_url = 'tcp://%s:%s' % (host, self.ctrl_port)
            with z.Socket(ctrl_url, z.zmq.REQ, 'connect') as sock:
                sock.send('stop')
                stopped.append(host)
        if hasattr(self, 'streamer'):
            self.streamer.terminate()
        return 'stopped %s' % stopped
1123866
def resume(self):
        
        if self.get_thread_count() == 0:
            self.scan_threads() # only refresh the snapshot if empty
        resumed = list()
        try:
            for aThread in self.iter_threads():
                aThread.resume()
                resumed.append(aThread)
        except Exception:
            for aThread in resumed:
                try:
                    aThread.suspend()
                except Exception:
                    pass
            raise
912388
public void stop() throws IOException, InterruptedException {
    for (int i = services.size() - 1; i >= 0; i--) {
      Service service = services.get(i);
      logger.info("Stopping Minicluster Service: "
          + service.getClass().getName());
      service.stop();
    }
    logger.info("All Minicluster Services stopped.");
  }
1199951
def fail_remaining(self):
        
        self._failed.update(self._graph.nodes)
        self._graph = Graph()
        self._running = set()
738555
function fork() {
            cluster.fork().on('message', function(message) {
                if (message.cmd === 'restart' && message.pid && restartQueue.indexOf(message.pid) === -1) {
                    // When worker asks to restart gracefully in cluster, then add it to restart queue.
                    log('Cluster graceful shutdown: queued. pid=' + message.pid);
                    restartQueue.push(message.pid);
                    checkRestartQueue();
                }
            });
        }
653957
def check_pause(self, low):
        '''
        
        '''
        if not self.jid:
            # Can't pause on salt-ssh since we can't track continuous state
            return
        pause_path = os.path.join(self.opts['cachedir'], 'state_pause', self.jid)
        start = time.time()
        if os.path.isfile(pause_path):
            try:
                while True:
                    tries = 0
                    with salt.utils.files.fopen(pause_path, 'rb') as fp_:
                        try:
                            pdat = msgpack_deserialize(fp_.read())
                        except msgpack.UnpackValueError:
                            # Reading race condition
                            if tries > 10:
                                # Break out if there are a ton of read errors
                                return
                            tries += 1
                            time.sleep(1)
                            continue
                        id_ = low['__id__']
                        key = ''
                        if id_ in pdat:
                            key = id_
                        elif '__all__' in pdat:
                            key = '__all__'
                        if key:
                            if 'duration' in pdat[key]:
                                now = time.time()
                                if now - start > pdat[key]['duration']:
                                    return 'run'
                            if 'kill' in pdat[key]:
                                return 'kill'
                        else:
                            return 'run'
                        time.sleep(1)
            except Exception as exc:
                log.error('Failed to read in pause data for file located at: %s', pause_path)
                return 'run'
        return 'run'
303598
async def wait_nodes(self, timeout, check_ready=True):
        
        return await self.wait_slaves(timeout, check_ready=check_ready)
318046
public synchronized void stop() throws IOException, TimeoutException {
    if (this.stopped) {
      return;
    }

    LOGGER.info("Stopping the " + GobblinAWSClusterLauncher.class.getSimpleName());

    try {
      if (this.clusterId.isPresent()) {
        sendShutdownRequest();
      }

      disconnectHelixManager();
    } finally {
      try {
        if (this.clusterId.isPresent()) {
          cleanUpClusterWorkDirectory(this.clusterId.get());
        }
      } finally {
        this.closer.close();
      }
    }

    this.countDownLatch.countDown();
    this.stopped = true;
  }
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.");
        }
    }
530432
def wait_for_compactions(self, timeout=600):
        
        for node in list(self.nodes.values()):
            if node.is_running():
                node.wait_for_compactions(timeout)
        return self
788336
def stop(self, sig=signal.SIGINT):
        ''''''
        for cpid in self.sandboxes:
            logger.warn('Stopping %i...' % cpid)
            try:
                os.kill(cpid, sig)
            except OSError:  # pragma: no cover
                logger.exception('Error stopping %s...' % cpid)

        # While we still have children running, wait for them
        # We edit the dictionary during the loop, so we need to copy its keys
        for cpid in list(self.sandboxes):
            try:
                logger.info('Waiting for %i...' % cpid)
                pid, status = os.waitpid(cpid, 0)
                logger.warn('%i stopped with status %i' % (pid, status >> 8))
            except OSError:  # pragma: no cover
                logger.exception('Error waiting for %i...' % cpid)
            finally:
                self.sandboxes.pop(cpid, None)