{@inheritDoc}

@throws IllegalStateException If manager is already closed.
546835
@Override
    public void close(FutureCallback<Void> callback) throws IllegalStateException {
        assertOpen();

        Future<?> future = this.eventGroup.shutdownGracefully(0L, 5L, TimeUnit.SECONDS);
        future.addListener(new NetworkManagerVoidFutureCallback(callback));
    }
88321
@Override
    public void shutdown() {
        Throwable shutdownException = null;
        try {
            fire(new ManagerStopping());
        } catch (Exception e) {
            try {
                fireException(e);
            } catch (Exception e2) {
                shutdownException = e2;
            }
        }
        synchronized (this) {
            for (Context context : contexts) {
                context.clearAll();
            }
            contexts.clear();
            extensions.clear();

            runtimeLogger.clear();

            handledThrowables.remove();
        }
        if (shutdownException != null) {
            UncheckedThrow.throwUnchecked(shutdownException);
        }
    }
242936
public synchronized void restart() throws IllegalStateException {

        if (this.isShutdown) {
            throw new IllegalStateException("isShutdown==true");
        } else if (this.taskRunnerThread == null) {
            this.taskRunnerThread =
                this.threadFactory.newThread(this.taskRunner);

            this.taskRunnerThread.start();
        } else {
            this.taskQueue.unpark();
        }
    }
174495
static public void close(FileSystemManager fsManager){
		if (fsManager != null){
			if (fsManager instanceof DefaultFileSystemManager){
				((DefaultFileSystemManager) fsManager).close();
			}else{
				throw new IllegalStateException("Only instance of DefaultFileSystemManager can be closed here.");
			}
		}
	}
157198
@Override
    public void onManagerEvent(ManagerEvent event)
    {

        // if this turns out to be slow, we could consider caching the reflection lookup

        try
        {

            Method method = this.getClass().getDeclaredMethod("handleEvent", new Class[]{event.getClass()});
            if (method != null)
            {
                method.invoke(this, event);
                return;
            }
        }
        catch (Exception e)
        {
            logger.error(e, e);
        }

        logger.error("The event " + event.getClass()
                + " couldn't be mapped to a method in AbstractManagerEventListener.java, someone should add it!");

    }
1241667
public static void stopServices(IServiceManager manager) {
		final List<Service> otherServices = new ArrayList<>();
		final List<Service> infraServices = new ArrayList<>();
		final LinkedList<DependencyNode> serviceQueue = new LinkedList<>();
		final Accessors accessors = new StoppingPhaseAccessors();

		// Build the dependency graph
		buildInvertedDependencyGraph(manager, serviceQueue, infraServices, otherServices, accessors);

		// Launch the services
		runDependencyGraph(serviceQueue, infraServices, otherServices, accessors);

		manager.awaitStopped();
	}
97810
public static void closeQuietly(final MessageProducer producer)
    {
        if (producer != null) {
            try {
                producer.close();
            }
            catch (JMSException je) {
                if (je.getCause() instanceof InterruptedException) {
                    LOG.trace("ActiveMQ caught and wrapped InterruptedException");
                }
                if (je.getCause() instanceof InterruptedIOException) {
                    LOG.trace("ActiveMQ caught and wrapped InterruptedIOException");
                }
                else {
                    LOG.warnDebug(je, "While closing producer");
                }
            }
        }
    }
