java.nio.channels.ShutdownChannelGroupException Java Examples

The following examples show how to use java.nio.channels.ShutdownChannelGroupException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsynchronousTlsChannelGroup.java    From pgadba with BSD 2-Clause "Simplified" License 5 votes vote down vote up
RegisteredSocket registerSocket(TlsChannel reader, SocketChannel socketChannel) throws ClosedChannelException {
  if (shutdown != Shutdown.No) {
    throw new ShutdownChannelGroupException();
  }
  RegisteredSocket socket = new RegisteredSocket(reader, socketChannel);
  currentRegistrations.getAndIncrement();
  pendingRegistrations.add(socket);
  selector.wakeup();
  return socket;
}
 
Example #2
Source File: AsynchronousTlsChannelGroup.java    From tls-channel with MIT License 5 votes vote down vote up
RegisteredSocket registerSocket(TlsChannel reader, SocketChannel socketChannel)
    throws ClosedChannelException {
  if (shutdown != Shutdown.No) {
    throw new ShutdownChannelGroupException();
  }
  RegisteredSocket socket = new RegisteredSocket(reader, socketChannel);
  currentRegistrations.getAndIncrement();
  pendingRegistrations.add(socket);
  selector.wakeup();
  return socket;
}
 
Example #3
Source File: WebServer.java    From Voovan with Apache License 2.0 5 votes vote down vote up
/**
 * 停止 WebServer
 */
public void stop(){
	try {
		System.out.println("=============================================================================================");
		System.out.println("[" + TDateTime.now() + "] Try to stop WebServer....");

		unInitModule();
		this.WebServerDestory(this);

		if(serverSocket!=null) {
			serverSocket.close();
		}
		System.out.println("[" + TDateTime.now() + "] Socket closed");

		SocketContext.gracefulShutdown();

		if(serverSocket.getAcceptEventRunnerGroup()!=null) {
			ThreadPool.gracefulShutdown(serverSocket.getAcceptEventRunnerGroup().getThreadPool());
		}
		if(serverSocket.getIoEventRunnerGroup()!=null) {
			ThreadPool.gracefulShutdown(serverSocket.getIoEventRunnerGroup().getThreadPool());
		}

		ThreadPool.gracefulShutdown(Global.getThreadPool());

		System.out.println("[" + TDateTime.now() + "] Thread pool is shutdown.");

		System.out.println("[" + TDateTime.now() + "] Now webServer is fully stoped.");
		TEnv.sleep(1000);
	}catch(ShutdownChannelGroupException e){
		return;
	}
}
 
Example #4
Source File: ShutdownChannelGroupExceptionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * java.nio.channels.ShutdownChannelGroupException#ShutdownChannelGroupException()
 */
public void test_empty() {
    ShutdownChannelGroupException e = new ShutdownChannelGroupException();
    assertTrue(e instanceof IllegalStateException);
    assertNull(e.getMessage());
    assertNull(e.getLocalizedMessage());
    assertNull(e.getCause());
}
 
Example #5
Source File: AsynchronousTlsChannelGroup.java    From pgadba with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void checkTerminated() {
  if (isTerminated()) {
    throw new ShutdownChannelGroupException();
  }
}
 
Example #6
Source File: AsynchronousTlsChannelGroup.java    From tls-channel with MIT License 4 votes vote down vote up
private void checkTerminated() {
  if (isTerminated()) {
    throw new ShutdownChannelGroupException();
  }
}