Search in sources :

Example 1 with SubshardProducerSpecification

use of org.opendaylight.mdsal.dom.spi.shard.SubshardProducerSpecification in project controller by opendaylight.

the class DistributedShardFrontend method createModificationFactory.

DistributedShardModificationFactory createModificationFactory(final Collection<DOMDataTreeIdentifier> prefixes) {
    // TODO this could be abstract
    final Map<DOMDataTreeIdentifier, SubshardProducerSpecification> affectedSubshards = new HashMap<>();
    for (final DOMDataTreeIdentifier producerPrefix : prefixes) {
        for (final ChildShardContext maybeAffected : childShards.values()) {
            final DOMDataTreeIdentifier bindPath;
            if (producerPrefix.contains(maybeAffected.getPrefix())) {
                bindPath = maybeAffected.getPrefix();
            } else if (maybeAffected.getPrefix().contains(producerPrefix)) {
                // Bound path is inside subshard
                bindPath = producerPrefix;
            } else {
                continue;
            }
            SubshardProducerSpecification spec = affectedSubshards.computeIfAbsent(maybeAffected.getPrefix(), k -> new SubshardProducerSpecification(maybeAffected));
            spec.addPrefix(bindPath);
        }
    }
    final DistributedShardModificationFactoryBuilder builder = new DistributedShardModificationFactoryBuilder(shardRoot);
    for (final SubshardProducerSpecification spec : affectedSubshards.values()) {
        final ForeignShardModificationContext foreignContext = new ForeignShardModificationContext(spec.getPrefix(), spec.createProducer());
        builder.addSubshard(foreignContext);
        builder.addSubshard(spec.getPrefix(), foreignContext);
    }
    return builder.build();
}
Also used : ChildShardContext(org.opendaylight.mdsal.dom.spi.shard.ChildShardContext) SubshardProducerSpecification(org.opendaylight.mdsal.dom.spi.shard.SubshardProducerSpecification) HashMap(java.util.HashMap) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) ForeignShardModificationContext(org.opendaylight.mdsal.dom.spi.shard.ForeignShardModificationContext)

Aggregations

HashMap (java.util.HashMap)1 DOMDataTreeIdentifier (org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier)1 ChildShardContext (org.opendaylight.mdsal.dom.spi.shard.ChildShardContext)1 ForeignShardModificationContext (org.opendaylight.mdsal.dom.spi.shard.ForeignShardModificationContext)1 SubshardProducerSpecification (org.opendaylight.mdsal.dom.spi.shard.SubshardProducerSpecification)1