use of org.opendaylight.controller.cluster.datastore.shardstrategy.PrefixShardStrategy in project controller by opendaylight.
the class ConfigurationImpl method getStrategyForPrefix.
@Override
public ShardStrategy getStrategyForPrefix(@Nonnull final DOMDataTreeIdentifier prefix) {
Preconditions.checkNotNull(prefix, "Prefix cannot be null");
// FIXME using prefix tables like in mdsal will be better
Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> bestMatchEntry = new SimpleEntry<>(new DOMDataTreeIdentifier(prefix.getDatastoreType(), YangInstanceIdentifier.EMPTY), null);
for (Entry<DOMDataTreeIdentifier, PrefixShardConfiguration> entry : prefixConfigMap.entrySet()) {
if (entry.getKey().contains(prefix) && entry.getKey().getRootIdentifier().getPathArguments().size() > bestMatchEntry.getKey().getRootIdentifier().getPathArguments().size()) {
bestMatchEntry = entry;
}
}
if (bestMatchEntry.getValue() == null) {
return null;
}
return new PrefixShardStrategy(ClusterUtils.getCleanShardName(bestMatchEntry.getKey().getRootIdentifier()), bestMatchEntry.getKey().getRootIdentifier());
}
Aggregations