Add Magnesium stream version 94/84694/8
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 25 Sep 2019 06:07:50 +0000 (08:07 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 25 Sep 2019 10:52:34 +0000 (12:52 +0200)
This is a variant of Sodium SR1 streaming format, which does not
allow presence of BigInteger tokens, as those values are superseded
by Uint64.

JIRA: CONTROLLER-1919
Change-Id: I1dc5c7376bf1ecf105e965e42d74806ed99ab9b1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumDataInput.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumDataOutput.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputOutput.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamVersion.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/TokenTypes.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/VersionedNormalizedNodeDataInput.java

diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumDataInput.java
new file mode 100644 (file)
index 0000000..74c8a69
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.node.utils.stream;
+
+import java.io.DataInput;
+import java.io.IOException;
+import java.math.BigInteger;
+
+final class MagnesiumDataInput extends AbstractMagnesiumDataInput {
+    MagnesiumDataInput(final DataInput input) {
+        super(input);
+    }
+
+    @Override
+    public NormalizedNodeStreamVersion getVersion() {
+        return NormalizedNodeStreamVersion.MAGNESIUM;
+    }
+
+    @Override
+    BigInteger readBigInteger() throws IOException {
+        throw new InvalidNormalizedNodeStreamException("BigInteger coding is not supported");
+    }
+}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumDataOutput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumDataOutput.java
new file mode 100644 (file)
index 0000000..a438268
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.node.utils.stream;
+
+import java.io.DataOutput;
+import java.io.IOException;
+import java.math.BigInteger;
+
+final class MagnesiumDataOutput extends AbstractMagnesiumDataOutput {
+    MagnesiumDataOutput(final DataOutput output) {
+        super(output);
+    }
+
+    @Override
+    short streamVersion() {
+        return TokenTypes.MAGNESIUM_VERSION;
+    }
+
+    @Override
+    void writeValue(final BigInteger value) throws IOException {
+        throw new IOException("BigInteger values are not supported");
+    }
+}
index e134d09e7f728acc70e95a1ecd1c0aff5017e1db..7e2fb2906f01e5b29f7460b053957be49792317d 100644 (file)
@@ -69,6 +69,8 @@ public final class NormalizedNodeInputOutput {
                 return new NeonSR2NormalizedNodeOutputStreamWriter(output);
             case SODIUM_SR1:
                 return new SodiumSR1DataOutput(output);
+            case MAGNESIUM:
+                return new MagnesiumDataOutput(output);
             default:
                 throw new IllegalStateException("Unhandled version " + version);
         }
index e597cb95bd0687641cab273eaf3989afd6407a61..e09c3e9eae1e20074d34330e164095bf1f3c4a61 100644 (file)
@@ -27,4 +27,9 @@ final class TokenTypes {
      * From-scratch designed version shipping in Sodium SR1.
      */
     static final short SODIUM_SR1_VERSION = 3;
+    /**
+     * Magnesium version. Structurally matches {@link #SODIUM_SR1_VERSION}, but does not allow BigIntegers to be
+     * present.
+     */
+    static final short MAGNESIUM_VERSION = 4;
 }
index 510b91dd1557568a0b04c80dfd8b41f78be8540d..68618fccbb9b8965908500975235759244689204 100644 (file)
@@ -43,6 +43,9 @@ final class VersionedNormalizedNodeDataInput extends ForwardingNormalizedNodeDat
             case TokenTypes.SODIUM_SR1_VERSION:
                 ret = new SodiumSR1DataInput(input);
                 break;
+            case TokenTypes.MAGNESIUM_VERSION:
+                ret = new MagnesiumDataInput(input);
+                break;
             default:
                 throw defunct("Unhandled stream version %s", version);
         }