Search in sources :

Example 1 with ForeignShardModificationContext

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

the class ShardProxyTransaction method ready.

@Override
public void ready() {
    LOG.debug("Readying transaction for shard {}", shardRoot);
    Preconditions.checkNotNull(modification, "Attempting to ready an empty transaction.");
    cohorts.add(modification.seal());
    for (Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry : modification.getChildShards().entrySet()) {
        cohorts.add(new ForeignShardThreePhaseCommitCohort(entry.getKey(), entry.getValue()));
    }
}
Also used : ForeignShardThreePhaseCommitCohort(org.opendaylight.mdsal.dom.store.inmemory.ForeignShardThreePhaseCommitCohort) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) ForeignShardModificationContext(org.opendaylight.mdsal.dom.spi.shard.ForeignShardModificationContext)

Example 2 with ForeignShardModificationContext

use of org.opendaylight.mdsal.dom.spi.shard.ForeignShardModificationContext 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

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