use of org.apache.synapse.transport.nhttp.config.ServerConnFactoryBuilder in project wso2-synapse by wso2.
the class PassThroughHttpListener method reload.
public void reload(final TransportInDescription transportIn) throws AxisFault {
if (state != BaseConstants.STARTED)
return;
// Close all listener endpoints and stop accepting new connections
passThroughListeningIOReactorManager.closeAllPTTListenerEndpoints(operatingPort);
// Rebuild connection factory
HttpHost host = new HttpHost(sourceConfiguration.getHostname(), sourceConfiguration.getPort(), sourceConfiguration.getScheme().getName());
ServerConnFactoryBuilder connFactoryBuilder = initConnFactoryBuilder(transportIn, host);
connFactory = connFactoryBuilder.build(sourceConfiguration.getHttpParams());
passThroughListeningIOReactorManager.getServerIODispatch(operatingPort).update(connFactory);
startEndpoints();
log.info(namePrefix + " Reloaded");
}
use of org.apache.synapse.transport.nhttp.config.ServerConnFactoryBuilder in project wso2-synapse by wso2.
the class MultiSSLProfileReloader method reloadSSLProfileConfig.
public String reloadSSLProfileConfig() throws AxisFault {
Parameter oldParameter = transportInDescription.getParameter("SSLProfiles");
Parameter profilePathParam = transportInDescription.getParameter("SSLProfilesConfigPath");
if (oldParameter != null && profilePathParam != null) {
transportInDescription.removeParameter(oldParameter);
ServerConnFactoryBuilder builder = new ServerConnFactoryBuilder(transportInDescription, null);
TransportInDescription loadedTransportIn = builder.loadMultiProfileSSLConfig();
if (loadedTransportIn != null) {
transportInDescription = loadedTransportIn;
httpCoreNIOMultiSSLListener.reload(transportInDescription);
return "SSLProfiles reloaded Successfully";
}
// add old value back
transportInDescription.addParameter(oldParameter);
}
return "Failed to reload SSLProfiles";
}
use of org.apache.synapse.transport.nhttp.config.ServerConnFactoryBuilder in project wso2-synapse by wso2.
the class PassThroughHttpListener method reloadSpecificEndPoints.
/**
* Re-load specific end points given in Transport In Description
*
* @param transportIn TransportInDescriptions of the new configuration
* @throws AxisFault
*/
public void reloadSpecificEndPoints(final TransportInDescription transportIn) throws AxisFault {
if (state != BaseConstants.STARTED) {
return;
}
HttpHost host = new HttpHost(sourceConfiguration.getHostname(), sourceConfiguration.getPort(), sourceConfiguration.getScheme().getName());
// Rebuild connection factory
ServerConnFactoryBuilder connFactoryBuilder = initConnFactoryBuilder(transportIn, host);
connFactory = connFactoryBuilder.build(sourceConfiguration.getHttpParams());
// Close listener endpoints and stop accepting new connections
passThroughListeningIOReactorManager.closeSpecificPTTListenerEndpoints(operatingPort, connFactory.getBindAddresses());
passThroughListeningIOReactorManager.getServerIODispatch(operatingPort).update(connFactory);
// start end points from new configuration
startSpecificEndpoints(connFactory.getBindAddresses());
log.info(namePrefix + " Reloaded");
}
use of org.apache.synapse.transport.nhttp.config.ServerConnFactoryBuilder in project wso2-synapse by wso2.
the class PassThroughHttpListener method init.
public void init(ConfigurationContext cfgCtx, TransportInDescription transportInDescription) throws AxisFault {
log.info("Initializing Pass-through HTTP/S Listener...");
pttInDescription = transportInDescription;
namePrefix = transportInDescription.getName().toUpperCase(Locale.US);
scheme = initScheme();
int portOffset = Integer.parseInt(System.getProperty("portOffset", "0"));
Parameter portParam = transportInDescription.getParameter("port");
int port = Integer.parseInt(portParam.getValue().toString());
operatingPort = port + portOffset;
portParam.setValue(String.valueOf(operatingPort));
portParam.getParameterElement().setText(String.valueOf(operatingPort));
System.setProperty(transportInDescription.getName() + ".nio.port", String.valueOf(operatingPort));
Object obj = cfgCtx.getProperty(PassThroughConstants.PASS_THROUGH_TRANSPORT_WORKER_POOL);
WorkerPool workerPool = null;
if (obj != null) {
workerPool = (WorkerPool) obj;
}
PassThroughTransportMetricsCollector metrics = new PassThroughTransportMetricsCollector(true, scheme.getName());
TransportView view = new TransportView(this, null, metrics, null);
MBeanRegistrar.getInstance().registerMBean(view, "Transport", "passthru-" + namePrefix.toLowerCase() + "-receiver");
sourceConfiguration = new SourceConfiguration(cfgCtx, transportInDescription, scheme, workerPool, metrics);
sourceConfiguration.build();
HttpHost host = new HttpHost(sourceConfiguration.getHostname(), sourceConfiguration.getPort(), sourceConfiguration.getScheme().getName());
ServerConnFactoryBuilder connFactoryBuilder = initConnFactoryBuilder(transportInDescription, host);
connFactory = connFactoryBuilder.build(sourceConfiguration.getHttpParams());
handler = new SourceHandler(sourceConfiguration);
passThroughListeningIOReactorManager = PassThroughListeningIOReactorManager.getInstance();
// register to receive updates on services for lifetime management
// cfgCtx.getAxisConfiguration().addObservers(axisObserver);
String prefix = namePrefix + "-Listener I/O dispatcher";
try {
ioReactor = (DefaultListeningIOReactor) passThroughListeningIOReactorManager.initIOReactor(operatingPort, handler, new PassThroughSharedListenerConfiguration(new NativeThreadFactory(new ThreadGroup(prefix + " thread group"), prefix), connFactory, sourceConfiguration));
} catch (IOReactorException e) {
handleException("Error initiating " + namePrefix + " ListeningIOReactor", e);
}
Map<String, String> o = (Map<String, String>) cfgCtx.getProperty(PassThroughConstants.EPR_TO_SERVICE_NAME_MAP);
if (o != null) {
this.eprToServiceNameMap = o;
} else {
eprToServiceNameMap = new HashMap<String, String>();
cfgCtx.setProperty(PassThroughConstants.EPR_TO_SERVICE_NAME_MAP, eprToServiceNameMap);
}
cfgCtx.setProperty(PassThroughConstants.PASS_THROUGH_TRANSPORT_WORKER_POOL, sourceConfiguration.getWorkerPool());
/* register to receive updates on services */
serviceTracker = new AxisServiceTracker(cfgCtx.getAxisConfiguration(), new AxisServiceFilter() {
public boolean matches(AxisService service) {
return // these are "private" services
!service.getName().startsWith("__") && BaseUtils.isUsingTransport(service, pttInDescription.getName());
}
}, new AxisServiceTrackerListener() {
public void serviceAdded(AxisService service) {
addToServiceURIMap(service);
}
public void serviceRemoved(AxisService service) {
removeServiceFfromURIMap(service);
}
});
}
use of org.apache.synapse.transport.nhttp.config.ServerConnFactoryBuilder in project wso2-synapse by wso2.
the class HttpCoreNIOListener method reload.
public void reload(final TransportInDescription transportIn) throws AxisFault {
if (state != BaseConstants.STARTED)
return;
// 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");
}
Aggregations