+
+ @Nonnull
+ @Override
+ public CDSShardAccess getShardAccess(@Nonnull final DOMDataTreeIdentifier subtree) {
+ Preconditions.checkArgument(
+ subtrees.stream().anyMatch(dataTreeIdentifier -> dataTreeIdentifier.contains(subtree)),
+ "Subtree %s is not controlled by this producer %s", subtree, this);
+
+ final DOMDataTreePrefixTableEntry<DOMDataTreeShardRegistration<DOMDataTreeShard>> lookup =
+ shardTable.lookup(subtree);
+ Preconditions.checkState(lookup != null, "Subtree %s is not contained in any registered shard.", subtree);
+
+ final DOMDataTreeIdentifier lookupId = lookup.getValue().getPrefix();
+
+ synchronized (shardAccessMap) {
+ if (shardAccessMap.get(lookupId) != null) {
+ return shardAccessMap.get(lookupId);
+ }
+
+ // TODO Maybe we can have static factory method and return the same instance
+ // for same subtrees. But maybe it is not needed since there can be only one
+ // producer attached to some subtree at a time. And also how we can close ShardAccess
+ // then
+ final CDSShardAccessImpl shardAccess = new CDSShardAccessImpl(lookupId, actorContext);
+ shardAccessMap.put(lookupId, shardAccess);
+ return shardAccess;
+ }
+ }