--- /dev/null
+/*
+ * 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");
+ }
+}
--- /dev/null
+/*
+ * 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");
+ }
+}
return new NeonSR2NormalizedNodeOutputStreamWriter(output);
case SODIUM_SR1:
return new SodiumSR1DataOutput(output);
+ case MAGNESIUM:
+ return new MagnesiumDataOutput(output);
default:
throw new IllegalStateException("Unhandled version " + version);
}
public enum NormalizedNodeStreamVersion {
LITHIUM,
NEON_SR2,
- SODIUM_SR1;
+ SODIUM_SR1,
+ MAGNESIUM;
}
* 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;
}
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);
}