Use SettableFuture<Empty> for readinessFuture 50/100050/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 9 Mar 2022 17:57:01 +0000 (18:57 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 9 Mar 2022 17:57:01 +0000 (18:57 +0100)
java.lang.Void is promoting use of nulls, whereas Empty.value() is
a non-null object. Migrate internal users.

Change-Id: I6a8a85917d9c3a8c3d5a9aadf691c9d1a63a767b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/AbstractDataStore.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/AbstractShardManagerCreator.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManager.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java

index 41cc58a..cf60b08 100644 (file)
@@ -45,6 +45,7 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@@ -62,7 +63,7 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractDataStore.class);
 
-    private final SettableFuture<Void> readinessFuture = SettableFuture.create();
+    private final SettableFuture<Empty> readinessFuture = SettableFuture.create();
     private final ClientIdentifier identifier;
     private final DataStoreClient client;
     private final ActorUtils actorUtils;
@@ -334,7 +335,7 @@ public abstract class AbstractDataStore implements DistributedDataStoreInterface
     }
 
     @VisibleForTesting
-    SettableFuture<Void> readinessFuture() {
+    SettableFuture<Empty> readinessFuture() {
         return readinessFuture;
     }
 
index d28734b..560b534 100644 (file)
@@ -18,9 +18,10 @@ import org.opendaylight.controller.cluster.datastore.DatastoreContextFactory;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
 import org.opendaylight.controller.cluster.datastore.utils.PrimaryShardInfoFutureCache;
+import org.opendaylight.yangtools.yang.common.Empty;
 
 public abstract class AbstractShardManagerCreator<T extends AbstractShardManagerCreator<T>> {
-    private SettableFuture<Void> readinessFuture;
+    private SettableFuture<Empty> readinessFuture;
     private ClusterWrapper cluster;
     private Configuration configuration;
     private DatastoreContextFactory datastoreContextFactory;
@@ -82,11 +83,11 @@ public abstract class AbstractShardManagerCreator<T extends AbstractShardManager
         return self();
     }
 
-    SettableFuture<Void> getReadinessFuture() {
+    SettableFuture<Empty> getReadinessFuture() {
         return readinessFuture;
     }
 
-    public T readinessFuture(final SettableFuture<Void> newReadinessFuture) {
+    public T readinessFuture(final SettableFuture<Empty> newReadinessFuture) {
         checkSealed();
         this.readinessFuture = newReadinessFuture;
         return self();
index 58e64f8..93b57ed 100644 (file)
@@ -102,6 +102,7 @@ import org.opendaylight.controller.cluster.raft.messages.ServerChangeStatus;
 import org.opendaylight.controller.cluster.raft.messages.ServerRemoved;
 import org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy;
 import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -142,7 +143,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
 
     private DatastoreContextFactory datastoreContextFactory;
 
-    private final SettableFuture<Void> readinessFuture;
+    private final SettableFuture<Empty> readinessFuture;
 
     private final PrimaryShardInfoFutureCache primaryShardInfoCache;
 
@@ -611,7 +612,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
     private void checkReady() {
         if (isReadyWithLeaderId()) {
             LOG.info("{}: All Shards are ready - data store {} is ready", persistenceId(), type);
-            readinessFuture.set(null);
+            readinessFuture.set(Empty.value());
         }
     }
 
index 56bbbf5..be3ba1e 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.controller.cluster.access.concepts.FrontendType;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.duration.FiniteDuration;
 
@@ -124,7 +125,7 @@ public class DistributedDataStoreTest extends AbstractActorTest {
 
             Executors.newSingleThreadExecutor().submit(() -> {
                 Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
-                distributedDataStore.readinessFuture().set(null);
+                distributedDataStore.readinessFuture().set(Empty.value());
             });
 
             long start = System.currentTimeMillis();
index 2f3e945..c7dc25f 100644 (file)
@@ -134,6 +134,7 @@ import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.XMLNamespace;
 import org.opendaylight.yangtools.yang.data.tree.api.DataTree;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@@ -153,7 +154,7 @@ public class ShardManagerTest extends AbstractClusterRefActorTest {
     private static int ID_COUNTER = 1;
     private static ActorRef mockShardActor;
     private static ShardIdentifier mockShardName;
-    private static SettableFuture<Void> ready;
+    private static SettableFuture<Empty> ready;
     private static EffectiveModelContext TEST_SCHEMA_CONTEXT;
 
     private final String shardMrgIDSuffix = "config" + ID_COUNTER++;