Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / shardmanager / ShardInformation.java
index ea882dcbdf03ad3f26a3a90ab73f2d2d719e09af..f5c94413c7840cb1247e9f36cb3d59358334beae 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.controller.cluster.datastore.messages.PeerAddressResolve
 import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager.OnShardInitialized;
 import org.opendaylight.controller.cluster.datastore.shardmanager.ShardManager.OnShardReady;
 import org.opendaylight.controller.cluster.raft.RaftState;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ReadOnlyDataTree;
+import org.opendaylight.yangtools.yang.data.tree.api.ReadOnlyDataTree;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -78,7 +78,7 @@ public final class ShardInformation {
 
     Props newProps() {
         Props props = requireNonNull(builder).id(shardId).peerAddresses(initialPeerAddresses)
-                .datastoreContext(datastoreContext).schemaContextProvider(schemaContextProvider).props();
+                .datastoreContext(datastoreContext).schemaContextProvider(schemaContextProvider::modelContext).props();
         builder = null;
         return props;
     }
@@ -100,8 +100,8 @@ public final class ShardInformation {
         return shardId;
     }
 
-    void setLocalDataTree(final Optional<ReadOnlyDataTree> dataTree) {
-        this.localShardDataTree = dataTree;
+    void setLocalDataTree(final ReadOnlyDataTree dataTree) {
+        localShardDataTree = Optional.ofNullable(dataTree);
     }
 
     Optional<ReadOnlyDataTree> getLocalShardDataTree() {
@@ -113,10 +113,10 @@ public final class ShardInformation {
     }
 
     void setDatastoreContext(final DatastoreContext newDatastoreContext, final ActorRef sender) {
-        this.datastoreContext = newDatastoreContext;
+        datastoreContext = newDatastoreContext;
         if (actor != null) {
             LOG.debug("Sending new DatastoreContext to {}", shardId);
-            actor.tell(this.datastoreContext, sender);
+            actor.tell(datastoreContext, sender);
         }
     }
 
@@ -152,17 +152,13 @@ public final class ShardInformation {
     }
 
     String getSerializedLeaderActor() {
-        if (isLeader()) {
-            return Serialization.serializedActorPath(getActor());
-        } else {
-            return addressResolver.resolve(leaderId);
-        }
+        return isLeader() ? Serialization.serializedActorPath(getActor()) : addressResolver.resolve(leaderId);
     }
 
     void setActorInitialized() {
         LOG.debug("Shard {} is initialized", shardId);
 
-        this.actorInitialized = true;
+        actorInitialized = true;
 
         notifyOnShardInitializedCallbacks();
     }
@@ -172,10 +168,10 @@ public final class ShardInformation {
             return;
         }
 
-        boolean ready = isShardReadyWithLeaderId();
-
-        LOG.debug("Shard {} is {} - notifying {} OnShardInitialized callbacks", shardId,
-            ready ? "ready" : "initialized", onShardInitializedSet.size());
+        final boolean ready = isShardReadyWithLeaderId();
+        final String readyStr = ready ? "ready" : "initialized";
+        LOG.debug("Shard {} is {} - notifying {} OnShardInitialized callbacks", shardId, readyStr,
+            onShardInitializedSet.size());
 
         Iterator<OnShardInitialized> iter = onShardInitializedSet.iterator();
         while (iter.hasNext()) {
@@ -197,7 +193,7 @@ public final class ShardInformation {
     }
 
     void setRole(final String newRole) {
-        this.role = newRole;
+        role = newRole;
 
         notifyOnShardInitializedCallbacks();
     }
@@ -207,13 +203,13 @@ public final class ShardInformation {
     }
 
     void setFollowerSyncStatus(final boolean syncStatus) {
-        this.followerSyncStatus = syncStatus;
+        followerSyncStatus = syncStatus;
     }
 
     boolean isInSync() {
-        if (RaftState.Follower.name().equals(this.role)) {
+        if (RaftState.Follower.name().equals(role)) {
             return followerSyncStatus;
-        } else if (RaftState.Leader.name().equals(this.role)) {
+        } else if (RaftState.Leader.name().equals(role)) {
             return true;
         }
 
@@ -221,10 +217,10 @@ public final class ShardInformation {
     }
 
     boolean setLeaderId(final String newLeaderId) {
-        final boolean changed = !Objects.equals(this.leaderId, newLeaderId);
-        this.leaderId = newLeaderId;
+        final boolean changed = !Objects.equals(leaderId, newLeaderId);
+        leaderId = newLeaderId;
         if (newLeaderId != null) {
-            this.leaderAvailable = true;
+            leaderAvailable = true;
         }
         notifyOnShardInitializedCallbacks();
 
@@ -256,11 +252,11 @@ public final class ShardInformation {
     }
 
     void setActiveMember(final boolean isActiveMember) {
-        this.activeMember = isActiveMember;
+        activeMember = isActiveMember;
     }
 
     EffectiveModelContext getSchemaContext() {
-        return schemaContextProvider.getEffectiveModelContext();
+        return schemaContextProvider.modelContext();
     }
 
     void setSchemaContext(final EffectiveModelContext schemaContext) {