public void undeploy(String runtimeName, String target) throws DeploymentException { try { DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan(); DeploymentPlan plan = builder.undeploy(runtimeName).remove(runtimeName).toServerGroup(target).build(); Future<DeploymentPlanResult> future = deploymentManager.execute(plan); future.get(); } catch (Exception ex) { log.warn("Cannot undeploy: " + runtimeName + ":" + ex.getMessage()); } }
private void executePlan(final DomainDeploymentManager manager, final DeploymentPlan plan) throws DeploymentExecutionException, ExecutionException, InterruptedException { if (plan.getDeploymentActions().size() > 0) { final DeploymentPlanResult planResult = manager.execute(plan).get(); final Map<UUID, DeploymentActionResult> actionResults = planResult.getDeploymentActionResults(); for (UUID uuid : actionResults.keySet()) { final Map<String, ServerGroupDeploymentActionResult> groupDeploymentActionResults = actionResults.get(uuid).getResultsByServerGroup(); for (String serverGroup2 : groupDeploymentActionResults.keySet()) { final Map<String, ServerUpdateResult> serverUpdateResults = groupDeploymentActionResults.get(serverGroup2).getResultByServer(); for (String server : serverUpdateResults.keySet()) { final Throwable t = serverUpdateResults.get(server).getFailureResult(); if (t != null) { throw new DeploymentExecutionException(t, "Error executing %s", type); } } } } } } }
@Override public Status execute() throws DeploymentExecutionException, DeploymentFailureException { try { final DomainDeploymentManager manager = client.getDeploymentManager(); final DeploymentPlanBuilder builder = manager.newDeploymentPlan(); DeploymentPlan plan = createPlan(builder); if (plan != null) { executePlan(manager, plan); } } catch (DeploymentFailureException e) { throw e; } catch (DeploymentExecutionException e) { throw e; } catch (Exception e) { throw new DeploymentExecutionException(e, "Error executing %s", type); } return Status.SUCCESS; }
private String executeDeploymentPlan(DeploymentPlan plan, DeploymentAction deployAction) throws Exception { Future<DeploymentPlanResult> future = deploymentManager.execute(plan); DeploymentPlanResult planResult = future.get(); Map<String, ServerGroupDeploymentPlanResult> actionResults = planResult.getServerGroupResults(); for (Entry<String, ServerGroupDeploymentPlanResult> result : actionResults.entrySet()) { for (Entry<String, ServerDeploymentPlanResult> planServerResult : result.getValue().getServerResults().entrySet()) { ServerUpdateResult actionResult = planServerResult.getValue().getDeploymentActionResults() .get(deployAction.getId()); if (actionResult != null) { Exception deploymentException = (Exception) actionResult.getFailureResult(); if (deploymentException != null) throw deploymentException; } } } return deployAction.getDeploymentUnitUniqueName(); } }
public String deploy(Archive<?> archive, String target) throws DeploymentException { try { final InputStream input = archive.as(ZipExporter.class).exportAsInputStream(); try { InitialDeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan(); DeploymentPlan plan = builder.add(archive.getName(), input).andDeploy().toServerGroup(target).build(); DeploymentAction deployAction = plan.getDeploymentActions().get(plan.getDeploymentActions().size() - 1); return executeDeploymentPlan(plan, deployAction); } finally { if (input != null) try { input.close(); } catch (IOException e) { log.warnf(e, "Failed to close resource %s", input); } } } catch (Exception e) { throw new DeploymentException("Could not deploy to container", e); } }
private boolean runDeploymentPlan() throws Exception { DomainDeploymentManager deploymentManager = client.getDeploymentManager(); DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan(); ModelNode model = getDomainModel(); DeploymentActionsCompleteBuilder completionBuilder = null; String serverGroup = null; Set<String> includedGroups = new HashSet<String>(); do { completionBuilder = deploymentSetBuilder(builder, model); if (completionBuilder != null) { serverGroup = chooseServerGroup(model, includedGroups); } } while (serverGroup == null && completionBuilder != null); if (completionBuilder != null) { includedGroups.add(serverGroup); ServerGroupDeploymentPlanBuilder groupPlanBuilder = completionBuilder.toServerGroup(serverGroup); DeploymentPlan plan = completeDeploymentPlan(groupPlanBuilder, model, includedGroups); if (plan != null) { Future<DeploymentPlanResult> future = deploymentManager.execute(plan); writeDeploymentPlanResult(future.get()); } } return continuePrompt(); }
private String executeDeploymentPlan(DeploymentPlan plan, DeploymentAction deployAction) throws Exception { Future<DeploymentPlanResult> future = deploymentManagerDeprecated.execute(plan); DeploymentPlanResult planResult = future.get(); Map<String, ServerGroupDeploymentPlanResult> actionResults = planResult.getServerGroupResults(); for (Entry<String, ServerGroupDeploymentPlanResult> result : actionResults.entrySet()) { for (Entry<String, ServerDeploymentPlanResult> planServerResult : result.getValue().getServerResults().entrySet()) { ServerUpdateResult actionResult = planServerResult.getValue().getDeploymentActionResults() .get(deployAction.getId()); if (actionResult != null) { Exception deploymentException = (Exception) actionResult.getFailureResult(); if (deploymentException != null) throw deploymentException; } } } return deployAction.getDeploymentUnitUniqueName(); } }
InitialDeploymentSetBuilder builder = deploymentManagerDeprecated.newDeploymentPlan().withRollbackAcrossGroups(); final DeployDeploymentPlanBuilder deployBuilder = builder.add(archive.getName(), input).andDeploy(); ServerGroupDeploymentPlanBuilder serverGroupBuilder = null;
DeploymentPlanBuilder builder = deploymentManagerDeprecated.newDeploymentPlan(); UndeployDeploymentPlanBuilder undeployBuilder = builder.undeploy(runtimeName); ServerGroupDeploymentPlanBuilder serverGroupBuilder = null; Future<DeploymentPlanResult> future = deploymentManagerDeprecated.execute(plan); future.get();