Package org.apache.tuscany.sca.domain

Examples of org.apache.tuscany.sca.domain.DomainException


                // get the composite from the node
                NodeModel node = domainModel.getNodes().get(nodeURI);
               
                if (node != null) {
                    if (node.getLifecycleState() != LifecyleState.AVAILABLE){
                        throw new DomainException("Node " + nodeURI + " is already marked as active");
                    } else {
                        for (ContributionModel contributionModel : node.getContributions().values()){
                            CompositeModel compositeModel = contributionModel.getComposites().get(compositeQName);
                           
                            if (compositeModel != null){
                                contributionModel.getDeployedComposites().put(compositeQName, compositeModel);
                                node.getDeployedComposites().put(compositeQName, compositeModel);
                                domainModel.getDeployedComposites().put(compositeQName, compositeModel);
                                domainManagementRuntime.getCompositeBuilder().build(compositeModel.getComposite());
                                domainModel.getDomainLevelComposite().getIncludes().add(compositeModel.getComposite());
                               

                            }
                        }
                    }
                }  
            } else {
                throw new DomainException("Composite " + compositeQNameString +
                                          " is already marked as deployed on node " + nodeURI);
            }
        } catch (Exception ex) {
            logger.log(Level.SEVERE, "Exception when registering domain level composite " +
                                     nodeURI +  " " +
View Full Code Here


            // Stop the SCA runtime that the domain is using
            domainManagementRuntime.stop();

                       
        } catch(ActivationException ex) {
            throw new DomainException(ex);
        }        
    }
View Full Code Here

            // automatically start all the composites
            for (QName compositeName : deployedCompositeNames) {
                startComposite(compositeName);
            }
        } else {
            throw new DomainException("Contribution " + contributionURI + " not found in domain contributions");
        }       
    }
View Full Code Here

           
            // remove contribution from the contribution processor
            try {
                domainManagementContributionService.remove(contributionURI);
            } catch (Exception ex){
                throw new DomainException(ex);
            }
           
            // stop and tidy any nodes running this contribution
            for ( NodeModel node : domainModel.getNodes().values()){
                if (node.getContributions().containsKey(contributionURI)) {
                    try {               
                        if (node.getLifecycleState() == LifecyleState.RUNNING) {
                            ((NodeModelImpl)node).getSCANodeManagerService().stop();
                            node.setLifecycleState(LifecyleState.DEPLOYED);
                        }
                       
                        // remove all contributions from this node including the
                        // one that is specifically being removed.
                        for (ContributionModel tmpContributionModel :  node.getContributions().values()){
                            ((NodeModelImpl)node).getSCANodeManagerService().removeContribution(tmpContributionModel.getContributionURI());
                        }
                       
                        node.getContributions().clear();
                        node.getDeployedComposites().clear();
                        node.setLifecycleState(LifecyleState.AVAILABLE);
                        node.getServices().clear();
                    } catch (Exception ex) {
                        // TODO - collate errors and report
                        ex.printStackTrace();
                    }
                }
            }
        } else {
            throw new DomainException("Contribution " + contributionURI + " not found in domain contributions");
        }
    }
View Full Code Here

        }
    }
   
    public void addDeploymentComposite(String contributionURI, String compositeXML) throws DomainException {
        // TODO
        throw new DomainException("Not yet implemented");       
    }
View Full Code Here

        throw new DomainException("Not yet implemented");       
    }
   
    public void updateDeploymentComposite(String contributionURI, String compositeXML) throws DomainException {
        // TODO
        throw new DomainException("Not yet implemented");        
    }
