Reduce use of scala.concurrent.duration.Duration 49/78449/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 5 Dec 2018 10:05:49 +0000 (11:05 +0100)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 5 Dec 2018 15:10:53 +0000 (15:10 +0000)
In most of the places we really are talking about a FiniteDuration,
hence use that class directly where it is an internal detail. Aside
from providing clarity, this also reduces potential confusion
with java.time.Duration.

Change-Id: I57d84c5ca058cfc6fa56ce57ebb0c8d4d3864a3a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
25 files changed:
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java
opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ClientActorContextTest.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorSnapshotMessageSupport.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTestKit.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/MessageCollectorActor.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/schema/provider/impl/RemoteYangTextSourceProviderImplTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/akka/impl/ActorSystemProviderImpl.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTree.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/actors/DataTreeNotificationListenerRegistrationActor.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/main/java/org/opendaylight/controller/cluster/datastore/utils/ActorContext.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/IntegrationTestKit.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MemberNode.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTestKit.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractEntityOwnershipTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipServiceTest.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java

index 2b6be7d5f1d42994f5b05311b4609301ecb77b31..0b630e2da8fd7b0769bf2c7e88da51184ac87bbd 100644 (file)
@@ -33,13 +33,12 @@ import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class ActorBehaviorTest {
 
     private static final String MEMBER_1_FRONTEND_TYPE_1 = "member-1-frontend-type-1";
-    private static final FiniteDuration TIMEOUT = Duration.apply(5, TimeUnit.SECONDS);
+    private static final FiniteDuration TIMEOUT = FiniteDuration.create(5, TimeUnit.SECONDS);
 
     private ActorSystem system;
     private TestProbe probe;
index e8ac87fb962af145efc73ae8ee9c2a0f0352b407..7df1c2f045d98fcdfa87f37c71165462d0e2d5eb 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.FrontendType;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class ClientActorContextTest {
@@ -69,8 +68,7 @@ public class ClientActorContextTest {
 
     @Test
     public void testExecuteInActorScheduled() {
-        final FiniteDuration delay = Duration.apply(1, TimeUnit.SECONDS);
-        ctx.executeInActor(command, delay);
+        ctx.executeInActor(command, FiniteDuration.create(1, TimeUnit.SECONDS));
         probe.expectMsg(command);
     }
 
index 4d68d8ea160d20b9ba8ec30072bacb21dc2c44e0..3b4c08c405bf02dace5565602d663166e4643e3f 100644 (file)
@@ -22,7 +22,7 @@ import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply
 import org.opendaylight.controller.cluster.raft.persisted.EmptyState;
 import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
 import org.slf4j.Logger;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Handles snapshot related messages for a RaftActor.
@@ -41,7 +41,7 @@ class RaftActorSnapshotMessageSupport {
     private final RaftActorSnapshotCohort cohort;
     private final Logger log;
 
-    private Duration snapshotReplyActorTimeout = Duration.create(30, TimeUnit.SECONDS);
+    private FiniteDuration snapshotReplyActorTimeout = FiniteDuration.create(30, TimeUnit.SECONDS);
 
     RaftActorSnapshotMessageSupport(final RaftActorContext context, final RaftActorSnapshotCohort cohort) {
         this.context = context;
@@ -129,7 +129,7 @@ class RaftActorSnapshotMessageSupport {
     }
 
     @VisibleForTesting
-    void setSnapshotReplyActorTimeout(Duration snapshotReplyActorTimeout) {
+    void setSnapshotReplyActorTimeout(FiniteDuration snapshotReplyActorTimeout) {
         this.snapshotReplyActorTimeout = snapshotReplyActorTimeout;
     }
 }
index d0cedce83a1d0787317e03c50e62537be511a774..d02819a4925a12fd00de323e62bdb63c64b799b6 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
index 0b4e2cb78ed8aa72290d24a69872aa21014f0083..6386d6c6ba1e7a9453161c3f67caa146e1dcd543 100644 (file)
@@ -23,7 +23,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class RaftActorTestKit extends TestKit {
@@ -51,7 +50,7 @@ public class RaftActorTestKit extends TestKit {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     public static void waitUntilLeader(final ActorRef actorRef) {
-        FiniteDuration duration = Duration.create(100, TimeUnit.MILLISECONDS);
+        FiniteDuration duration = FiniteDuration.create(100, TimeUnit.MILLISECONDS);
         for (int i = 0; i < 20 * 5; i++) {
             Future<Object> future = Patterns.ask(actorRef, FindLeader.INSTANCE, new Timeout(duration));
             try {
index 9daacb040f87a9ee25ba9a06c8c3c25acc4687fe..8f0cc998030b66b2d19157da6df197812f240a3f 100644 (file)
@@ -40,7 +40,6 @@ import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 /**
@@ -251,7 +250,7 @@ public class AbstractLeaderElectionScenarioTest {
         RaftState actualState;
         try {
             actualState = (RaftState) Await.result(Patterns.ask(actor.self(), GetBehaviorState.INSTANCE,
-                Timeout.apply(5, TimeUnit.SECONDS)), Duration.apply(5, TimeUnit.SECONDS));
+                Timeout.apply(5, TimeUnit.SECONDS)), FiniteDuration.create(5, TimeUnit.SECONDS));
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {
index 861c04c875af86dba06e6ef83779cceec8bef7ca..8d3377310581571aad360eb06c4cc7137be80340 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.raft.utils;
 
 import akka.actor.ActorRef;
@@ -27,7 +26,6 @@ import java.util.concurrent.TimeoutException;
 import org.junit.Assert;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class MessageCollectorActor extends UntypedAbstractActor {
@@ -57,7 +55,7 @@ public class MessageCollectorActor extends UntypedAbstractActor {
 
     @SuppressWarnings({"unchecked", "checkstyle:illegalCatch"})
     public static List<Object> getAllMessages(final ActorRef actor) {
-        FiniteDuration operationDuration = Duration.create(5, TimeUnit.SECONDS);
+        FiniteDuration operationDuration = FiniteDuration.create(5, TimeUnit.SECONDS);
         Timeout operationTimeout = new Timeout(operationDuration);
         Future<Object> future = Patterns.ask(actor, GET_ALL_MESSAGES, operationTimeout);
 
@@ -228,7 +226,7 @@ public class MessageCollectorActor extends UntypedAbstractActor {
 
     public static void waitUntilReady(final ActorRef actor) throws TimeoutException, InterruptedException {
         long timeout = 500;
-        FiniteDuration duration = Duration.create(timeout, TimeUnit.MILLISECONDS);
+        FiniteDuration duration = FiniteDuration.create(timeout, TimeUnit.MILLISECONDS);
         for (int i = 0; i < 10; i++) {
             try {
                 Await.ready(Patterns.ask(actor, ARE_YOU_READY, timeout), duration);
index 90fc4772d8acbdab301d5845487afb0b9836b479..6a3f2337b8a54dff4941355e91f86a92aeee53ad 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 public class RemoteYangTextSourceProviderImplTest {
 
@@ -56,7 +56,7 @@ public class RemoteYangTextSourceProviderImplTest {
                 remoteRepository.getYangTextSchemaSource(ID);
         assertTrue(retrievedSourceFuture.isCompleted());
         YangTextSchemaSource resultSchemaSource = Await.result(retrievedSourceFuture,
-                Duration.Zero()).getRepresentation();
+                FiniteDuration.Zero()).getRepresentation();
         assertEquals(resultSchemaSource.getIdentifier(), schemaSource.getIdentifier());
         assertArrayEquals(resultSchemaSource.read(), schemaSource.read());
     }
@@ -70,13 +70,13 @@ public class RemoteYangTextSourceProviderImplTest {
         Future<YangTextSchemaSourceSerializationProxy> retrievedSourceFuture =
                 remoteRepository.getYangTextSchemaSource(ID);
         assertTrue(retrievedSourceFuture.isCompleted());
-        Await.result(retrievedSourceFuture, Duration.Zero());
+        Await.result(retrievedSourceFuture, FiniteDuration.Zero());
     }
 
     @Test
     public void testGetProvidedSources() throws Exception {
         Set<SourceIdentifier> remoteProvidedSources = Await.result(remoteRepository
-                .getProvidedSources(), Duration.Zero());
+                .getProvidedSources(), FiniteDuration.Zero());
         assertEquals(providedSources, remoteProvidedSources);
     }
 
index 9d1126a78309664fa5269f1737e3c36419564026..746ccf5524b9f0fa686654f3abb497edac7de6ad 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.yangtools.util.ListenerRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 public class ActorSystemProviderImpl implements ActorSystemProvider, AutoCloseable {
     private static final String ACTOR_SYSTEM_NAME = "opendaylight-cluster-data";
@@ -56,7 +56,7 @@ public class ActorSystemProviderImpl implements ActorSystemProvider, AutoCloseab
         LOG.info("Shutting down ActorSystem");
 
         try {
-            Await.result(actorSystem.terminate(), Duration.create(10, TimeUnit.SECONDS));
+            Await.result(actorSystem.terminate(), FiniteDuration.create(10, TimeUnit.SECONDS));
         } catch (final Exception e) {
             LOG.warn("Error awaiting actor termination", e);
         }
index 6584b8d5b85eae434a515943c798980275d5daed..2e524b96b78036cb41c9d1019fbfdaf9c9d766d8 100644 (file)
@@ -38,7 +38,8 @@ import scala.concurrent.duration.FiniteDuration;
 public class DatastoreContext implements ClientActorConfig {
     public static final String METRICS_DOMAIN = "org.opendaylight.controller.cluster.datastore";
 
-    public static final Duration DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT = Duration.create(10, TimeUnit.MINUTES);
+    public static final FiniteDuration DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT = FiniteDuration.create(10,
+        TimeUnit.MINUTES);
     public static final int DEFAULT_OPERATION_TIMEOUT_IN_MS = 5000;
     public static final int DEFAULT_SHARD_TX_COMMIT_TIMEOUT_IN_SECONDS = 30;
     public static final int DEFAULT_JOURNAL_RECOVERY_BATCH_SIZE = 1;
@@ -69,7 +70,7 @@ public class DatastoreContext implements ClientActorConfig {
     private final DefaultConfigParamsImpl raftConfig = new DefaultConfigParamsImpl();
 
     private InMemoryDOMDataStoreConfigProperties dataStoreProperties;
-    private Duration shardTransactionIdleTimeout = DatastoreContext.DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT;
+    private FiniteDuration shardTransactionIdleTimeout = DatastoreContext.DEFAULT_SHARD_TRANSACTION_IDLE_TIMEOUT;
     private long operationTimeoutInMillis = DEFAULT_OPERATION_TIMEOUT_IN_MS;
     private String dataStoreMXBeanType;
     private int shardTransactionCommitTimeoutInSeconds = DEFAULT_SHARD_TX_COMMIT_TIMEOUT_IN_SECONDS;
@@ -375,7 +376,7 @@ public class DatastoreContext implements ClientActorConfig {
 
 
         public Builder shardTransactionIdleTimeout(final long timeout, final TimeUnit unit) {
-            datastoreContext.shardTransactionIdleTimeout = Duration.create(timeout, unit);
+            datastoreContext.shardTransactionIdleTimeout = FiniteDuration.create(timeout, unit);
             return this;
         }
 
index c69b839bea8595acc6f63a2ff80b0e1b7cdf80f3..334bd8e2d2cc43de963999feb088dd872d6b5c11 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorRef;
@@ -107,7 +106,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailed
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 /**
@@ -865,7 +863,7 @@ public class Shard extends RaftActor {
         if (txCommitTimeoutCheckSchedule == null) {
             // Schedule a message to be periodically sent to check if the current in-progress
             // transaction should be expired and aborted.
-            FiniteDuration period = Duration.create(transactionCommitTimeout / 3, TimeUnit.MILLISECONDS);
+            FiniteDuration period = FiniteDuration.create(transactionCommitTimeout / 3, TimeUnit.MILLISECONDS);
             txCommitTimeoutCheckSchedule = getContext().system().scheduler().schedule(
                     period, period, getSelf(),
                     TX_COMMIT_TIMEOUT_CHECK_MESSAGE, getContext().dispatcher(), ActorRef.noSender());
index ecd6e8be9234559680ef2f6dd3f5cbbb40b4297b..92263f2102a701d415fc433d1c50916d71e97c29 100644 (file)
@@ -83,7 +83,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFac
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Internal shard state, similar to a DOMStore, but optimized for use in the actor system,
@@ -110,7 +110,7 @@ public class ShardDataTree extends ShardDataTreeTransactionParent {
         }
     }
 
-    private static final Timeout COMMIT_STEP_TIMEOUT = new Timeout(Duration.create(5, TimeUnit.SECONDS));
+    private static final Timeout COMMIT_STEP_TIMEOUT = new Timeout(FiniteDuration.create(5, TimeUnit.SECONDS));
     private static final Logger LOG = LoggerFactory.getLogger(ShardDataTree.class);
 
     /**
index 6ab4247310dfce5d96d6716f1841a2f8d63cee21..38c7620b63dd7dd4d86dcd83f599d6cf86236484 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistration;
 import org.opendaylight.controller.cluster.datastore.messages.CloseDataTreeNotificationListenerRegistrationReply;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Actor co-located with a shard. It exists only to terminate the registration when
@@ -59,7 +59,7 @@ public final class DataTreeNotificationListenerRegistrationActor extends Abstrac
             registration = null;
 
             if (killSchedule == null) {
-                killSchedule = getContext().system().scheduler().scheduleOnce(Duration.create(killDelay,
+                killSchedule = getContext().system().scheduler().scheduleOnce(FiniteDuration.create(killDelay,
                         TimeUnit.MILLISECONDS), getSelf(), PoisonPill.getInstance(), getContext().dispatcher(),
                         ActorRef.noSender());
             }
index 621b037341c8a183027c9f57190270ff50166fa2..56bdd7f8ea2cb6329dbdfe9cf79f38759f0375d0 100644 (file)
@@ -122,7 +122,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.ExecutionContext;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 /**
@@ -1325,7 +1324,7 @@ class ShardManager extends AbstractUntypedPersistentActorWithMetering {
     @Override
     public SupervisorStrategy supervisorStrategy() {
 
-        return new OneForOneStrategy(10, Duration.create("1 minute"),
+        return new OneForOneStrategy(10, FiniteDuration.create(1, TimeUnit.MINUTES),
                 (Function<Throwable, Directive>) t -> {
                     LOG.warn("Supervisor Strategy caught unexpected exception - resuming", t);
                     return SupervisorStrategy.resume();
index bba4d6140e1fb697769a7d32e3a5ff0ea07ba153..62652342ded45979b09cc647a76be42f8347a946 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore.utils;
 
 import static akka.pattern.Patterns.ask;
@@ -59,7 +58,6 @@ import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.ExecutionContext;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 /**
@@ -150,10 +148,11 @@ public class ActorContext {
     private void setCachedProperties() {
         txRateLimiter = new TransactionRateLimiter(this);
 
-        operationDuration = Duration.create(datastoreContext.getOperationTimeoutInMillis(), TimeUnit.MILLISECONDS);
+        operationDuration = FiniteDuration.create(datastoreContext.getOperationTimeoutInMillis(),
+            TimeUnit.MILLISECONDS);
         operationTimeout = new Timeout(operationDuration);
 
-        transactionCommitOperationTimeout =  new Timeout(Duration.create(
+        transactionCommitOperationTimeout =  new Timeout(FiniteDuration.create(
                 datastoreContext.getShardTransactionCommitTimeoutInSeconds(), TimeUnit.SECONDS));
 
         shardInitializationTimeout = new Timeout(datastoreContext.getShardInitializationTimeout().duration().$times(2));
index ce80810a006c10be6fe578d53f16a9928e7fd591..aaef33e4af97ce035120b7a6aa189aef7dff737d 100644 (file)
@@ -84,7 +84,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFac
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Abstract base for shard unit tests.
@@ -303,7 +303,7 @@ public abstract class AbstractShardTest extends AbstractActorTest {
         Future<Object> future = Patterns.ask(shard, newBatchedModifications(nextTransactionId(),
                 id, node, true, true, 1), new Timeout(5, TimeUnit.SECONDS));
         try {
-            Await.ready(future, Duration.create(5, TimeUnit.SECONDS));
+            Await.ready(future, FiniteDuration.create(5, TimeUnit.SECONDS));
         } catch (TimeoutException e) {
             throw new ExecutionException(e);
         }
index 23ed5d6b716cd72a6c76b472543a1e11a463f141..3ee49b6f941ae5bd43bdf394480d72373ef0daa5 100644 (file)
@@ -85,7 +85,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Abstract base class for TransactionProxy unit tests.
@@ -458,7 +458,7 @@ public abstract class AbstractTransactionProxyTest extends AbstractTest {
         for (Future<?> future : proxy.getCohortFutures()) {
             assertNotNull("Ready operation Future is null", future);
             try {
-                futureResults.add(Await.result(future, Duration.create(5, TimeUnit.SECONDS)));
+                futureResults.add(Await.result(future, FiniteDuration.create(5, TimeUnit.SECONDS)));
             } catch (Exception e) {
                 futureResults.add(e);
             }
index 965eaf0066e16b507b447c057b8424d17d3dfa51..dc78e031354f586484251bd2c63d5adc3f12f63b 100644 (file)
@@ -51,7 +51,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 public class IntegrationTestKit extends ShardTestKit {
 
@@ -277,7 +277,7 @@ public class IntegrationTestKit extends ShardTestKit {
         ActorContext actorContext = datastore.getActorContext();
 
         Future<ActorRef> future = actorContext.findLocalShardAsync(shardName);
-        ActorRef shardActor = Await.result(future, Duration.create(10, TimeUnit.SECONDS));
+        ActorRef shardActor = Await.result(future, FiniteDuration.create(10, TimeUnit.SECONDS));
 
         AssertionError lastError = null;
         Stopwatch sw = Stopwatch.createStarted();
@@ -302,7 +302,7 @@ public class IntegrationTestKit extends ShardTestKit {
         ActorContext actorContext = datastore.getActorContext();
 
         Future<ActorRef> future = actorContext.findLocalShardAsync(shardName);
-        ActorRef shardActor = Await.result(future, Duration.create(10, TimeUnit.SECONDS));
+        ActorRef shardActor = Await.result(future, FiniteDuration.create(10, TimeUnit.SECONDS));
 
         AssertionError lastError = null;
         Stopwatch sw = Stopwatch.createStarted();
index fbfa91133f34f8a0bed1f2791d144c389fdd836a..faa482496c889a876c47e7826560375cdee508c8 100644 (file)
@@ -37,7 +37,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Class that represents a cluster member node for unit tests. It encapsulates an actor system with
@@ -135,7 +135,7 @@ public class MemberNode {
         ActorContext actorContext = datastore.getActorContext();
 
         Future<ActorRef> future = actorContext.findLocalShardAsync(shardName);
-        ActorRef shardActor = Await.result(future, Duration.create(10, TimeUnit.SECONDS));
+        ActorRef shardActor = Await.result(future, FiniteDuration.create(10, TimeUnit.SECONDS));
 
         AssertionError lastError = null;
         Stopwatch sw = Stopwatch.createStarted();
index 2c0f5631c05e11b84df45b05548cbff165a1dfc7..b22ca277e507479ac86846c912f18e9f5d0615e9 100644 (file)
@@ -26,7 +26,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class ShardTestKit extends TestKit {
@@ -45,7 +44,7 @@ public class ShardTestKit extends TestKit {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     public static String waitUntilLeader(final ActorRef shard) {
-        FiniteDuration duration = Duration.create(100, TimeUnit.MILLISECONDS);
+        FiniteDuration duration = FiniteDuration.create(100, TimeUnit.MILLISECONDS);
         for (int i = 0; i < 20 * 5; i++) {
             Future<Object> future = Patterns.ask(shard, FindLeader.INSTANCE, new Timeout(duration));
             try {
@@ -69,7 +68,7 @@ public class ShardTestKit extends TestKit {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     public void waitUntilNoLeader(final ActorRef shard) {
-        FiniteDuration duration = Duration.create(100, TimeUnit.MILLISECONDS);
+        FiniteDuration duration = FiniteDuration.create(100, TimeUnit.MILLISECONDS);
         Object lastResponse = null;
         for (int i = 0; i < 20 * 5; i++) {
             Future<Object> future = Patterns.ask(shard, FindLeader.INSTANCE, new Timeout(duration));
index 580c8057197a7224af8c13de5a742a03efca4e61..65ca16a0f536d1b43eb8da1c9a15db2b26a741ab 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore;
 
 import akka.actor.ActorRef;
@@ -26,7 +25,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Covers negative test cases.
@@ -68,13 +67,13 @@ public class ShardTransactionFailureTest extends AbstractActorTest {
 
         Future<Object> future = akka.pattern.Patterns.ask(subject,
                 new ReadData(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000);
-        Await.result(future, Duration.create(3, TimeUnit.SECONDS));
+        Await.result(future, FiniteDuration.create(3, TimeUnit.SECONDS));
 
         subject.underlyingActor().getDOMStoreTransaction().abortFromTransactionActor();
 
         future = akka.pattern.Patterns.ask(subject, new ReadData(YangInstanceIdentifier.EMPTY,
                 DataStoreVersions.CURRENT_VERSION), 3000);
-        Await.result(future, Duration.create(3, TimeUnit.SECONDS));
+        Await.result(future, FiniteDuration.create(3, TimeUnit.SECONDS));
     }
 
 
@@ -90,13 +89,13 @@ public class ShardTransactionFailureTest extends AbstractActorTest {
 
         Future<Object> future = akka.pattern.Patterns.ask(subject,
                 new ReadData(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000);
-        Await.result(future, Duration.create(3, TimeUnit.SECONDS));
+        Await.result(future, FiniteDuration.create(3, TimeUnit.SECONDS));
 
         subject.underlyingActor().getDOMStoreTransaction().abortFromTransactionActor();
 
         future = akka.pattern.Patterns.ask(subject, new ReadData(YangInstanceIdentifier.EMPTY,
                 DataStoreVersions.CURRENT_VERSION), 3000);
-        Await.result(future, Duration.create(3, TimeUnit.SECONDS));
+        Await.result(future, FiniteDuration.create(3, TimeUnit.SECONDS));
     }
 
     @Test(expected = ReadFailedException.class)
@@ -111,12 +110,12 @@ public class ShardTransactionFailureTest extends AbstractActorTest {
 
         Future<Object> future = akka.pattern.Patterns.ask(subject,
                 new DataExists(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000);
-        Await.result(future, Duration.create(3, TimeUnit.SECONDS));
+        Await.result(future, FiniteDuration.create(3, TimeUnit.SECONDS));
 
         subject.underlyingActor().getDOMStoreTransaction().abortFromTransactionActor();
 
         future = akka.pattern.Patterns.ask(subject,
                 new DataExists(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION), 3000);
-        Await.result(future, Duration.create(3, TimeUnit.SECONDS));
+        Await.result(future, FiniteDuration.create(3, TimeUnit.SECONDS));
     }
 }
index b31c1fc2691c86f96e7ff712e5ce57e396e1153c..986432312bdadae5a400a455098ba33cd03af509 100644 (file)
@@ -61,7 +61,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 /**
@@ -252,7 +251,7 @@ public class AbstractEntityOwnershipTest extends AbstractActorTest {
         AssertionError lastError = null;
         Stopwatch sw = Stopwatch.createStarted();
         while (sw.elapsed(TimeUnit.SECONDS) <= 5) {
-            FiniteDuration operationDuration = Duration.create(5, TimeUnit.SECONDS);
+            FiniteDuration operationDuration = FiniteDuration.create(5, TimeUnit.SECONDS);
             Future<Object> future = Patterns.ask(shard, GetOnDemandRaftState.INSTANCE, new Timeout(operationDuration));
             OnDemandRaftState raftState = (OnDemandRaftState)Await.result(future, operationDuration);
             try {
index 56b9f81b219eb63411fe42a71ff618060ac4babe..3ca33ef2b0e7c7ea7e0e352839e8de118278ccd5 100644 (file)
@@ -67,7 +67,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Unit tests for DistributedEntityOwnershipService.
@@ -123,7 +123,7 @@ public class DistributedEntityOwnershipServiceTest extends AbstractClusterRefEnt
 
         Future<ActorRef> future = dataStore.getActorContext().findLocalShardAsync(
                 DistributedEntityOwnershipService.ENTITY_OWNERSHIP_SHARD_NAME);
-        ActorRef shardActor = Await.result(future, Duration.create(10, TimeUnit.SECONDS));
+        ActorRef shardActor = Await.result(future, FiniteDuration.create(10, TimeUnit.SECONDS));
         assertNotNull(DistributedEntityOwnershipService.ENTITY_OWNERSHIP_SHARD_NAME + " not found", shardActor);
 
         service.close();
index e289d7d08768139cfe6b3ec1362fddf7a375bc02..5dbc1cdb3950b42df9595e0c25c4ae5bb0cf7cc8 100644 (file)
@@ -13,12 +13,13 @@ import akka.actor.OneForOneStrategy;
 import akka.actor.Props;
 import akka.actor.SupervisorStrategy;
 import com.google.common.base.Preconditions;
+import java.util.concurrent.TimeUnit;
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.controller.remote.rpc.registry.RpcRegistry;
 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * This class acts as a supervisor, creates all the actors, resumes them, if an exception is thrown. It also registers
@@ -87,7 +88,7 @@ public class RpcManager extends AbstractUntypedActor {
 
     @Override
     public SupervisorStrategy supervisorStrategy() {
-        return new OneForOneStrategy(10, Duration.create("1 minute"), t -> {
+        return new OneForOneStrategy(10, FiniteDuration.create(1, TimeUnit.MINUTES), t -> {
             LOG.error("An exception happened actor will be resumed", t);
             return SupervisorStrategy.resume();
         });
index c84197cf6abb462f859750d9e6031ed38c51ae45..c427044c6093b8e602cda9cecb6cc5cf0266e990 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.remote.rpc;
 
 import static org.mockito.Mockito.mock;
@@ -23,7 +22,7 @@ import org.junit.Test;
 import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
 import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import scala.concurrent.Await;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 public class RemoteRpcProviderTest {
     static ActorSystem system;
@@ -53,7 +52,7 @@ public class RemoteRpcProviderTest {
 
             final ActorRef actorRef = Await.result(
                     system.actorSelection(moduleConfig.getRpcManagerPath()).resolveOne(
-                            Duration.create(1, TimeUnit.SECONDS)), Duration.create(2, TimeUnit.SECONDS));
+                            FiniteDuration.create(1, TimeUnit.SECONDS)), FiniteDuration.create(2, TimeUnit.SECONDS));
 
             Assert.assertTrue(actorRef.path().toString().contains(moduleConfig.getRpcManagerPath()));
         }