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;
}
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);
}
Aggregations