Bump versions 9.0.4-SNAPSHOT
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / PersistenceProtocol.java
index 36acfb2925a66aa932812a43cc0fdc96dbff7e63..82fca03087c6ac794caa188cd2928c989015af71 100644 (file)
@@ -7,19 +7,16 @@
  */
 package org.opendaylight.controller.cluster.access.commands;
 
-import com.google.common.annotations.Beta;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.WritableObject;
 
 /**
  * Enumeration of transaction persistence protocols. These govern which protocol is executed between the frontend
  * and backend to drive persistence of a particular transaction.
- *
- * @author Robert Varga
  */
-@Beta
 public enum PersistenceProtocol implements WritableObject {
     /**
      * Abort protocol. The transaction has been aborted on the frontend and its effects should not be visible
@@ -33,7 +30,7 @@ public enum PersistenceProtocol implements WritableObject {
     },
     /**
      * Simple commit protocol. The transaction should be committed to the global history. The receiving backend
-     * it the only entity which needs to persist its effects, hence a simple request/reply protocol is sufficient.
+     * is the only entity which needs to persist its effects, hence a simple request/reply protocol is sufficient.
      */
     SIMPLE {
         @Override
@@ -50,7 +47,16 @@ public enum PersistenceProtocol implements WritableObject {
         byte byteValue() {
             return 3;
         }
-
+    },
+    /**
+     * Transaction is ready. This is not a really a persistence protocol, but an indication that frontend has
+     * completed modifications on the transaction and considers it ready, without deciding the actual commit protocol.
+     */
+    READY {
+        @Override
+        byte byteValue() {
+            return 4;
+        }
     };
 
     @Override
@@ -58,28 +64,24 @@ public enum PersistenceProtocol implements WritableObject {
         out.writeByte(byteValue());
     }
 
-    abstract byte byteValue();
-
     public static PersistenceProtocol readFrom(final DataInput in) throws IOException {
         return valueOf(in.readByte());
     }
 
+    abstract byte byteValue();
+
     static int byteValue(final PersistenceProtocol finish) {
         return finish == null ? 0 : finish.byteValue();
     }
 
-    static PersistenceProtocol valueOf(final byte b) {
-        switch (b) {
-            case 0:
-                return null;
-            case 1:
-                return ABORT;
-            case 2:
-                return SIMPLE;
-            case 3:
-                return THREE_PHASE;
-            default:
-                throw new IllegalArgumentException("Unhandled byte value " + b);
-        }
+    static @Nullable PersistenceProtocol valueOf(final byte value) {
+        return switch (value) {
+            case 0 -> null;
+            case 1 -> ABORT;
+            case 2 -> SIMPLE;
+            case 3 -> THREE_PHASE;
+            case 4 -> READY;
+            default -> throw new IllegalArgumentException("Unhandled byte value " + value);
+        };
     }
 }