private void logEvent(boolean before, ExtendedDeploymentContext.Phase phase, ExtendedDeploymentContext context) { Level logLevel = Level.FINEST; if(logger.isLoggable(logLevel)){ try{ StringBuilder sb = new StringBuilder(); if(before){ sb.append("ServiceOrchestrator receiving event \n { [Before] "); }else{ sb.append("ServiceOrchestrator receiving event \n { [After] "); } sb.append(" [Phase : "+phase.toString()+"]"); if(context != null){ OpsParams params = context.getCommandParameters(OpsParams.class); sb.append(" [Command : "+params.command+"]"); sb.append(" [Origin : "+params.origin+"]"); }else{ sb.append(" [DeploymentContext is null, command and origin not available]"); } sb.append(" }"); logger.log(logLevel, sb.toString()); }catch(Exception e){ //ignore, this is debugging info. } } }
DeployCommandParameters deployCommandParameters = context.getCommandParameters(DeployCommandParameters.class); if(logger.isLoggable(Level.FINE)) { logger.fine("JpaDeployer.event(): Handling APPLICATION_PREPARED origin is:" + deployCommandParameters.origin);
public void run() { if (phase.equals(ExtendedDeploymentContext.Phase.PREPARE)) { OpsParams params = context.getCommandParameters(OpsParams.class); String appName = params.name(); if (params.origin == OpsParams.Origin.deploy) { serviceOrchestratorImpl.preDeploy(appName, context); } else if (params.origin == OpsParams.Origin.load) { if (params.command == OpsParams.Command.startup_server) { if (isValidApplication(appName)) { serviceOrchestratorImpl.startup(appName, context); } } else { if (params.command == OpsParams.Command.enable) { if (isValidApplication(appName)) { serviceOrchestratorImpl.enable(appName, context); } } } } } else if (phase.equals(ExtendedDeploymentContext.Phase.STOP)) { OpsParams params = context.getCommandParameters(OpsParams.class); String appName = params.name(); if (params.origin == OpsParams.Origin.undeploy) { if (params.command == OpsParams.Command.disable) { serviceOrchestratorImpl.preUndeploy(appName, context); } } } } });
if (event.is(Deployment.APPLICATION_PREPARED) && isDas()) { ExtendedDeploymentContext context = (ExtendedDeploymentContext)event.hook(); OpsParams opsparams = context.getCommandParameters(OpsParams.class); DeployCommandParameters dcp = context.getCommandParameters(DeployCommandParameters.class);
if (event.is(Deployment.APPLICATION_PREPARED) && isDas()) { ExtendedDeploymentContext context = (ExtendedDeploymentContext)event.hook(); OpsParams opsparams = context.getCommandParameters(OpsParams.class); DeployCommandParameters dcp = context.getCommandParameters(DeployCommandParameters.class);
public void run() { if (phase.equals(ExtendedDeploymentContext.Phase.REPLICATION)) { OpsParams params = context.getCommandParameters(OpsParams.class); if (params.origin == OpsParams.Origin.deploy) { String appName = params.name(); serviceOrchestratorImpl.postDeploy(appName, context); } //make sure it is indeed undeploy and not disable. //params.origin is "undeploy" for both "undeploy" as well "disable" phase //hence using the actual command issued to confirm. if (params.origin == OpsParams.Origin.undeploy) { if (params.command == OpsParams.Command.undeploy) { serviceOrchestratorImpl.undeploy(params, context); } } //we get only after-CLEAN-unload-disable event. //we expect after-STOP-unload-disable, but since the target is not "DAS", //DAS will not receive such event. String appName = params.name(); if (params.origin == OpsParams.Origin.unload) { if (params.command == OpsParams.Command.disable) { if (isValidApplication(appName)) { serviceOrchestratorImpl.disable(appName, context); } } } } } });
public void undeploy(String appName, ExtendedDeploymentContext context) { ActionReport report = context.getActionReport(); UndeployCommandParameters params = context.getCommandParameters(UndeployCommandParameters.class); ApplicationInfo info = appRegistry.get(appName); if (info==null) { report.failure(context.getLogger(), "Application " + appName + " not registered", null); events.send(new Event(Deployment.UNDEPLOYMENT_FAILURE, context)); return; } events.send(new Event(Deployment.UNDEPLOYMENT_START, info)); // for DAS target, the undeploy should unload the application // as well if (DeploymentUtils.isDASTarget(params.target)) { unload(info, context); } if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) { events.send(new Event(Deployment.UNDEPLOYMENT_SUCCESS, context)); deploymentLifecycleProbeProvider.applicationUndeployedEvent(appName, getApplicationType(info)); } else { events.send(new Event(Deployment.UNDEPLOYMENT_FAILURE, context)); } appRegistry.remove(appName); }
public void undeploy(String appName, ExtendedDeploymentContext context) { ActionReport report = context.getActionReport(); UndeployCommandParameters params = context.getCommandParameters(UndeployCommandParameters.class); ApplicationInfo info = appRegistry.get(appName); if (info==null) { report.failure(context.getLogger(), "Application " + appName + " not registered", null); events.send(new Event(Deployment.UNDEPLOYMENT_FAILURE, context)); return; } events.send(new Event(Deployment.UNDEPLOYMENT_START, info)); // for DAS target, the undeploy should unload the application // as well if (DeploymentUtils.isDASTarget(params.target)) { unload(info, context); } if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) { events.send(new Event(Deployment.UNDEPLOYMENT_SUCCESS, context)); deploymentLifecycleProbeProvider.applicationUndeployedEvent(appName, getApplicationType(info)); } else { events.send(new Event(Deployment.UNDEPLOYMENT_FAILURE, context)); } appRegistry.remove(appName); }
final ActionReport report = context.getActionReport(); final DeployCommandParameters commandParams = context.getCommandParameters(DeployCommandParameters.class);
final ActionReport report = context.getActionReport(); final DeployCommandParameters commandParams = context.getCommandParameters(DeployCommandParameters.class);