Search in sources :

Example 6 with ServerConnFactoryBuilder

use of org.apache.synapse.transport.nhttp.config.ServerConnFactoryBuilder in project wso2-synapse by wso2.

the class HttpCoreNIOListener method reloadSpecificEndpoints.

/**
 * Restart specific endpoints which was updated by new configurations
 *
 * @param transportIn TransportInDescription of new configuration
 * @throws AxisFault
 */
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");
}
Also used : ListenerEndpoint(org.apache.http.nio.reactor.ListenerEndpoint) HttpHost(org.apache.http.HttpHost) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) ServerConnFactoryBuilder(org.apache.synapse.transport.nhttp.config.ServerConnFactoryBuilder)

Aggregations

ServerConnFactoryBuilder (org.apache.synapse.transport.nhttp.config.ServerConnFactoryBuilder)6 HttpHost (org.apache.http.HttpHost)5 Parameter (org.apache.axis2.description.Parameter)2 ListenerEndpoint (org.apache.http.nio.reactor.ListenerEndpoint)2 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AxisService (org.apache.axis2.description.AxisService)1 TransportInDescription (org.apache.axis2.description.TransportInDescription)1 NativeThreadFactory (org.apache.axis2.transport.base.threads.NativeThreadFactory)1 WorkerPool (org.apache.axis2.transport.base.threads.WorkerPool)1 AxisServiceFilter (org.apache.axis2.transport.base.tracker.AxisServiceFilter)1 AxisServiceTracker (org.apache.axis2.transport.base.tracker.AxisServiceTracker)1 AxisServiceTrackerListener (org.apache.axis2.transport.base.tracker.AxisServiceTrackerListener)1 IOReactorException (org.apache.http.nio.reactor.IOReactorException)1 SourceConfiguration (org.apache.synapse.transport.passthru.config.SourceConfiguration)1 PassThroughSharedListenerConfiguration (org.apache.synapse.transport.passthru.core.PassThroughSharedListenerConfiguration)1 PassThroughTransportMetricsCollector (org.apache.synapse.transport.passthru.jmx.PassThroughTransportMetricsCollector)1 TransportView (org.apache.synapse.transport.passthru.jmx.TransportView)1