View Full Code Here

    public void addToDomainLevelComposite(QName compositeQName, String nodeURI) throws DomainException {
       
        try {
            // check to see if this composite has already been added
            if (domainModel.getDeployedComposites().containsKey(compositeQName) ){
                throw new DomainException("Composite " + compositeQName.toString() +
                                          " had already been added to the domain level composite");
            }
           
            // find the contribution that has this composite
            ContributionModel contributionModel = findContributionFromComposite(compositeQName);
           
            if (contributionModel == null){
                throw new DomainException("Can't find contribution for composite " + compositeQName.toString());
            }
           
            // find the composite object from the contribution
            CompositeModel compositeModel = contributionModel.getComposites().get(compositeQName);
           
            if (compositeModel == null){
                throw new DomainException("Can't find composite model " + compositeQName.toString() +
                                          " in contribution " + contributionModel.getContributionURI());
           
           
            // build the contribution to create the services and references
            domainModel.getDeployedComposites().put(compositeQName, compositeModel);
            domainManagementRuntime.getCompositeBuilder().build(compositeModel.getComposite());               
            domainModel.getDomainLevelComposite().getIncludes().add(compositeModel.getComposite());
           
            NodeModel node = null;
           
            // find the node for the composite to run on
            if (nodeURI != null) {
                // find the named node
                node = domainModel.getNodes().get(nodeURI);
               
                if (node == null){
                    throw new DomainException("Node " + nodeURI + " not found in domain");
                }
            } else {
                // noddy algorithm to find a free node
                // TODO - do something better
                for(NodeModel tmpNode : domainModel.getNodes().values()) {
                    if (tmpNode.getLifecycleState() == LifecyleState.AVAILABLE){
                        node = tmpNode;
                    }
                }
               
                if (node == null){
                    throw new DomainException("No free node available to run composite "  + compositeQName.toString());
                }               
            }

            // find all the composites that the node must know about
            List<Contribution> dependentContributions = new ArrayList<Contribution>();
            findDependentContributions(contributionModel.getContribution(), dependentContributions);
            
            // assign the set of contributions to the node model
            for (Contribution tmpContribution : dependentContributions){
                node.getContributions().put(tmpContribution.getURI(),
                                            domainModel.getContributions().get(tmpContribution.getURI()));
            }
           
            // assign the composite to the node model
            node.getDeployedComposites().put(compositeQName, compositeModel);
           
            node.setLifecycleState(LifecyleState.DEPLOYED);
   
            // now pass this information over to the real node
      
           
            // add contributions. Use the dependent contribution list here rather than the
            // one built up in the node model to ensure that contributions are added in the correct order
            // I.e. the top most in the dependency tree last.
            for (Contribution tmpContribution : dependentContributions){
                ((NodeModelImpl)node).getSCANodeManagerService().addContribution(tmpContribution.getURI(),
                         domainModel.getContributions().get(tmpContribution.getURI()).getContributionURL());
            }
   
            // deploy composite
            ((NodeModelImpl)node).getSCANodeManagerService().addToDomainLevelComposite(compositeQName.toString());
                       
            // spray all of the service endpoints from this composite out to interested nodes
            notifyDomainChange();
        } catch (DomainException ex) {           
            throw ex; 
        } catch (Exception ex) {
            throw new DomainException(ex);
        }
           
    }   
View Full Code Here

                        ex.printStackTrace();
                    }               
                }
            }
        } else {
            throw new DomainException("Composite " + compositeQName.toString() + " not found in domain contributions");
        }
    }
View Full Code Here

        try {
            // find the composite object from the list of deployed composites
            CompositeModel compositeModel = domainModel.getDeployedComposites().get(compositeQName);
           
            if (compositeModel == null){
                throw new DomainException("Can't start composite " + compositeQName.toString() +
                                          " as it hasn't been added to the domain level composite");
            }
           
            // find the contribution that has this composite
            ContributionModel contributionModel = findContributionFromComposite(compositeQName);
           
            if (contributionModel == null){
                throw new DomainException("Can't find contribution for composite " + compositeQName.toString());
            }
           
            NodeModel node = null;
           
            // find the node that has this composite
            for(NodeModel tmpNode : domainModel.getNodes().values()) {
                if (tmpNode.getDeployedComposites().containsKey(compositeQName)){
                    node = tmpNode;
                    break;
                }
            }
           
            if (node != null){
                if (node.getLifecycleState() == LifecyleState.DEPLOYED){
                 // start the node
                    ((NodeModelImpl)node).getSCANodeManagerService().start();
                    node.setLifecycleState(LifecyleState.RUNNING);
                }
               
            } else {
                // composite not assigned to node for some reason
                throw new DomainException("Composite "  + compositeQName.toString() +
                                          " is not associated with a node and cannot be started");
            }
        } catch (NodeException ex){
            throw new DomainException(ex);
        }
        
    }
View Full Code Here

    public void stopComposite(QName compositeName) throws DomainException {
        // find the composite object from the list of deployed composites
        CompositeModel composite = domainModel.getDeployedComposites().get(compositeName);
       
        if (composite == null){
            throw new DomainException("Can't stop composite " + compositeName.toString() +
                                      " as it hasn't been added to the domain level composite");
        }
               
        // stop all the nodes running this composite
        for(NodeModel node : domainModel.getNodes().values()) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.domain.DomainException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.