897627
@Override
    public Class<?> getInvokedBusinessInterface()
                    throws IllegalStateException
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        // d367572.1 start
        synchronized (this)
        {
            if ((state == PRE_CREATE) ||
                (state == CREATING) ||
                (state == DESTROYED))
            {
                if (isTraceOn && tc.isDebugEnabled())
                    Tr.debug(tc, "Incorrect state: " + getStateName(state));
                throw new IllegalStateException(getStateName(state));
            }
        }
        // d367572.1 end

        Class<?> bInterface = null;
        EJSWrapperBase wrapper = null;

        // -----------------------------------------------------------------------
        // Obtain the Method Context for the current thread (EJSDeployedSupport),
        // which contains the 'wrapper' used to invoke the current method.
        //
        // The invoked 'business interface' is the first and only interface
        // for the wrapper class.
        //
        // Note that this method is NOT allowed for the EJB 2.1 component
        // interfaces... and results in an exception.
        // -----------------------------------------------------------------------

        EJSDeployedSupport methodContext = EJSContainer.getMethodContext();

        // d367572.7 start of eliminate potential NPE if methodContext is null.
        if (methodContext != null)
        {
            wrapper = methodContext.ivWrapper;

            if (wrapper != null)
            {
                // For an aggregate wrapper, all interfaces must be evaluated for
                // exposing the method. If a single interface is found, return it,
                // otherwise it is ambiguous.                             F743-34304
                if (wrapper.ivBusinessInterfaceIndex == EJSWrapperBase.AGGREGATE_LOCAL_INDEX)
                {
                    Method method = methodContext.methodInfo.ivMethod;
                    String methodName = method.getName();
                    Class<?>[] methodParams = method.getParameterTypes();
                    for (Class<?> curInterface : wrapper.bmd.ivBusinessLocalInterfaceClasses)
                    {
                        try
                        {
                            curInterface.getMethod(methodName, methodParams);
                            if (isTraceOn && tc.isDebugEnabled())
                                Tr.debug(tc, "Method " + methodName + " found on interface " + curInterface);
                            if (bInterface != null)
                            {
                                throw new IllegalStateException("Ambiguous invoked business interface.");
                            }
                            bInterface = curInterface;
                        } catch (SecurityException ex) // d679175
                        {
                            // this normal and means the interface doesn't expose this method.
                            if (isTraceOn && tc.isDebugEnabled())
                                Tr.debug(tc, "Method " + methodName + " not found on interface " + curInterface);
                        } catch (NoSuchMethodException ex) // d679175
                        {
                            // this normal and means the interface doesn't expose this method.
                            if (isTraceOn && tc.isDebugEnabled())
                                Tr.debug(tc, "Method " + methodName + " not found on interface " + curInterface);
                        }
                    }
                }

                // For performance (and in case No-Interface view) obtain the
                // 'interface' using the index provided on the wrapper, rather
                // than using reflections as done in prior releases.       F743-1756
                else if (wrapper.ivInterface == WrapperInterface.BUSINESS_LOCAL)
                {
                    bInterface = wrapper.bmd.ivBusinessLocalInterfaceClasses[wrapper.ivBusinessInterfaceIndex];
                }
                else if (wrapper.ivInterface == WrapperInterface.BUSINESS_REMOTE ||
                         wrapper.ivInterface == WrapperInterface.BUSINESS_RMI_REMOTE)
                {
                    bInterface = wrapper.bmd.ivBusinessRemoteInterfaceClasses[wrapper.ivBusinessInterfaceIndex];
                }
            }
        } // d367572.7 end

        if (bInterface == null)
        {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "getInvokedBusinessInterface : IllegalStateException : " +
                             "Not invoked through business interface");

            throw new IllegalStateException("Not invoked through business interface");
        }

        if (isTraceOn && tc.isDebugEnabled())
            Tr.debug(tc, "getInvokedBusinessInterface : " + bInterface);

        return bInterface;
    }
707151
@Override
    public void close() throws IllegalStateException, IOException {

        // validate state
        if (isClosed())
    	    throw new IllegalStateException("Serial connection is not open; cannot 'close()'.");

        // remove serial port listener
        SerialInterrupt.removeListener(fileDescriptor);

    	// close serial port now
        com.pi4j.jni.Serial.close(fileDescriptor);

        // reset file descriptor
        fileDescriptor = -1;
	}
186193
@Override
    public void close() throws Exception {
        try {
            this.servers.stream().filter(Objects::nonNull).forEach(BookieServer::shutdown);
            if (this.zkServer.get() != null) {
                this.zkServer.get().close();
            }
        } finally {
            cleanupDirectories();
        }

        Thread c = this.cleanup.getAndSet(null);
        if (c != null) {
            Runtime.getRuntime().removeShutdownHook(c);
        }
    }
