Trace the originating generation in RGE 29/73529/2
authorStephen Kitt <skitt@redhat.com>
Thu, 28 Jun 2018 11:48:21 +0000 (13:48 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 28 Jun 2018 14:33:40 +0000 (14:33 +0000)
This adds the originating generation in RetiredGenerationException’s
message.

Change-Id: Ie4cb11a0cc151176d765fc6d200cd7dd295798e1
Signed-off-by: Stephen Kitt <skitt@redhat.com>
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/RetiredGenerationException.java
opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/RetiredGenerationExceptionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java

index 219f281..7730318 100644 (file)
@@ -19,8 +19,9 @@ import com.google.common.annotations.Beta;
 public final class RetiredGenerationException extends RequestException {
     private static final long serialVersionUID = 1L;
 
-    public RetiredGenerationException(final long newGeneration) {
-        super("Originating generation was superseded by " + Long.toUnsignedString(newGeneration));
+    public RetiredGenerationException(final long originatingGeneration, final long newGeneration) {
+        super("Originating generation " + Long.toUnsignedString(originatingGeneration) + " was superseded by "
+            + Long.toUnsignedString(newGeneration));
     }
 
     @Override
index 1d0f016..778f2d7 100644 (file)
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertTrue;
 
 public class RetiredGenerationExceptionTest extends RequestExceptionTest<RetiredGenerationException> {
 
-    private static final RequestException OBJECT = new RetiredGenerationException(100);
+    private static final RequestException OBJECT = new RetiredGenerationException(99, 100);
 
     @Override
     protected void isRetriable() {
@@ -23,7 +23,7 @@ public class RetiredGenerationExceptionTest extends RequestExceptionTest<Retired
     @Override
     protected void checkMessage() {
         final String message = OBJECT.getMessage();
-        assertTrue("Originating generation was superseded by 100".equals(message));
+        assertTrue("Originating generation 99 was superseded by 100".equals(message));
         assertNull(OBJECT.getCause());
     }
 }
index c3cd8ef..7b1f9df 100644 (file)
@@ -474,7 +474,8 @@ public class Shard extends RaftActor {
             }
             if (cmp > 0) {
                 LOG.debug("{}: rejecting request from outdated client {}", persistenceId(), clientId);
-                throw new RetiredGenerationException(existing.getIdentifier().getGeneration());
+                throw new RetiredGenerationException(clientId.getGeneration(),
+                    existing.getIdentifier().getGeneration());
             }
 
             LOG.info("{}: retiring state {}, outdated by request from client {}", persistenceId(), existing, clientId);

©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.