use of org.glassfish.api.ActionReport in project Payara by payara.
the class PersistentEJBTimerService method deployEJBTimerService.
private static boolean deployEJBTimerService(File root, File appScratchFile, String resourceName, boolean is_upgrade) {
boolean deployed = false;
logger.log(Level.INFO, "Loading EJBTimerService. Please wait.");
File app = null;
try {
app = FileUtils.getManagedFile(TIMER_SERVICE_APP_NAME + ".war", new File(root, "lib/install/applications/"));
} catch (Exception e) {
logger.log(Level.WARNING, "Caught unexpected exception", e);
}
if (app == null || !app.exists()) {
logger.log(Level.WARNING, "Cannot deploy or load persistent EJBTimerService: " + "required WAR file (" + TIMER_SERVICE_APP_NAME + ".war) is not installed");
} else {
DeployCommandParameters params = new DeployCommandParameters(app);
params.name = TIMER_SERVICE_APP_NAME;
try {
EjbContainerUtil _ejbContainerUtil = EjbContainerUtilImpl.getInstance();
// first access of the Timer Service application
if (_ejbContainerUtil.isDas() && appScratchFile.createNewFile() && !is_upgrade) {
params.origin = OpsParams.Origin.deploy;
} else {
params.origin = OpsParams.Origin.load;
}
params.target = _ejbContainerUtil.getServerEnvironment().getInstanceName();
ActionReport report = _ejbContainerUtil.getServices().getService(ActionReport.class, "plain");
Deployment deployment = _ejbContainerUtil.getDeployment();
ExtendedDeploymentContext dc = deployment.getBuilder(logger, params, report).source(app).build();
dc.addTransientAppMetaData(DatabaseConstants.JTA_DATASOURCE_JNDI_NAME_OVERRIDE, resourceName);
Properties appProps = dc.getAppProps();
appProps.setProperty(ServerTags.OBJECT_TYPE, DeploymentProperties.SYSTEM_ALL);
deployment.deploy(dc);
if (report.getActionExitCode() != ActionReport.ExitCode.SUCCESS) {
logger.log(Level.WARNING, "Cannot deploy or load EJBTimerService: ", report.getFailureCause());
} else {
deployed = true;
}
} catch (Exception e) {
logger.log(Level.WARNING, "Cannot deploy or load EJBTimerService: ", e);
} finally {
if (!deployed && params.origin.isDeploy() && appScratchFile.exists()) {
// Remove marker file if deploy failed
if (!appScratchFile.delete()) {
logger.log(Level.WARNING, "Failed to remove the marker file " + appScratchFile);
}
}
}
}
return deployed;
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class CreateJdbcConnectionPool 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();
HashMap attrList = new HashMap();
attrList.put(ResourceConstants.CONNECTION_POOL_NAME, jdbc_connection_pool_id);
attrList.put(ResourceConstants.DATASOURCE_CLASS, datasourceclassname);
attrList.put(ServerTags.DESCRIPTION, description);
attrList.put(ResourceConstants.RES_TYPE, restype);
attrList.put(ResourceConstants.STEADY_POOL_SIZE, steadypoolsize);
attrList.put(ResourceConstants.MAX_POOL_SIZE, maxpoolsize);
attrList.put(ResourceConstants.MAX_WAIT_TIME_IN_MILLIS, maxwait);
attrList.put(ResourceConstants.POOL_SIZE_QUANTITY, poolresize);
attrList.put(ResourceConstants.INIT_SQL, initsql);
attrList.put(ResourceConstants.IDLE_TIME_OUT_IN_SECONDS, idletimeout);
attrList.put(ResourceConstants.TRANS_ISOLATION_LEVEL, isolationlevel);
attrList.put(ResourceConstants.IS_ISOLATION_LEVEL_GUARANTEED, isisolationguaranteed.toString());
attrList.put(ResourceConstants.IS_CONNECTION_VALIDATION_REQUIRED, isconnectvalidatereq.toString());
attrList.put(ResourceConstants.CONNECTION_VALIDATION_METHOD, validationmethod);
attrList.put(ResourceConstants.VALIDATION_TABLE_NAME, validationtable);
attrList.put(ResourceConstants.CONN_FAIL_ALL_CONNECTIONS, failconnection.toString());
attrList.put(ResourceConstants.NON_TRANSACTIONAL_CONNECTIONS, nontransactionalconnections.toString());
attrList.put(ResourceConstants.ALLOW_NON_COMPONENT_CALLERS, allownoncomponentcallers.toString());
attrList.put(ResourceConstants.VALIDATE_ATMOST_ONCE_PERIOD_IN_SECONDS, validateatmostonceperiod);
attrList.put(ResourceConstants.CONNECTION_LEAK_TIMEOUT_IN_SECONDS, leaktimeout);
attrList.put(ResourceConstants.CONNECTION_LEAK_RECLAIM, leakreclaim.toString());
attrList.put(ResourceConstants.CONNECTION_CREATION_RETRY_ATTEMPTS, creationretryattempts);
attrList.put(ResourceConstants.CONNECTION_CREATION_RETRY_INTERVAL_IN_SECONDS, creationretryinterval);
attrList.put(ResourceConstants.DRIVER_CLASSNAME, driverclassname);
attrList.put(ResourceConstants.SQL_TRACE_LISTENERS, sqltracelisteners);
attrList.put(ResourceConstants.STATEMENT_TIMEOUT_IN_SECONDS, statementtimeout);
attrList.put(ResourceConstants.STATEMENT_LEAK_TIMEOUT_IN_SECONDS, statementLeaktimeout);
attrList.put(ResourceConstants.STATEMENT_LEAK_RECLAIM, statementLeakreclaim.toString());
attrList.put(ResourceConstants.STATEMENT_CACHE_SIZE, statementcachesize);
attrList.put(ResourceConstants.LAZY_CONNECTION_ASSOCIATION, lazyconnectionassociation.toString());
attrList.put(ResourceConstants.LAZY_CONNECTION_ENLISTMENT, lazyconnectionenlistment.toString());
attrList.put(ResourceConstants.ASSOCIATE_WITH_THREAD, associatewiththread.toString());
attrList.put(ResourceConstants.MATCH_CONNECTIONS, matchconnections.toString());
attrList.put(ResourceConstants.MAX_CONNECTION_USAGE_COUNT, maxconnectionusagecount);
attrList.put(ResourceConstants.PING, ping.toString());
attrList.put(ResourceConstants.POOLING, pooling.toString());
attrList.put(ResourceConstants.VALIDATION_CLASSNAME, validationclassname);
attrList.put(ResourceConstants.WRAP_JDBC_OBJECTS, wrapjdbcobjects.toString());
ResourceStatus rs;
try {
JDBCConnectionPoolManager connPoolMgr = new JDBCConnectionPoolManager();
rs = connPoolMgr.create(domain.getResources(), attrList, properties, target);
} catch (Exception e) {
String actual = e.getMessage();
String def = "JDBC connection pool: {0} could not be created, reason: {1}";
report.setMessage(localStrings.getLocalString("create.jdbc.connection.pool.fail", def, jdbc_connection_pool_id, actual));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
if (rs.getMessage() != null) {
report.setMessage(rs.getMessage());
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getMessage() == null) {
report.setMessage(localStrings.getLocalString("create.jdbc.connection.pool.fail", "JDBC connection pool {0} creation failed", jdbc_connection_pool_id, ""));
}
if (rs.getException() != null)
report.setFailureCause(rs.getException());
} else {
// TODO only for DAS
if ("true".equalsIgnoreCase(ping.toString())) {
ActionReport subReport = report.addSubActionsReport();
ParameterMap parameters = new ParameterMap();
parameters.set("pool_name", jdbc_connection_pool_id);
commandRunner.getCommandInvocation("ping-connection-pool", subReport, context.getSubject()).parameters(parameters).execute();
if (ActionReport.ExitCode.FAILURE.equals(subReport.getActionExitCode())) {
subReport.setMessage(localStrings.getLocalString("ping.create.jdbc.connection.pool.fail", "\nAttempting to ping during JDBC Connection Pool " + "Creation : {0} - Failed.", jdbc_connection_pool_id));
subReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
} else {
subReport.setMessage(localStrings.getLocalString("ping.create.jdbc.connection.pool.success", "\nAttempting to ping during JDBC Connection Pool " + "Creation : {0} - Succeeded.", jdbc_connection_pool_id));
}
}
}
report.setActionExitCode(ec);
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class CreateJdbcResource 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();
HashMap attrList = new HashMap();
attrList.put(ResourceConstants.JNDI_NAME, jndiName);
attrList.put(ResourceConstants.POOL_NAME, connectionPoolId);
attrList.put(ServerTags.DESCRIPTION, description);
attrList.put(ResourceConstants.ENABLED, enabled.toString());
ResourceStatus rs;
try {
rs = jdbcMgr.create(domain.getResources(), attrList, properties, target);
} catch (Exception e) {
report.setMessage(localStrings.getLocalString("create.jdbc.resource.failed", "JDBC resource {0} creation failed", jndiName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
if (rs.getMessage() != null) {
report.setMessage(rs.getMessage());
}
if (rs.getStatus() == ResourceStatus.FAILURE) {
ec = ActionReport.ExitCode.FAILURE;
if (rs.getException() != null)
report.setFailureCause(rs.getException());
}
report.setActionExitCode(ec);
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class GetValidationTableNames method execute.
/**
* @inheritDoc
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
PoolInfo poolInfo = new PoolInfo(poolName, applicationName, moduleName);
Set<String> validationTableNames = jdbcAdminService.getValidationTableNames(poolInfo);
Properties extraProperties = new Properties();
extraProperties.put("validationTableNames", new ArrayList(validationTableNames));
report.setExtraProperties(extraProperties);
} catch (Exception e) {
report.setMessage("_get-validation-table-names failed : " + e.getMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
report.setActionExitCode(ec);
}
use of org.glassfish.api.ActionReport in project Payara by payara.
the class GetValidationClassNames method execute.
/**
* @inheritDoc
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
Set<String> validationClassNames = jdbcAdminService.getValidationClassNames(className);
Properties extraProperties = new Properties();
extraProperties.put("validationClassNames", new ArrayList(validationClassNames));
report.setExtraProperties(extraProperties);
} catch (Exception e) {
report.setMessage("_get-validation-class-names failed : " + e.getMessage());
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
return;
}
ActionReport.ExitCode ec = ActionReport.ExitCode.SUCCESS;
report.setActionExitCode(ec);
}
Aggregations