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()));
}
}
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();
}
Aggregations