Use java.time.Duration instead.
Change-Id: I34ad2c608c1a24e712058ed65c447ac8a5f69728
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import com.google.common.base.MoreObjects;
import com.google.common.base.MoreObjects.ToStringHelper;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import org.opendaylight.controller.cluster.access.concepts.RuntimeRequestException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import scala.concurrent.duration.FiniteDuration;
/**
* Base class for a connection to the backend. Responsible to queueing and dispatch of requests toward the backend.
// for that condition and take appropriate action, but this is more convenient and less error-prone.
final long normalized = delay <= 0 ? 0 : Math.min(delay, context.config().getBackendAlivenessTimerInterval());
- final FiniteDuration dur = FiniteDuration.fromNanos(normalized);
+ final var dur = Duration.ofNanos(normalized);
LOG.debug("{}: connection {} scheduling timeout in {}", context.persistenceId(), this, dur);
context.executeInActor(this::runTimer, dur);
haveTimer = true;
import com.google.common.base.Stopwatch;
import com.google.common.base.Verify;
+import java.time.Duration;
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.checkerframework.checker.lock.qual.Holding;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.concepts.Registration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import scala.concurrent.duration.FiniteDuration;
/**
* A behavior, which handles messages sent to a {@link AbstractClientActor}.
}
private static final Logger LOG = LoggerFactory.getLogger(ClientActorBehavior.class);
- private static final FiniteDuration RESOLVE_RETRY_DURATION = FiniteDuration.apply(1, TimeUnit.SECONDS);
+ private static final Duration RESOLVE_RETRY_DURATION = Duration.ofSeconds(1);
/**
* Map of connections to the backend. This map is concurrent to allow lookups, but given complex operations
import static java.util.Objects.requireNonNull;
import com.google.common.base.Ticker;
+import java.time.Duration;
import java.util.concurrent.TimeUnit;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorSystem;
import org.opendaylight.controller.cluster.messaging.MessageSlicer;
import org.opendaylight.yangtools.concepts.Identifiable;
import scala.concurrent.ExecutionContext;
-import scala.concurrent.duration.FiniteDuration;
/**
* An actor context associated with this {@link AbstractClientActor}.
}
public <T extends BackendInfo> Cancellable executeInActor(final @NonNull InternalCommand<T> command,
- final FiniteDuration delay) {
+ final Duration delay) {
return scheduler.scheduleOnce(requireNonNull(delay), self(), requireNonNull(command),
executionContext, ActorRef.noSender());
}
import static org.junit.Assert.assertSame;
import com.google.common.base.Ticker;
-import java.util.concurrent.TimeUnit;
+import java.time.Duration;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.testkit.TestProbe;
import org.apache.pekko.testkit.javadsl.TestKit;
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.FiniteDuration;
@RunWith(MockitoJUnitRunner.class)
public class ClientActorContextTest {
@Test
public void testExecuteInActorScheduled() {
- ctx.executeInActor(command, FiniteDuration.create(1, TimeUnit.SECONDS));
+ ctx.executeInActor(command, Duration.ofSeconds(1));
probe.expectMsg(command);
}