Search in sources :

Example 1 with FragmentsCache

use of org.eclipse.winery.repository.targetallocation.util.FragmentsCache in project winery by eclipse.

the class CriteriaCached method allocate.

@Override
public List<TopologyWrapper> allocate(TopologyWrapper topology) throws Exception {
    Set<String> originalTopLevelNTIds = topology.getTopLevelNTs().stream().map(HasId::getId).collect(Collectors.toSet());
    fragmentsCache = new FragmentsCache(topology.getPresentTargetLabels());
    List<TopologyWrapper> generatedTopologies = super.allocate(topology);
    // remove NTs that were no top level nts originally but are now because of injection
    generatedTopologies.forEach(t -> t.removeNotNeededNTs(originalTopLevelNTIds));
    return generatedTopologies;
}
Also used : FragmentsCache(org.eclipse.winery.repository.targetallocation.util.FragmentsCache) TopologyWrapper(org.eclipse.winery.repository.targetallocation.util.TopologyWrapper)

Example 2 with FragmentsCache

use of org.eclipse.winery.repository.targetallocation.util.FragmentsCache in project winery by eclipse.

the class FulfillPolicies method generateTargetLabelTopologies.

@Override
public List<TopologyWrapper> generateTargetLabelTopologies(TopologyWrapper topology) throws AllocationException {
    if (fragmentsCache == null) {
        fragmentsCache = new FragmentsCache(topology.getPresentTargetLabels());
    }
    Map<TNodeTemplate, Set<String>> possibleTargetLabels = assignTargetLabels(topology);
    List<List<PermutationHelper>> possibilities = new ArrayList<>();
    for (Map.Entry<TNodeTemplate, Set<String>> entry : possibleTargetLabels.entrySet()) {
        List<PermutationHelper> possibility = new ArrayList<>();
        for (String targetLabel : entry.getValue()) {
            possibility.add(new PermutationHelper(entry.getKey(), targetLabel));
        }
        possibilities.add(possibility);
    }
    List<List<PermutationHelper>> permutations = AllocationUtils.getPermutations(possibilities, outputCap);
    return AllocationUtils.generateTargetLabelTopologies(topology, permutations);
}
Also used : PermutationHelper(org.eclipse.winery.repository.targetallocation.util.PermutationHelper) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) FragmentsCache(org.eclipse.winery.repository.targetallocation.util.FragmentsCache) ArrayList(java.util.ArrayList) List(java.util.List) TNodeTemplate(org.eclipse.winery.model.tosca.TNodeTemplate) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

FragmentsCache (org.eclipse.winery.repository.targetallocation.util.FragmentsCache)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)1 PermutationHelper (org.eclipse.winery.repository.targetallocation.util.PermutationHelper)1 TopologyWrapper (org.eclipse.winery.repository.targetallocation.util.TopologyWrapper)1