X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcds-access-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fclient%2FClientActorBehavior.java;h=3f8c11a9137ed3bc5cccda43b8a37f55d6f46f3d;hb=HEAD;hp=14ca1ef38c8f850071d3e1b04f520faa7a496b69;hpb=62cddd88e42e8f3c6a92bbf42c97b0d6806f44ae;p=controller.git diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java index 14ca1ef38c..3f8c11a913 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ClientActorBehavior.java @@ -9,7 +9,6 @@ package org.opendaylight.controller.cluster.access.client; import static java.util.Objects.requireNonNull; -import com.google.common.annotations.Beta; import com.google.common.base.Stopwatch; import com.google.common.base.Verify; import java.util.Collection; @@ -45,10 +44,7 @@ import scala.concurrent.duration.FiniteDuration; /** * A behavior, which handles messages sent to a {@link AbstractClientActor}. - * - * @author Robert Varga */ -@Beta public abstract class ClientActorBehavior extends RecoveredClientActorBehavior implements Identifiable { /** @@ -152,12 +148,11 @@ public abstract class ClientActorBehavior extends return ((InternalCommand) command).execute(this); } - if (command instanceof SuccessEnvelope) { - return onRequestSuccess((SuccessEnvelope) command); + if (command instanceof SuccessEnvelope successEnvelope) { + return onRequestSuccess(successEnvelope); } - - if (command instanceof FailureEnvelope) { - return internalOnRequestFailure((FailureEnvelope) command); + if (command instanceof FailureEnvelope failureEnvelope) { + return internalOnRequestFailure(failureEnvelope); } if (MessageAssembler.isHandledMessage(command)) { @@ -174,10 +169,10 @@ public abstract class ClientActorBehavior extends } private static long extractCookie(final Identifier id) { - if (id instanceof TransactionIdentifier) { - return ((TransactionIdentifier) id).getHistoryId().getCookie(); - } else if (id instanceof LocalHistoryIdentifier) { - return ((LocalHistoryIdentifier) id).getCookie(); + if (id instanceof TransactionIdentifier transactionId) { + return transactionId.getHistoryId().getCookie(); + } else if (id instanceof LocalHistoryIdentifier historyId) { + return historyId.getCookie(); } else { throw new IllegalArgumentException("Unhandled identifier " + id); } @@ -215,7 +210,7 @@ public abstract class ClientActorBehavior extends * sessionId and if it does not match our current connection just ignore it. */ final Optional optBackend = conn.getBackendInfo(); - if (optBackend.isPresent() && optBackend.get().getSessionId() != command.getSessionId()) { + if (optBackend.isPresent() && optBackend.orElseThrow().getSessionId() != command.getSessionId()) { LOG.debug("{}: Mismatched current connection {} and envelope {}, ignoring response", persistenceId(), conn, command); return this; @@ -327,8 +322,8 @@ public abstract class ClientActorBehavior extends LOG.error("{}: failed to resolve shard {}", persistenceId(), shard, failure); final RequestException cause; - if (failure instanceof RequestException) { - cause = (RequestException) failure; + if (failure instanceof RequestException requestException) { + cause = requestException; } else { cause = new RuntimeRequestException("Failed to resolve shard " + shard, failure); } @@ -420,7 +415,7 @@ public abstract class ClientActorBehavior extends final Long shard = oldConn.cookie(); LOG.info("{}: refreshing backend for shard {}", persistenceId(), shard); - resolver().refreshBackendInfo(shard, conn.getBackendInfo().get()).whenComplete( + resolver().refreshBackendInfo(shard, conn.getBackendInfo().orElseThrow()).whenComplete( (backend, failure) -> context().executeInActor(behavior -> { backendConnectFinished(shard, conn, backend, failure); return behavior;