66261
public void rollback() throws ServiceBusException, InterruptedException {
        if (this.messagingFactory == null) {
            throw new ServiceBusException(false, "MessagingFactory should not be null");
        }

        this.messagingFactory.endTransaction(this, false);
    }
358293
@Override
    public void stop() throws Exception {
        if (!this.started) {
            logger.warn(String.format("management=%s is already stopped", this.name));
            return;
        }

        // this.nettyClientOpsThread.setStarted(false);

        for (ManagementEventListener lstr : managementEventListeners) {
            try {
                lstr.onServiceStopped();
            } catch (Throwable ee) {
                logger.error("Exception while invoking onServiceStopped", ee);
            }
        }

        // We store the original state first
        this.store();

        // Stop all associations
        FastMap<String, Association> associationsTemp = this.associations;
        for (FastMap.Entry<String, Association> n = associationsTemp.head(), end = associationsTemp.tail(); (n = n.getNext()) != end;) {
            Association associationTemp = n.getValue();
            if (associationTemp.isStarted()) {
                ((NettyAssociationImpl) associationTemp).stop();
            }
        }

        FastList<Server> tempServers = servers;
        for (FastList.Node<Server> n = tempServers.head(), end = tempServers.tail(); (n = n.getNext()) != end;) {
            Server serverTemp = n.getValue();
            if (serverTemp.isStarted()) {
                try {
                    ((NettyServerImpl) serverTemp).stop();
                } catch (Exception e) {
                    logger.error(String.format("Exception while stopping the Server=%s", serverTemp.getName()), e);
                }
            }
        }

        // waiting till stopping associations
        for (int i1 = 0; i1 < 20; i1++) {
            boolean assConnected = false;
            for (FastMap.Entry<String, Association> n = this.associations.head(), end = this.associations.tail(); (n = n
                    .getNext()) != end;) {
                Association associationTemp = n.getValue();
                if (associationTemp.isConnected()) {
                    assConnected = true;
                    break;
                }
            }
            if (!assConnected)
                break;
            Thread.sleep(100);
        }

        // TODO - make a general shutdown and waiting for it instead of "waiting till stopping associations" 
        this.bossGroup.shutdownGracefully();
        this.workerGroup.shutdownGracefully();
        this.clientExecutor.shutdown();
       

        // TODO Should servers be also checked for shutdown?

        this.started = false;

    }
86119
def manager(self, value):
        ""
        pid = current_process().ident
        if _managers is None:
            raise RuntimeError("Can not set the manager following a system exit.")
        if pid not in _managers:
            _managers[pid] = value
        else:
            raise Exception("Manager already set for pid %s" % pid)
371165
protected synchronized void lock(ManagedObject managedObject)
                    throws ObjectManagerException
    {
        throw new InvalidStateException(this, InternalTransaction.stateTerminated, InternalTransaction.stateNames[InternalTransaction.stateTerminated]);
    }
661735
public final void shutdown()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "shutdown"
                            );

        objectManagerState.shutdown();

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "shutdown"
                            );
    }
1170822
public void close() throws IllegalStateException {
		if (this.open) {
			// Close channels
			this.rtpChannel.close();
			if (!this.rtcpMux) {
				this.rtcpChannel.close();
			}
			
			if(logger.isDebugEnabled()) {
				logger.debug(this.mediaType + " channel " + this.ssrc + " is closed");
			}

			// Reset state
			reset();
			this.open = false;
		} else {
			throw new IllegalStateException("Channel is already inactive");
		}
	}
438086
@Override
    public void close() throws IOException, IllegalStateException {
        if (this.open.compareAndSet(true, false)) {
            try {
                this.eventGroup.shutdownGracefully(0L, 5L, TimeUnit.SECONDS).sync();
            } catch (Exception e) {
                throw new IOException("Could not be gracefully closed.", e);
            }
        } else {
            throw new IllegalStateException("Network Manager is already closed");
        }
    }