use of org.opendaylight.mdsal.dom.spi.shard.ChildShardContext in project controller by opendaylight.
the class DistributedShardChangePublisher method setupListenerContext.
private <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> setupListenerContext(final YangInstanceIdentifier listenerPath, final L listener) {
// we need to register the listener registration path based on the shards root
// we have to strip the shard path from the listener path and then register
YangInstanceIdentifier strippedIdentifier = listenerPath;
if (!shardPath.isEmpty()) {
strippedIdentifier = YangInstanceIdentifier.create(stripShardPath(shardPath, listenerPath));
}
final DOMDataTreeListenerWithSubshards subshardListener = new DOMDataTreeListenerWithSubshards(strippedIdentifier, listener);
final AbstractDOMDataTreeChangeListenerRegistration<L> reg = setupContextWithoutSubshards(listenerPath, strippedIdentifier, subshardListener);
for (final ChildShardContext maybeAffected : childShards.values()) {
if (listenerPath.contains(maybeAffected.getPrefix().getRootIdentifier())) {
// consumer has initialDataChangeEvent subshard somewhere on lower level
// register to the notification manager with snapshot and forward child notifications to parent
LOG.debug("Adding new subshard{{}} to listener at {}", maybeAffected.getPrefix(), listenerPath);
subshardListener.addSubshard(maybeAffected);
} else if (maybeAffected.getPrefix().getRootIdentifier().contains(listenerPath)) {
// already registering to the lowest shard possible
throw new UnsupportedOperationException("Listener should be registered directly " + "into initialDataChangeEvent subshard");
}
}
return reg;
}
use of org.opendaylight.mdsal.dom.spi.shard.ChildShardContext in project controller by opendaylight.
the class DistributedShardFrontend method addChildShard.
private void addChildShard(final DOMDataTreeIdentifier prefix, final DOMDataTreeShard child) {
Preconditions.checkArgument(child instanceof WriteableDOMDataTreeShard);
childShards.put(prefix, new ChildShardContext(prefix, (WriteableDOMDataTreeShard) child));
}
use of org.opendaylight.mdsal.dom.spi.shard.ChildShardContext 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