use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class CreateHttpListener 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) {
final ActionReport report = context.getActionReport();
if (!validateInputs(report)) {
return;
}
Target targetUtil = services.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
networkConfig = config.getNetworkConfig();
HttpService httpService = config.getHttpService();
if (!(verifyUniqueName(report, networkConfig) && verifyUniquePort(report, networkConfig) && verifyDefaultVirtualServer(report))) {
return;
}
VirtualServer vs = httpService.getVirtualServerByName(defaultVirtualServer);
boolean listener = false;
boolean protocol = false;
boolean transport = false;
try {
transport = createOrGetTransport(null);
protocol = createProtocol(context);
createHttp(context);
final ThreadPool threadPool = getThreadPool(networkConfig);
listener = createNetworkListener(networkConfig, transport, threadPool);
updateVirtualServer(vs);
} catch (TransactionFailure e) {
try {
if (listener) {
deleteListener(context);
}
if (protocol) {
deleteProtocol(context);
}
if (transport) {
deleteTransport(context);
}
} catch (Exception e1) {
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO, e.getMessage(), e);
}
throw new RuntimeException(e.getMessage());
}
if (logger.isLoggable(Level.INFO)) {
logger.log(Level.INFO, e.getMessage(), e);
}
report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_LISTENER_FAIL), listenerId, e.getMessage()));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class UpgradeTest method threadPools.
@Test
public void threadPools() {
List<String> names = new ArrayList<String>();
for (ThreadPool pool : getHabitat().<Config>getService(Config.class).getThreadPools().getThreadPool()) {
names.add(pool.getName());
}
assertTrue(names.contains("http-thread-pool") && names.contains("thread-pool-1"));
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class GrizzlyConfigTest method defaults.
@Test
public void defaults() throws IOException {
GrizzlyConfig grizzlyConfig = null;
try {
grizzlyConfig = new GrizzlyConfig("grizzly-config.xml");
final ThreadPool threadPool = grizzlyConfig.getConfig().getNetworkListeners().getThreadPool().get(0);
Assert.assertEquals("5", threadPool.getMaxThreadPoolSize());
} finally {
if (grizzlyConfig != null) {
grizzlyConfig.shutdown();
}
}
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class AdminEndpointDecider method setValues.
private void setValues() {
// can't change
asadminContextRoot = AdminAdapter.PREFIX_URI;
// asadminHosts = Collections.emptyList(); //asadmin is handled completely by the adapter, no VS needed
NetworkListener nl = cfg.getAdminListener();
ThreadPool tp = nl.findThreadPool();
if (tp != null) {
try {
maxThreadPoolSize = Integer.parseInt(tp.getMaxThreadPoolSize());
} catch (NumberFormatException ne) {
}
}
String dvs = nl.findHttpProtocol().getHttp().getDefaultVirtualServer();
guiHosts = Collections.unmodifiableList(Arrays.asList(dvs));
// same for now
asadminHosts = guiHosts;
try {
address = InetAddress.getByName(nl.getAddress());
} catch (UnknownHostException e) {
throw new IllegalStateException(e);
}
if (ServerTags.ADMIN_LISTENER_ID.equals(nl.getName())) {
// at the root context for separate admin-listener
guiContextRoot = "";
try {
port = Integer.parseInt(nl.getPort());
} catch (NumberFormatException ne) {
port = ADMIN_PORT;
}
} else {
try {
port = Integer.parseInt(nl.getPort());
} catch (NumberFormatException ne) {
// this is the last resort
port = 8080;
}
// get the context root from admin-service
AdminService as = cfg.getAdminService();
if (as == null)
guiContextRoot = ServerEnvironmentImpl.DEFAULT_ADMIN_CONSOLE_CONTEXT_ROOT;
else
setGuiContextRootFromAdminService(as);
}
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class GrizzlyConfigSchemaMigrator method ensureAdminThreadPool.
private void ensureAdminThreadPool() throws TransactionFailure {
final ThreadPools threadPools = currentConfig.getThreadPools();
boolean adminThreadPoolFound = false;
for (ThreadPool pool : threadPools.getThreadPool()) {
adminThreadPoolFound |= "admin-thread-pool".equals(pool.getName());
}
if (!adminThreadPoolFound) {
ConfigSupport.apply(new SingleConfigCode<ThreadPools>() {
@Override
public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure {
final ThreadPool pool = param.createChild(ThreadPool.class);
param.getThreadPool().add(pool);
pool.setName("admin-thread-pool");
pool.setMaxThreadPoolSize("50");
pool.setMaxQueueSize("256");
return null;
}
}, threadPools);
}
}
Aggregations