use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class IIOPUtils method postConstruct.
// private GlassFishORBManager gfORBMgr;
public void postConstruct() {
processType = processEnv.getProcessType();
if (processEnv.getProcessType().isServer()) {
Config c = services.getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
iiopService = c.getExtensionByType(IiopService.class);
final Collection<ThreadPool> threadPool = c.getThreadPools().getThreadPool();
final Collection<NetworkListener> listeners = allByContract(NetworkListener.class);
final Set<String> names = new TreeSet<String>();
threadPools = new ArrayList<ThreadPool>();
for (NetworkListener listener : listeners) {
names.add(listener.getThreadPool());
}
for (ThreadPool pool : threadPool) {
if (!names.contains(pool.getName())) {
threadPools.add(pool);
}
}
serverRefs = allByContract(ServerRef.class);
}
IIOPUtils.initMe(this);
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class RestMonitoringEndpointDecider method setValues.
private void setValues() {
NetworkListener networkListener = config.getAdminListener();
ThreadPool threadPool = networkListener.findThreadPool();
// Set Thread pool size
if (threadPool != null) {
try {
maxThreadPoolSize = Integer.parseInt(threadPool.getMaxThreadPoolSize());
} catch (NumberFormatException ex) {
}
}
String defaultVirtualServer = networkListener.findHttpProtocol().getHttp().getDefaultVirtualServer();
hosts = Collections.unmodifiableList(Arrays.asList(defaultVirtualServer));
// Set network address
try {
address = InetAddress.getByName(networkListener.getAddress());
} catch (UnknownHostException e) {
throw new IllegalStateException(e);
}
// Set the context root and port number
if (ServerTags.ADMIN_LISTENER_ID.equals(networkListener.getName())) {
// Get the context root from the rest monitoring service
if (restMonitoringServiceConfiguration == null) {
contextRoot = DEFAULT_CONTEXT_ROOT;
} else {
contextRoot = restMonitoringServiceConfiguration.getContextRoot();
}
try {
port = Integer.parseInt(networkListener.getPort());
} catch (NumberFormatException ne) {
port = DEFAULT_ADMIN_PORT;
}
} else {
try {
port = Integer.parseInt(networkListener.getPort());
} catch (NumberFormatException ne) {
port = DEFAULT_ADMIN_PORT;
}
// Get the context root from the rest monitoring service
if (restMonitoringServiceConfiguration == null) {
contextRoot = DEFAULT_CONTEXT_ROOT;
} else {
contextRoot = restMonitoringServiceConfiguration.getContextRoot();
}
}
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class WebContainerImpl method bind.
private void bind(Port port, WebListener webListener, String vsId) {
String protocol = Port.HTTP_PROTOCOL;
final int portNumber = port.getPortNumber();
final String defaultVS = vsId;
final WebListener listener = webListener;
if (webListener == null) {
listenerName = getListenerName();
webListener = new HttpListener();
webListener.setId(listenerName);
webListener.setPort(portNumber);
} else {
listenerName = webListener.getId();
protocol = webListener.getProtocol();
}
listeners.add(webListener);
if (protocol.equals(Port.HTTP_PROTOCOL)) {
securityEnabled = "false";
} else if (protocol.equals(Port.HTTPS_PROTOCOL)) {
securityEnabled = "true";
}
try {
ConfigSupport.apply(new SingleConfigCode<Protocols>() {
public Object run(Protocols param) throws TransactionFailure {
final Protocol protocol = param.createChild(Protocol.class);
protocol.setName(listenerName);
protocol.setSecurityEnabled(securityEnabled);
param.getProtocol().add(protocol);
final Http http = protocol.createChild(Http.class);
http.setDefaultVirtualServer(defaultVS);
http.setFileCache(http.createChild(FileCache.class));
protocol.setHttp(http);
return protocol;
}
}, networkConfig.getProtocols());
ConfigSupport.apply(new ConfigCode() {
public Object run(ConfigBeanProxy... params) throws TransactionFailure {
NetworkListeners nls = (NetworkListeners) params[0];
Transports transports = (Transports) params[1];
final NetworkListener listener = nls.createChild(NetworkListener.class);
listener.setName(listenerName);
listener.setPort(Integer.toString(portNumber));
listener.setProtocol(listenerName);
listener.setThreadPool("http-thread-pool");
if (listener.findThreadPool() == null) {
final ThreadPool pool = nls.createChild(ThreadPool.class);
pool.setName(listenerName);
listener.setThreadPool(listenerName);
}
listener.setTransport("tcp");
if (listener.findTransport() == null) {
final Transport transport = transports.createChild(Transport.class);
transport.setName(listenerName);
listener.setTransport(listenerName);
}
nls.getNetworkListener().add(listener);
return listener;
}
}, networkConfig.getNetworkListeners(), networkConfig.getTransports());
if (webListener.getProtocol().equals("https")) {
NetworkListener networkListener = networkConfig.getNetworkListener(listenerName);
Protocol httpProtocol = networkListener.findHttpProtocol();
ConfigSupport.apply(new SingleConfigCode<Protocol>() {
public Object run(Protocol param) throws TransactionFailure {
Ssl newSsl = param.createChild(Ssl.class);
populateSslElement(newSsl, listener);
System.out.println("SSL " + newSsl.getKeyStore() + " " + newSsl.getKeyStorePassword() + " " + newSsl.getTrustStore() + " " + newSsl.getTrustStorePassword());
param.setSsl(newSsl);
return newSsl;
}
}, httpProtocol);
}
com.sun.enterprise.config.serverbeans.VirtualServer vs = httpService.getVirtualServerByName(config.getVirtualServerId());
ConfigSupport.apply(new SingleConfigCode<com.sun.enterprise.config.serverbeans.VirtualServer>() {
public Object run(com.sun.enterprise.config.serverbeans.VirtualServer avs) throws PropertyVetoException {
avs.addNetworkListener(listenerName);
return avs;
}
}, vs);
} catch (Exception e) {
if (listeners.contains(webListener)) {
listeners.remove(webListener);
}
e.printStackTrace();
}
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class DeleteThreadpool method preAuthorization.
@Override
public boolean preAuthorization(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
config = CLIUtil.updateConfigIfNeeded(config, target, habitat);
threadPools = config.getThreadPools();
if (!isThreadPoolExists(threadPools)) {
report.setMessage(localStrings.getLocalString("delete.threadpool.notexists", "Thread Pool named {0} does not exist.", threadpool_id));
report.setActionExitCode(ExitCode.FAILURE);
return false;
}
pool = null;
for (ThreadPool tp : config.getThreadPools().getThreadPool()) {
if (tp.getName().equals(threadpool_id)) {
pool = tp;
}
}
List<NetworkListener> nwlsnrList = pool.findNetworkListeners();
for (NetworkListener nwlsnr : nwlsnrList) {
if (pool.getName().equals(nwlsnr.getThreadPool())) {
report.setMessage(localStrings.getLocalString("delete.threadpool.beingused", "{0} threadpool is being used in the network listener {1}", threadpool_id, nwlsnr.getName()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return false;
}
}
return true;
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class DeleteThreadpool method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
try {
ConfigSupport.apply(new SingleConfigCode<ThreadPools>() {
public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure {
List<ThreadPool> poolList = param.getThreadPool();
for (ThreadPool pool : poolList) {
String currPoolId = pool.getName();
if (currPoolId != null && currPoolId.equals(threadpool_id)) {
poolList.remove(pool);
break;
}
}
return poolList;
}
}, threadPools);
report.setActionExitCode(ExitCode.SUCCESS);
} catch (TransactionFailure e) {
String str = e.getMessage();
report.setMessage(localStrings.getLocalString("delete.threadpool" + ".failed", "Delete Thread Pool failed because of: ", str));
report.setActionExitCode(ExitCode.FAILURE);
report.setFailureCause(e);
}
}
Aggregations