use of alien4cloud.model.deployment.matching.ILocationMatch in project alien4cloud by alien4cloud.
the class LocationMatchingService method match.
/**
* Given a topology, return a list of locations on which the topo can be deployed
*
* @param topology The topology to match against the location matcher.
* @param applicationEnvironment eventually the environment related to the topology to match.
* @return A list of candidates Location Matches.
*/
public List<ILocationMatch> match(Topology topology, ApplicationEnvironment applicationEnvironment) {
List<ILocationMatch> matches;
// If no registered matcher id found later on, then match with the default matcher
ILocationMatcher matcher = defaultLocationMatcher;
// TODO Now we just take the first matcher found. To fix. Later, use the configured matcher
Map<String, Map<String, ILocationMatcher>> instancesByPlugins = locationMatcherFactoriesRegistry.getInstancesByPlugins();
if (MapUtils.isNotEmpty(instancesByPlugins)) {
Map<String, ILocationMatcher> matchers = instancesByPlugins.values().iterator().next();
if (MapUtils.isNotEmpty(matchers)) {
matcher = matchers.values().iterator().next();
}
}
matches = matcher.match(topology);
// keep only the authorized ones
authorizationFilter.filter(matches, applicationEnvironment);
return CollectionUtils.isEmpty(matches) ? null : matches;
}
use of alien4cloud.model.deployment.matching.ILocationMatch in project alien4cloud by alien4cloud.
the class MockLocationMatcher method match.
@Override
public List<ILocationMatch> match(Topology topology) throws LocationMatchingException {
log.info("Mock location matcher <" + this.getClass().getName() + "> called!");
List<ILocationMatch> matched = Lists.newArrayList();
// get all enabled orchestrators
try {
List<Orchestrator> enabledOrchestrators = orchestratorService.getAllEnabledOrchestrators();
if (CollectionUtils.isEmpty(enabledOrchestrators)) {
return matched;
}
Map<String, Orchestrator> orchestratorMap = AlienUtils.fromListToMap(enabledOrchestrators, "id", true);
List<Location> locations = locationService.getOrchestratorsLocations(orchestratorMap.keySet());
for (Location location : locations) {
matched.add(new LocationMatch(location, orchestratorMap.get(location.getOrchestratorId()), null));
}
new MockLocationMatchOrchestratorFilter(selfContext).filter(matched, topology);
return matched;
} catch (Exception e) {
throw new LocationMatchingException("Failed to match topology <" + topology.getId() + "> against locations. ", e);
}
}
Aggregations