+
+ @Nonnull
+ @Override
+ public CDSShardAccess getShardAccess(@Nonnull final DOMDataTreeIdentifier subtree) {
+ synchronized (shardAccessMap) {
+ Preconditions.checkArgument(subtrees.contains(subtree),
+ "Subtree {} is not controlled by this producer {}", subtree, this);
+ if (shardAccessMap.get(subtree) != null) {
+ return shardAccessMap.get(subtree);
+ }
+
+ // 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(subtree, actorContext);
+ shardAccessMap.put(subtree, shardAccess);
+ return shardAccess;
+ }
+ }