use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.
the class CommandThreadPool method postConstruct.
/**
* Process the instance file if this is DAS and there are instances configured already in this domain
*/
@Override
public void postConstruct() {
// If this is not the DAS, no need for this pool
if (serverEnv.isInstance()) {
return;
}
int poolSize = 5;
Config svrConfig = domain.getConfigNamed("server-config");
// during build; got to check the reason why later.
if (svrConfig != null) {
NetworkConfig nwc = svrConfig.getNetworkConfig();
if (nwc != null) {
List<NetworkListener> lss = nwc.getNetworkListeners().getNetworkListener();
if ((lss != null) && (!lss.isEmpty())) {
for (NetworkListener ls : lss) {
if (ServerTags.ADMIN_LISTENER_ID.equals(ls.getName())) {
if (ls.findThreadPool() != null) {
poolSize = Integer.parseInt(ls.findThreadPool().getMaxThreadPoolSize());
}
}
}
}
}
}
svc = Executors.newFixedThreadPool(poolSize, new InstanceStateThreadFactory());
}
use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.
the class CreateSsl method findOrCreateProtocol.
public Protocol findOrCreateProtocol(final String name, final boolean create) throws TransactionFailure {
NetworkConfig networkConfig = config.getNetworkConfig();
Protocol protocol = networkConfig.findProtocol(name);
if (protocol == null && create) {
protocol = (Protocol) ConfigSupport.apply(new SingleConfigCode<Protocols>() {
@Override
public Object run(Protocols param) throws TransactionFailure {
Protocol newProtocol = param.createChild(Protocol.class);
newProtocol.setName(name);
newProtocol.setSecurityEnabled("true");
param.getProtocol().add(newProtocol);
return newProtocol;
}
}, habitat.<Protocols>getService(Protocols.class));
}
return protocol;
}
use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.
the class RuntimeRootImpl method getAdminListener.
private NetworkListener getAdminListener() {
final NetworkConfig network = networkConfig();
final NetworkListener listener = network.getNetworkListener(ADMIN_LISTENER_NAME);
return listener;
}
use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.
the class GrizzlyService method createNetworkProxy.
/*
* Creates a new NetworkProxy for a particular HttpListner
* @param listener NetworkListener
* @param networkConfig HttpService
*/
public synchronized Future<Result<Thread>> createNetworkProxy(NetworkListener listener) {
if (!Boolean.valueOf(listener.getEnabled())) {
// in case the listener will be enabled
addChangeListener(listener);
LOGGER.log(Level.INFO, KernelLoggerInfo.grizzlyPortDisabled, new Object[] { listener.getName(), listener.getPort() });
return null;
}
// create the proxy for the port.
GrizzlyProxy proxy = new GrizzlyProxy(this, listener);
Future<Result<Thread>> future = null;
try {
proxy.initialize();
if (!isLightWeightListener(listener)) {
final NetworkConfig networkConfig = listener.getParent(NetworkListeners.class).getParent(NetworkConfig.class);
// attach all virtual servers to this port
for (VirtualServer vs : networkConfig.getParent(Config.class).getHttpService().getVirtualServer()) {
List<String> vsListeners = StringUtils.parseStringList(vs.getNetworkListeners(), " ,");
if (vsListeners == null || vsListeners.isEmpty() || vsListeners.contains(listener.getName())) {
if (!hosts.contains(vs.getId())) {
hosts.add(vs.getId());
}
}
}
addChangeListener(listener);
addChangeListener(listener.findThreadPool());
addChangeListener(listener.findTransport());
final Protocol protocol = listener.findHttpProtocol();
if (protocol != null) {
addChangeListener(protocol);
addChangeListener(protocol.getHttp());
addChangeListener(protocol.getHttp().getFileCache());
addChangeListener(protocol.getSsl());
}
}
future = proxy.start();
// add the new proxy to our list of proxies.
proxies.add(proxy);
} catch (Throwable e) {
final Future<Result<Thread>> errorFuture = Futures.createReadyFuture(new Result<Thread>(e));
future = errorFuture;
} finally {
if (future == null) {
final FutureImpl<Result<Thread>> errorFuture = Futures.<Result<Thread>>createUnsafeFuture();
errorFuture.result(new Result<Thread>(new IllegalStateException("Unexpected error")));
future = errorFuture;
}
futures.add(future);
}
return future;
}
use of org.glassfish.grizzly.config.dom.NetworkConfig in project Payara by payara.
the class ServerHelper method getAdminListener.
public static NetworkListener getAdminListener(Config config) {
NetworkConfig nwc = config.getNetworkConfig();
if (nwc == null)
throw new IllegalStateException("Can't operate without <http-service>");
List<NetworkListener> lss = nwc.getNetworkListeners().getNetworkListener();
if (lss == null || lss.isEmpty())
throw new IllegalStateException("Can't operate without at least one <network-listener>");
for (NetworkListener ls : lss) {
if (ServerTags.ADMIN_LISTENER_ID.equals(ls.getName())) {
return ls;
}
}
// if we can't find the admin-listener, then use the first one
return lss.get(0);
}
Aggregations