Search in sources :

Example 1 with IPlanBuilderPlugin

use of org.opentosca.planbuilder.core.plugins.typebased.IPlanBuilderPlugin in project container by OpenTOSCA.

the class BPELScopeBuilder method createOperationChain.

/**
 * Creates a complete ProvisioningChain for the given NodeTemplate
 *
 * @param nodeTemplate an TNodeTemplate to create a ProvisioningChain for
 * @return a complete ProvisioningChain
 */
public OperationChain createOperationChain(BPELPlanContext context, final TNodeTemplate nodeTemplate, final List<String> operationNames) {
    // get nodetype implementations
    final Collection<TNodeTypeImplementation> nodeTypeImpls = ModelUtils.findNodeTypeImplementation(nodeTemplate, context.getCsar());
    if (nodeTypeImpls.isEmpty()) {
        LOG.warn("No implementations available for NodeTemplate {} , can't generate Provisioning logic", nodeTemplate.getId());
        return null;
    }
    final OperationChain chain = new OperationChain(nodeTemplate);
    // calculate infrastructure nodes
    final List<TNodeTemplate> infraNodes = new ArrayList<>();
    ModelUtils.getInfrastructureNodes(nodeTemplate, infraNodes, context.getCsar());
    // we'll add here a dummy infra node, representing the management
    // infrastructure of the tosca engine (WAR IA's implementing tosca
    // operation,..)
    infraNodes.add(new TOSCAManagementInfrastructureNodeTemplate());
    // check for IA Plugins
    final List<IPlanBuilderPrePhaseIAPlugin<?>> iaPlugins = pluginRegistry.getIaPlugins();
    final List<IPlanBuilderPrePhaseIAPlugin<BPELPlanContext>> iaPlugins2 = Lists.newArrayList();
    iaPlugins.forEach(x -> iaPlugins2.add((IPlanBuilderPrePhaseIAPlugin<BPELPlanContext>) x));
    LOG.debug("Calculating best IA candidates for nodeTemplate {} ", nodeTemplate.getId());
    // calculate nodeImpl candidates where all IAs of each can be
    // provisioned
    calculateBestImplementationIACandidates(context, nodeTypeImpls, iaPlugins2, infraNodes, chain);
    for (final IANodeTypeImplCandidate wrapper : chain.iaCandidates) {
        final int length = wrapper.ias.size();
        for (int i = 0; i < length; i++) {
            final TImplementationArtifact ia = wrapper.ias.get(i);
            final TNodeTemplate infraNode = wrapper.infraNodes.get(i);
            final IPlanBuilderPlugin plugin = wrapper.plugins.get(i);
            LOG.debug("Found IA {} for deployment on the InfraNode {} with the Plugin {}", ia.getName(), infraNode.getId(), plugin.getID());
        }
    }
    // check for DA Plugins
    final List<IPlanBuilderPrePhaseDAPlugin<?>> daPlugins = pluginRegistry.getDaPlugins();
    final List<IPlanBuilderPrePhaseDAPlugin<BPELPlanContext>> daPlugins2 = Lists.newArrayList();
    daPlugins.forEach(x -> daPlugins2.add((IPlanBuilderPrePhaseDAPlugin<BPELPlanContext>) x));
    // calculate nodeImpl candidates where all DAs of each can be
    // provisioned
    calculateBestImplementationDACandidates(context, nodeTemplate, nodeTypeImpls, daPlugins2, infraNodes, chain);
    for (final DANodeTypeImplCandidate wrapper : chain.daCandidates) {
        final int length = wrapper.das.size();
        for (int i = 0; i < length; i++) {
            final TDeploymentArtifact da = wrapper.das.get(i);
            final TNodeTemplate infraNode = wrapper.infraNodes.get(i);
            final IPlanBuilderPlugin plugin = wrapper.plugins.get(i);
            LOG.debug("Found DA {} for deployment on the InfraNode {} with the Plugin {}", da.getName(), infraNode.getId(), plugin.getID());
        }
    }
    // filter for nodeTypeImpl Candidates where both DAs and IAs can
    // be provisioned
    filterIncompatibleIADACandidates(chain);
    // check for prov plugins
    final List<IPlanBuilderProvPhaseOperationPlugin<?>> provPlugins = pluginRegistry.getProvPlugins();
    // search for prov plugins according to the chosen IA provisionings in
    // the chain
    calculateProvPlugins(chain, provPlugins, context.getCsar());
    // filter ia and da candidates where the operations can't be executed
    filterIADACandidates(chain);
    // order provisioning candidates
    reorderProvCandidates(chain);
    // TODO consistency plugins
    // select provisioning
    selectProvisioning(chain, operationNames);
    return chain;
}
Also used : TImplementationArtifact(org.eclipse.winery.model.tosca.TImplementationArtifact) IPlanBuilderPrePhaseIAPlugin(org.opentosca.planbuilder.core.plugins.artifactbased.IPlanBuilderPrePhaseIAPlugin) IPlanBuilderProvPhaseOperationPlugin(org.opentosca.planbuilder.core.plugins.artifactbased.IPlanBuilderProvPhaseOperationPlugin) TOSCAManagementInfrastructureNodeTemplate(org.opentosca.planbuilder.core.bpel.handlers.TOSCAManagementInfrastructureNodeTemplate) ArrayList(java.util.ArrayList) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) IPlanBuilderPlugin(org.opentosca.planbuilder.core.plugins.typebased.IPlanBuilderPlugin) IPlanBuilderPrePhaseDAPlugin(org.opentosca.planbuilder.core.plugins.artifactbased.IPlanBuilderPrePhaseDAPlugin) TDeploymentArtifact(org.eclipse.winery.model.tosca.TDeploymentArtifact) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Example 2 with IPlanBuilderPlugin

