use of alien4cloud.deployment.matching.plugins.ILocationMatcher 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;
}
Aggregations