BUG-5280: add maxMessages field to ConnectClientSuccess 28/43328/9
authorRobert Varga <rovarga@cisco.com>
Mon, 8 Aug 2016 14:31:44 +0000 (16:31 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Fri, 12 Aug 2016 08:39:14 +0000 (08:39 +0000)
This field will act as a hint on how many messages may
be queued by the frontend towards the backend at any
given time.

Change-Id: Ibb8bbe2af9595bc0ecee090acea35aa78a9250b7
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccess.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ConnectClientSuccessProxyV1.java

index c230259..7b2ea07 100644 (file)
@@ -35,19 +35,21 @@ public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier,
     private final List<ActorSelection> alternates;
     private final DataTree dataTree;
     private final ActorRef backend;
+    private final long maxMessages;
 
     ConnectClientSuccess(final ClientIdentifier target, final ActorRef backend, final List<ActorSelection> alternates,
-        final Optional<DataTree> dataTree) {
+        final Optional<DataTree> dataTree, final long maxMessages) {
         super(target);
         this.backend = Preconditions.checkNotNull(backend);
         this.alternates = ImmutableList.copyOf(alternates);
         this.dataTree = dataTree.orElse(null);
+        Preconditions.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<ActorSelection> alternates,
-            final @Nonnull DataTree dataTree) {
-        this(target, backend, alternates, Optional.of(dataTree));
+            final @Nonnull List<ActorSelection> alternates, final @Nonnull DataTree dataTree, final long maxMessages) {
+        this(target, backend, alternates, Optional.of(dataTree), maxMessages);
     }
 
     /**
@@ -67,6 +69,10 @@ public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier,
         return Optional.ofNullable(dataTree);
     }
 
+    public long getMaxMessages() {
+        return maxMessages;
+    }
+
     @Override
     protected ConnectClientSuccessProxyV1 externalizableProxy(final ABIVersion version) {
         return new ConnectClientSuccessProxyV1(this);
index d05ca37..6c9ae2a 100644 (file)
@@ -32,6 +32,7 @@ final class ConnectClientSuccessProxyV1 extends AbstractSuccessProxy<ClientIdent
 
     private List<ActorSelection> alternates;
     private ActorRef backend;
+    private long maxMessages;
 
     public ConnectClientSuccessProxyV1() {
         // For Externalizable
@@ -54,6 +55,8 @@ final class ConnectClientSuccessProxyV1 extends AbstractSuccessProxy<ClientIdent
         for (ActorSelection b : alternates) {
             out.writeObject(b.toSerializationFormat());
         }
+
+        out.writeLong(maxMessages);
     }
 
     @Override
@@ -71,11 +74,13 @@ final class ConnectClientSuccessProxyV1 extends AbstractSuccessProxy<ClientIdent
         for (int i = 0; i < backendsSize; ++i) {
             alternates.add(ActorSelection.apply(ActorRef.noSender(), (String)in.readObject()));
         }
+
+        maxMessages = in.readLong();
     }
 
     @Override
     protected ConnectClientSuccess createSuccess(final ClientIdentifier target) {
-        return new ConnectClientSuccess(target, backend, alternates, Optional.empty());
+        return new ConnectClientSuccess(target, backend, alternates, Optional.empty(), maxMessages);
     }
 
     @Override