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 219f2819dc4e89f5623444aab1a6460e3c90dd58..7730318f578d31c02272abac6faad7ff193f4f99 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 1d0f016ce783c748a895a753b5f6e9a480696d4c..778f2d7e59bdee059c637d339acfc322d83e089f 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 c3cd8ef80fdc04b91879356030c70fe2c30ee237..7b1f9df12d290c8815d57f5c2c90ecfe85c8d54f 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);