private static String getName(URL url) { if ("file".equals(url.getProtocol())) { try { File f = new File(url.toURI()); return f.getName(); } catch (URISyntaxException e) { throw MESSAGES.invalidUri(e, url); } } String path = url.getPath(); int idx = path.lastIndexOf('/'); while (idx == path.length() - 1) { path = path.substring(0, idx); idx = path.lastIndexOf('/'); } if (idx == -1) { throw MESSAGES.cannotDeriveDeploymentName(url); } return path.substring(idx + 1); }
@Override public Future<DeploymentPlanResult> execute(DeploymentPlan plan) { if (!(plan instanceof DeploymentPlanImpl)) { throw MESSAGES.cannotUseDeploymentPlan(); } DeploymentPlanImpl planImpl = DeploymentPlanImpl.class.cast(plan); Map<UUID, List<String>> actionsById = new HashMap<UUID, List<String>>(); Operation operation = getDeploymentPlanOperation(planImpl, actionsById); Future<ModelNode> future = client.executeAsync(operation, null); return new DomainDeploymentPlanResultFuture(planImpl, future, new LinkedHashSet<ServerIdentity>(client.getServerStatuses().keySet()), actionsById); }
@Override protected void finalize() throws Throwable { try { if(! closed) { // Create the leak description final Throwable t = ControllerClientMessages.MESSAGES.controllerClientNotClosed(); t.setStackTrace(allocationStackTrace); ControllerClientLogger.ROOT_LOGGER.leakedControllerClient(t); // Close StreamUtils.safeClose(this); } } finally { super.finalize(); } }
/** * @param name * @param fullDomain */ public DuplicateDeploymentNameException(String name, boolean fullDomain) { super((fullDomain ? MESSAGES.domainDeploymentAlreadyExists(name) : MESSAGES.serverDeploymentAlreadyExists(name))); this.name = name; }
@Override @Deprecated public DeploymentPlanBuilder withRollback() { if (deploymentActions.size() > 0) { // Someone has cast to this impl class cleanup(); throw MESSAGES.operationsNotAllowed(InitialDeploymentPlanBuilder.class.getSimpleName()); } if (shutdown) { cleanup(); throw MESSAGES.globalRollbackNotCompatible(); } return new DeploymentPlanBuilderImpl(this, true); }
@Override public DeploymentPlanBuilder withShutdown() { // TODO determine how to remove content. Perhaps with a signal to the // deployment repository service such that as part of shutdown after // undeploys are done it then removes the content? if (deploymentActions.size() > 0) { // Someone has to cast this impl class cleanup(); throw MESSAGES.operationsNotAllowed(InitialDeploymentPlanBuilder.class.getSimpleName()); } if (globalRollback) { cleanup(); throw MESSAGES.globalRollbackNotCompatible(); } if (shutdown && gracefulShutdownPeriod != -1) { cleanup(); throw MESSAGES.gracefulShutdownAlreadyConfigured(gracefulShutdownPeriod); } return new DeploymentPlanBuilderImpl(this, -1); }
DeploymentPlanBuilderImpl getNewBuilder(DeploymentActionImpl mod) { DeploymentSetPlanImpl currentSet = getCurrentDeploymentSetPlan(); if (currentSet.hasServerGroupPlans()) { throw MESSAGES.cannotAddDeploymentAction(); } DeploymentSetPlanImpl newSet = currentSet.addAction(mod); return new DeploymentPlanBuilderImpl(this, newSet); }
public static UpdateResultHandlerResponse fromModelNode(ModelNode modelNode) { String outcome = modelNode.hasDefined("outcome") ? modelNode.get("outcome").asString() : MESSAGES.failed(); UpdateResultHandlerResponse result; if ("success".equals(outcome)) { result = createSuccessResponse(modelNode.get("result")); } else if ("cancelled".equals(outcome)) { return createCancellationResponse(); } else { String message = modelNode.hasDefined("failure-description") ? modelNode.get("failure-description").toString() : MESSAGES.noFailureDetails(); result = createFailureResponse(new UpdateFailedException(message)); } if (modelNode.get("rolled-back").asBoolean(false)) { result = createRollbackResponse(result); } else if (modelNode.hasDefined("rollback-failure-description")) { String message = modelNode.get("rollback-failure-description").toString(); result = createRollbackFailedResponse(result, new UpdateFailedException(message)); } return result; } public static UpdateResultHandlerResponse createSuccessResponse(ModelNode result) {
@Override public InitialDeploymentSetBuilder withGracefulShutdown(long timeout, TimeUnit timeUnit) { DeploymentSetPlanImpl currentSet = getCurrentDeploymentSetPlan(); long period = timeUnit.toMillis(timeout); if (currentSet.isShutdown() && period != currentSet.getGracefulShutdownTimeout()) { throw MESSAGES.gracefulShutdownAlreadyConfigured(currentSet.getGracefulShutdownTimeout()); } DeploymentSetPlanImpl newSet = currentSet.setGracefulTimeout(period); return new InitialDeploymentSetBuilderImpl(this, newSet); }
public static Double calculateOffset(MeasurementUnit first, MeasurementUnit second) throws MeasurementConversionException { if (first.isComparableTo(second) == false) { throw new MeasurementConversionException(MESSAGES.cannotConvert(first.name(), second.name())); } return Scale.calculateOffset(first.scale, second.scale); }
@Override public RemoveDeploymentPlanBuilder andRemoveUndeployed() { DeploymentSetPlanImpl currentSet = getCurrentDeploymentSetPlan(); if (currentSet.hasServerGroupPlans()) { throw MESSAGES.cannotAddDeploymentActionsAfterStart(); } DeploymentActionImpl mod = DeploymentActionImpl.getRemoveAction(undeployModification.getDeploymentUnitUniqueName()); DeploymentSetPlanImpl newSet = currentSet.addAction(mod); return new RemoveDeploymentPlanBuilderImpl(this, newSet); } }
@Override public DeploymentPlanBuilder withGracefulShutdown(long timeout, TimeUnit timeUnit) { // TODO determine how to remove content. Perhaps with a signal to the // deployment repository service such that as part of shutdown after // undeploys are done it then removes the content? if (deploymentActions.size() > 0) { // Someone has to cast this impl class cleanup(); throw MESSAGES.operationsNotAllowed(InitialDeploymentPlanBuilder.class.getSimpleName()); } if (globalRollback) { cleanup(); throw MESSAGES.globalRollbackNotCompatible(); } long period = timeUnit.toMillis(timeout); if (shutdown && period != gracefulShutdownPeriod) { cleanup(); throw MESSAGES.gracefulShutdownAlreadyConfigured(gracefulShutdownPeriod); } return new DeploymentPlanBuilderImpl(this, period); }
@Override public ReplaceDeploymentPlanBuilder replace(String replacement, String toReplace) { DeploymentSetPlanImpl currentSet = getCurrentDeploymentSetPlan(); if (currentSet.hasServerGroupPlans()) { throw MESSAGES.cannotAddDeploymentAction(); } DeploymentActionImpl mod = DeploymentActionImpl.getReplaceAction(replacement, toReplace); DeploymentSetPlanImpl newSet = currentSet.addAction(mod); return new ReplaceDeploymentPlanBuilderImpl(this, newSet); }
/** * @param name * @param fullDomain */ public DuplicateDeploymentNameException(String name, boolean fullDomain) { super(fullDomain ? MESSAGES.domainDeploymentAlreadyExists(name) : MESSAGES.serverDeploymentAlreadyExists(name)); this.name = name; }
@Override public UndeployDeploymentPlanBuilder undeploy(String key) { DeploymentSetPlanImpl currentSet = getCurrentDeploymentSetPlan(); if (currentSet.hasServerGroupPlans()) { throw MESSAGES.cannotAddDeploymentAction(); } DeploymentActionImpl mod = DeploymentActionImpl.getUndeployAction(key); DeploymentSetPlanImpl newSet = currentSet.addAction(mod); return new UndeployDeploymentPlanBuilderImpl(this, newSet); }
private String getName(URL url) { if ("file".equals(url.getProtocol())) { try { File f = new File(url.toURI()); return f.getName(); } catch (URISyntaxException e) { cleanup(); throw MESSAGES.invalidUri(e, url); } } String path = url.getPath(); int idx = path.lastIndexOf('/'); while (idx == path.length() - 1) { path = path.substring(0, idx); idx = path.lastIndexOf('/'); } if (idx == -1) { cleanup(); throw MESSAGES.cannotDeriveDeploymentName(url); } return path.substring(idx + 1); }
/** {@inheritDoc} */ @Override public Future<ServerDeploymentPlanResult> execute(DeploymentPlan plan) { if (!(plan instanceof DeploymentPlanImpl)) { throw MESSAGES.cannotUseDeploymentPlan(); } DeploymentPlanImpl planImpl = (DeploymentPlanImpl) plan; Operation operation = getCompositeOperation(planImpl); Future<ModelNode> nodeFuture = executeOperation(operation); return new ServerDeploymentPlanResultFuture(planImpl, nodeFuture); }
@Override public RemoveDeploymentPlanBuilder remove(String key) { DeploymentSetPlanImpl currentSet = getCurrentDeploymentSetPlan(); if (currentSet.hasServerGroupPlans()) { throw MESSAGES.cannotAddDeploymentAction(); } DeploymentActionImpl mod = DeploymentActionImpl.getRemoveAction(key); DeploymentSetPlanImpl newSet = currentSet.addAction(mod); return new RemoveDeploymentPlanBuilderImpl(this, newSet); }
@Override public DeployDeploymentPlanBuilder andDeploy() { DeploymentSetPlanImpl currentSet = getCurrentDeploymentSetPlan(); if (currentSet.hasServerGroupPlans()) { throw MESSAGES.cannotAddDeploymentAction(); } DeploymentActionImpl mod = DeploymentActionImpl.getDeployAction(newContentKey); DeploymentSetPlanImpl newSet = currentSet.addAction(mod); return new DeployDeploymentPlanBuilderImpl(this, newSet); }
@Override public AddDeploymentPlanBuilder add(String name) throws IOException { DeploymentSetPlanImpl currentSet = getCurrentDeploymentSetPlan(); if (currentSet.hasServerGroupPlans()) { throw MESSAGES.cannotAddDeploymentAction(); } DeploymentActionImpl mod = DeploymentActionImpl.getAddAction(name, null, null); DeploymentSetPlanImpl newSet = currentSet.addAction(mod); return new AddDeploymentPlanBuilderImpl(this, newSet); }