X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fcds-access-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Faccess%2Fcommands%2FConnectClientSuccess.java;h=8f16d61e349433a158db6065ebfad351536e0e87;hb=e84f63ee098fff5b02cbce1281ca0d1208f966fa;hp=c2302598e339b03101767603f94d81059759d060;hpb=50005093051d43b0fb02edbb05b37c694c186257;p=controller.git diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccess.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccess.java index c2302598e3..8f16d61e34 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccess.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccess.java @@ -7,19 +7,22 @@ */ package org.opendaylight.controller.cluster.access.commands; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + import akka.actor.ActorRef; import akka.actor.ActorSelection; import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects.ToStringHelper; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.List; import java.util.Optional; -import javax.annotation.Nonnull; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.ABIVersion; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; import org.opendaylight.controller.cluster.access.concepts.RequestSuccess; -import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; +import org.opendaylight.yangtools.yang.data.tree.api.ReadOnlyDataTree; /** * Successful reply to an {@link ConnectClientRequest}. Client actor which initiated this connection should use @@ -32,22 +35,30 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; public final class ConnectClientSuccess extends RequestSuccess { private static final long serialVersionUID = 1L; - private final List alternates; - private final DataTree dataTree; - private final ActorRef backend; + @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class " + + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class " + + "aren't serialized. FindBugs does not recognize this.") + private final @NonNull List alternates; + + @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "See justification above.") + private final ReadOnlyDataTree dataTree; + private final @NonNull ActorRef backend; + private final int maxMessages; - ConnectClientSuccess(final ClientIdentifier target, final ActorRef backend, final List alternates, - final Optional dataTree) { - super(target); - this.backend = Preconditions.checkNotNull(backend); + ConnectClientSuccess(final ClientIdentifier target, final long sequence, final ActorRef backend, + final List alternates, final int maxMessages, final ReadOnlyDataTree dataTree) { + super(target, sequence); + this.backend = requireNonNull(backend); this.alternates = ImmutableList.copyOf(alternates); - this.dataTree = dataTree.orElse(null); + this.dataTree = dataTree; + checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages); + this.maxMessages = maxMessages; } - public ConnectClientSuccess(final @Nonnull ClientIdentifier target, final @Nonnull ActorRef backend, - final @Nonnull List alternates, - final @Nonnull DataTree dataTree) { - this(target, backend, alternates, Optional.of(dataTree)); + public ConnectClientSuccess(final @NonNull ClientIdentifier target, final long sequence, + final @NonNull ActorRef backend, final @NonNull List alternates, + final @NonNull ReadOnlyDataTree dataTree, final int maxMessages) { + this(target, sequence, backend, alternates, maxMessages, requireNonNull(dataTree)); } /** @@ -55,18 +66,22 @@ public final class ConnectClientSuccess extends RequestSuccess getAlternates() { + public @NonNull List getAlternates() { return alternates; } - public @Nonnull ActorRef getBackend() { + public @NonNull ActorRef getBackend() { return backend; } - public Optional getDataTree() { + public Optional getDataTree() { return Optional.ofNullable(dataTree); } + public int getMaxMessages() { + return maxMessages; + } + @Override protected ConnectClientSuccessProxyV1 externalizableProxy(final ABIVersion version) { return new ConnectClientSuccessProxyV1(this); @@ -79,6 +94,7 @@ public final class ConnectClientSuccess extends RequestSuccess