List of usage examples for org.apache.http.nio.reactor ListenerEndpoint close
void close();
From source file:org.wso2.carbon.inbound.endpoint.protocol.hl7.core.InboundHL7IOReactor.java
public static boolean unbind(int port) { ListenerEndpoint ep = endpointMap.get(port); endpointMap.remove(port);//from www . ja va 2 s. c om processorMap.remove(port); multiIOHandler.disconnectSessions(port); if (ep == null) { return false; } ep.close(); return true; }
From source file:org.opcfoundation.ua.transport.https.HttpsServer.java
protected void shutdownReactor() { for (SocketHandle sh : socketHandleSnapshot()) { ListenerEndpoint le = sh.listenerEndpoint; if (le != null) le.close(); sh.listenerEndpoint = null;//ww w . j ava2 s . c o m } if (ioReactor != null) { try { ioReactor.shutdown(); } catch (IOException e) { log.error("Failed to shutdown ioReactor", e); } ioReactor = null; } if (sslReactorThread != null) { sslReactorThread.interrupt(); try { sslThreadSemaphore.acquire(); } catch (InterruptedException e) { } sslThreadSemaphore = null; sslReactorThread = null; } if (plainReactorThread != null) { plainReactorThread.interrupt(); try { plainThreadSemaphore.acquire(); } catch (InterruptedException e) { } plainThreadSemaphore = null; plainReactorThread = null; } }
From source file:org.apache.synapse.transport.nhttp.HttpCoreNIOListener.java
public void reload(final TransportInDescription transportIn) throws AxisFault { if (state != BaseConstants.STARTED) return;//from w w w.j a v a 2 s .co m // Close all listener endpoints and stop accepting new connections Set<ListenerEndpoint> endpoints = ioReactor.getEndpoints(); for (ListenerEndpoint endpoint : endpoints) { endpoint.close(); } // Rebuild connection factory HttpHost host = new HttpHost(listenerContext.getHostname(), listenerContext.getPort(), scheme.getName()); ServerConnFactoryBuilder connFactoryBuilder = initConnFactoryBuilder(transportIn, host); connFactory = connFactoryBuilder.build(params); iodispatch.update(connFactory); startEndpoints(); log.info(name + " Reloaded"); }
From source file:org.apache.synapse.transport.nhttp.HttpCoreNIOListener.java
/** * Restart specific endpoints which was updated by new configurations * * @param transportIn TransportInDescription of new configuration * @throws AxisFault/*w w w. j a v a 2 s .com*/ */ public void reloadSpecificEndpoints(final TransportInDescription transportIn) throws AxisFault { if (state != BaseConstants.STARTED) { return; } HttpHost host = new HttpHost(listenerContext.getHostname(), listenerContext.getPort(), scheme.getName()); // Rebuild connection factory ServerConnFactoryBuilder connFactoryBuilder = initConnFactoryBuilder(transportIn, host); connFactory = connFactoryBuilder.build(params); iodispatch.update(connFactory); List<InetSocketAddress> endPointsClosed = new ArrayList<InetSocketAddress>(); //Close endpoints related to new profile's bind addresses Set<InetSocketAddress> endPointsToReload = connFactory.getBindAddresses(); for (InetSocketAddress inetSocketAddress : endPointsToReload) { for (ListenerEndpoint listenerEndpoint : ioReactor.getEndpoints()) { if (inetSocketAddress.getHostName() .equalsIgnoreCase(((InetSocketAddress) listenerEndpoint.getAddress()).getHostName())) { listenerEndpoint.close(); endPointsClosed.add((InetSocketAddress) listenerEndpoint.getAddress()); } } } //Start closed inpoints again with new configurations startSpecificEndpoints(endPointsClosed); log.info(name + " Reloaded"); }
From source file:org.apache.synapse.transport.passthru.core.PassThroughListeningIOReactorManager.java
/** * Close all endpoints started by PTT Listeners. * * @param port Port of the Endpoint for PTT axis2 Listener * @return is all Endpoints closed/*from w ww . j av a 2 s . c o m*/ */ public boolean closeAllPTTListenerEndpoints(int port) { try { ListeningIOReactor listeningIOReactor = passThroughListenerIOReactorMapper.get(port); if (listeningIOReactor != null) { Set<ListenerEndpoint> endpoints = listeningIOReactor.getEndpoints(); // If it is shared IO Reactor then only close endpoints related to PTT Listener if (passThroughListenerServerIODispatchMapper.get(port) instanceof MultiListenerServerIODispatch) { for (ListenerEndpoint listenerEndpoint : endpoints) { if (listenerEndpoint.getAddress() instanceof InetSocketAddress) { int endPointPort = ((InetSocketAddress) listenerEndpoint.getAddress()).getPort(); if (dynamicPTTListeningEndpointMapper.containsKey(endPointPort)) { continue; } log.info("Closing Endpoint Listener for port " + port); listenerEndpoint.close(); log.info("Successfully closed Endpoint Listener for port " + port); } } } else { for (ListenerEndpoint listenerEndpoint : endpoints) { log.info("Closing Endpoint Listener for port " + port); listenerEndpoint.close(); log.info("Successfully closed Endpoint Listener for port " + port); } } } return true; } catch (Exception e) { log.error("Error occurred when closing Endpoint in PassThrough Transport Related to port " + port, e); return false; } }
From source file:org.apache.synapse.transport.passthru.core.PassThroughListeningIOReactorManager.java
/** * Close specific endpoints started by PTT Listeners using give set of bind addresses. * * @param port Port of the listener * @param bindAddresses bind address list of endpoints to be closed * @return true if successfully closed, false if any error *//*from w ww.ja v a 2 s .c o m*/ public boolean closeSpecificPTTListenerEndpoints(int port, Set<InetSocketAddress> bindAddresses) { try { ListeningIOReactor listeningIOReactor = passThroughListenerIOReactorMapper.get(port); if (listeningIOReactor != null) { Set<ListenerEndpoint> endpoints = listeningIOReactor.getEndpoints(); // If it is shared IO Reactor then only close endpoints related to PTT Listener if (passThroughListenerServerIODispatchMapper.get(port) instanceof MultiListenerServerIODispatch) { for (ListenerEndpoint listenerEndpoint : endpoints) { if (listenerEndpoint.getAddress() instanceof InetSocketAddress) { int endPointPort = ((InetSocketAddress) listenerEndpoint.getAddress()).getPort(); if (dynamicPTTListeningEndpointMapper.containsKey(endPointPort)) { continue; } for (InetSocketAddress inetSocketAddress : bindAddresses) { if (inetSocketAddress.getHostName().equalsIgnoreCase( ((InetSocketAddress) listenerEndpoint.getAddress()).getHostName())) { listenerEndpoint.close(); } } } } } else { for (ListenerEndpoint listenerEndpoint : endpoints) { for (InetSocketAddress inetSocketAddress : bindAddresses) { if (inetSocketAddress.getHostName().equalsIgnoreCase( ((InetSocketAddress) listenerEndpoint.getAddress()).getHostName())) { listenerEndpoint.close(); } } } } } return true; } catch (Exception e) { log.error("Error occurred when closing Endpoint in PassThrough Transport Related to port " + port, e); return false; } }