use of org.opentosca.planbuilder.core.plugins.typebased.IPlanBuilderPlugin in project container by OpenTOSCA.

the class BPELScopeBuilder method createOperationCall.

/**
 * Creates a complete ProvisioningChain for the given NodeTemplate
 *
 * @param nodeTemplate an TNodeTemplate to create a ProvisioningChain for
 * @return a complete ProvisioningChain
 */
public OperationChain createOperationCall(BPELPlanContext context, final TNodeTemplate nodeTemplate, final String interfaceName, final String operationName) {
    // get nodetype implementations
    final Collection<TNodeTypeImplementation> nodeTypeImpls = ModelUtils.findNodeTypeImplementation(nodeTemplate, context.getCsar());
    if (nodeTypeImpls.isEmpty()) {
        LOG.warn("No implementations available for NodeTemplate {} , can't generate Provisioning logic", nodeTemplate.getId());
        return null;
    }
    final OperationChain chain = new OperationChain(nodeTemplate);
    // calculate infrastructure nodes
    final List<TNodeTemplate> infraNodes = new ArrayList<>();
    ModelUtils.getInfrastructureNodes(nodeTemplate, infraNodes, context.getCsar());
    // we'll add here a dummy infra node, representing the management
    // infrastructure of the tosca engine (WAR IA's implementing tosca
    // operation,..)
    infraNodes.add(new TOSCAManagementInfrastructureNodeTemplate());
    // check for IA Plugins
    final List<IPlanBuilderPrePhaseIAPlugin<?>> iaPlugins = pluginRegistry.getIaPlugins();
    final List<IPlanBuilderPrePhaseIAPlugin<BPELPlanContext>> iaPlugins2 = Lists.newArrayList();
    iaPlugins.forEach(x -> iaPlugins2.add((IPlanBuilderPrePhaseIAPlugin<BPELPlanContext>) x));
    LOG.debug("Calculating best IA candidates for nodeTemplate {} ", nodeTemplate.getId());
    // calculate nodeImpl candidates where all IAs of each can be
    // provisioned
    calculateBestImplementationIACandidates(context, nodeTypeImpls, iaPlugins2, infraNodes, chain, interfaceName, operationName);
    for (final IANodeTypeImplCandidate iaCandidate : chain.iaCandidates) {
        final int length = iaCandidate.ias.size();
        for (int i = 0; i < length; i++) {
            final TImplementationArtifact ia = iaCandidate.ias.get(i);
            final TNodeTemplate infraNode = iaCandidate.infraNodes.get(i);
            final IPlanBuilderPlugin plugin = iaCandidate.plugins.get(i);
            LOG.debug("Found IA {} for deployment on the InfraNode {} with the Plugin {}", ia.getName(), infraNode.getId(), plugin.getID());
        }
    }
    // check for prov plugins
    final List<IPlanBuilderProvPhaseOperationPlugin<?>> provPlugins = pluginRegistry.getProvPlugins();
    // search for prov plugins according to the chosen IA provisionings in
    // the chain
    calculateProvPlugins(chain, provPlugins, interfaceName, operationName, context.getCsar());
    // filter ia and da candidates where the operations can't be executed
    filterIADACandidates(chain);
    // order provisioning candidates
    reorderProvCandidates(chain);
    // TODO consistency plugins
    final List<String> array = new ArrayList<>();
    array.add(operationName);
    // select provisioning
    selectProvisioning(chain, array);
    return chain;
}
Also used : TImplementationArtifact(org.eclipse.winery.model.tosca.TImplementationArtifact) IPlanBuilderPrePhaseIAPlugin(org.opentosca.planbuilder.core.plugins.artifactbased.IPlanBuilderPrePhaseIAPlugin) IPlanBuilderProvPhaseOperationPlugin(org.opentosca.planbuilder.core.plugins.artifactbased.IPlanBuilderProvPhaseOperationPlugin) TOSCAManagementInfrastructureNodeTemplate(org.opentosca.planbuilder.core.bpel.handlers.TOSCAManagementInfrastructureNodeTemplate) ArrayList(java.util.ArrayList) TNodeTypeImplementation(org.eclipse.winery.model.tosca.TNodeTypeImplementation) IPlanBuilderPlugin(org.opentosca.planbuilder.core.plugins.typebased.IPlanBuilderPlugin) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate)

Aggregations

ArrayList (java.util.ArrayList)2 TImplementationArtifact (org.eclipse.winery.model.tosca.TImplementationArtifact)2 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)2 TNodeTypeImplementation (org.eclipse.winery.model.tosca.TNodeTypeImplementation)2 TOSCAManagementInfrastructureNodeTemplate (org.opentosca.planbuilder.core.bpel.handlers.TOSCAManagementInfrastructureNodeTemplate)2 IPlanBuilderPrePhaseIAPlugin (org.opentosca.planbuilder.core.plugins.artifactbased.IPlanBuilderPrePhaseIAPlugin)2 IPlanBuilderProvPhaseOperationPlugin (org.opentosca.planbuilder.core.plugins.artifactbased.IPlanBuilderProvPhaseOperationPlugin)2 IPlanBuilderPlugin (org.opentosca.planbuilder.core.plugins.typebased.IPlanBuilderPlugin)2 TDeploymentArtifact (org.eclipse.winery.model.tosca.TDeploymentArtifact)1 IPlanBuilderPrePhaseDAPlugin (org.opentosca.planbuilder.core.plugins.artifactbased.IPlanBuilderPrePhaseDAPlugin)1