Controlled shutdown of pool. Go through the list of available clients
in the queue and call {@link HClient#close()} on each. Toggles
a flag to indicate we are going into shutdown mode. Any subsequent calls
will throw an IllegalArgumentException.
339831
@Override
  public void shutdown() {
    if (!active.compareAndSet(true, false) ) {
      throw new IllegalArgumentException("shutdown() called for inactive pool: " + getName());
    }
    log.info("Shutdown triggered on {}", getName());
    Set<HClient> clients = new HashSet<HClient>();
    availableClientQueue.drainTo(clients);
    if ( clients.size() > 0 ) {
      for (HClient hClient : clients) {
        hClient.close();
      }
    }
    log.info("Shutdown complete on {}", getName());
  }
894257
public static void close() {
    synchronized (poolMap) {
      for (Pool pool : poolMap.values()) {
        try {
          pool.close();
        } catch (InterruptedException exception) {
          //eat
        }
      }
      shutdownExecutor();
      poolMap.clear();
    }
  }
426369
ListenableFuture<Void> closeAsync() {
    ListenableFuture<Void> retFuture = null;
    synchronized (lock) {
      if (closureFuture != null) {
        throw new IllegalStateException("Close has already been invoked");
      }
      // Fail all pending waiters.
      Waiter waiter = readWaiters.poll();
      while (waiter != null) {
        waiter.put(newSpannerException(ErrorCode.INTERNAL, "Client has been closed"));
        waiter = readWaiters.poll();
      }
      waiter = readWriteWaiters.poll();
      while (waiter != null) {
        waiter.put(newSpannerException(ErrorCode.INTERNAL, "Client has been closed"));
        waiter = readWriteWaiters.poll();
      }
      closureFuture = SettableFuture.create();
      retFuture = closureFuture;
      pendingClosure =
          totalSessions() + numSessionsBeingCreated + 1 /* For pool maintenance thread */;

      poolMaintainer.close();
      readSessions.clear();
      writePreparedSessions.clear();
      for (final PooledSession session : ImmutableList.copyOf(allSessions)) {
        if (session.leakedException != null) {
          logger.log(Level.WARNING, "Leaked session", session.leakedException);
        }
        if (session.state != SessionState.CLOSING) {
          closeSessionAsync(session);
        }
      }
    }
    retFuture.addListener(
        new Runnable() {
          @Override
          public void run() {
            executorFactory.release(executor);
          }
        },
        MoreExecutors.directExecutor());

    return retFuture;
  }
755807
def stop(self):
        
        if self.__end.is_set():
            return
        self.__end.set()
        self.__send_retry_requests_timer.cancel()
        self.__threadpool.stop()
        self.__crud_threadpool.stop()
        self.__amqplink.stop()
        self.__network_retry_thread.join()
        # Clear out remaining pending requests
        with self.__requests:
            shutdown = LinkShutdownException('Client stopped')
            for req in self.__requests.values():
                req.exception = shutdown
                req._set()
                self.__clear_references(req, remove_request=False)
            if self.__requests:
                logger.warning('%d unfinished request(s) discarded', len(self.__requests))
            self.__requests.clear()
        #
        self.__network_retry_thread = None
        self.__network_retry_queue = None
        self.__container_params = None
435536
public void shutdown() throws IOException {
		if(shutdownDone) {
			return;
		}
		if(resourceStore != null) {
			resourceStore.shutdown();
		}
		if(resourceIndex != null) {
			resourceIndex.shutdown();
		}
		if(shutdownables != null) {
			for(Shutdownable s : shutdownables) {
				s.shutdown();
			}
		}
		shutdownDone = true;
	}
1214552
@Override
  public ServerImpl shutdown() {
    boolean shutdownTransportServers;
    synchronized (lock) {
      if (shutdown) {
        return this;
      }
      shutdown = true;
      shutdownTransportServers = started;
      if (!shutdownTransportServers) {
        transportServersTerminated = true;
        checkForTermination();
      }
    }
    if (shutdownTransportServers) {
      for (InternalServer ts : transportServers) {
        ts.shutdown();
      }
    }
    return this;
  }
1152544
private void stopThreadPool(ExecutorService threadPool) {
        LibraryUtils.checkCondition(threadPool == null, "Thread pool is null when calling stop");

        if (threadPool.isShutdown()) {
            logger.debug(threadPool.toString() + " is already stopped.");

        } else {

            logger.debug(threadPool.toString() + " is about to shutdown.");
            threadPool.shutdown(); // Shutdown thread pool

            try { // Wait for shutdown
                threadPool.awaitTermination(config.getThreadTerminationDelaySeconds(), TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                logger.debug("Wait thread pool termination is interrupted.");
            }

            if (!threadPool.isShutdown()) { // ShutdownNow after waiting
                logger.debug(threadPool.toString() + " is force to shutdown now.");
                threadPool.shutdownNow();
            }

            logger.debug(threadPool.toString() + " is stopped.");
        }
    }
385114
public void shutDown() {
        synchronized (channels) {
            isCurrentlyShutingDown = true;
            for (final SynchronizeFXWebsocketChannel server : channels.values()) {
                server.shutdown();
            }
            servers.clear();
            channels.clear();
            clients.clear();
            isCurrentlyShutingDown = false;
        }
    }
500512
public void shutDown() {
    logger.info("Shutting down RPC server.");
    channel.close().addListener(new GenericFutureListener<Future<Void>>() {

      @Override
      public void operationComplete(Future<Void> future) throws Exception {
        parentGroup.shutdownGracefully();
        childGroup.shutdownGracefully();
      }
    }).awaitUninterruptibly();
  }
152788
public static void shutdown(HazelcastInstance instance) {
        if (instance instanceof HazelcastClientProxy) {
            final HazelcastClientProxy proxy = (HazelcastClientProxy) instance;
            HazelcastClientInstanceImpl client = proxy.client;
            if (client == null) {
                return;
            }
            proxy.client = null;
            CLIENTS.remove(client.getName());

            try {
                client.shutdown();
            } catch (Throwable ignored) {
                EmptyStatement.ignore(ignored);
            } finally {
                OutOfMemoryErrorDispatcher.deregisterClient(client);
            }
        }
    }
1373389
@Override
    public void shutdown() {
        try {
            verifyMaintainability();
        } catch (VerificationFailedException ex) {
            throw new RuntimeException("Can not shutdown " + this + "!", ex);
        }

        this.shutdownInitiated = true;
        try {
            dataObservable.shutdown();
        } finally {
            try {
                deactivate();
            } catch (CouldNotPerformException | InterruptedException ex) {
                ExceptionPrinter.printHistory("Could not shutdown " + this + "!", ex, logger);
            }
        }
    }
1324890
def on_close(self):
        
        print 'Connection closed.'
        self.remove_client()
        
        client_count = len(self.get_clients().keys())
        new_client_message = '1 client disconnected, now we have %d %s!' % (client_count, 'client' if client_count <= 1 else 'clients')
        self.broadcast(new_client_message)
1307212
@FFDCIgnore(value = { InterruptedException.class })
    public void close() {
        // remove all the clients from the deque, closing them as we go
        while (numClientsClosed.get() < numClients) {
            try {
                Client client = clients.takeFirst();
                try {
                    client.close();
                } catch (Exception e) {
                    //Ignore this
                }
                numClientsClosed.incrementAndGet();

                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    Tr.event(tc, "pool closed   - " + numClientsClosed + " of " + numClients + " clients closed");
            } catch (InterruptedException e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    Tr.event(tc, "InterruptedException during close - will retry");
            }
        }
    }
784609
public static base_response Shutdown(nitro_service client, shutdown resource) throws Exception {
		shutdown Shutdownresource = new shutdown();
		return Shutdownresource.perform_operation(client);
	}
1095370
@Override
    protected void shutdown() {
        if (isSmEnabled()) {
            try {
                // Try to send a last SM Acknowledgement. Most servers won't find this information helpful, as the SM
                // state is dropped after a clean disconnect anyways. OTOH it doesn't hurt much either.
                sendSmAcknowledgementInternal();
            } catch (InterruptedException | NotConnectedException e) {
                LOGGER.log(Level.FINE, "Can not send final SM ack as connection is not connected", e);
            }
        }
        shutdown(false);
    }
106820
public void shutdown(boolean clear) {
        if (executionQueue != null) {
            executionQueue.shutdownNow();
        }

        if (joynrInjector != null) {
            // switch to lp receiver and call servlet shutdown to be able to receive responses
            ServletMessageReceiver servletReceiver = joynrInjector.getInstance(ServletMessageReceiver.class);
            servletReceiver.switchToLongPolling();

            for (JoynrApplication app : apps) {
                try {
                    app.shutdown();
                } catch (Exception e) {
                    logger.debug("error shutting down app: " + app.getClass(), e);
                }
            }
            servletReceiver.shutdown(clear);
        }
        try {
            if (executionQueue != null) {
                executionQueue.awaitTermination(timeout, TimeUnit.SECONDS);
            }
        } catch (InterruptedException e) {
            return;
        }

    }
324990
public void shutdown() {
        for (Client client : trackedClients) {
            // best effort closing -- ignores many problems
            try {
                client.drain();
                client.close();
            }
            catch (Exception e) {}
        }
        loaderClient = null;

        try {
            server.shutdown();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        try {
            server.join(20000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }