Skip to content

Commit

Permalink
Concurrent constants moved to ConcurrencyNames
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Oct 15, 2022
1 parent 449aa14 commit 183f828
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
import org.jvnet.hk2.config.TransactionFailure;
import org.jvnet.hk2.config.types.Property;

import static org.glassfish.resources.admin.cli.ResourceConstants.CONTEXT_INFO;
import static org.glassfish.resources.admin.cli.ResourceConstants.CONTEXT_INFO_DEFAULT_VALUE;
import static org.glassfish.resources.admin.cli.ResourceConstants.CONTEXT_INFO_ENABLED;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.CONTEXT_INFO;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.CONTEXT_INFO_DEFAULT_VALUE;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.CONTEXT_INFO_ENABLED;
import static org.glassfish.resources.admin.cli.ResourceConstants.ENABLED;
import static org.glassfish.resources.admin.cli.ResourceConstants.JNDI_NAME;
import static org.glassfish.resources.admin.cli.ResourceConstants.SYSTEM_ALL_REQ;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -18,8 +19,15 @@

import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.config.serverbeans.ServerTags;
import com.sun.enterprise.deployment.xml.ConcurrencyTagNames;
import com.sun.enterprise.util.LocalStringManagerImpl;
import com.sun.enterprise.util.SystemPropertyConstants;

import jakarta.inject.Inject;

import java.util.HashMap;
import java.util.Properties;

import org.glassfish.api.ActionReport;
import org.glassfish.api.I18n;
import org.glassfish.api.Param;
Expand All @@ -30,14 +38,10 @@
import org.glassfish.config.support.CommandTarget;
import org.glassfish.config.support.TargetType;
import org.glassfish.hk2.api.PerLookup;
import org.glassfish.resources.admin.cli.ResourceConstants;
import org.glassfish.resourcebase.resources.api.ResourceStatus;
import org.glassfish.resources.admin.cli.ResourceConstants;
import org.jvnet.hk2.annotations.Service;

import jakarta.inject.Inject;
import java.util.HashMap;
import java.util.Properties;


/**
* Create Context Service Command
Expand All @@ -61,7 +65,7 @@ public class CreateContextService implements AdminCommand {
@Param(name="contextinfoenabled", alias="contextInfoEnabled", defaultValue="true", optional=true)
private Boolean contextinfoenabled;

@Param(name="contextinfo", alias="contextInfo", defaultValue=ResourceConstants.CONTEXT_INFO_DEFAULT_VALUE, optional=true)
@Param(name="contextinfo", alias="contextInfo", defaultValue=ConcurrencyTagNames.CONTEXT_INFO_DEFAULT_VALUE, optional=true)
private String contextinfo;

@Param(optional=true)
Expand Down Expand Up @@ -91,8 +95,8 @@ public void execute(AdminCommandContext context) {

HashMap attrList = new HashMap();
attrList.put(ResourceConstants.JNDI_NAME, jndiName);
attrList.put(ResourceConstants.CONTEXT_INFO_ENABLED, contextinfoenabled.toString());
attrList.put(ResourceConstants.CONTEXT_INFO, contextinfo);
attrList.put(ConcurrencyTagNames.CONTEXT_INFO_ENABLED, contextinfoenabled.toString());
attrList.put(ConcurrencyTagNames.CONTEXT_INFO, contextinfo);
attrList.put(ServerTags.DESCRIPTION, description);
attrList.put(ResourceConstants.ENABLED, enabled.toString());
ResourceStatus rs;
Expand All @@ -112,8 +116,9 @@ public void execute(AdminCommandContext context) {
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
if (rs.getException() != null) {
report.setFailureCause(rs.getException());
}
}
report.setActionExitCode(ec);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -17,6 +18,12 @@
package org.glassfish.concurrent.admin;

import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.deployment.xml.ConcurrencyTagNames;

import jakarta.inject.Inject;

import java.util.HashMap;

import org.glassfish.api.ActionReport;
import org.glassfish.api.I18n;
import org.glassfish.api.Param;
Expand All @@ -27,13 +34,9 @@
import org.glassfish.config.support.CommandTarget;
import org.glassfish.config.support.TargetType;
import org.glassfish.hk2.api.PerLookup;
import org.glassfish.resources.admin.cli.ResourceConstants;
import org.glassfish.resourcebase.resources.api.ResourceStatus;
import org.jvnet.hk2.annotations.Service;

import jakarta.inject.Inject;
import java.util.HashMap;


/**
* Create Managed Executor Service Command
Expand Down Expand Up @@ -61,11 +64,10 @@ public class CreateManagedExecutorService extends CreateManagedExecutorServiceBa
@Override
protected void setAttributeList(HashMap attrList) {
super.setAttributeList(attrList);
attrList.put(ResourceConstants.MAXIMUM_POOL_SIZE,
maximumpoolsize.toString());
attrList.put(ResourceConstants.TASK_QUEUE_CAPACITY,
taskqueuecapacity.toString());
attrList.put(ConcurrencyTagNames.MAXIMUM_POOL_SIZE, maximumpoolsize.toString());
attrList.put(ConcurrencyTagNames.TASK_QUEUE_CAPACITY, taskqueuecapacity.toString());
}

/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
Expand Down Expand Up @@ -95,8 +97,9 @@ public void execute(AdminCommandContext context) {
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
if (rs.getException() != null) {
report.setFailureCause(rs.getException());
}
}
report.setActionExitCode(ec);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -17,14 +17,30 @@

package org.glassfish.concurrent.admin;

import com.sun.enterprise.config.serverbeans.ServerTags;
import com.sun.enterprise.util.LocalStringManagerImpl;
import com.sun.enterprise.util.SystemPropertyConstants;
import org.glassfish.api.Param;
import org.glassfish.resources.admin.cli.ResourceConstants;

import java.util.HashMap;
import java.util.Properties;

import org.glassfish.api.Param;

import static com.sun.enterprise.config.serverbeans.ServerTags.DESCRIPTION;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.CONTEXT_INFO;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.CONTEXT_INFO_DEFAULT_VALUE;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.CONTEXT_INFO_ENABLED;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.CORE_POOL_SIZE;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.HUNG_AFTER_SECONDS;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.HUNG_LOGGER_INITIAL_DELAY_SECONDS;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.HUNG_LOGGER_INTERVAL_SECONDS;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.HUNG_LOGGER_PRINT_ONCE;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.KEEP_ALIVE_SECONDS;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.LONG_RUNNING_TASKS;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.THREAD_LIFETIME_SECONDS;
import static com.sun.enterprise.deployment.xml.ConcurrencyTagNames.THREAD_PRIORITY;
import static org.glassfish.resources.admin.cli.ResourceConstants.ENABLED;
import static org.glassfish.resources.admin.cli.ResourceConstants.JNDI_NAME;


/**
* Base command for creating managed executor service and managed
Expand All @@ -33,7 +49,7 @@
*/
public class CreateManagedExecutorServiceBase {

final protected static LocalStringManagerImpl localStrings = new LocalStringManagerImpl(CreateManagedExecutorServiceBase.class);
protected static final LocalStringManagerImpl localStrings = new LocalStringManagerImpl(CreateManagedExecutorServiceBase.class);

@Param(name="jndi_name", primary=true)
protected String jndiName;
Expand All @@ -44,7 +60,7 @@ public class CreateManagedExecutorServiceBase {
@Param(name="contextinfoenabled", alias="contextInfoEnabled", defaultValue="true", optional=true)
private Boolean contextinfoenabled;

@Param(name="contextinfo", alias="contextInfo", defaultValue=ResourceConstants.CONTEXT_INFO_DEFAULT_VALUE, optional=true)
@Param(name="contextinfo", alias="contextInfo", defaultValue=CONTEXT_INFO_DEFAULT_VALUE, optional=true)
protected String contextinfo;

@Param(name="threadpriority", alias="threadPriority", defaultValue=""+Thread.NORM_PRIORITY, optional=true)
Expand Down Expand Up @@ -84,26 +100,19 @@ public class CreateManagedExecutorServiceBase {
protected String target = SystemPropertyConstants.DAS_SERVER_NAME;

protected void setAttributeList(HashMap attrList) {
attrList.put(ResourceConstants.JNDI_NAME, jndiName);
attrList.put(ResourceConstants.CONTEXT_INFO_ENABLED, contextinfoenabled.toString());
attrList.put(ResourceConstants.CONTEXT_INFO, contextinfo);
attrList.put(ResourceConstants.THREAD_PRIORITY,
threadpriority.toString());
attrList.put(ResourceConstants.LONG_RUNNING_TASKS,
longrunningtasks.toString());
attrList.put(ResourceConstants.HUNG_AFTER_SECONDS,
hungafterseconds.toString());
attrList.put(ResourceConstants.HUNG_LOGGER_PRINT_ONCE,
hungloggerprintonce.toString());
attrList.put(ResourceConstants.HUNG_LOGGER_INITIAL_DELAY_SECONDS, hungloggerinitialdelayseconds.toString());
attrList.put(ResourceConstants.HUNG_LOGGER_INTERVAL_SECONDS, hungloggerintervalseconds.toString());
attrList.put(ResourceConstants.CORE_POOL_SIZE,
corepoolsize.toString());
attrList.put(ResourceConstants.KEEP_ALIVE_SECONDS,
keepaliveseconds.toString());
attrList.put(ResourceConstants.THREAD_LIFETIME_SECONDS,
threadlifetimeseconds.toString());
attrList.put(ServerTags.DESCRIPTION, description);
attrList.put(ResourceConstants.ENABLED, enabled.toString());
attrList.put(JNDI_NAME, jndiName);
attrList.put(CONTEXT_INFO_ENABLED, contextinfoenabled.toString());
attrList.put(CONTEXT_INFO, contextinfo);
attrList.put(THREAD_PRIORITY, threadpriority.toString());
attrList.put(LONG_RUNNING_TASKS, longrunningtasks.toString());
attrList.put(HUNG_AFTER_SECONDS, hungafterseconds.toString());
attrList.put(HUNG_LOGGER_PRINT_ONCE, hungloggerprintonce.toString());
attrList.put(HUNG_LOGGER_INITIAL_DELAY_SECONDS, hungloggerinitialdelayseconds.toString());
attrList.put(HUNG_LOGGER_INTERVAL_SECONDS, hungloggerintervalseconds.toString());
attrList.put(CORE_POOL_SIZE, corepoolsize.toString());
attrList.put(KEEP_ALIVE_SECONDS, keepaliveseconds.toString());
attrList.put(THREAD_LIFETIME_SECONDS, threadlifetimeseconds.toString());
attrList.put(DESCRIPTION, description);
attrList.put(ENABLED, enabled.toString());
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2022 Contributors to the Eclipse Foundation
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -18,8 +19,15 @@

import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.config.serverbeans.ServerTags;
import com.sun.enterprise.deployment.xml.ConcurrencyTagNames;
import com.sun.enterprise.util.LocalStringManagerImpl;
import com.sun.enterprise.util.SystemPropertyConstants;

import jakarta.inject.Inject;

import java.util.HashMap;
import java.util.Properties;

import org.glassfish.api.ActionReport;
import org.glassfish.api.I18n;
import org.glassfish.api.Param;
Expand All @@ -30,18 +38,13 @@
import org.glassfish.config.support.CommandTarget;
import org.glassfish.config.support.TargetType;
import org.glassfish.hk2.api.PerLookup;
import org.glassfish.resources.admin.cli.ResourceConstants;
import org.glassfish.resourcebase.resources.api.ResourceStatus;
import org.glassfish.resources.admin.cli.ResourceConstants;
import org.jvnet.hk2.annotations.Service;

import jakarta.inject.Inject;
import java.util.HashMap;
import java.util.Properties;


/**
* Create Managed Thread Factory Command
*
*/
@TargetType(value={CommandTarget.DAS, CommandTarget.DOMAIN, CommandTarget.CLUSTER, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG, })
@ExecuteOn(RuntimeType.ALL)
Expand All @@ -61,7 +64,7 @@ public class CreateManagedThreadFactory implements AdminCommand {
@Param(name="contextinfoenabled", alias="contextInfoEnabled", defaultValue="true", optional=true)
private Boolean contextinfoenabled;

@Param(name="contextinfo", alias="contextInfo", defaultValue=ResourceConstants.CONTEXT_INFO_DEFAULT_VALUE, optional=true)
@Param(name="contextinfo", alias="contextInfo", defaultValue=ConcurrencyTagNames.CONTEXT_INFO_DEFAULT_VALUE, optional=true)
private String contextinfo;

@Param(name="threadpriority", alias="threadPriority", defaultValue=""+Thread.NORM_PRIORITY, optional=true)
Expand All @@ -88,15 +91,15 @@ public class CreateManagedThreadFactory implements AdminCommand {
*
* @param context information
*/
@Override
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();

HashMap attrList = new HashMap();
attrList.put(ResourceConstants.JNDI_NAME, jndiName);
attrList.put(ResourceConstants.CONTEXT_INFO_ENABLED, contextinfoenabled.toString());
attrList.put(ResourceConstants.CONTEXT_INFO, contextinfo);
attrList.put(ResourceConstants.THREAD_PRIORITY,
threadpriority.toString());
attrList.put(ConcurrencyTagNames.CONTEXT_INFO_ENABLED, contextinfoenabled.toString());
attrList.put(ConcurrencyTagNames.CONTEXT_INFO, contextinfo);
attrList.put(ConcurrencyTagNames.THREAD_PRIORITY, threadpriority.toString());
attrList.put(ServerTags.DESCRIPTION, description);
attrList.put(ResourceConstants.ENABLED, enabled.toString());
ResourceStatus rs;
Expand All @@ -115,8 +118,9 @@ public void execute(AdminCommandContext context) {
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
if (rs.getException() != null) {
report.setFailureCause(rs.getException());
}
}
report.setActionExitCode(ec);
}
Expand Down

0 comments on commit 183f828

Please sign in to comment.