Clean up RaftActorContextImpl formatting
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / PayloadVersion.java
index 154b89ac37c89a10aea03d75f2effab9a046be7c..298f835c5c85c1cc71db2bdb2b9b5834b6629b4a 100644 (file)
@@ -15,8 +15,8 @@ import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeStreamVersion;
 import org.opendaylight.yangtools.concepts.WritableObject;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion;
 
 /**
  * Enumeration of all ABI versions supported by this implementation of persistence. An ABI version has to be bumped
@@ -31,8 +31,6 @@ import org.opendaylight.yangtools.concepts.WritableObject;
  * participant instance should oppose RAFT candidates which produce persistence of an unsupported version. If a follower
  * encounters an unsupported version it must not become fully-operational, as it does not have an accurate view
  * of shard state.
- *
- * @author Robert Varga
  */
 @Beta
 public enum PayloadVersion implements WritableObject {
@@ -50,24 +48,27 @@ public enum PayloadVersion implements WritableObject {
     },
 
     /**
-     * Initial ABI version, as shipped with Boron Simultaneous release.
+     * ABI version shipped enabled {@code 2022.09 Chlorine SR2}. This version revises the serialization format of
+     * payloads proxies to reduce their size. Otherwise this format is equivalent to {@code #MAGNESIUM}.
+     *
+     * @deprecated Use {@link #POTASSIUM} instead.
      */
-    // We seed the initial version to be the same as DataStoreVersions.BORON_VERSION for compatibility reasons.
-    BORON(5) {
+    @Deprecated(since = "8.0.0", forRemoval = true)
+    CHLORINE_SR2(9) {
         @Override
         public NormalizedNodeStreamVersion getStreamVersion() {
-            return NormalizedNodeStreamVersion.LITHIUM;
+            return NormalizedNodeStreamVersion.MAGNESIUM;
         }
     },
 
     /**
-     * Revised payload version. Payloads remain the same as {@link #BORON}, but messages bearing QNames in any shape
-     * are using {@link NormalizedNodeStreamVersion#SODIUM}, which improves encoding.
+     * ABI version shipped enabled {@code 2023.09 Potassium}. This version removes Augmentation identifier and nodes.
+     * Otherwise this format is equivalent to {@link #CHLORINE_SR2}.
      */
-    SODIUM(6) {
+    POTASSIUM(10) {
         @Override
         public NormalizedNodeStreamVersion getStreamVersion() {
-            return NormalizedNodeStreamVersion.SODIUM;
+            return NormalizedNodeStreamVersion.POTASSIUM;
         }
     },
 
@@ -112,7 +113,7 @@ public enum PayloadVersion implements WritableObject {
      * @return Current {@link PayloadVersion}
      */
     public static @NonNull PayloadVersion current() {
-        return SODIUM;
+        return POTASSIUM;
     }
 
     /**
@@ -126,20 +127,12 @@ public enum PayloadVersion implements WritableObject {
      */
     public static @NonNull PayloadVersion valueOf(final short version)
             throws FutureVersionException, PastVersionException {
-        switch (Short.toUnsignedInt(version)) {
-            case 0:
-            case 1:
-            case 2:
-            case 3:
-            case 4:
-                throw new PastVersionException(version, BORON);
-            case 5:
-                return BORON;
-            case 6:
-                return SODIUM;
-            default:
-                throw new FutureVersionException(version, SODIUM);
-        }
+        return switch (Short.toUnsignedInt(version)) {
+            case 0, 1, 2, 3, 4, 5, 6, 7, 8 -> throw new PastVersionException(version, CHLORINE_SR2);
+            case 9 -> CHLORINE_SR2;
+            case 10 -> POTASSIUM;
+            default -> throw new FutureVersionException(version, CHLORINE_SR2);
+        };
     }
 
     @Override
@@ -160,7 +153,7 @@ public enum PayloadVersion implements WritableObject {
         try {
             return valueOf(s);
         } catch (FutureVersionException | PastVersionException e) {
-            throw new IOException("Unsupported version", e);
+            throw new IOException(e);
         }
     }
 }