Users will typically select one of the subtrees to create
cursor on, hence add a fast path which will perform a simple
lookup.
Change-Id: Ied0710a765edf8cdd4ebd7f2712f310f82f35b1a
Signed-off-by: Robert Varga <rovarga@cisco.com>
(cherry picked from commit
2ff021b039e02cfc74661383a2a204992b4ef200)
}
private DOMDataTreeShardWriteTransaction lookup(final DOMDataTreeIdentifier prefix) {
}
private DOMDataTreeShardWriteTransaction lookup(final DOMDataTreeIdentifier prefix) {
+ final DOMDataTreeShardWriteTransaction fast = transactions.get(prefix);
+ if (fast != null) {
+ return fast;
+ }
+
+ LOG.debug("Prefix {} not found in available subtrees {}, fallback to slow path", prefix, transactions.keySet());
for (final Entry<DOMDataTreeIdentifier, DOMDataTreeShardWriteTransaction> e : transactions.entrySet()) {
if (e.getKey().contains(prefix)) {
for (final Entry<DOMDataTreeIdentifier, DOMDataTreeShardWriteTransaction> e : transactions.entrySet()) {
if (e.getKey().contains(prefix)) {
- Preconditions.checkArgument(!producer.isDelegatedToChild(prefix),
- "Path %s is delegated to child producer.", prefix);
public synchronized DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
Preconditions.checkState(!closed, "Transaction is closed already");
Preconditions.checkState(openCursor == null, "There is still a cursor open");
public synchronized DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
Preconditions.checkState(!closed, "Transaction is closed already");
Preconditions.checkState(openCursor == null, "There is still a cursor open");
+ Preconditions.checkArgument(!producer.isDelegatedToChild(prefix), "Path %s is delegated to child producer.",
+ prefix);
final DOMDataTreeShardWriteTransaction lookup = lookup(prefix);
Preconditions.checkArgument(lookup != null, "Path %s is not accessible from transaction %s", prefix, this);
final DOMDataTreeShardWriteTransaction lookup = lookup(prefix);
Preconditions.checkArgument(lookup != null, "Path %s is not accessible from transaction %s", prefix, this);
public DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
Preconditions.checkState(!finished, "Transaction is finished/closed already.");
Preconditions.checkState(cursor == null, "Previous cursor wasn't closed");
public DOMDataTreeWriteCursor createCursor(final DOMDataTreeIdentifier prefix) {
Preconditions.checkState(!finished, "Transaction is finished/closed already.");
Preconditions.checkState(cursor == null, "Previous cursor wasn't closed");
- final DOMDataTreeWriteCursor ret = getCursor();
final YangInstanceIdentifier relativePath = toRelative(prefix.getRootIdentifier());
final YangInstanceIdentifier relativePath = toRelative(prefix.getRootIdentifier());
+ final DOMDataTreeWriteCursor ret = getCursor();
ret.enter(relativePath.getPathArguments());
return ret;
}
ret.enter(relativePath.getPathArguments());
return ret;
}