private ListenerEndpoint startEndpoint(InetSocketAddress inetSocketAddress, ListeningIOReactor defaultListeningIOReactor, String endPointName) throws Exception { ListenerEndpoint endpoint = defaultListeningIOReactor.listen(inetSocketAddress); try { endpoint.waitFor(); InetSocketAddress address = (InetSocketAddress) endpoint.getAddress(); if (!address.isUnresolved()) { log.info((endPointName != null ? "Pass-through " + endPointName : " Pass-through Http ") + " Listener started on " + address.getHostName() + ":" + address.getPort()); } else { log.info((endPointName != null ? "Pass-through " + endPointName : " Pass-through Http ") + " Listener started on " + address); } } catch (Exception e) { throw new Exception("Endpoint does not start for port " + inetSocketAddress.getPort() + "May be IO Reactor not started or endpoint binding exception ", e); } return endpoint; }
@Override public void run() { // Starts the reactor and initiates the dispatch of I/O // event notifications to the given IOEventDispatch. try { LOGGER.info("Submitted http listening to thread 'HttpStack listener'"); ioReactor.execute(ioEventDispatch); } catch (IOException e) { LOGGER.severe("I/O Exception in HttpStack: " + e.getMessage()); } LOGGER.info("Shutdown HttpStack"); } };
@Override public void stop() { log.info("Stopping Http Server [" + id + "] ... "); try { ioReactor.shutdown(); } catch (IOException e) { log.warn("Error occured while shutting down", e); } log.info("Http Server stopped"); }
/** * Pause IO Reactor which is registered by HTTPListener running on given port * * @param port Port of axis2 PTT Listener * @throws IOException Exception throwing when pausing */ public void pauseIOReactor(int port) throws IOException { ListeningIOReactor listeningIOReactor = passThroughListenerIOReactorMapper.get(port); ServerIODispatch serverIODispatch = passThroughListenerServerIODispatchMapper.get(port); if (listeningIOReactor != null) { if (serverIODispatch instanceof MultiListenerServerIODispatch || serverIODispatch instanceof MultiListenerSSLServerIODispatch) { log.info("Pausing shared IO Reactor bind for port " + port + " will be caused for pausing non " + "axis2 Listeners "); } else { log.info("Pausing IO Reactor bind for port " + port); } listeningIOReactor.pause(); } else { log.error("Cannot find Pass Through Listener for port " + port); } }
ListeningIOReactor listeningIOReactor = passThroughListenerIOReactorMapper.get(port); if (listeningIOReactor != null) { Set<ListenerEndpoint> endpoints = listeningIOReactor.getEndpoints();
sh.listenerEndpoint = ioReactor.listen( sh.getSocketAddress() );
@Override public void run() { // Starts the reactor and initiates the dispatch of I/O // event notifications to the given IOEventDispatch. try { LOGGER.info("Submitted http listening to thread 'HttpStack listener'"); ioReactor.execute(ioEventDispatch); } catch (IOException e) { LOGGER.severe("I/O Exception in HttpStack: " + e.getMessage()); } LOGGER.info("Shutdown HttpStack"); } };
public void stop() throws IOException { LOG.debug("Stopping the jhc ioReactor "); ioReactor.shutdown(); LOG.debug("Waiting the runner"); try { runner.join(); } catch (InterruptedException e) { //do nothing here } isStarted = false; LOG.debug("Runner stopped"); } }
public void destroy() { log.info("Closing service '" + this.getServiceName() + "'"); runnable.destroy(); log.info("Pausing reactor for service '" + this.getServiceName() + "' and port " + this.getServiceConfig().getPort()); try { ioReactor.pause(); } catch (IOException e) { log.debug("Error closing server socket: " + e.getMessage(), e); } log.info("Stopping reactor thread for service '" + this.getServiceName() + "'"); reactorThread.interrupt(); try { reactorThread.join(10000); } catch (InterruptedException e) { log.debug("Interrupted", e); } } }
ListeningIOReactor listeningIOReactor = passThroughListenerIOReactorMapper.get(port); if (listeningIOReactor != null) { Set<ListenerEndpoint> endpoints = listeningIOReactor.getEndpoints();
ioReactor.listen(new InetSocketAddress(httpPort));
public void run() { try { listeningIOReactor.execute(serverIODispatch); } catch (Exception e) { log.fatal("Exception encountered in the " + prefix + " Listener. " + "No more connections will be accepted by this transport", e); } finally { log.info(prefix + " Listener shutdown."); if (serverIODispatch instanceof MultiListenerServerIODispatch) { log.info("Shutting down shared IO Reactor"); } } } }, "PassThrough " + prefix + " Listener");
public void stop() throws IOException { if (this.ioReactor != null) { this.ioReactor.shutdown(2000); } }
try { ioReactor = new DefaultListeningIOReactor(2, parameters); ioReactor.listen(new InetSocketAddress(this.getServiceConfig().getPort())); } catch (IOException e) { log.error("I/O for service '" + this.getServiceName() + "' error: " + e.getMessage());
public void run() { log.info("For service '" + serviceName + "' listening on port " + port); while (!Thread.interrupted()) { try { ioReactor.execute(ioEventDispatch); } catch (InterruptedIOException ex) { break; } catch (IOException e) { if (!shutdown) { log.error("I/O error initialising connection thread for service '" + serviceName + "' : " + e.getMessage()); } break; } } log.info("For service '" + serviceName + "' listening on port " + port + " ended NIO reactor thread."); }
/** * ShutdownIOReactor which is registered by HTTPListener running on given port * * @param port Port of axis2 PTT Listener * @param miliSeconds Waiting Time before close IO Reactor * @throws IOException Exception throwing when Shutdown */ public void shutdownIOReactor(int port, long miliSeconds) throws IOException { ListeningIOReactor ioReactor = shutdownReactor(port); if (ioReactor != null) { try { ioReactor.shutdown(miliSeconds); } catch (IOException e) { throw new IOException( "IOException occurred when shutting down IOReactor for Listener started on port " + port, e); } passThroughListenerIOReactorMapper.remove(port); passThroughListenerServerIODispatchMapper.remove(port); } }
@Override public void start() { if (!isInitialized()) throw new IllegalStateException( "Server initialization is incomplete, can not start the server"); log.info("Starting Http Server [" + id + "] ... "); try { ioReactor.listen(buildInetSocketAddress()); log.info("Http Server started"); ioReactor.execute(ioEventDispatch); } catch (InterruptedIOException iex) { log.error("Server was interrupted: ", iex); } catch (IOException ioex) { log.error("IO exception: ", ioex); } }