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 2b6be7d..0b630e2 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 e8ac87f..7df1c2f 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 4d68d8e..3b4c08c 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 d0cedce..d02819a 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 0b4e2cb..6386d6c 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 9daacb0..8f0cc99 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 861c04c..8d33773 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 90fc477..6a3f233 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 9d1126a..746ccf5 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 6584b8d..2e524b9 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 c69b839..334bd8e 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 ecd6e8b..92263f2 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 6ab4247..38c7620 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 621b037..56bdd7f 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 bba4d61..6265234 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 ce80810..aaef33e 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 23ed5d6..3ee49b6 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 965eaf0..dc78e03 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 fbfa911..faa4824 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 2c0f563..b22ca27 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 580c805..65ca16a 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 b31c1fc..9864323 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 56b9f81..3ca33ef 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 e289d7d..5dbc1cd 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 c84197c..c427044 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()));
         }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.