public synchronized void include(List<URI> uris) throws Fabric3Exception { include(uris, false); }
public synchronized void include(Composite composite) throws Fabric3Exception { instantiateAndDeploy(composite); }
public synchronized void activateDefinitions(URI uri) throws DeploymentException { activateAndDeployDefinitions(uri, false); }
public synchronized void include(QName deployable, String planName) throws DeploymentException { Composite wrapper = createWrapper(deployable); DeploymentPlan plan; if (planName == null) { if (RuntimeMode.CONTROLLER == info.getRuntimeMode() && !isLocal()) { plan = contributionHelper.findDefaultPlan(deployable); if (plan == null) { plan = SYNTHETIC_PLAN; } } else { plan = SYNTHETIC_PLAN; } } else { // plan specified plan = contributionHelper.findPlan(planName); if (plan == null) { throw new DeploymentPlanNotFoundException("Deployment plan not found: " + planName); } } for (DeployListener listener : listeners) { listener.onDeploy(deployable, plan.getName()); } instantiateAndDeploy(wrapper, plan, false); for (DeployListener listener : listeners) { listener.onDeployCompleted(deployable, plan.getName()); } }
public void recover(DomainJournal journal) throws DeploymentException { for (URI uri : journal.getContributions()) { activateAndDeployDefinitions(uri, true); DeploymentPlan merged = merge(plans); List<Composite> deployableComposites = contributionHelper.getDeployables(contributions); instantiateAndDeploy(deployableComposites, contributions, merged, true);
public synchronized void include(List<URI> uris) throws DeploymentException { Set<Contribution> contributions = contributionHelper.findContributions(uris); List<Composite> deployables = contributionHelper.getDeployables(contributions); if (RuntimeMode.CONTROLLER == info.getRuntimeMode() && !isLocal()) { Map<URI, DeploymentPlan> plans = new HashMap<URI, DeploymentPlan>(); for (Contribution contribution : contributions) { DeploymentPlan merged = merge(plans.values()); instantiateAndDeploy(deployables, contributions, merged, false); for (Composite deployable : deployables) { QName name = deployable.getName(); instantiateAndDeploy(deployables, contributions, SYNTHETIC_PLAN, false); for (Composite deployable : deployables) { for (DeployListener listener : listeners) {
if (isTransactional()) { domain = CopyUtil.copy(domain); activateDefinitions(contribution); if (!recover || RuntimeMode.VM == info.getRuntimeMode()) { allocateAndDeploy(domain, plan); } else { allocate(domain, plan); selectBinding(domain); collector.markAsProvisioned(domain);
/** * Instantiates and optionally deploys deployables from a set of contributions. Deployment is performed if recovery mode is false or the runtime is * operating in single VM mode. When recovering in a distributed domain, the components contained in the deployables will be instantiated but not deployed * to zones. This is because the domain can run headless (i.e. without a controller) and may already be hosting deployed components. * * @param deployables the deployables * @param contributions the contributions to deploy * @param recover true if recovery mode is enabled * @throws Fabric3Exception if an error occurs during instantiation or deployment */ private void instantiateAndDeploy(List<Composite> deployables, Set<Contribution> contributions, boolean recover) throws Fabric3Exception { LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); for (Contribution contribution : contributions) { if (ContributionState.STORED == contribution.getState()) { throw new Fabric3Exception("Contribution is not installed: " + contribution.getUri()); } } InstantiationContext context = logicalModelInstantiator.include(deployables, domain); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } if (!recover || RuntimeMode.VM == info.getRuntimeMode()) { // in single VM mode, recovery includes deployment deploy(domain); } else { collector.markAsProvisioned(domain); } contributions.forEach(Contribution::deploy); }
if (isTransactional()) { domain = CopyUtil.copy(domain); activateDefinitions(contribution); InstantiationContext context = logicalModelInstantiator.include(composite, domain); if (context.hasErrors()) { allocateAndDeploy(domain, plan); } catch (DeploymentException e) {
/** * Activates and optionally deploys definitions to a domain. * * @param uri the URI of the contribution containing the definitions to activate * @param recover true if recovery is being performed. If true and the runtime is in distributed (controller) mode, definitions will only be * activated. * @throws DeploymentException if there is an error activating definitions */ private synchronized void activateAndDeployDefinitions(URI uri, boolean recover) throws DeploymentException { Contribution contribution = metadataStore.find(uri); if (contribution == null) { throw new DeploymentException("Contribution not installed: " + uri); } if (ContributionState.INSTALLED != contribution.getState()) { throw new ContributionNotInstalledException("Contribution is not installed: " + uri); } Set<PolicySet> policySets = activateDefinitions(contribution); if (!policySets.isEmpty()) { if (!recover || RuntimeMode.VM == info.getRuntimeMode()) { deployPolicySets(policySets); } } }
/** * Allocates and deploys new components in the domain. * * @param domain the domain component * @param plan the deployment plan * @throws DeploymentException if an error is encountered during deployment */ private void allocateAndDeploy(LogicalCompositeComponent domain, DeploymentPlan plan) throws DeploymentException { // Allocate the components to runtime nodes try { allocate(domain, plan); } catch (AllocationException e) { throw new DeploymentException("Error deploying composite", e); } // Select bindings selectBinding(domain); try { // generate and provision any new components and new wires Deployment deployment = generator.generate(domain, true); collector.markAsProvisioned(domain); Deployment fullDeployment = null; if (generateFullDeployment) { fullDeployment = generator.generate(domain, false); } DeploymentPackage deploymentPackage = new DeploymentPackage(deployment, fullDeployment); deployer.deploy(deploymentPackage); } catch (GenerationException e) { throw new DeploymentException("Error deploying components", e); } }
/** * Instantiates and optionally deploys deployables from a set of contributions. Deployment is performed if recovery mode is false or the runtime is * operating in single VM mode. When recovering in a distributed domain, the components contained in the deployables will be instantiated but not deployed * to zones. This is because the domain can run headless (i.e. without a controller) and may already be hosting deployed components. * * @param deployables the deployables * @param contributions the contributions to deploy * @param recover true if recovery mode is enabled * @throws Fabric3Exception if an error occurs during instantiation or deployment */ private void instantiateAndDeploy(List<Composite> deployables, Set<Contribution> contributions, boolean recover) throws Fabric3Exception { LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); for (Contribution contribution : contributions) { if (ContributionState.STORED == contribution.getState()) { throw new Fabric3Exception("Contribution is not installed: " + contribution.getUri()); } } InstantiationContext context = logicalModelInstantiator.include(deployables, domain); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } if (!recover || RuntimeMode.VM == info.getRuntimeMode()) { // in single VM mode, recovery includes deployment deploy(domain); } else { collector.markAsProvisioned(domain); } contributions.forEach(Contribution::deploy); }
public synchronized void include(Composite composite) throws Fabric3Exception { instantiateAndDeploy(composite); }
public synchronized void include(QName deployable) throws DeploymentException { include(deployable, null); }
/** * Instantiates and deploys the given composite. * * @param composite the composite to instantiate and deploy * @throws Fabric3Exception if a deployment error occurs */ private void instantiateAndDeploy(Composite composite) throws Fabric3Exception { LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); QName name = composite.getName(); QNameSymbol symbol = new QNameSymbol(name); ResourceElement<QNameSymbol, Composite> element = metadataStore.find(Composite.class, symbol); if (element == null) { throw new Fabric3Exception("Composite not found in metadata store: " + name); } Contribution contribution = element.getResource().getContribution(); if (ContributionState.STORED == contribution.getState()) { throw new Fabric3Exception("Contribution is not installed: " + contribution.getUri()); } InstantiationContext context = logicalModelInstantiator.include(composite, domain); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } deploy(domain); contribution.deploy(); }
/** * Include all deployables contained in the list of contributions in the domain. * * @param uris the contributions to deploy * @param recover true if this is a recovery operation * @throws Fabric3Exception if an error is encountered during inclusion */ private synchronized void include(List<URI> uris, boolean recover) throws Fabric3Exception { Set<Contribution> contributions = contributionHelper.findContributions(uris); List<Composite> deployables = contributionHelper.getDeployables(contributions); instantiateAndDeploy(deployables, contributions, recover); }
public synchronized void include(List<URI> uris) throws Fabric3Exception { include(uris, false); }
/** * Instantiates and deploys the given composite. * * @param composite the composite to instantiate and deploy * @throws Fabric3Exception if a deployment error occurs */ private void instantiateAndDeploy(Composite composite) throws Fabric3Exception { LogicalCompositeComponent domain = logicalComponentManager.getDomainComposite(); QName name = composite.getName(); QNameSymbol symbol = new QNameSymbol(name); ResourceElement<QNameSymbol, Composite> element = metadataStore.find(Composite.class, symbol); if (element == null) { throw new Fabric3Exception("Composite not found in metadata store: " + name); } Contribution contribution = element.getResource().getContribution(); if (ContributionState.STORED == contribution.getState()) { throw new Fabric3Exception("Contribution is not installed: " + contribution.getUri()); } InstantiationContext context = logicalModelInstantiator.include(composite, domain); if (context.hasErrors()) { throw new AssemblyException(context.getErrors()); } deploy(domain); contribution.deploy(); }
public synchronized void include(Composite composite, boolean simulated) throws DeploymentException { QName name = composite.getName(); for (DeployListener listener : listeners) { listener.onDeploy(name, SYNTHETIC_PLAN_NAME); } instantiateAndDeploy(composite, SYNTHETIC_PLAN, simulated); }
/** * Include all deployables contained in the list of contributions in the domain. * * @param uris the contributions to deploy * @param recover true if this is a recovery operation * @throws Fabric3Exception if an error is encountered during inclusion */ private synchronized void include(List<URI> uris, boolean recover) throws Fabric3Exception { Set<Contribution> contributions = contributionHelper.findContributions(uris); List<Composite> deployables = contributionHelper.getDeployables(contributions); instantiateAndDeploy(deployables, contributions, recover); }