/* (non-Javadoc)
@see com.ibm.wsspi.kernel.service.utils.ServerQuiesceListener#serverStopping()
519260
@Override
    public void serverStopping() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Server is stopping");
        }
        WebContainer wc = (WebContainer) WebContainer.getWebContainer();
        WebContainer.setServerStopping(true);
        if (wc!=null) wc.waitForApplicationInitialization();
    }
184202
@Override
    public void applicationStopping(String appName)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            Tr.entry(tc, "MEF.applicationStopping for application " + appName);
        }

        synchronized (ivStateLock)
        {
            if (ivState == ACTIVE_STATE)
            {
                // No thread is ever waiting for a notification while
                // in the active state, so simply change state to
                // indicate deactivate is pending.
                ivState = DEACTIVATE_PENDING_STATE;
            }
            else if (ivState == ACTIVATING_STATE)
            {
                // Change state to indicate deactivate is pending
                // and notify any thread that is waiting for the activate
                // to complete.
                ivState = DEACTIVATE_PENDING_STATE;
                ivStateLock.notifyAll();
            }
            else if (ivState == DEACTIVATE_PENDING_STATE)
            {
                // activateendpoint threw an exception and changed
                // state to deactivate pending.  So we need to notify
                // threads that are waiting for the activate
                // to complete (e.g. threads blocked by createEndpoint
                // during the activation of an endpoint).
                ivStateLock.notifyAll();
            }
            else if (ivState == INACTIVE_STATE)
            {
                // This is possible, but not likely. For example, we could create this
                // MEF object and initialized it to INACTIVE_STATE.  An exception occurs
                // before we make it to the activateEndpoint method for this MEF.  If
                // that happens, then it is possible to get to this method while in
                // the inactive state.  So simply trace fact that this MEF was called
                // in inactive state and nothing was actually done.
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                {
                    Tr.event(tc, "MEF.applicationStopping for application " + appName
                                 + " was called for an inactive endpoint.");
                }
            }
            else
            {
                // The only other state is DEACTIVATING_STATE. This method should NEVER
                // be called while in the deactivating state. Runtime framework should call
                // this method before it ever attempts to stop the modules of an application.
                // Thus, we should not enter deactivating state until after this method is called.
                // Create FFDC log file for this problem and trace occurrence of this event.
                // No reason to throw the exception since we created it just for the purpose
                // of doing the FFDC.
                String msg = "Internal programming error - applicationStopping called for application \""
                             + appName + "\" while in deactivating state. This should NEVER occur.";
                IllegalStateException ex = new IllegalStateException(msg);
                FFDCFilter.processException(ex, CLASS_NAME + ".applicationStopping", "1208", this);
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                {
                    Tr.event(tc, msg);
                }
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        {
            Tr.exit(tc, "MEF.applicationStopping for application " + appName);
        }
    }
849125
public ProviderConfig<T> setServer(ServerConfig server) {
        if (this.server == null) {
            this.server = new ArrayList<ServerConfig>();
        }
        this.server.add(server);
        return this;
    }
172007
@SafeVarargs
    public final ServerListenerBuilder addStoppingCallbacks(Consumer<? super Server>... consumers) {
        return addStoppingCallbacks(Arrays.asList(consumers));
    }
695829
protected final void doStop() {

        log.info("Stopping {} in {}", new Object[]{this, getLocationOrNull()});

        if (getAttribute(SERVICE_STATE_ACTUAL)
                .equals(Lifecycle.STOPPED)) {
            log.warn("The entity {} is already stopped", new Object[]{this});
            return;
        }

        ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING);
        try {
            preStop();
            driver.stop();
            postDriverStop();
            postStop();
            ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPED);
            log.info("The entity stop operation {} is completed without errors",
                    new Object[]{this});
        } catch (Throwable t) {
            ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
            throw Exceptions.propagate(t);
        }
    }
747088
private void announceMPStopping() {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "announceMPStopping");

        if (_destinationManager != null)
            _destinationManager.announceMPStopping();

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "announceMPStopping");
    }
165512
synchronized void setServerProcessStopping() {
        this.requiredState = InternalState.STOPPED;
        internalSetState(null, InternalState.STOPPED, InternalState.PROCESS_STOPPING);
    }
532238
@Override
    public void applicationStopped(ApplicationInfo appInfo) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(this, tc, "application stopped : " + appInfo.getName());

        runFutureGeneratePluginTask();
        this.appsInService--;
    }
701085
@Override
  public ServerBartender findServerByName(String name)
  {
    for (ClusterHeartbeat cluster : _clusterMap.values()) {
      ServerBartender server = cluster.findServerByName(name);
      
      if (server != null) {
        return server;
      }
    }
    
    return null;
  }
627008
protected synchronized void doStop() throws Exception
    {
        try
        {
            // Stop servlets
            super.doStop();

            // Stop filters
            for (int i= _filters.size(); i-- > 0;)
            {
                FilterHolder holder= (FilterHolder)_filters.get(i);
                holder.stop();
            }
        }
        finally
        {
            _webApplicationContext= null;
            _sessionListeners= null;
            _requestListeners= null;
            _requestAttributeListeners= null;
            _contextAttributeListeners= null;
        }
    }
902597
public CompletableFuture<Void> shutdownServer() {
		CompletableFuture<Void> shutdownFuture = new CompletableFuture<>();
		if (serverShutdownFuture.compareAndSet(null, shutdownFuture)) {
			log.info("Shutting down {} @ {}", serverName, serverAddress);

			final CompletableFuture<Void> groupShutdownFuture = new CompletableFuture<>();
			if (bootstrap != null) {
				EventLoopGroup group = bootstrap.group();
				if (group != null && !group.isShutdown()) {
					group.shutdownGracefully(0L, 0L, TimeUnit.MILLISECONDS)
							.addListener(finished -> {
								if (finished.isSuccess()) {
									groupShutdownFuture.complete(null);
								} else {
									groupShutdownFuture.completeExceptionally(finished.cause());
								}
							});
				} else {
					groupShutdownFuture.complete(null);
				}
			} else {
				groupShutdownFuture.complete(null);
			}

			final CompletableFuture<Void> handlerShutdownFuture = new CompletableFuture<>();
			if (handler == null) {
				handlerShutdownFuture.complete(null);
			} else {
				handler.shutdown().whenComplete((result, throwable) -> {
					if (throwable != null) {
						handlerShutdownFuture.completeExceptionally(throwable);
					} else {
						handlerShutdownFuture.complete(null);
					}
				});
			}

			final CompletableFuture<Void> queryExecShutdownFuture = CompletableFuture.runAsync(() -> {
				if (queryExecutor != null) {
					ExecutorUtils.gracefulShutdown(10L, TimeUnit.MINUTES, queryExecutor);
				}
			});

			CompletableFuture.allOf(
					queryExecShutdownFuture, groupShutdownFuture, handlerShutdownFuture
			).whenComplete((result, throwable) -> {
				if (throwable != null) {
					shutdownFuture.completeExceptionally(throwable);
				} else {
					shutdownFuture.complete(null);
				}
			});
		}
		return serverShutdownFuture.get();
	}
919640
public void setServerGroupReplicationConfigurations(java.util.Collection<ServerGroupReplicationConfiguration> serverGroupReplicationConfigurations) {
        if (serverGroupReplicationConfigurations == null) {
            this.serverGroupReplicationConfigurations = null;
            return;
        }

        this.serverGroupReplicationConfigurations = new java.util.ArrayList<ServerGroupReplicationConfiguration>(serverGroupReplicationConfigurations);
    }
909418
@Override
    public synchronized void messagingEngineStopping(
                                                     final JsMessagingEngine messagingEngine, final int mode)
    {

        final String methodName = "messagingEngineStopping";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.entry(this, TRACE, methodName, new Object[] { messagingEngine, Integer.valueOf(mode) });
        }

        SibTr.info(TRACE, "ME_STOPPING_CWSIV0784", new Object[] {
                                                                 messagingEngine.getName(),
                                                                 messagingEngine.getBus() });

//        dropConnection (messagingEngine.getUuid().toString(), null, true);

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.exit(this, TRACE, methodName);
        }
    }
729279
public JettyBootstrap stopServer() throws JettyBootstrapException {
        LOG.info("Stopping Server...");
        try {
            if (isServerStarted()) {
                handlers.stop();

                server.stop();

                LOG.info("Server stopped.");
            } else {
                LOG.warn("Can't stop server. Already stopped");
            }
        } catch (Exception e) {
            throw new JettyBootstrapException(e);
        }

        return this;
    }
1101455
public void stop() throws Exception {
        // verify server isn't null
        if (server == null) {
            throw new NullPointerException("Internal server instance was null, server already stopped perhaps?");
        }
        
        logger.info("HttpServer [{}] on [{}] stopping...", configuration.safeGetName(), configuration.getPortString());

        server.stop();

        logger.info("HttpServer [{}] on [{}] stopped", configuration.safeGetName(), configuration.getPortString());
    }
1137251
@Override
    public void isLeader() {
        LOG.warn("Server instance with server id {} is elected as leader", serverId);
        serviceState.becomingActive();
        try {
            for (ActiveStateChangeHandler handler : activeStateChangeHandlers) {
                handler.instanceIsActive();
            }
            activeInstanceState.update(serverId);
            serviceState.setActive();
        } catch (Exception e) {
            LOG.error("Got exception while activating", e);
            notLeader();
            rejoinElection();
        }
    }
37924
protected Server getServer(final Settings settings, final String serverId) {
		if (settings == null)
			return null;
		List<Server> servers = settings.getServers();
		if (servers == null || servers.isEmpty())
			return null;

		for (Server server : servers)
			if (serverId.equals(server.getId()))
				return server;
		return null;
	}