From 5d761355a11fc761e8faccb36b05453013f1e4d1 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 17 Nov 2020 15:48:13 +0100 Subject: [PATCH] Speed up root overwrite check We can use YangInstanceIdentifier.isEmpty() and extract the single ModificationType we care about. Change-Id: Ie29c32ea0b197547bce67a7b2ffdd530e79276da Signed-off-by: Robert Varga --- .../controller/cluster/datastore/ShardDataTree.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java index 786041f6e4..b3688a87fa 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java @@ -475,26 +475,22 @@ public class ShardDataTree extends ShardDataTreeTransactionParent { } } - private void checkRootOverwrite(DataTreeCandidate candidate) { + private void checkRootOverwrite(final DataTreeCandidate candidate) { final DatastoreContext datastoreContext = shard.getDatastoreContext(); if (!datastoreContext.isSnapshotOnRootOverwrite()) { return; } if (!datastoreContext.isPersistent()) { - return; - } - - if (candidate.getRootNode().getModificationType().equals(ModificationType.UNMODIFIED)) { + // FIXME: why don't we want a snapshot in non-persistent state? return; } // top level container ie "/" - if ((candidate.getRootPath().equals(YangInstanceIdentifier.empty()) - && candidate.getRootNode().getModificationType().equals(ModificationType.WRITE))) { + if (candidate.getRootPath().isEmpty() + && candidate.getRootNode().getModificationType() == ModificationType.WRITE) { LOG.debug("{}: shard root overwritten, enqueuing snapshot", logContext); shard.self().tell(new InitiateCaptureSnapshot(), noSender()); - return; } } -- 2.36.6