private boolean hasError() { return report.getActionExitCode() != ExitCode.SUCCESS; } @Inject @Optional
private boolean isError() { return report.getActionExitCode() == ActionReport.ExitCode.FAILURE; }
private boolean hasError() { return report.getActionExitCode() != ExitCode.SUCCESS; } @Inject(optional = true)
private boolean isError() { return report.getActionExitCode() == ActionReport.ExitCode.FAILURE; }
public ActionReport.ExitCode getExitCode() { return report.getActionExitCode(); }
public ExitStatus getExitStatus() { final ActionReport.ExitCode actionExitCode = actionReport.getActionExitCode(); switch (actionExitCode) { case SUCCESS: return ExitStatus.SUCCESS; case WARNING: return ExitStatus.WARNING; case FAILURE: return ExitStatus.FAILURE; default: throw new RuntimeException("Unknown exit code: " + actionExitCode); } }
public ExitStatus getExitStatus() { final ActionReport.ExitCode actionExitCode = actionReport.getActionExitCode(); switch (actionExitCode) { case SUCCESS: return ExitStatus.SUCCESS; case WARNING: return ExitStatus.WARNING; case FAILURE: return ExitStatus.FAILURE; default: throw new RuntimeException("Unknown exit code: " + actionExitCode); } }
if (report.getActionExitCode() != ActionReport.ExitCode.SUCCESS) { return;
private String killInstance(AdminCommandContext context) { String msg = initializeInstance(); if (msg != null) return msg; String nodeName = instance.getNodeRef(); Node node = nodes.getNode(nodeName); NodeUtils nodeUtils = new NodeUtils(habitat, logger); // asadmin command to run on instances node ArrayList<String> command = new ArrayList<String>(); command.add("stop-local-instance"); command.add("--kill"); command.add(instanceName); String humanCommand = makeCommandHuman(command); String firstErrorMessage = Strings.get("stop.local.instance.kill", instanceName, nodeName, humanCommand); if (logger.isLoggable(Level.FINE)) logger.fine("stop-instance: running " + humanCommand + " on " + nodeName); nodeUtils.runAdminCommandOnNode(node, command, context, firstErrorMessage, humanCommand, null); ActionReport killreport = context.getActionReport(); if (killreport.getActionExitCode() != ActionReport.ExitCode.SUCCESS) { return killreport.getMessage(); } return null; }
private String killInstance(AdminCommandContext context) { String msg = initializeInstance(); if (msg != null) return msg; String nodeName = instance.getNodeRef(); Node node = nodes.getNode(nodeName); NodeUtils nodeUtils = new NodeUtils(habitat, logger); // asadmin command to run on instances node ArrayList<String> command = new ArrayList<String>(); command.add("stop-local-instance"); command.add("--kill"); command.add(instanceName); String humanCommand = makeCommandHuman(command); String firstErrorMessage = Strings.get("stop.local.instance.kill", instanceName, nodeName, humanCommand); logger.fine("stop-instance: running " + humanCommand + " on " + nodeName); nodeUtils.runAdminCommandOnNode(node, command, context, firstErrorMessage, humanCommand, null); ActionReport killreport = context.getActionReport(); if (killreport.getActionExitCode() != ActionReport.ExitCode.SUCCESS) { return killreport.getMessage(); } return null; }
private void reexecuteJobFromCheckpoint(CheckpointFilename cf) { Checkpoint checkpoint = null; try { RestPayloadImpl.Outbound outbound = new RestPayloadImpl.Outbound(true); checkpoint = loadCheckpoint(cf, outbound); } catch (Exception ex) { logger.log(Level.WARNING, KernelLoggerInfo.exceptionLoadCheckpoint, ex); } if (checkpoint != null) { logger.log(Level.INFO, KernelLoggerInfo.checkpointAutoResumeStart, new Object[]{checkpoint.getJob().getName()}); commandRunner.executeFromCheckpoint(checkpoint, false, new AdminCommandEventBrokerImpl()); ActionReport report = checkpoint.getContext().getActionReport(); logger.log(Level.INFO, KernelLoggerInfo.checkpointAutoResumeDone, new Object[]{checkpoint.getJob().getName(), report.getActionExitCode(), report.getTopMessagePart()}); } }
private void deployMEJB() throws IOException { _logger.info("Loading MEJB app on JNDI look up"); ServerContext serverContext = habitat.getService(ServerContext.class); File mejbArchive = new File(serverContext.getInstallRoot(), "lib/install/applications/mejb.jar"); DeployCommandParameters deployParams = new DeployCommandParameters(mejbArchive); String targetName = habitat.<Server>getService(Server.class, ServerEnvironment.DEFAULT_INSTANCE_NAME).getName(); deployParams.target = targetName; deployParams.name = "mejb"; ActionReport report = habitat.getService(ActionReport.class, "plain"); Deployment deployment = habitat.getService(Deployment.class); ExtendedDeploymentContext dc = deployment.getBuilder(_logger, deployParams, report).source(mejbArchive).build(); deployment.deploy(dc); if (report.getActionExitCode() != ActionReport.ExitCode.SUCCESS) { throw new RuntimeException("Failed to deploy MEJB app: " + report.getFailureCause()); } } }
public boolean executeAdminCommand(ActionReport report, String commandName, String operand, String... parameters) { ParameterMap params = new ParameterMap(); if (operand!=null) { params.add("DEFAULT", operand); } for (int i=0;i<parameters.length;) { String key = parameters[i++]; String value=null; if (i<parameters.length) { value = parameters[i++]; } params.add(key, value); } CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation(commandName, report); inv.parameters(params); inv.execute(); return (report.getActionExitCode()==ActionReport.ExitCode.SUCCESS); }
public boolean executeAdminCommand(ActionReport report, String commandName, String operand, String... parameters) { ParameterMap params = new ParameterMap(); if (operand!=null) { params.add("DEFAULT", operand); } for (int i=0;i<parameters.length;) { String key = parameters[i++]; String value=null; if (i<parameters.length) { value = parameters[i++]; } params.add(key, value); } CommandRunner.CommandInvocation inv = commandRunner.getCommandInvocation(commandName, report); inv.parameters(params); inv.execute(); return (report.getActionExitCode()==ActionReport.ExitCode.SUCCESS); }
deployment.disable(commandParams, app, appInfo, report, logger); if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) { throw new Exception(report.getMessage());
public void undeploy(OSGiApplicationInfo osgiAppInfo) throws DeploymentException { final Bundle b = osgiAppInfo.getBundle(); raiseEvent(State.UNDEPLOYING, b, null); ActionReport report = getReport(); OSGiUndeploymentRequest request = createOSGiUndeploymentRequest(deployer, env, report, osgiAppInfo); request.execute(); raiseEvent(State.UNDEPLOYED, b, null); // raise event even if something went wrong if (report.getActionExitCode() == ActionReport.ExitCode.FAILURE) { throw new DeploymentException("Undeployment of " + b + " failed because of following reason: " + report.getMessage(), report.getFailureCause()); } }
public void undeploy(OSGiApplicationInfo osgiAppInfo) throws DeploymentException { final Bundle b = osgiAppInfo.getBundle(); raiseEvent(State.UNDEPLOYING, b, null); ActionReport report = getReport(); OSGiUndeploymentRequest request = createOSGiUndeploymentRequest(deployer, env, report, osgiAppInfo); request.execute(); raiseEvent(State.UNDEPLOYED, b, null); // raise event even if something went wrong if (report.getActionExitCode() == ActionReport.ExitCode.FAILURE) { throw new DeploymentException("Undeployment of " + b + " failed because of following reason: " + report.getMessage(), report.getFailureCause()); } }
private void copyActionReportContent(ActionReport source, ActionReport dest) { if (source == null || dest == null) { return; } dest.setActionExitCode(source.getActionExitCode()); dest.setExtraProperties(source.getExtraProperties()); //No deep copy. Any change of source is unexpected copyMessagePart(source.getTopMessagePart(), dest.getTopMessagePart()); List<? extends ActionReport> subReports = source.getSubActionsReport(); if (subReports != null) { for (ActionReport subrep : subReports) { copyActionReportContent(subrep, dest.addSubActionsReport()); } } }
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); }