public Set<ProtocolDescription> protocols() { Set<ProtocolDescription> protocols = new HashSet<ProtocolDescription>(); for (Deployment dep : deployments) { protocols.add(dep.getDescription().getProtocol()); } return protocols; }
public List<Deployment> deployedDeploymentsInUnDeployOrder() { List<Deployment> managedDeployment = new ArrayList<Deployment>(); for (Deployment deployment : deployments) { DeploymentDescription desc = deployment.getDescription(); if (desc.managed() || deployment.isDeployed()) { managedDeployment.add(deployment); } } Collections.sort(managedDeployment, new Comparator<Deployment>() { public int compare(Deployment o1, Deployment o2) { return new Integer(o2.getDescription().getOrder()).compareTo(o1.getDescription().getOrder()); } }); return Collections.unmodifiableList(managedDeployment); }
public DeploymentScenario addDeployment(DeploymentDescription deployment) { Validate.notNull(deployment, "Deployment must be specified"); validateNotSameNameAndTypeOfDeployment(deployment); validateNotSameArchiveAndSameTarget(deployment); this.deployments.add(new Deployment(deployment)); return this; }
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription deploymentDescription = deployment.getDescription(); /* * TODO: should the DeploymentDescription producer some how be automatically registered ? * Or should we just 'know' who is the first one to create the context */ deploymentDescriptionProducer.set(deploymentDescription); deploymentProducer.set(deployment); deployEvent.fire(new BeforeDeploy(deployableContainer, deploymentDescription)); try { if (deploymentDescription.isArchiveDeployment()) { protocolMetadata.set(deployableContainer.deploy( deploymentDescription.getTestableArchive() != null ? deploymentDescription.getTestableArchive() : deploymentDescription.getArchive())); } else { deployableContainer.deploy(deploymentDescription.getDescriptor()); } deployment.deployed(); } catch (Exception e) { deployment.deployedWithError(e); throw e; } deployEvent.fire(new AfterDeploy(deployableContainer, deploymentDescription)); return null; } });
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription description = deployment.getDescription(); deployEvent.fire(new BeforeUnDeploy(deployableContainer, description)); try { if (deployment.getDescription().isArchiveDeployment()) { try { deployableContainer.undeploy( description.getTestableArchive() != null ? description.getTestableArchive() : description.getArchive()); } catch (Exception e) { if (!deployment.hasDeploymentError()) { throw e; } } } else { deployableContainer.undeploy(description.getDescriptor()); } } finally { deployment.undeployed(); } deployEvent.fire(new AfterUnDeploy(deployableContainer, description)); return null; } });
.thenReturn(new ContainerImpl("Z", deployableContainer, new ContainerDefImpl("Z"))); Deployment deploymentZ = new Deployment(new DeploymentDescription("Z", ShrinkWrap.create(JavaArchive.class)) .setTarget(new TargetDescription("Z"))); Deployment deploymentX = new Deployment(new DeploymentDescription("X", ShrinkWrap.create(JavaArchive.class)) .setTarget(new TargetDescription("X"))); if (deploymentContext.isActive()) { Deployment activeContext = deploymentContext.getActiveId(); if (!"Z".equals(activeContext.getDescription().getName())) { Assert.fail( "Wrong deployment context active, potential leak in Enricher. Active context was " + activeContext .getDescription() .getName());
scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_1_NAME)).deployed(); scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_2_NAME)).deployed(); scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_3_NAME)).deployed(); scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_4_NAME)).deployed(); scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_4_NAME)).getDescription().getDescriptor()); scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_3_NAME)).getDescription().getArchive()); scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_1_NAME)).getDescription().getArchive()); .getDescription() .getTestableArchive());
public List<Deployment> deployedDeployments() { List<Deployment> result = new ArrayList<Deployment>(); for (Deployment dep : this.deployments) { if (dep.isDeployed()) { result.add(dep); } } return result; }
private void setupAndExecuteUnDeployment(String containerName, boolean managed) { DeploymentDescription description = createDeploymentDescription(containerName) .shouldBeManaged(managed); scenario.get().addDeployment(description); controller.get().start(containerName); scenario.get().deployment(new DeploymentTargetDescription(DEPLOYMENT_NAME)).deployed(); controller.get().stop(containerName); }
private void waitForDeploymentCompletion(Deployment deployment, final AddonId addonToDeploy, int quantity, TimeUnit unit) throws DeploymentException { AddonRegistry registry = runnable.getForge().getAddonRegistry(); Addon addon = registry.getAddon(addonToDeploy); try { Future<Void> future = addon.getFuture(); if (!future.isDone()) { future.get(); } Addons.waitUntilStartedOrMissing(addon, quantity, unit); } catch (Exception e) { deployment.deployedWithError(e); throw new DeploymentException("AddonDependency " + addonToDeploy + " failed to deploy.", e); } if (addon.getStatus().isFailed()) { DeploymentException e = new DeploymentException("AddonDependency " + addonToDeploy + " failed to deploy."); deployment.deployedWithError(e); throw new DeploymentException("AddonDependency " + addonToDeploy + " failed to deploy.", e); } }
public List<Deployment> deploymentsInError() { List<Deployment> result = new ArrayList<Deployment>(); for (Deployment dep : this.deployments) { if (dep.hasDeploymentError()) { result.add(dep); } } return result; }
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription deploymentDescription = deployment.getDescription(); /* * TODO: should the DeploymentDescription producer some how be automatically registered ? * Or should we just 'know' who is the first one to create the context */ deploymentDescriptionProducer.set(deploymentDescription); deploymentProducer.set(deployment); deployEvent.fire(new BeforeDeploy(deployableContainer, deploymentDescription)); try { if (deploymentDescription.isArchiveDeployment()) { protocolMetadata.set(deployableContainer.deploy( deploymentDescription.getTestableArchive() != null ? deploymentDescription.getTestableArchive() : deploymentDescription.getArchive())); } else { deployableContainer.deploy(deploymentDescription.getDescriptor()); } deployment.deployed(); } catch (Exception e) { deployment.deployedWithError(e); throw e; } deployEvent.fire(new AfterDeploy(deployableContainer, deploymentDescription)); return null; } });
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription description = deployment.getDescription(); deployEvent.fire(new BeforeUnDeploy(deployableContainer, description)); try { if (deployment.getDescription().isArchiveDeployment()) { try { deployableContainer.undeploy( description.getTestableArchive() != null ? description.getTestableArchive() : description.getArchive()); } catch (Exception e) { if (!deployment.hasDeploymentError()) { throw e; } } } else { deployableContainer.undeploy(description.getDescriptor()); } } finally { deployment.undeployed(); } deployEvent.fire(new AfterUnDeploy(deployableContainer, description)); return null; } });
.thenReturn(new ContainerImpl("Z", deployableContainer, new ContainerDefImpl("Z"))); Deployment deploymentZ = new Deployment(new DeploymentDescription("Z", ShrinkWrap.create(JavaArchive.class)) .setTarget(new TargetDescription("Z"))); Deployment deploymentX = new Deployment(new DeploymentDescription("X", ShrinkWrap.create(JavaArchive.class)) .setTarget(new TargetDescription("X"))); if (deploymentContext.isActive()) { Deployment activeContext = deploymentContext.getActiveId(); if (!"Z".equals(activeContext.getDescription().getName())) { Assert.fail( "Wrong deployment context active, potential leak in Enricher. Active context was " + activeContext .getDescription() .getName());
public List<Deployment> deployedDeployments() { List<Deployment> result = new ArrayList<Deployment>(); for (Deployment dep : this.deployments) { if (dep.isDeployed()) { result.add(dep); } } return result; }
private void setupAndExecuteUnDeployment(String containerName, boolean managed) { DeploymentDescription description = createDeploymentDescription(containerName) .shouldBeManaged(managed); scenario.get().addDeployment(description); controller.get().start(containerName); scenario.get().deployment(new DeploymentTargetDescription(DEPLOYMENT_NAME)).deployed(); controller.get().stop(containerName); }
deployment.deployedWithError(e); throw e;
public List<Deployment> deploymentsInError() { List<Deployment> result = new ArrayList<Deployment>(); for (Deployment dep : this.deployments) { if (dep.hasDeploymentError()) { result.add(dep); } } return result; }
public Set<ProtocolDescription> protocols() { Set<ProtocolDescription> protocols = new HashSet<ProtocolDescription>(); for (Deployment dep : deployments) { protocols.add(dep.getDescription().getProtocol()); } return protocols; }
public List<Deployment> deployedDeploymentsInUnDeployOrder() { List<Deployment> managedDeployment = new ArrayList<Deployment>(); for (Deployment deployment : deployments) { DeploymentDescription desc = deployment.getDescription(); if (desc.managed() || deployment.isDeployed()) { managedDeployment.add(deployment); } } Collections.sort(managedDeployment, new Comparator<Deployment>() { public int compare(Deployment o1, Deployment o2) { return new Integer(o2.getDescription().getOrder()).compareTo(o1.getDescription().getOrder()); } }); return Collections.unmodifiableList(managedDeployment); }