Use yang-data-codec-binfmt 25/86425/6
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 15 Dec 2019 16:41:34 +0000 (17:41 +0100)
committerStephen Kitt <skitt@redhat.com>
Tue, 17 Dec 2019 10:29:26 +0000 (10:29 +0000)
yang-data-codec-binfmt now carries migrated code from sal-clustering-commons,
make sure we use as much as we can, so that we do not duplicate code.

Change-Id: I5d50a63317c2d502c0eb7f71e1e6875cd95d7f9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
60 files changed:
features/mdsal/odl-mdsal-clustering-commons/pom.xml
features/mdsal/odl-mdsal-clustering-commons/src/main/feature/feature.xml
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/ABIVersion.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadPathTransactionRequestProxyV1.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ModifyTransactionRequestProxyV1.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/ReadTransactionSuccessProxyV1.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/TransactionDataModification.java
opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/TransactionModification.java
opendaylight/md-sal/sal-clustering-commons/pom.xml
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactory.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractLithiumDataInput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractLithiumDataOutput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractMagnesiumDataInput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractMagnesiumDataOutput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataInput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/CompatNormalizedNodeDataInput.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/CompatNormalizedNodeDataOutput.java [new file with mode: 0644]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ForwardingDataInput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ForwardingNormalizedNodeDataInput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/InvalidNormalizedNodeStreamException.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNode.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNormalizedNodeInputStreamReader.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNormalizedNodeOutputStreamWriter.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumPathArgument.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumTokens.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumValue.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumDataInput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumDataOutput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumNode.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumPathArgument.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumValue.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2NormalizedNodeInputStreamReader.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2NormalizedNodeOutputStreamWriter.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2Tokens.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeDataInput.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeDataOutput.java
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/SerializationUtils.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SodiumSR1DataInput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SodiumSR1DataOutput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/TokenTypes.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/VersionedNormalizedNodeDataInput.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/QNameFactoryTest.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumWriteObjectMappingTest.java [deleted file]
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeStreamReaderWriterTest.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/VersionedExternalizableMessage.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/DeleteModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MergeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/Modification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/WriteModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DataTreeCandidateInputOutput.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PayloadVersion.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteAction.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/ActionRoutingTable.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/RoutingTable.java

index ba16171..f59abb0 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>odl-yangtools-codec</artifactId>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
 
         <dependency>
             <groupId>${project.groupId}</groupId>
index bf6fbbe..c9627c5 100644 (file)
@@ -15,5 +15,6 @@
         <feature version="[6,7)">odl-dropwizard-metrics</feature>
         <feature version="[6,7)">odl-servlet-api</feature>
         <feature version="[4,5)">odl-yangtools-data</feature>
+        <feature version="[4,5)">odl-yangtools-codec</feature>
     </feature>
 </features>
index 26093c1..cfaf477 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;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index 16049fb..2cd4ec9 100644 (file)
@@ -12,10 +12,10 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeStreamVersion;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion;
 
 /**
  * Abstract base class for serialization proxies associated with {@link AbstractReadTransactionRequest}s. It implements
@@ -45,7 +45,7 @@ abstract class AbstractReadPathTransactionRequestProxyV1<T extends AbstractReadP
     @Override
     public final void writeExternal(final ObjectOutput out) throws IOException {
         super.writeExternal(out);
-        try (NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(out, streamVersion)) {
+        try (NormalizedNodeDataOutput nnout = streamVersion.newDataOutput(out)) {
             nnout.writeYangInstanceIdentifier(path);
         }
     }
@@ -53,7 +53,7 @@ abstract class AbstractReadPathTransactionRequestProxyV1<T extends AbstractReadP
     @Override
     public final void readExternal(final ObjectInput in) throws ClassNotFoundException, IOException {
         super.readExternal(in);
-        path = NormalizedNodeInputOutput.newDataInput(in).readYangInstanceIdentifier();
+        path = NormalizedNodeDataInput.newDataInput(in).readYangInstanceIdentifier();
     }
 
     @Override
index d6fc4e5..384c889 100644 (file)
@@ -18,10 +18,9 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeStreamVersion;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion;
 import org.opendaylight.yangtools.yang.data.impl.schema.ReusableImmutableNormalizedNodeStreamWriter;
 
 /**
@@ -32,6 +31,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ReusableImmutableNormali
  */
 final class ModifyTransactionRequestProxyV1 extends AbstractTransactionRequestProxy<ModifyTransactionRequest> {
     private static final long serialVersionUID = 1L;
+
     private List<TransactionModification> modifications;
     private Optional<PersistenceProtocol> protocol;
     private transient NormalizedNodeStreamVersion streamVersion;
@@ -59,7 +59,7 @@ final class ModifyTransactionRequestProxyV1 extends AbstractTransactionRequestPr
         final int size = in.readInt();
         if (size != 0) {
             modifications = new ArrayList<>(size);
-            final NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(in);
+            final NormalizedNodeDataInput nnin = NormalizedNodeDataInput.newDataInput(in);
             final ReusableImmutableNormalizedNodeStreamWriter writer =
                     ReusableImmutableNormalizedNodeStreamWriter.create();
             for (int i = 0; i < size; ++i) {
@@ -77,7 +77,7 @@ final class ModifyTransactionRequestProxyV1 extends AbstractTransactionRequestPr
         out.writeByte(PersistenceProtocol.byteValue(protocol.orElse(null)));
         out.writeInt(modifications.size());
         if (!modifications.isEmpty()) {
-            try (NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(out, streamVersion)) {
+            try (NormalizedNodeDataOutput nnout = streamVersion.newDataOutput(out)) {
                 for (TransactionModification op : modifications) {
                     op.writeTo(nnout);
                 }
index f755d3e..357c3d9 100644 (file)
@@ -12,10 +12,10 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Optional;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeStreamVersion;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion;
 
 /**
  * Externalizable proxy for use with {@link ReadTransactionSuccess}. It implements the initial (Boron) serialization
@@ -48,7 +48,7 @@ final class ReadTransactionSuccessProxyV1 extends AbstractTransactionSuccessProx
 
         if (data.isPresent()) {
             out.writeBoolean(true);
-            try (NormalizedNodeDataOutput nnout = NormalizedNodeInputOutput.newDataOutput(out, streamVersion)) {
+            try (NormalizedNodeDataOutput nnout = streamVersion.newDataOutput(out)) {
                 nnout.writeNormalizedNode(data.get());
             }
         } else {
@@ -61,7 +61,7 @@ final class ReadTransactionSuccessProxyV1 extends AbstractTransactionSuccessProx
         super.readExternal(in);
 
         if (in.readBoolean()) {
-            data = Optional.of(NormalizedNodeInputOutput.newDataInput(in).readNormalizedNode());
+            data = Optional.of(NormalizedNodeDataInput.newDataInput(in).readNormalizedNode());
         } else {
             data = Optional.empty();
         }
index cc901d6..eb2b308 100644 (file)
@@ -11,9 +11,9 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
 import java.io.IOException;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 
 /**
  * A {@link TransactionModification} which has a data component.
index a67886b..a4e0194 100644 (file)
@@ -12,10 +12,10 @@ import static java.util.Objects.requireNonNull;
 import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects;
 import java.io.IOException;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 
 /**
  * An individual modification of a transaction's state. This class and its subclasses are not serializable, but rather
index 8caa7d0..824bd61 100644 (file)
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>yang-model-util</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-data-codec-binfmt</artifactId>
+    </dependency>
   </dependencies>
 
   <build>
index a0d8a31..21ad302 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 
+@Deprecated(forRemoval = true)
 public final class QNameFactory {
     private static final class StringQName implements Immutable {
         private final @NonNull String localName;
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractLithiumDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractLithiumDataInput.java
deleted file mode 100644 (file)
index d921076..0000000
+++ /dev/null
@@ -1,448 +0,0 @@
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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 static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.Sets;
-import java.io.DataInput;
-import java.io.IOException;
-import java.io.StringReader;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.dom.DOMSource;
-import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
-import org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate;
-import org.opendaylight.yangtools.yang.common.Empty;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * NormalizedNodeInputStreamReader reads the byte stream and constructs the normalized node including its children
- * nodes. This process goes in recursive manner, where each NodeTypes object signifies the start of the object, except
- * END_NODE. If a node can have children, then that node's end is calculated based on appearance of END_NODE.
- */
-abstract class AbstractLithiumDataInput extends AbstractNormalizedNodeDataInput {
-
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractLithiumDataInput.class);
-
-    private final List<String> codedStringMap = new ArrayList<>();
-
-    private QName lastLeafSetQName;
-
-    AbstractLithiumDataInput(final DataInput input) {
-        super(input);
-    }
-
-    @Override
-    public final void streamNormalizedNode(final NormalizedNodeStreamWriter writer) throws IOException {
-        streamNormalizedNode(requireNonNull(writer), input.readByte());
-    }
-
-    private void streamNormalizedNode(final NormalizedNodeStreamWriter writer, final byte nodeType) throws IOException {
-        switch (nodeType) {
-            case LithiumNode.ANY_XML_NODE:
-                streamAnyxml(writer);
-                break;
-            case LithiumNode.AUGMENTATION_NODE:
-                streamAugmentation(writer);
-                break;
-            case LithiumNode.CHOICE_NODE:
-                streamChoice(writer);
-                break;
-            case LithiumNode.CONTAINER_NODE:
-                streamContainer(writer);
-                break;
-            case LithiumNode.LEAF_NODE:
-                streamLeaf(writer);
-                break;
-            case LithiumNode.LEAF_SET:
-                streamLeafSet(writer);
-                break;
-            case LithiumNode.ORDERED_LEAF_SET:
-                streamOrderedLeafSet(writer);
-                break;
-            case LithiumNode.LEAF_SET_ENTRY_NODE:
-                streamLeafSetEntry(writer);
-                break;
-            case LithiumNode.MAP_ENTRY_NODE:
-                streamMapEntry(writer);
-                break;
-            case LithiumNode.MAP_NODE:
-                streamMap(writer);
-                break;
-            case LithiumNode.ORDERED_MAP_NODE:
-                streamOrderedMap(writer);
-                break;
-            case LithiumNode.UNKEYED_LIST:
-                streamUnkeyedList(writer);
-                break;
-            case LithiumNode.UNKEYED_LIST_ITEM:
-                streamUnkeyedListItem(writer);
-                break;
-            default:
-                throw new InvalidNormalizedNodeStreamException("Unexpected node " + nodeType);
-        }
-    }
-
-    private void streamAnyxml(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming anyxml node {}", identifier);
-
-        final DOMSource value = readDOMSource();
-        if (writer.startAnyxmlNode(identifier, DOMSource.class)) {
-            writer.domSourceValue(value);
-            writer.endNode();
-        }
-    }
-
-    private void streamAugmentation(final NormalizedNodeStreamWriter writer) throws IOException {
-        final AugmentationIdentifier augIdentifier = readAugmentationIdentifier();
-        LOG.trace("Streaming augmentation node {}", augIdentifier);
-        writer.startAugmentationNode(augIdentifier);
-        commonStreamContainer(writer);
-    }
-
-    private void streamChoice(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming choice node {}", identifier);
-        writer.startChoiceNode(identifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-        commonStreamContainer(writer);
-    }
-
-    private void streamContainer(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming container node {}", identifier);
-        writer.startContainerNode(identifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-        commonStreamContainer(writer);
-    }
-
-    private void streamLeaf(final NormalizedNodeStreamWriter writer) throws IOException {
-        startLeaf(writer);
-        endLeaf(writer, readObject());
-    }
-
-    // Leaf inside a MapEntryNode, it can potentially be a key leaf, in which case we want to de-duplicate values.
-    private void streamLeaf(final NormalizedNodeStreamWriter writer, final NodeIdentifierWithPredicates entryId)
-            throws IOException {
-        final NodeIdentifier identifier = startLeaf(writer);
-        final Object value = readObject();
-        final Object entryValue = entryId.getValue(identifier.getNodeType());
-        endLeaf(writer, entryValue == null ? value : entryValue);
-    }
-
-    private NodeIdentifier startLeaf(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming leaf node {}", identifier);
-        writer.startLeafNode(identifier);
-        return identifier;
-    }
-
-    private static void endLeaf(final NormalizedNodeStreamWriter writer, final Object value) throws IOException {
-        writer.scalarValue(value);
-        writer.endNode();
-    }
-
-    private void streamLeafSet(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming leaf set node {}", identifier);
-        writer.startLeafSet(identifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-        commonStreamLeafSet(writer, identifier);
-    }
-
-    private void streamOrderedLeafSet(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming ordered leaf set node {}", identifier);
-        writer.startOrderedLeafSet(identifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-        commonStreamLeafSet(writer, identifier);
-    }
-
-    private void commonStreamLeafSet(final NormalizedNodeStreamWriter writer, final NodeIdentifier identifier)
-            throws IOException {
-        lastLeafSetQName = identifier.getNodeType();
-        try {
-            commonStreamContainer(writer);
-        } finally {
-            // Make sure we never leak this
-            lastLeafSetQName = null;
-        }
-    }
-
-    private void streamLeafSetEntry(final NormalizedNodeStreamWriter writer) throws IOException {
-        final QName name = lastLeafSetQName != null ? lastLeafSetQName : readQName();
-        final Object value = readObject();
-        final NodeWithValue<Object> leafIdentifier = new NodeWithValue<>(name, value);
-        LOG.trace("Streaming leaf set entry node {}, value {}", leafIdentifier, value);
-        writer.startLeafSetEntryNode(leafIdentifier);
-        writer.scalarValue(value);
-        writer.endNode();
-    }
-
-    private void streamMap(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming map node {}", identifier);
-        writer.startMapNode(identifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-        commonStreamContainer(writer);
-    }
-
-    private void streamOrderedMap(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming ordered map node {}", identifier);
-        writer.startOrderedMapNode(identifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-        commonStreamContainer(writer);
-    }
-
-    private void streamMapEntry(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifierWithPredicates entryIdentifier = readNormalizedNodeWithPredicates();
-        LOG.trace("Streaming map entry node {}", entryIdentifier);
-        writer.startMapEntryNode(entryIdentifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-
-        // Same loop as commonStreamContainer(), but ...
-        for (byte nodeType = input.readByte(); nodeType != LithiumNode.END_NODE; nodeType = input.readByte()) {
-            if (nodeType == LithiumNode.LEAF_NODE) {
-                // ... leaf nodes may need de-duplication
-                streamLeaf(writer, entryIdentifier);
-            } else {
-                streamNormalizedNode(writer, nodeType);
-            }
-        }
-        writer.endNode();
-    }
-
-    private void streamUnkeyedList(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming unkeyed list node {}", identifier);
-        writer.startUnkeyedList(identifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-        commonStreamContainer(writer);
-    }
-
-    private void streamUnkeyedListItem(final NormalizedNodeStreamWriter writer) throws IOException {
-        final NodeIdentifier identifier = readNodeIdentifier();
-        LOG.trace("Streaming unkeyed list item node {}", identifier);
-        writer.startUnkeyedListItem(identifier, NormalizedNodeStreamWriter.UNKNOWN_SIZE);
-        commonStreamContainer(writer);
-    }
-
-    private void commonStreamContainer(final NormalizedNodeStreamWriter writer) throws IOException {
-        for (byte nodeType = input.readByte(); nodeType != LithiumNode.END_NODE; nodeType = input.readByte()) {
-            streamNormalizedNode(writer, nodeType);
-        }
-        writer.endNode();
-    }
-
-    private DOMSource readDOMSource() throws IOException {
-        String xml = readObject().toString();
-        try {
-            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-            factory.setNamespaceAware(true);
-            Element node = factory.newDocumentBuilder().parse(
-                    new InputSource(new StringReader(xml))).getDocumentElement();
-            return new DOMSource(node);
-        } catch (SAXException | ParserConfigurationException e) {
-            throw new IOException("Error parsing XML: " + xml, e);
-        }
-    }
-
-    final QName defaultReadQName() throws IOException {
-        // Read in the same sequence of writing
-        String localName = readCodedString();
-        String namespace = readCodedString();
-        String revision = Strings.emptyToNull(readCodedString());
-
-        return QNameFactory.create(localName, namespace, revision);
-    }
-
-    final String readCodedString() throws IOException {
-        final byte valueType = input.readByte();
-        switch (valueType) {
-            case LithiumTokens.IS_NULL_VALUE:
-                return null;
-            case LithiumTokens.IS_CODE_VALUE:
-                final int code = input.readInt();
-                try {
-                    return codedStringMap.get(code);
-                } catch (IndexOutOfBoundsException e) {
-                    throw new IOException("String code " + code + " was not found", e);
-                }
-            case LithiumTokens.IS_STRING_VALUE:
-                final String value = input.readUTF().intern();
-                codedStringMap.add(value);
-                return value;
-            default:
-                throw new IOException("Unhandled string value type " + valueType);
-        }
-    }
-
-    private Set<QName> readQNameSet() throws IOException {
-        // Read the children count
-        final int count = input.readInt();
-        final Set<QName> children = Sets.newHashSetWithExpectedSize(count);
-        for (int i = 0; i < count; i++) {
-            children.add(readQName());
-        }
-        return children;
-    }
-
-    abstract AugmentationIdentifier readAugmentationIdentifier() throws IOException;
-
-    abstract NodeIdentifier readNodeIdentifier() throws IOException;
-
-    final AugmentationIdentifier defaultReadAugmentationIdentifier() throws IOException {
-        return AugmentationIdentifier.create(readQNameSet());
-    }
-
-    private NodeIdentifierWithPredicates readNormalizedNodeWithPredicates() throws IOException {
-        final QName qname = readQName();
-        final int count = input.readInt();
-        switch (count) {
-            case 0:
-                return NodeIdentifierWithPredicates.of(qname);
-            case 1:
-                return NodeIdentifierWithPredicates.of(qname, readQName(), readObject());
-            default:
-                // ImmutableList is used by ImmutableOffsetMapTemplate for lookups, hence we use that.
-                final Builder<QName> keys = ImmutableList.builderWithExpectedSize(count);
-                final Object[] values = new Object[count];
-                for (int i = 0; i < count; i++) {
-                    keys.add(readQName());
-                    values[i] = readObject();
-                }
-
-                return NodeIdentifierWithPredicates.of(qname, ImmutableOffsetMapTemplate.ordered(keys.build())
-                    .instantiateWithValues(values));
-        }
-    }
-
-    private Object readObject() throws IOException {
-        byte objectType = input.readByte();
-        switch (objectType) {
-            case LithiumValue.BITS_TYPE:
-                return readObjSet();
-
-            case LithiumValue.BOOL_TYPE:
-                return input.readBoolean();
-
-            case LithiumValue.BYTE_TYPE:
-                return input.readByte();
-
-            case LithiumValue.INT_TYPE:
-                return input.readInt();
-
-            case LithiumValue.LONG_TYPE:
-                return input.readLong();
-
-            case LithiumValue.QNAME_TYPE:
-                return readQName();
-
-            case LithiumValue.SHORT_TYPE:
-                return input.readShort();
-
-            case LithiumValue.STRING_TYPE:
-                return input.readUTF();
-
-            case LithiumValue.STRING_BYTES_TYPE:
-                return readStringBytes();
-
-            case LithiumValue.BIG_DECIMAL_TYPE:
-                return new BigDecimal(input.readUTF());
-
-            case LithiumValue.BIG_INTEGER_TYPE:
-                return new BigInteger(input.readUTF());
-
-            case LithiumValue.BINARY_TYPE:
-                byte[] bytes = new byte[input.readInt()];
-                input.readFully(bytes);
-                return bytes;
-
-            case LithiumValue.YANG_IDENTIFIER_TYPE:
-                return readYangInstanceIdentifierInternal();
-
-            case LithiumValue.EMPTY_TYPE:
-            // Leaf nodes no longer allow null values and thus we no longer emit null values. Previously, the "empty"
-            // yang type was represented as null so we translate an incoming null value to Empty. It was possible for
-            // a BI user to set a string leaf to null and we're rolling the dice here but the chances for that are
-            // very low. We'd have to know the yang type but, even if we did, we can't let a null value pass upstream
-            // so we'd have to drop the leaf which might cause other issues.
-            case LithiumValue.NULL_TYPE:
-                return Empty.getInstance();
-
-            default:
-                return null;
-        }
-    }
-
-    private String readStringBytes() throws IOException {
-        byte[] bytes = new byte[input.readInt()];
-        input.readFully(bytes);
-        return new String(bytes, StandardCharsets.UTF_8);
-    }
-
-    @Override
-    public final YangInstanceIdentifier readYangInstanceIdentifier() throws IOException {
-        return readYangInstanceIdentifierInternal();
-    }
-
-    private YangInstanceIdentifier readYangInstanceIdentifierInternal() throws IOException {
-        int size = input.readInt();
-        final Builder<PathArgument> pathArguments = ImmutableList.builderWithExpectedSize(size);
-        for (int i = 0; i < size; i++) {
-            pathArguments.add(readPathArgument());
-        }
-        return YangInstanceIdentifier.create(pathArguments.build());
-    }
-
-    private Set<String> readObjSet() throws IOException {
-        int count = input.readInt();
-        Set<String> children = new HashSet<>(count);
-        for (int i = 0; i < count; i++) {
-            children.add(readCodedString());
-        }
-        return children;
-    }
-
-    @Override
-    public final PathArgument readPathArgument() throws IOException {
-        // read Type
-        int type = input.readByte();
-
-        switch (type) {
-            case LithiumPathArgument.AUGMENTATION_IDENTIFIER:
-                return readAugmentationIdentifier();
-            case LithiumPathArgument.NODE_IDENTIFIER:
-                return readNodeIdentifier();
-            case LithiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES:
-                return readNormalizedNodeWithPredicates();
-            case LithiumPathArgument.NODE_IDENTIFIER_WITH_VALUE:
-                return new NodeWithValue<>(readQName(), readObject());
-            default:
-                // FIXME: throw hard error
-                return null;
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractLithiumDataOutput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractLithiumDataOutput.java
deleted file mode 100644 (file)
index 25e14b1..0000000
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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 static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.base.Verify.verifyNotNull;
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableMap;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.Set;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.Empty;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * "original" type mapping. Baseline is Lithium but it really was introduced in Oxygen, where {@code type empty} was
- * remapped from null.
- *
- * <p>
- * {@code uint8}, {@code uint16}, {@code uint32} use java.lang types with widening, hence their value types overlap with
- * mapping of {@code int16}, {@code int32} and {@code int64}, making that difference indiscernible without YANG schema
- * knowledge.
- */
-abstract class AbstractLithiumDataOutput extends AbstractNormalizedNodeDataOutput {
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractLithiumDataOutput.class);
-    private static final TransformerFactory TF = TransformerFactory.newInstance();
-    private static final ImmutableMap<Class<?>, Byte> KNOWN_TYPES = ImmutableMap.<Class<?>, Byte>builder()
-            .put(String.class, LithiumValue.STRING_TYPE)
-            .put(Byte.class, LithiumValue.BYTE_TYPE)
-            .put(Integer.class, LithiumValue.INT_TYPE)
-            .put(Long.class, LithiumValue.LONG_TYPE)
-            .put(Boolean.class, LithiumValue.BOOL_TYPE)
-            .put(QName.class, LithiumValue.QNAME_TYPE)
-            .put(Short.class, LithiumValue.SHORT_TYPE)
-            .put(BigInteger.class, LithiumValue.BIG_INTEGER_TYPE)
-            .put(BigDecimal.class, LithiumValue.BIG_DECIMAL_TYPE)
-            .put(byte[].class, LithiumValue.BINARY_TYPE)
-            .put(Empty.class, LithiumValue.EMPTY_TYPE)
-            .build();
-
-    private final Map<String, Integer> stringCodeMap = new HashMap<>();
-
-    private QName lastLeafSetQName;
-    private boolean inSimple;
-
-    AbstractLithiumDataOutput(final DataOutput output) {
-        super(output);
-    }
-
-    @Override
-    public final void startLeafNode(final NodeIdentifier name) throws IOException {
-        LOG.trace("Starting a new leaf node");
-        startNode(name, LithiumNode.LEAF_NODE);
-        inSimple = true;
-    }
-
-    @Override
-    public final void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        LOG.trace("Starting a new leaf set");
-        commonStartLeafSet(name, LithiumNode.LEAF_SET);
-    }
-
-    @Override
-    public final void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        LOG.trace("Starting a new ordered leaf set");
-        commonStartLeafSet(name, LithiumNode.ORDERED_LEAF_SET);
-    }
-
-    private void commonStartLeafSet(final NodeIdentifier name, final byte nodeType) throws IOException {
-        startNode(name, nodeType);
-        lastLeafSetQName = name.getNodeType();
-    }
-
-    @Override
-    public final void startLeafSetEntryNode(final NodeWithValue<?> name) throws IOException {
-        LOG.trace("Starting a new leaf set entry node");
-
-        output.writeByte(LithiumNode.LEAF_SET_ENTRY_NODE);
-
-        // lastLeafSetQName is set if the parent LeafSetNode was previously written. Otherwise this is a
-        // stand alone LeafSetEntryNode so write out it's name here.
-        if (lastLeafSetQName == null) {
-            writeQNameInternal(name.getNodeType());
-        }
-        inSimple = true;
-    }
-
-    @Override
-    public final void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        LOG.trace("Starting a new container node");
-        startNode(name, LithiumNode.CONTAINER_NODE);
-    }
-
-    @Override
-    public final void startYangModeledAnyXmlNode(final NodeIdentifier name, final int childSizeHint)
-            throws IOException {
-        LOG.trace("Starting a new yang modeled anyXml node");
-        startNode(name, LithiumNode.YANG_MODELED_ANY_XML_NODE);
-    }
-
-    @Override
-    public final void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        LOG.trace("Starting a new unkeyed list");
-        startNode(name, LithiumNode.UNKEYED_LIST);
-    }
-
-    @Override
-    public final void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        LOG.trace("Starting a new unkeyed list item");
-        startNode(name, LithiumNode.UNKEYED_LIST_ITEM);
-    }
-
-    @Override
-    public final void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        LOG.trace("Starting a new map node");
-        startNode(name, LithiumNode.MAP_NODE);
-    }
-
-    @Override
-    public final void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint)
-            throws IOException {
-        LOG.trace("Starting a new map entry node");
-        startNode(identifier, LithiumNode.MAP_ENTRY_NODE);
-        writeKeyValueMap(identifier.entrySet());
-    }
-
-    @Override
-    public final void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        LOG.trace("Starting a new ordered map node");
-        startNode(name, LithiumNode.ORDERED_MAP_NODE);
-    }
-
-    @Override
-    public final void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        LOG.trace("Starting a new choice node");
-        startNode(name, LithiumNode.CHOICE_NODE);
-    }
-
-    @Override
-    public final void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException {
-        requireNonNull(identifier, "Node identifier should not be null");
-        LOG.trace("Starting a new augmentation node");
-
-        output.writeByte(LithiumNode.AUGMENTATION_NODE);
-        writeAugmentationIdentifier(identifier);
-    }
-
-    @Override
-    public final boolean startAnyxmlNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
-        if (DOMSource.class.isAssignableFrom(objectModel)) {
-            LOG.trace("Starting anyxml node");
-            startNode(name, LithiumNode.ANY_XML_NODE);
-            inSimple = true;
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public final void scalarValue(final Object value) throws IOException {
-        writeObject(value);
-    }
-
-    @Override
-    public final void domSourceValue(final DOMSource value) throws IOException {
-        final StringWriter writer = new StringWriter();
-        try {
-            TF.newTransformer().transform(value, new StreamResult(writer));
-        } catch (TransformerException e) {
-            throw new IOException("Error writing anyXml", e);
-        }
-        writeObject(writer.toString());
-    }
-
-    @Override
-    public final void endNode() throws IOException {
-        LOG.trace("Ending the node");
-        if (!inSimple) {
-            lastLeafSetQName = null;
-            output.writeByte(LithiumNode.END_NODE);
-        }
-        inSimple = false;
-    }
-
-    @Override
-    @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST",
-            justification = "The casts in the switch clauses are indirectly confirmed via the determination of 'type'.")
-    final void writePathArgumentInternal(final PathArgument pathArgument) throws IOException {
-        final byte type = LithiumPathArgument.getSerializablePathArgumentType(pathArgument);
-        output.writeByte(type);
-
-        switch (type) {
-            case LithiumPathArgument.NODE_IDENTIFIER:
-                NodeIdentifier nodeIdentifier = (NodeIdentifier) pathArgument;
-                writeQNameInternal(nodeIdentifier.getNodeType());
-                break;
-            case LithiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES:
-                NodeIdentifierWithPredicates nodeIdentifierWithPredicates =
-                    (NodeIdentifierWithPredicates) pathArgument;
-                writeQNameInternal(nodeIdentifierWithPredicates.getNodeType());
-                writeKeyValueMap(nodeIdentifierWithPredicates.entrySet());
-                break;
-            case LithiumPathArgument.NODE_IDENTIFIER_WITH_VALUE:
-                NodeWithValue<?> nodeWithValue = (NodeWithValue<?>) pathArgument;
-                writeQNameInternal(nodeWithValue.getNodeType());
-                writeObject(nodeWithValue.getValue());
-                break;
-            case LithiumPathArgument.AUGMENTATION_IDENTIFIER:
-                // No Qname in augmentation identifier
-                writeAugmentationIdentifier((AugmentationIdentifier) pathArgument);
-                break;
-            default:
-                throw new IllegalStateException("Unknown node identifier type is found : "
-                        + pathArgument.getClass().toString());
-        }
-    }
-
-    @Override
-    final void writeYangInstanceIdentifierInternal(final YangInstanceIdentifier identifier) throws IOException {
-        List<PathArgument> pathArguments = identifier.getPathArguments();
-        output.writeInt(pathArguments.size());
-
-        for (PathArgument pathArgument : pathArguments) {
-            writePathArgumentInternal(pathArgument);
-        }
-    }
-
-    final void defaultWriteAugmentationIdentifier(final @NonNull AugmentationIdentifier aid) throws IOException {
-        final Set<QName> qnames = aid.getPossibleChildNames();
-        // Write each child's qname separately, if list is empty send count as 0
-        if (!qnames.isEmpty()) {
-            output.writeInt(qnames.size());
-            for (QName qname : qnames) {
-                writeQNameInternal(qname);
-            }
-        } else {
-            LOG.debug("augmentation node does not have any child");
-            output.writeInt(0);
-        }
-    }
-
-    final void defaultWriteQName(final QName qname) throws IOException {
-        writeString(qname.getLocalName());
-        writeModule(qname.getModule());
-    }
-
-    final void defaultWriteModule(final QNameModule module) throws IOException {
-        writeString(module.getNamespace().toString());
-        final Optional<Revision> revision = module.getRevision();
-        if (revision.isPresent()) {
-            writeString(revision.get().toString());
-        } else {
-            writeByte(LithiumTokens.IS_NULL_VALUE);
-        }
-    }
-
-    abstract void writeModule(QNameModule module) throws IOException;
-
-    abstract void writeAugmentationIdentifier(@NonNull AugmentationIdentifier aid) throws IOException;
-
-    private void startNode(final PathArgument arg, final byte nodeType) throws IOException {
-        requireNonNull(arg, "Node identifier should not be null");
-        checkState(!inSimple, "Attempted to start a child in a simple node");
-
-        // First write the type of node
-        output.writeByte(nodeType);
-        // Write Start Tag
-        writeQNameInternal(arg.getNodeType());
-    }
-
-    private void writeObjSet(final Set<?> set) throws IOException {
-        output.writeInt(set.size());
-        for (Object o : set) {
-            checkArgument(o instanceof String, "Expected value type to be String but was %s (%s)", o.getClass(), o);
-            writeString((String) o);
-        }
-    }
-
-    private void writeObject(final Object value) throws IOException {
-        byte type = getSerializableType(value);
-        // Write object type first
-        output.writeByte(type);
-
-        switch (type) {
-            case LithiumValue.BOOL_TYPE:
-                output.writeBoolean((Boolean) value);
-                break;
-            case LithiumValue.QNAME_TYPE:
-                writeQNameInternal((QName) value);
-                break;
-            case LithiumValue.INT_TYPE:
-                output.writeInt((Integer) value);
-                break;
-            case LithiumValue.BYTE_TYPE:
-                output.writeByte((Byte) value);
-                break;
-            case LithiumValue.LONG_TYPE:
-                output.writeLong((Long) value);
-                break;
-            case LithiumValue.SHORT_TYPE:
-                output.writeShort((Short) value);
-                break;
-            case LithiumValue.BITS_TYPE:
-                writeObjSet((Set<?>) value);
-                break;
-            case LithiumValue.BINARY_TYPE:
-                byte[] bytes = (byte[]) value;
-                output.writeInt(bytes.length);
-                output.write(bytes);
-                break;
-            case LithiumValue.YANG_IDENTIFIER_TYPE:
-                writeYangInstanceIdentifierInternal((YangInstanceIdentifier) value);
-                break;
-            case LithiumValue.EMPTY_TYPE:
-                break;
-            case LithiumValue.STRING_BYTES_TYPE:
-                final byte[] valueBytes = value.toString().getBytes(StandardCharsets.UTF_8);
-                output.writeInt(valueBytes.length);
-                output.write(valueBytes);
-                break;
-            default:
-                output.writeUTF(value.toString());
-                break;
-        }
-    }
-
-    private void writeKeyValueMap(final Set<Entry<QName, Object>> entrySet) throws IOException {
-        if (!entrySet.isEmpty()) {
-            output.writeInt(entrySet.size());
-            for (Entry<QName, Object> entry : entrySet) {
-                writeQNameInternal(entry.getKey());
-                writeObject(entry.getValue());
-            }
-        } else {
-            output.writeInt(0);
-        }
-    }
-
-    private void writeString(final @NonNull String string) throws IOException {
-        final Integer value = stringCodeMap.get(verifyNotNull(string));
-        if (value == null) {
-            stringCodeMap.put(string, stringCodeMap.size());
-            writeByte(LithiumTokens.IS_STRING_VALUE);
-            writeUTF(string);
-        } else {
-            writeByte(LithiumTokens.IS_CODE_VALUE);
-            writeInt(value);
-        }
-    }
-
-    @VisibleForTesting
-    static final byte getSerializableType(final Object node) {
-        final Byte type = KNOWN_TYPES.get(requireNonNull(node).getClass());
-        if (type != null) {
-            if (type == LithiumValue.STRING_TYPE
-                    && ((String) node).length() >= LithiumValue.STRING_BYTES_LENGTH_THRESHOLD) {
-                return LithiumValue.STRING_BYTES_TYPE;
-            }
-            return type;
-        }
-
-        if (node instanceof Set) {
-            return LithiumValue.BITS_TYPE;
-        }
-
-        if (node instanceof YangInstanceIdentifier) {
-            return LithiumValue.YANG_IDENTIFIER_TYPE;
-        }
-
-        throw new IllegalArgumentException("Unknown value type " + node.getClass().getSimpleName());
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractMagnesiumDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractMagnesiumDataInput.java
deleted file mode 100644 (file)
index a51b121..0000000
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * 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 static com.google.common.base.Verify.verifyNotNull;
-import static java.util.Objects.requireNonNull;
-import static org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter.UNKNOWN_SIZE;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.util.concurrent.UncheckedExecutionException;
-import java.io.DataInput;
-import java.io.IOException;
-import java.io.StringReader;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import javax.xml.transform.dom.DOMSource;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
-import org.opendaylight.yangtools.rfc8528.data.api.MountPointIdentifier;
-import org.opendaylight.yangtools.util.xml.UntrustedXML;
-import org.opendaylight.yangtools.yang.common.Empty;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.Uint16;
-import org.opendaylight.yangtools.yang.common.Uint32;
-import org.opendaylight.yangtools.yang.common.Uint64;
-import org.opendaylight.yangtools.yang.common.Uint8;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Abstract base class for NormalizedNodeDataInput based on {@link MagnesiumNode}, {@link MagnesiumPathArgument} and
- * {@link MagnesiumValue}.
- */
-abstract class AbstractMagnesiumDataInput extends AbstractNormalizedNodeDataInput {
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractMagnesiumDataInput.class);
-
-    // Known singleton objects
-    private static final @NonNull Byte INT8_0 = 0;
-    private static final @NonNull Short INT16_0 = 0;
-    private static final @NonNull Integer INT32_0 = 0;
-    private static final @NonNull Long INT64_0 = 0L;
-    private static final byte @NonNull[] BINARY_0 = new byte[0];
-    private static final @NonNull AugmentationIdentifier EMPTY_AID = AugmentationIdentifier.create(ImmutableSet.of());
-
-    // FIXME: these should be available as constants
-    private static final @NonNull Uint8 UINT8_0 = Uint8.valueOf(0);
-    private static final @NonNull Uint16 UINT16_0 = Uint16.valueOf(0);
-    private static final @NonNull Uint32 UINT32_0 = Uint32.valueOf(0);
-    private static final @NonNull Uint64 UINT64_0 = Uint64.valueOf(0);
-
-    private final List<AugmentationIdentifier> codedAugments = new ArrayList<>();
-    private final List<NodeIdentifier> codedNodeIdentifiers = new ArrayList<>();
-    private final List<QNameModule> codedModules = new ArrayList<>();
-    private final List<String> codedStrings = new ArrayList<>();
-
-    AbstractMagnesiumDataInput(final DataInput input) {
-        super(input);
-    }
-
-    @Override
-    public final void streamNormalizedNode(final NormalizedNodeStreamWriter writer) throws IOException {
-        streamNormalizedNode(requireNonNull(writer), null, input.readByte());
-    }
-
-    private void streamNormalizedNode(final NormalizedNodeStreamWriter writer, final PathArgument parent,
-            final byte nodeHeader) throws IOException {
-        switch (nodeHeader & MagnesiumNode.TYPE_MASK) {
-            case MagnesiumNode.NODE_LEAF:
-                streamLeaf(writer, parent, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_CONTAINER:
-                streamContainer(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_LIST:
-                streamList(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_MAP:
-                streamMap(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_MAP_ORDERED:
-                streamMapOrdered(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_LEAFSET:
-                streamLeafset(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_LEAFSET_ORDERED:
-                streamLeafsetOrdered(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_CHOICE:
-                streamChoice(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_AUGMENTATION:
-                streamAugmentation(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_ANYXML:
-                streamAnyxml(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_ANYXML_MODELED:
-                streamAnyxmlModeled(writer, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_LIST_ENTRY:
-                streamListEntry(writer, parent, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_LEAFSET_ENTRY:
-                streamLeafsetEntry(writer, parent, nodeHeader);
-                break;
-            case MagnesiumNode.NODE_MAP_ENTRY:
-                streamMapEntry(writer, parent, nodeHeader);
-                break;
-            default:
-                throw new InvalidNormalizedNodeStreamException("Unexpected node header " + nodeHeader);
-        }
-    }
-
-    private void streamAnyxml(final NormalizedNodeStreamWriter writer, final byte nodeHeader) throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        LOG.trace("Streaming anyxml node {}", identifier);
-
-        final DOMSource value = readDOMSource();
-        if (writer.startAnyxmlNode(identifier, DOMSource.class)) {
-            writer.domSourceValue(value);
-            writer.endNode();
-        }
-    }
-
-    private void streamAnyxmlModeled(final NormalizedNodeStreamWriter writer, final byte nodeHeader)
-            throws IOException {
-        // TODO: decide how to deal with these
-        throw new UnsupportedOperationException("Reading YANG-modeled anyxml was never supported");
-    }
-
-    private void streamAugmentation(final NormalizedNodeStreamWriter writer, final byte nodeHeader) throws IOException {
-        final AugmentationIdentifier augIdentifier = decodeAugmentationIdentifier(nodeHeader);
-        LOG.trace("Streaming augmentation node {}", augIdentifier);
-        writer.startAugmentationNode(augIdentifier);
-        commonStreamContainer(writer, augIdentifier);
-    }
-
-    private void streamChoice(final NormalizedNodeStreamWriter writer, final byte nodeHeader) throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        LOG.trace("Streaming choice node {}", identifier);
-        writer.startChoiceNode(identifier, UNKNOWN_SIZE);
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void streamContainer(final NormalizedNodeStreamWriter writer, final byte nodeHeader) throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        LOG.trace("Streaming container node {}", identifier);
-        writer.startContainerNode(identifier, UNKNOWN_SIZE);
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void streamLeaf(final NormalizedNodeStreamWriter writer, final PathArgument parent, final byte nodeHeader)
-            throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        LOG.trace("Streaming leaf node {}", identifier);
-        writer.startLeafNode(identifier);
-
-        final Object value;
-        if ((nodeHeader & MagnesiumNode.PREDICATE_ONE) == MagnesiumNode.PREDICATE_ONE) {
-            if (!(parent instanceof NodeIdentifierWithPredicates)) {
-                throw new InvalidNormalizedNodeStreamException("Invalid predicate leaf " + identifier + " in parent "
-                        + parent);
-            }
-
-            value = ((NodeIdentifierWithPredicates) parent).getValue(identifier.getNodeType());
-            if (value == null) {
-                throw new InvalidNormalizedNodeStreamException("Failed to find predicate leaf " + identifier
-                    + " in parent " + parent);
-            }
-        } else {
-            value = readLeafValue();
-        }
-
-        writer.scalarValue(value);
-        writer.endNode();
-    }
-
-    private void streamLeafset(final NormalizedNodeStreamWriter writer, final byte nodeHeader) throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        LOG.trace("Streaming leaf set node {}", identifier);
-        writer.startLeafSet(identifier, UNKNOWN_SIZE);
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void streamLeafsetOrdered(final NormalizedNodeStreamWriter writer, final byte nodeHeader)
-            throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        LOG.trace("Streaming ordered leaf set node {}", identifier);
-        writer.startOrderedLeafSet(identifier, UNKNOWN_SIZE);
-
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void streamLeafsetEntry(final NormalizedNodeStreamWriter writer, final PathArgument parent,
-            final byte nodeHeader) throws IOException {
-        final NodeIdentifier nodeId = decodeNodeIdentifier(nodeHeader, parent);
-        final Object value = readLeafValue();
-        final NodeWithValue<Object> leafIdentifier = new NodeWithValue<>(nodeId.getNodeType(), value);
-        LOG.trace("Streaming leaf set entry node {}", leafIdentifier);
-        writer.startLeafSetEntryNode(leafIdentifier);
-        writer.scalarValue(value);
-        writer.endNode();
-    }
-
-    private void streamList(final NormalizedNodeStreamWriter writer, final byte nodeHeader) throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        writer.startUnkeyedList(identifier, UNKNOWN_SIZE);
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void streamListEntry(final NormalizedNodeStreamWriter writer, final PathArgument parent,
-            final byte nodeHeader) throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader, parent);
-        LOG.trace("Streaming unkeyed list item node {}", identifier);
-        writer.startUnkeyedListItem(identifier, UNKNOWN_SIZE);
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void streamMap(final NormalizedNodeStreamWriter writer, final byte nodeHeader) throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        LOG.trace("Streaming map node {}", identifier);
-        writer.startMapNode(identifier, UNKNOWN_SIZE);
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void streamMapOrdered(final NormalizedNodeStreamWriter writer, final byte nodeHeader) throws IOException {
-        final NodeIdentifier identifier = decodeNodeIdentifier(nodeHeader);
-        LOG.trace("Streaming ordered map node {}", identifier);
-        writer.startOrderedMapNode(identifier, UNKNOWN_SIZE);
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void streamMapEntry(final NormalizedNodeStreamWriter writer, final PathArgument parent,
-            final byte nodeHeader) throws IOException {
-        final NodeIdentifier nodeId = decodeNodeIdentifier(nodeHeader, parent);
-
-        final int size;
-        switch (mask(nodeHeader, MagnesiumNode.PREDICATE_MASK)) {
-            case MagnesiumNode.PREDICATE_ZERO:
-                size = 0;
-                break;
-            case MagnesiumNode.PREDICATE_ONE:
-                size = 1;
-                break;
-            case MagnesiumNode.PREDICATE_1B:
-                size = input.readUnsignedByte();
-                break;
-            case MagnesiumNode.PREDICATE_4B:
-                size = input.readInt();
-                break;
-            default:
-                // ISE on purpose: this should never ever happen
-                throw new IllegalStateException("Failed to decode NodeIdentifierWithPredicates size from header "
-                        + nodeHeader);
-        }
-
-        final NodeIdentifierWithPredicates identifier = readNodeIdentifierWithPredicates(nodeId.getNodeType(), size);
-        LOG.trace("Streaming map entry node {}", identifier);
-        writer.startMapEntryNode(identifier, UNKNOWN_SIZE);
-        commonStreamContainer(writer, identifier);
-    }
-
-    private void commonStreamContainer(final NormalizedNodeStreamWriter writer, final PathArgument parent)
-            throws IOException {
-        for (byte nodeType = input.readByte(); nodeType != MagnesiumNode.NODE_END; nodeType = input.readByte()) {
-            streamNormalizedNode(writer, parent, nodeType);
-        }
-        writer.endNode();
-    }
-
-    private @NonNull NodeIdentifier decodeNodeIdentifier() throws IOException {
-        final QNameModule module = decodeQNameModule();
-        final String localName = readRefString();
-        final NodeIdentifier nodeId;
-        try {
-            nodeId = QNameFactory.getNodeIdentifier(module, localName);
-        } catch (ExecutionException e) {
-            throw new InvalidNormalizedNodeStreamException("Illegal QName module=" + module + " localName="
-                    + localName, e);
-        }
-
-        codedNodeIdentifiers.add(nodeId);
-        return nodeId;
-    }
-
-    private NodeIdentifier decodeNodeIdentifier(final byte nodeHeader) throws IOException {
-        return decodeNodeIdentifier(nodeHeader, null);
-    }
-
-    private NodeIdentifier decodeNodeIdentifier(final byte nodeHeader, final PathArgument parent) throws IOException {
-        final int index;
-        switch (nodeHeader & MagnesiumNode.ADDR_MASK) {
-            case MagnesiumNode.ADDR_DEFINE:
-                return readNodeIdentifier();
-            case MagnesiumNode.ADDR_LOOKUP_1B:
-                index = input.readUnsignedByte();
-                break;
-            case MagnesiumNode.ADDR_LOOKUP_4B:
-                index = input.readInt();
-                break;
-            case MagnesiumNode.ADDR_PARENT:
-                if (parent instanceof NodeIdentifier) {
-                    return (NodeIdentifier) parent;
-                }
-                throw new InvalidNormalizedNodeStreamException("Invalid node identifier reference to parent " + parent);
-            default:
-                throw new InvalidNormalizedNodeStreamException("Unexpected node identifier addressing in header "
-                        + nodeHeader);
-        }
-
-        try {
-            return codedNodeIdentifiers.get(index);
-        } catch (IndexOutOfBoundsException e) {
-            throw new InvalidNormalizedNodeStreamException("Invalid QName reference " + index, e);
-        }
-    }
-
-    private AugmentationIdentifier decodeAugmentationIdentifier(final byte nodeHeader) throws IOException {
-        final int index;
-        switch (nodeHeader & MagnesiumNode.ADDR_MASK) {
-            case MagnesiumNode.ADDR_DEFINE:
-                return readAugmentationIdentifier();
-            case MagnesiumNode.ADDR_LOOKUP_1B:
-                index = input.readUnsignedByte();
-                break;
-            case MagnesiumNode.ADDR_LOOKUP_4B:
-                index = input.readInt();
-                break;
-            default:
-                throw new InvalidNormalizedNodeStreamException(
-                    "Unexpected augmentation identifier addressing in header " + nodeHeader);
-        }
-
-        try {
-            return codedAugments.get(index);
-        } catch (IndexOutOfBoundsException e) {
-            throw new InvalidNormalizedNodeStreamException("Invalid augmentation identifier reference " + index, e);
-        }
-    }
-
-    @Override
-    public final YangInstanceIdentifier readYangInstanceIdentifier() throws IOException {
-        final byte type = input.readByte();
-        if (type == MagnesiumValue.YIID) {
-            return readYangInstanceIdentifier(input.readInt());
-        } else if (type >= MagnesiumValue.YIID_0) {
-            // Note 'byte' is range limited, so it is always '&& type <= MagnesiumValue.YIID_31'
-            return readYangInstanceIdentifier(type - MagnesiumValue.YIID_0);
-        } else {
-            throw new InvalidNormalizedNodeStreamException("Unexpected YangInstanceIdentifier type " + type);
-        }
-    }
-
-    private @NonNull YangInstanceIdentifier readYangInstanceIdentifier(final int size) throws IOException {
-        if (size > 0) {
-            final Builder<PathArgument> builder = ImmutableList.builderWithExpectedSize(size);
-            for (int i = 0; i < size; ++i) {
-                builder.add(readPathArgument());
-            }
-            return YangInstanceIdentifier.create(builder.build());
-        } else if (size == 0) {
-            return YangInstanceIdentifier.empty();
-        } else {
-            throw new InvalidNormalizedNodeStreamException("Invalid YangInstanceIdentifier size " + size);
-        }
-    }
-
-    @Override
-    public final QName readQName() throws IOException {
-        final byte type = input.readByte();
-        switch (type) {
-            case MagnesiumValue.QNAME:
-                return decodeQName();
-            case MagnesiumValue.QNAME_REF_1B:
-                return decodeQNameRef1();
-            case MagnesiumValue.QNAME_REF_2B:
-                return decodeQNameRef2();
-            case MagnesiumValue.QNAME_REF_4B:
-                return decodeQNameRef4();
-            default:
-                throw new InvalidNormalizedNodeStreamException("Unexpected QName type " + type);
-        }
-    }
-
-    @Override
-    public final PathArgument readPathArgument() throws IOException {
-        final byte header = input.readByte();
-        switch (header & MagnesiumPathArgument.TYPE_MASK) {
-            case MagnesiumPathArgument.AUGMENTATION_IDENTIFIER:
-                return readAugmentationIdentifier(header);
-            case MagnesiumPathArgument.NODE_IDENTIFIER:
-                verifyPathIdentifierOnly(header);
-                return readNodeIdentifier(header);
-            case MagnesiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES:
-                return readNodeIdentifierWithPredicates(header);
-            case MagnesiumPathArgument.NODE_WITH_VALUE:
-                verifyPathIdentifierOnly(header);
-                return readNodeWithValue(header);
-            case MagnesiumPathArgument.MOUNTPOINT_IDENTIFIER:
-                verifyPathIdentifierOnly(header);
-                return MountPointIdentifier.create(readNodeIdentifier(header).getNodeType());
-            default:
-                throw new InvalidNormalizedNodeStreamException("Unexpected PathArgument header " + header);
-        }
-    }
-
-    private AugmentationIdentifier readAugmentationIdentifier() throws IOException {
-        final AugmentationIdentifier result = readAugmentationIdentifier(input.readInt());
-        codedAugments.add(result);
-        return result;
-    }
-
-    private AugmentationIdentifier readAugmentationIdentifier(final byte header) throws IOException {
-        final byte count = mask(header, MagnesiumPathArgument.AID_COUNT_MASK);
-        switch (count) {
-            case MagnesiumPathArgument.AID_COUNT_1B:
-                return readAugmentationIdentifier(input.readUnsignedByte());
-            case MagnesiumPathArgument.AID_COUNT_2B:
-                return readAugmentationIdentifier(input.readUnsignedShort());
-            case MagnesiumPathArgument.AID_COUNT_4B:
-                return readAugmentationIdentifier(input.readInt());
-            default:
-                return readAugmentationIdentifier(rshift(count, MagnesiumPathArgument.AID_COUNT_SHIFT));
-        }
-    }
-
-    private AugmentationIdentifier readAugmentationIdentifier(final int size) throws IOException {
-        if (size > 0) {
-            final List<QName> qnames = new ArrayList<>(size);
-            for (int i = 0; i < size; ++i) {
-                qnames.add(readQName());
-            }
-            return AugmentationIdentifier.create(ImmutableSet.copyOf(qnames));
-        } else if (size == 0) {
-            return EMPTY_AID;
-        } else {
-            throw new InvalidNormalizedNodeStreamException("Invalid augmentation identifier size " + size);
-        }
-    }
-
-    private NodeIdentifier readNodeIdentifier() throws IOException {
-        return decodeNodeIdentifier();
-    }
-
-    private NodeIdentifier readNodeIdentifier(final byte header) throws IOException {
-        switch (header & MagnesiumPathArgument.QNAME_MASK) {
-            case MagnesiumPathArgument.QNAME_DEF:
-                return decodeNodeIdentifier();
-            case MagnesiumPathArgument.QNAME_REF_1B:
-                return decodeNodeIdentifierRef1();
-            case MagnesiumPathArgument.QNAME_REF_2B:
-                return decodeNodeIdentifierRef2();
-            case MagnesiumPathArgument.QNAME_REF_4B:
-                return decodeNodeIdentifierRef4();
-            default:
-                throw new InvalidNormalizedNodeStreamException("Invalid QName coding in " + header);
-        }
-    }
-
-    private NodeIdentifierWithPredicates readNodeIdentifierWithPredicates(final byte header) throws IOException {
-        final QName qname = readNodeIdentifier(header).getNodeType();
-        switch (mask(header, MagnesiumPathArgument.SIZE_MASK)) {
-            case MagnesiumPathArgument.SIZE_1B:
-                return readNodeIdentifierWithPredicates(qname, input.readUnsignedByte());
-            case MagnesiumPathArgument.SIZE_2B:
-                return readNodeIdentifierWithPredicates(qname, input.readUnsignedShort());
-            case MagnesiumPathArgument.SIZE_4B:
-                return readNodeIdentifierWithPredicates(qname, input.readInt());
-            default:
-                return readNodeIdentifierWithPredicates(qname, rshift(header, MagnesiumPathArgument.SIZE_SHIFT));
-        }
-    }
-
-    private NodeIdentifierWithPredicates readNodeIdentifierWithPredicates(final QName qname, final int size)
-            throws IOException {
-        if (size == 1) {
-            return NodeIdentifierWithPredicates.of(qname, readQName(), readLeafValue());
-        } else if (size > 1) {
-            final ImmutableMap.Builder<QName, Object> builder = ImmutableMap.builderWithExpectedSize(size);
-            for (int i = 0; i < size; ++i) {
-                builder.put(readQName(), readLeafValue());
-            }
-            return NodeIdentifierWithPredicates.of(qname, builder.build());
-        } else if (size == 0) {
-            return NodeIdentifierWithPredicates.of(qname);
-        } else {
-            throw new InvalidNormalizedNodeStreamException("Invalid predicate count " + size);
-        }
-    }
-
-    private NodeWithValue<?> readNodeWithValue(final byte header) throws IOException {
-        final QName qname = readNodeIdentifier(header).getNodeType();
-        return new NodeWithValue<>(qname, readLeafValue());
-    }
-
-    private static void verifyPathIdentifierOnly(final byte header) throws InvalidNormalizedNodeStreamException {
-        if (mask(header, MagnesiumPathArgument.SIZE_MASK) != 0) {
-            throw new InvalidNormalizedNodeStreamException("Invalid path argument header " + header);
-        }
-    }
-
-    private @NonNull NodeIdentifier decodeNodeIdentifierRef1() throws IOException {
-        return lookupNodeIdentifier(input.readUnsignedByte());
-    }
-
-    private @NonNull NodeIdentifier decodeNodeIdentifierRef2() throws IOException {
-        return lookupNodeIdentifier(input.readUnsignedShort() + 256);
-    }
-
-    private @NonNull NodeIdentifier decodeNodeIdentifierRef4() throws IOException {
-        return lookupNodeIdentifier(input.readInt());
-    }
-
-    private @NonNull QName decodeQName() throws IOException {
-        return decodeNodeIdentifier().getNodeType();
-    }
-
-    private @NonNull QName decodeQNameRef1() throws IOException {
-        return lookupQName(input.readUnsignedByte());
-    }
-
-    private @NonNull QName decodeQNameRef2() throws IOException {
-        return lookupQName(input.readUnsignedShort() + 256);
-    }
-
-    private @NonNull QName decodeQNameRef4() throws IOException {
-        return lookupQName(input.readInt());
-    }
-
-    private @NonNull QNameModule decodeQNameModule() throws IOException {
-        final byte type = input.readByte();
-        final int index;
-        switch (type) {
-            case MagnesiumValue.MODREF_1B:
-                index = input.readUnsignedByte();
-                break;
-            case MagnesiumValue.MODREF_2B:
-                index = input.readUnsignedShort() + 256;
-                break;
-            case MagnesiumValue.MODREF_4B:
-                index = input.readInt();
-                break;
-            default:
-                return decodeQNameModuleDef(type);
-        }
-
-        try {
-            return codedModules.get(index);
-        } catch (IndexOutOfBoundsException e) {
-            throw new InvalidNormalizedNodeStreamException("Invalid QNameModule reference " + index, e);
-        }
-    }
-
-    // QNameModule definition, i.e. two encoded strings
-    private @NonNull QNameModule decodeQNameModuleDef(final byte type) throws IOException {
-        final String namespace = readRefString(type);
-
-        final byte refType = input.readByte();
-        final String revision = refType == MagnesiumValue.STRING_EMPTY ? null : readRefString(refType);
-        final QNameModule module;
-        try {
-            module = QNameFactory.createModule(namespace, revision);
-        } catch (UncheckedExecutionException e) {
-            throw new InvalidNormalizedNodeStreamException("Illegal QNameModule ns=" + namespace + " rev=" + revision,
-                e);
-        }
-
-        codedModules.add(module);
-        return module;
-    }
-
-    private @NonNull String readRefString() throws IOException {
-        return readRefString(input.readByte());
-    }
-
-    private @NonNull String readRefString(final byte type) throws IOException {
-        final String str;
-        switch (type) {
-            case MagnesiumValue.STRING_REF_1B:
-                return lookupString(input.readUnsignedByte());
-            case MagnesiumValue.STRING_REF_2B:
-                return lookupString(input.readUnsignedShort() + 256);
-            case MagnesiumValue.STRING_REF_4B:
-                return lookupString(input.readInt());
-            case MagnesiumValue.STRING_EMPTY:
-                return "";
-            case MagnesiumValue.STRING_2B:
-                str = readString2();
-                break;
-            case MagnesiumValue.STRING_4B:
-                str = readString4();
-                break;
-            case MagnesiumValue.STRING_CHARS:
-                str = readCharsString();
-                break;
-            case MagnesiumValue.STRING_UTF:
-                str = input.readUTF();
-                break;
-            default:
-                throw new InvalidNormalizedNodeStreamException("Unexpected String type " + type);
-        }
-
-        // TODO: consider interning Strings -- that would help with bits, but otherwise it's probably not worth it
-        codedStrings.add(verifyNotNull(str));
-        return str;
-    }
-
-    private @NonNull String readString() throws IOException {
-        final byte type = input.readByte();
-        switch (type) {
-            case MagnesiumValue.STRING_EMPTY:
-                return "";
-            case MagnesiumValue.STRING_UTF:
-                return input.readUTF();
-            case MagnesiumValue.STRING_2B:
-                return readString2();
-            case MagnesiumValue.STRING_4B:
-                return readString4();
-            case MagnesiumValue.STRING_CHARS:
-                return readCharsString();
-            default:
-                throw new InvalidNormalizedNodeStreamException("Unexpected String type " + type);
-        }
-    }
-
-    private @NonNull String readString2() throws IOException {
-        return readByteString(input.readUnsignedShort());
-    }
-
-    private @NonNull String readString4() throws IOException {
-        return readByteString(input.readInt());
-    }
-
-    private @NonNull String readByteString(final int size) throws IOException {
-        if (size > 0) {
-            final byte[] bytes = new byte[size];
-            input.readFully(bytes);
-            return new String(bytes, StandardCharsets.UTF_8);
-        } else if (size == 0) {
-            return "";
-        } else {
-            throw new InvalidNormalizedNodeStreamException("Invalid String bytes length " + size);
-        }
-    }
-
-    private @NonNull String readCharsString() throws IOException {
-        final int size = input.readInt();
-        if (size > 0) {
-            final char[] chars = new char[size];
-            for (int i = 0; i < size; ++i) {
-                chars[i] = input.readChar();
-            }
-            return String.valueOf(chars);
-        } else if (size == 0) {
-            return "";
-        } else {
-            throw new InvalidNormalizedNodeStreamException("Invalid String chars length " + size);
-        }
-    }
-
-    private @NonNull NodeIdentifier lookupNodeIdentifier(final int index) throws InvalidNormalizedNodeStreamException {
-        try {
-            return codedNodeIdentifiers.get(index);
-        } catch (IndexOutOfBoundsException e) {
-            throw new InvalidNormalizedNodeStreamException("Invalid QName reference " + index, e);
-        }
-    }
-
-    private @NonNull QName lookupQName(final int index) throws InvalidNormalizedNodeStreamException {
-        return lookupNodeIdentifier(index).getNodeType();
-    }
-
-    private @NonNull String lookupString(final int index) throws InvalidNormalizedNodeStreamException {
-        try {
-            return codedStrings.get(index);
-        } catch (IndexOutOfBoundsException e) {
-            throw new InvalidNormalizedNodeStreamException("Invalid String reference " + index, e);
-        }
-    }
-
-    private @NonNull DOMSource readDOMSource() throws IOException {
-        final String str = readString();
-        try {
-            return new DOMSource(UntrustedXML.newDocumentBuilder().parse(new InputSource(new StringReader(str)))
-                .getDocumentElement());
-        } catch (SAXException e) {
-            throw new IOException("Error parsing XML: " + str, e);
-        }
-    }
-
-    private @NonNull Object readLeafValue() throws IOException {
-        final byte type = input.readByte();
-        switch (type) {
-            case MagnesiumValue.BOOLEAN_FALSE:
-                return Boolean.FALSE;
-            case MagnesiumValue.BOOLEAN_TRUE:
-                return Boolean.TRUE;
-            case MagnesiumValue.EMPTY:
-                return Empty.getInstance();
-            case MagnesiumValue.INT8:
-                return input.readByte();
-            case MagnesiumValue.INT8_0:
-                return INT8_0;
-            case MagnesiumValue.INT16:
-                return input.readShort();
-            case MagnesiumValue.INT16_0:
-                return INT16_0;
-            case MagnesiumValue.INT32:
-                return input.readInt();
-            case MagnesiumValue.INT32_0:
-                return INT32_0;
-            case MagnesiumValue.INT32_2B:
-                return input.readShort() & 0xFFFF;
-            case MagnesiumValue.INT64:
-                return input.readLong();
-            case MagnesiumValue.INT64_0:
-                return INT64_0;
-            case MagnesiumValue.INT64_4B:
-                return input.readInt() & 0xFFFFFFFFL;
-            case MagnesiumValue.UINT8:
-                return Uint8.fromByteBits(input.readByte());
-            case MagnesiumValue.UINT8_0:
-                return UINT8_0;
-            case MagnesiumValue.UINT16:
-                return Uint16.fromShortBits(input.readShort());
-            case MagnesiumValue.UINT16_0:
-                return UINT16_0;
-            case MagnesiumValue.UINT32:
-                return Uint32.fromIntBits(input.readInt());
-            case MagnesiumValue.UINT32_0:
-                return UINT32_0;
-            case MagnesiumValue.UINT32_2B:
-                return Uint32.fromIntBits(input.readShort() & 0xFFFF);
-            case MagnesiumValue.UINT64:
-                return Uint64.fromLongBits(input.readLong());
-            case MagnesiumValue.UINT64_0:
-                return UINT64_0;
-            case MagnesiumValue.UINT64_4B:
-                return Uint64.fromLongBits(input.readInt() & 0xFFFFFFFFL);
-            case MagnesiumValue.BIGDECIMAL:
-                // FIXME: use string -> BigDecimal cache
-                return new BigDecimal(input.readUTF());
-            case MagnesiumValue.BIGINTEGER:
-                return readBigInteger();
-            case MagnesiumValue.STRING_EMPTY:
-                return "";
-            case MagnesiumValue.STRING_UTF:
-                return input.readUTF();
-            case MagnesiumValue.STRING_2B:
-                return readString2();
-            case MagnesiumValue.STRING_4B:
-                return readString4();
-            case MagnesiumValue.STRING_CHARS:
-                return readCharsString();
-            case MagnesiumValue.BINARY_0:
-                return BINARY_0;
-            case MagnesiumValue.BINARY_1B:
-                return readBinary(128 + input.readUnsignedByte());
-            case MagnesiumValue.BINARY_2B:
-                return readBinary(384 + input.readUnsignedShort());
-            case MagnesiumValue.BINARY_4B:
-                return readBinary(input.readInt());
-            case MagnesiumValue.YIID_0:
-                return YangInstanceIdentifier.empty();
-            case MagnesiumValue.YIID:
-                return readYangInstanceIdentifier(input.readInt());
-            case MagnesiumValue.QNAME:
-                return decodeQName();
-            case MagnesiumValue.QNAME_REF_1B:
-                return decodeQNameRef1();
-            case MagnesiumValue.QNAME_REF_2B:
-                return decodeQNameRef2();
-            case MagnesiumValue.QNAME_REF_4B:
-                return decodeQNameRef4();
-            case MagnesiumValue.BITS_0:
-                return ImmutableSet.of();
-            case MagnesiumValue.BITS_1B:
-                return readBits(input.readUnsignedByte() + 29);
-            case MagnesiumValue.BITS_2B:
-                return readBits(input.readUnsignedShort() + 285);
-            case MagnesiumValue.BITS_4B:
-                return readBits(input.readInt());
-
-            default:
-                if (type > MagnesiumValue.BINARY_0 && type <= MagnesiumValue.BINARY_127) {
-                    return readBinary(type - MagnesiumValue.BINARY_0);
-                } else if (type > MagnesiumValue.BITS_0 && type < MagnesiumValue.BITS_1B) {
-                    return readBits(type - MagnesiumValue.BITS_0);
-                } else if (type > MagnesiumValue.YIID_0) {
-                    // Note 'byte' is range limited, so it is always '&& type <= MagnesiumValue.YIID_31'
-                    return readYangInstanceIdentifier(type - MagnesiumValue.YIID_0);
-                } else {
-                    throw new InvalidNormalizedNodeStreamException("Invalid value type " + type);
-                }
-        }
-    }
-
-    abstract @NonNull BigInteger readBigInteger() throws IOException;
-
-    private byte @NonNull [] readBinary(final int size) throws IOException {
-        if (size > 0) {
-            final byte[] ret = new byte[size];
-            input.readFully(ret);
-            return ret;
-        } else if (size == 0) {
-            return BINARY_0;
-        } else {
-            throw new InvalidNormalizedNodeStreamException("Invalid binary length " + size);
-        }
-    }
-
-    private @NonNull ImmutableSet<String> readBits(final int size) throws IOException {
-        if (size > 0) {
-            final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
-            for (int i = 0; i < size; ++i) {
-                builder.add(readRefString());
-            }
-            return builder.build();
-        } else if (size == 0) {
-            return ImmutableSet.of();
-        } else {
-            throw new InvalidNormalizedNodeStreamException("Invalid bits length " + size);
-        }
-    }
-
-    private static byte mask(final byte header, final byte mask) {
-        return (byte) (header & mask);
-    }
-
-    private static int rshift(final byte header, final byte shift) {
-        return (header & 0xFF) >>> shift;
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractMagnesiumDataOutput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractMagnesiumDataOutput.java
deleted file mode 100644 (file)
index 3f28f06..0000000
+++ /dev/null
@@ -1,694 +0,0 @@
-/*
- * 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 static com.google.common.base.Preconditions.checkArgument;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Optional;
-import java.util.Set;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.rfc8528.data.api.MountPointIdentifier;
-import org.opendaylight.yangtools.yang.common.Empty;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.common.Uint16;
-import org.opendaylight.yangtools.yang.common.Uint32;
-import org.opendaylight.yangtools.yang.common.Uint64;
-import org.opendaylight.yangtools.yang.common.Uint8;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract base class for NormalizedNodeDataOutput based on {@link MagnesiumNode}, {@link MagnesiumPathArgument} and
- * {@link MagnesiumValue}.
- */
-abstract class AbstractMagnesiumDataOutput extends AbstractNormalizedNodeDataOutput {
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractMagnesiumDataOutput.class);
-
-    // Marker for encoding state when we have entered startLeafNode() within a startMapEntry() and that leaf corresponds
-    // to a key carried within NodeIdentifierWithPredicates.
-    private static final Object KEY_LEAF_STATE = new Object();
-    // Marker for nodes which have simple content and do not use END_NODE marker to terminate
-    private static final Object NO_ENDNODE_STATE = new Object();
-
-    private static final TransformerFactory TF = TransformerFactory.newInstance();
-
-    /**
-     * Stack tracking encoding state. In general we track the node identifier of the currently-open element, but there
-     * are a few other circumstances where we push other objects. See {@link #KEY_LEAF_STATE} and
-     * {@link #NO_ENDNODE_STATE}.
-     */
-    private final Deque<Object> stack = new ArrayDeque<>();
-
-    // Coding maps
-    private final Map<AugmentationIdentifier, Integer> aidCodeMap = new HashMap<>();
-    private final Map<QNameModule, Integer> moduleCodeMap = new HashMap<>();
-    private final Map<String, Integer> stringCodeMap = new HashMap<>();
-    private final Map<QName, Integer> qnameCodeMap = new HashMap<>();
-
-    AbstractMagnesiumDataOutput(final DataOutput output) {
-        super(output);
-    }
-
-    @Override
-    public final void startLeafNode(final NodeIdentifier name) throws IOException {
-        final Object current = stack.peek();
-        if (current instanceof NodeIdentifierWithPredicates) {
-            final QName qname = name.getNodeType();
-            if (((NodeIdentifierWithPredicates) current).containsKey(qname)) {
-                writeQNameNode(MagnesiumNode.NODE_LEAF | MagnesiumNode.PREDICATE_ONE, qname);
-                stack.push(KEY_LEAF_STATE);
-                return;
-            }
-        }
-
-        startSimpleNode(MagnesiumNode.NODE_LEAF, name);
-    }
-
-    @Override
-    public final void startLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startQNameNode(MagnesiumNode.NODE_LEAFSET, name);
-    }
-
-    @Override
-    public final void startOrderedLeafSet(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startQNameNode(MagnesiumNode.NODE_LEAFSET_ORDERED, name);
-    }
-
-    @Override
-    public final void startLeafSetEntryNode(final NodeWithValue<?> name) throws IOException {
-        if (matchesParentQName(name.getNodeType())) {
-            output.writeByte(MagnesiumNode.NODE_LEAFSET_ENTRY);
-            stack.push(NO_ENDNODE_STATE);
-        } else {
-            startSimpleNode(MagnesiumNode.NODE_LEAFSET_ENTRY, name);
-        }
-    }
-
-    @Override
-    public final void startContainerNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startQNameNode(MagnesiumNode.NODE_CONTAINER, name);
-    }
-
-    @Override
-    public final void startUnkeyedList(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startQNameNode(MagnesiumNode.NODE_LIST, name);
-    }
-
-    @Override
-    public final void startUnkeyedListItem(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startInheritedNode(MagnesiumNode.NODE_LIST_ENTRY, name);
-    }
-
-    @Override
-    public final void startMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startQNameNode(MagnesiumNode.NODE_MAP, name);
-    }
-
-    @Override
-    public final void startMapEntryNode(final NodeIdentifierWithPredicates identifier, final int childSizeHint)
-            throws IOException {
-        final int size = identifier.size();
-        if (size == 1) {
-            startInheritedNode((byte) (MagnesiumNode.NODE_MAP_ENTRY | MagnesiumNode.PREDICATE_ONE), identifier);
-        } else if (size == 0) {
-            startInheritedNode((byte) (MagnesiumNode.NODE_MAP_ENTRY | MagnesiumNode.PREDICATE_ZERO), identifier);
-        } else if (size < 256) {
-            startInheritedNode((byte) (MagnesiumNode.NODE_MAP_ENTRY | MagnesiumNode.PREDICATE_1B), identifier);
-            output.writeByte(size);
-        } else {
-            startInheritedNode((byte) (MagnesiumNode.NODE_MAP_ENTRY | MagnesiumNode.PREDICATE_4B), identifier);
-            output.writeInt(size);
-        }
-
-        writePredicates(identifier);
-    }
-
-    @Override
-    public final void startOrderedMapNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startQNameNode(MagnesiumNode.NODE_MAP_ORDERED, name);
-    }
-
-    @Override
-    public final void startChoiceNode(final NodeIdentifier name, final int childSizeHint) throws IOException {
-        startQNameNode(MagnesiumNode.NODE_CHOICE, name);
-    }
-
-    @Override
-    public final void startAugmentationNode(final AugmentationIdentifier identifier) throws IOException {
-        final Integer code = aidCodeMap.get(identifier);
-        if (code == null) {
-            aidCodeMap.put(identifier, aidCodeMap.size());
-            output.writeByte(MagnesiumNode.NODE_AUGMENTATION | MagnesiumNode.ADDR_DEFINE);
-            final Set<QName> qnames = identifier.getPossibleChildNames();
-            output.writeInt(qnames.size());
-            for (QName qname : qnames) {
-                writeQNameInternal(qname);
-            }
-        } else {
-            writeNodeType(MagnesiumNode.NODE_AUGMENTATION, code);
-        }
-        stack.push(identifier);
-    }
-
-    @Override
-    public final boolean startAnyxmlNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
-        if (DOMSource.class.isAssignableFrom(objectModel)) {
-            startSimpleNode(MagnesiumNode.NODE_ANYXML, name);
-            return true;
-        }
-        return false;
-    }
-
-    @Override
-    public final void domSourceValue(final DOMSource value) throws IOException {
-        final StringWriter writer = new StringWriter();
-        try {
-            TF.newTransformer().transform(value, new StreamResult(writer));
-        } catch (TransformerException e) {
-            throw new IOException("Error writing anyXml", e);
-        }
-        writeValue(writer.toString());
-    }
-
-    @Override
-    public final void startYangModeledAnyXmlNode(final NodeIdentifier name, final int childSizeHint)
-            throws IOException {
-        // FIXME: implement this
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public final void endNode() throws IOException {
-        if (stack.pop() instanceof PathArgument) {
-            output.writeByte(MagnesiumNode.NODE_END);
-        }
-    }
-
-    @Override
-    public final void scalarValue(final Object value) throws IOException {
-        if (KEY_LEAF_STATE.equals(stack.peek())) {
-            LOG.trace("Inside a map entry key leaf, not emitting value {}", value);
-        } else {
-            writeObject(value);
-        }
-    }
-
-    @Override
-    final void writeQNameInternal(final QName qname) throws IOException {
-        final Integer code = qnameCodeMap.get(qname);
-        if (code == null) {
-            output.writeByte(MagnesiumValue.QNAME);
-            encodeQName(qname);
-        } else {
-            writeQNameRef(code);
-        }
-    }
-
-    @Override
-    final void writePathArgumentInternal(final PathArgument pathArgument) throws IOException {
-        if (pathArgument instanceof NodeIdentifier) {
-            writeNodeIdentifier((NodeIdentifier) pathArgument);
-        } else if (pathArgument instanceof NodeIdentifierWithPredicates) {
-            writeNodeIdentifierWithPredicates((NodeIdentifierWithPredicates) pathArgument);
-        } else if (pathArgument instanceof AugmentationIdentifier) {
-            writeAugmentationIdentifier((AugmentationIdentifier) pathArgument);
-        } else if (pathArgument instanceof NodeWithValue) {
-            writeNodeWithValue((NodeWithValue<?>) pathArgument);
-        } else if (pathArgument instanceof MountPointIdentifier) {
-            writeMountPointIdentifier((MountPointIdentifier) pathArgument);
-        } else {
-            throw new IOException("Unhandled PathArgument " + pathArgument);
-        }
-    }
-
-    private void writeAugmentationIdentifier(final AugmentationIdentifier identifier) throws IOException {
-        final Set<QName> qnames = identifier.getPossibleChildNames();
-        final int size = qnames.size();
-        if (size < 29) {
-            output.writeByte(MagnesiumPathArgument.AUGMENTATION_IDENTIFIER
-                | size << MagnesiumPathArgument.AID_COUNT_SHIFT);
-        } else if (size < 256) {
-            output.writeByte(MagnesiumPathArgument.AUGMENTATION_IDENTIFIER | MagnesiumPathArgument.AID_COUNT_1B);
-            output.writeByte(size);
-        } else if (size < 65536) {
-            output.writeByte(MagnesiumPathArgument.AUGMENTATION_IDENTIFIER | MagnesiumPathArgument.AID_COUNT_2B);
-            output.writeShort(size);
-        } else {
-            output.writeByte(MagnesiumPathArgument.AUGMENTATION_IDENTIFIER | MagnesiumPathArgument.AID_COUNT_4B);
-            output.writeInt(size);
-        }
-
-        for (QName qname : qnames) {
-            writeQNameInternal(qname);
-        }
-    }
-
-    private void writeNodeIdentifier(final NodeIdentifier identifier) throws IOException {
-        writePathArgumentQName(identifier.getNodeType(), MagnesiumPathArgument.NODE_IDENTIFIER);
-    }
-
-    private void writeMountPointIdentifier(final MountPointIdentifier identifier) throws IOException {
-        writePathArgumentQName(identifier.getNodeType(), MagnesiumPathArgument.MOUNTPOINT_IDENTIFIER);
-    }
-
-    private void writeNodeIdentifierWithPredicates(final NodeIdentifierWithPredicates identifier) throws IOException {
-        final int size = identifier.size();
-        if (size < 5) {
-            writePathArgumentQName(identifier.getNodeType(),
-                (byte) (MagnesiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES
-                        | size << MagnesiumPathArgument.SIZE_SHIFT));
-        } else if (size < 256) {
-            writePathArgumentQName(identifier.getNodeType(),
-                (byte) (MagnesiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES | MagnesiumPathArgument.SIZE_1B));
-            output.writeByte(size);
-        } else if (size < 65536) {
-            writePathArgumentQName(identifier.getNodeType(),
-                (byte) (MagnesiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES | MagnesiumPathArgument.SIZE_2B));
-            output.writeShort(size);
-        } else {
-            writePathArgumentQName(identifier.getNodeType(),
-                (byte) (MagnesiumPathArgument.NODE_IDENTIFIER_WITH_PREDICATES | MagnesiumPathArgument.SIZE_4B));
-            output.writeInt(size);
-        }
-
-        writePredicates(identifier);
-    }
-
-    private void writePredicates(final NodeIdentifierWithPredicates identifier) throws IOException {
-        for (Entry<QName, Object> e : identifier.entrySet()) {
-            writeQNameInternal(e.getKey());
-            writeObject(e.getValue());
-        }
-    }
-
-    private void writeNodeWithValue(final NodeWithValue<?> identifier) throws IOException {
-        writePathArgumentQName(identifier.getNodeType(), MagnesiumPathArgument.NODE_WITH_VALUE);
-        writeObject(identifier.getValue());
-    }
-
-    private void writePathArgumentQName(final QName qname, final byte typeHeader) throws IOException {
-        final Integer code = qnameCodeMap.get(qname);
-        if (code != null) {
-            final int val = code;
-            if (val < 256) {
-                output.writeByte(typeHeader | MagnesiumPathArgument.QNAME_REF_1B);
-                output.writeByte(val);
-            } else if (val < 65792) {
-                output.writeByte(typeHeader | MagnesiumPathArgument.QNAME_REF_2B);
-                output.writeShort(val - 256);
-            } else {
-                output.writeByte(typeHeader | MagnesiumPathArgument.QNAME_REF_4B);
-                output.writeInt(val);
-            }
-        } else {
-            // implied '| MagnesiumPathArgument.QNAME_DEF'
-            output.writeByte(typeHeader);
-            encodeQName(qname);
-        }
-    }
-
-    @Override
-    final void writeYangInstanceIdentifierInternal(final YangInstanceIdentifier identifier) throws IOException {
-        writeValue(identifier);
-    }
-
-    private void writeObject(final @NonNull Object value) throws IOException {
-        if (value instanceof String) {
-            writeValue((String) value);
-        } else if (value instanceof Boolean) {
-            writeValue((Boolean) value);
-        } else if (value instanceof Byte) {
-            writeValue((Byte) value);
-        } else if (value instanceof Short) {
-            writeValue((Short) value);
-        } else if (value instanceof Integer) {
-            writeValue((Integer) value);
-        } else if (value instanceof Long) {
-            writeValue((Long) value);
-        } else if (value instanceof Uint8) {
-            writeValue((Uint8) value);
-        } else if (value instanceof Uint16) {
-            writeValue((Uint16) value);
-        } else if (value instanceof Uint32) {
-            writeValue((Uint32) value);
-        } else if (value instanceof Uint64) {
-            writeValue((Uint64) value);
-        } else if (value instanceof QName) {
-            writeQNameInternal((QName) value);
-        } else if (value instanceof YangInstanceIdentifier) {
-            writeValue((YangInstanceIdentifier) value);
-        } else if (value instanceof byte[]) {
-            writeValue((byte[]) value);
-        } else if (value instanceof Empty) {
-            output.writeByte(MagnesiumValue.EMPTY);
-        } else if (value instanceof Set) {
-            writeValue((Set<?>) value);
-        } else if (value instanceof BigDecimal) {
-            writeValue((BigDecimal) value);
-        } else if (value instanceof BigInteger) {
-            writeValue((BigInteger) value);
-        } else {
-            throw new IOException("Unhandled value type " + value.getClass());
-        }
-    }
-
-    private void writeValue(final boolean value) throws IOException {
-        output.writeByte(value ? MagnesiumValue.BOOLEAN_TRUE : MagnesiumValue.BOOLEAN_FALSE);
-    }
-
-    private void writeValue(final byte value) throws IOException {
-        if (value != 0) {
-            output.writeByte(MagnesiumValue.INT8);
-            output.writeByte(value);
-        } else {
-            output.writeByte(MagnesiumValue.INT8_0);
-        }
-    }
-
-    private void writeValue(final short value) throws IOException {
-        if (value != 0) {
-            output.writeByte(MagnesiumValue.INT16);
-            output.writeShort(value);
-        } else {
-            output.writeByte(MagnesiumValue.INT16_0);
-        }
-    }
-
-    private void writeValue(final int value) throws IOException {
-        if ((value & 0xFFFF0000) != 0) {
-            output.writeByte(MagnesiumValue.INT32);
-            output.writeInt(value);
-        } else if (value != 0) {
-            output.writeByte(MagnesiumValue.INT32_2B);
-            output.writeShort(value);
-        } else {
-            output.writeByte(MagnesiumValue.INT32_0);
-        }
-    }
-
-    private void writeValue(final long value) throws IOException {
-        if ((value & 0xFFFFFFFF00000000L) != 0) {
-            output.writeByte(MagnesiumValue.INT64);
-            output.writeLong(value);
-        } else if (value != 0) {
-            output.writeByte(MagnesiumValue.INT64_4B);
-            output.writeInt((int) value);
-        } else {
-            output.writeByte(MagnesiumValue.INT64_0);
-        }
-    }
-
-    private void writeValue(final Uint8 value) throws IOException {
-        final byte b = value.byteValue();
-        if (b != 0) {
-            output.writeByte(MagnesiumValue.UINT8);
-            output.writeByte(b);
-        } else {
-            output.writeByte(MagnesiumValue.UINT8_0);
-        }
-    }
-
-    private void writeValue(final Uint16 value) throws IOException {
-        final short s = value.shortValue();
-        if (s != 0) {
-            output.writeByte(MagnesiumValue.UINT16);
-            output.writeShort(s);
-        } else {
-            output.writeByte(MagnesiumValue.UINT16_0);
-        }
-    }
-
-    private void writeValue(final Uint32 value) throws IOException {
-        final int i = value.intValue();
-        if ((i & 0xFFFF0000) != 0) {
-            output.writeByte(MagnesiumValue.UINT32);
-            output.writeInt(i);
-        } else if (i != 0) {
-            output.writeByte(MagnesiumValue.UINT32_2B);
-            output.writeShort(i);
-        } else {
-            output.writeByte(MagnesiumValue.UINT32_0);
-        }
-    }
-
-    private void writeValue(final Uint64 value) throws IOException {
-        final long l = value.longValue();
-        if ((l & 0xFFFFFFFF00000000L) != 0) {
-            output.writeByte(MagnesiumValue.UINT64);
-            output.writeLong(l);
-        } else if (l != 0) {
-            output.writeByte(MagnesiumValue.UINT64_4B);
-            output.writeInt((int) l);
-        } else {
-            output.writeByte(MagnesiumValue.UINT64_0);
-        }
-    }
-
-    private void writeValue(final BigDecimal value) throws IOException {
-        output.writeByte(MagnesiumValue.BIGDECIMAL);
-        output.writeUTF(value.toString());
-    }
-
-    abstract void writeValue(BigInteger value) throws IOException;
-
-    private void writeValue(final String value) throws IOException {
-        if (value.isEmpty()) {
-            output.writeByte(MagnesiumValue.STRING_EMPTY);
-        } else if (value.length() <= Short.MAX_VALUE / 2) {
-            output.writeByte(MagnesiumValue.STRING_UTF);
-            output.writeUTF(value);
-        } else if (value.length() <= 1048576) {
-            final byte[] bytes = value.getBytes(StandardCharsets.UTF_8);
-            if (bytes.length < 65536) {
-                output.writeByte(MagnesiumValue.STRING_2B);
-                output.writeShort(bytes.length);
-            } else {
-                output.writeByte(MagnesiumValue.STRING_4B);
-                output.writeInt(bytes.length);
-            }
-            output.write(bytes);
-        } else {
-            output.writeByte(MagnesiumValue.STRING_CHARS);
-            output.writeInt(value.length());
-            output.writeChars(value);
-        }
-    }
-
-    private void writeValue(final byte[] value) throws IOException {
-        if (value.length < 128) {
-            output.writeByte(MagnesiumValue.BINARY_0 + value.length);
-        } else if (value.length < 384) {
-            output.writeByte(MagnesiumValue.BINARY_1B);
-            output.writeByte(value.length - 128);
-        } else if (value.length < 65920) {
-            output.writeByte(MagnesiumValue.BINARY_2B);
-            output.writeShort(value.length - 384);
-        } else {
-            output.writeByte(MagnesiumValue.BINARY_4B);
-            output.writeInt(value.length);
-        }
-        output.write(value);
-    }
-
-    private void writeValue(final YangInstanceIdentifier value) throws IOException {
-        final List<PathArgument> args = value.getPathArguments();
-        final int size = args.size();
-        if (size > 31) {
-            output.writeByte(MagnesiumValue.YIID);
-            output.writeInt(size);
-        } else {
-            output.writeByte(MagnesiumValue.YIID_0 + size);
-        }
-        for (PathArgument arg : args) {
-            writePathArgumentInternal(arg);
-        }
-    }
-
-    private void writeValue(final Set<?> value) throws IOException {
-        final int size = value.size();
-        if (size < 29) {
-            output.writeByte(MagnesiumValue.BITS_0 + size);
-        } else if (size < 285) {
-            output.writeByte(MagnesiumValue.BITS_1B);
-            output.writeByte(size - 29);
-        } else if (size < 65821) {
-            output.writeByte(MagnesiumValue.BITS_2B);
-            output.writeShort(size - 285);
-        } else {
-            output.writeByte(MagnesiumValue.BITS_4B);
-            output.writeInt(size);
-        }
-
-        for (Object bit : value) {
-            checkArgument(bit instanceof String, "Expected value type to be String but was %s", bit);
-            encodeString((String) bit);
-        }
-    }
-
-    // Check if the proposed QName matches the parent. This is only effective if the parent is identified by
-    // NodeIdentifier -- which is typically true
-    private boolean matchesParentQName(final QName qname) {
-        final Object current = stack.peek();
-        return current instanceof NodeIdentifier && qname.equals(((NodeIdentifier) current).getNodeType());
-    }
-
-    // Start an END_NODE-terminated node, which typically has a QName matching the parent. If that is the case we emit
-    // a parent reference instead of an explicit QName reference -- saving at least one byte
-    private void startInheritedNode(final byte type, final PathArgument name) throws IOException {
-        final QName qname = name.getNodeType();
-        if (matchesParentQName(qname)) {
-            output.write(type);
-        } else {
-            writeQNameNode(type, qname);
-        }
-        stack.push(name);
-    }
-
-    // Start an END_NODE-terminated node, which needs its QName encoded
-    private void startQNameNode(final byte type, final PathArgument name) throws IOException {
-        writeQNameNode(type, name.getNodeType());
-        stack.push(name);
-    }
-
-    // Start a simple node, which is not terminated through END_NODE and encode its QName
-    private void startSimpleNode(final byte type, final PathArgument name) throws IOException {
-        writeQNameNode(type, name.getNodeType());
-        stack.push(NO_ENDNODE_STATE);
-    }
-
-    // Encode a QName-based (i.e. NodeIdentifier*) node with a particular QName. This will either result in a QName
-    // definition, or a reference, where this is encoded along with the node type.
-    private void writeQNameNode(final int type, final @NonNull QName qname) throws IOException {
-        final Integer code = qnameCodeMap.get(qname);
-        if (code == null) {
-            output.writeByte(type | MagnesiumNode.ADDR_DEFINE);
-            encodeQName(qname);
-        } else {
-            writeNodeType(type, code);
-        }
-    }
-
-    // Write a node type + lookup
-    private void writeNodeType(final int type, final int code) throws IOException {
-        if (code <= 255) {
-            output.writeByte(type | MagnesiumNode.ADDR_LOOKUP_1B);
-            output.writeByte(code);
-        } else {
-            output.writeByte(type | MagnesiumNode.ADDR_LOOKUP_4B);
-            output.writeInt(code);
-        }
-    }
-
-    // Encode a QName using lookup tables, resuling either in a reference to an existing entry, or emitting two
-    // String values.
-    private void encodeQName(final @NonNull QName qname) throws IOException {
-        final Integer prev = qnameCodeMap.put(qname, qnameCodeMap.size());
-        if (prev != null) {
-            throw new IOException("Internal coding error: attempted to re-encode " + qname + "%s already encoded as "
-                    + prev);
-        }
-
-        final QNameModule module = qname.getModule();
-        final Integer code = moduleCodeMap.get(module);
-        if (code == null) {
-            moduleCodeMap.put(module, moduleCodeMap.size());
-            encodeString(module.getNamespace().toString());
-            final Optional<Revision> rev = module.getRevision();
-            if (rev.isPresent()) {
-                encodeString(rev.get().toString());
-            } else {
-                output.writeByte(MagnesiumValue.STRING_EMPTY);
-            }
-        } else {
-            writeModuleRef(code);
-        }
-        encodeString(qname.getLocalName());
-    }
-
-    // Encode a String using lookup tables, resulting either in a reference to an existing entry, or emitting as
-    // a literal value
-    private void encodeString(final @NonNull String str) throws IOException {
-        final Integer code = stringCodeMap.get(str);
-        if (code != null) {
-            writeRef(code);
-        } else {
-            stringCodeMap.put(str, stringCodeMap.size());
-            writeValue(str);
-        }
-    }
-
-    // Write a QName with a lookup table reference. This is a combination of asserting the value is a QName plus
-    // the effects of writeRef()
-    private void writeQNameRef(final int code) throws IOException {
-        final int val = code;
-        if (val < 256) {
-            output.writeByte(MagnesiumValue.QNAME_REF_1B);
-            output.writeByte(val);
-        } else if (val < 65792) {
-            output.writeByte(MagnesiumValue.QNAME_REF_2B);
-            output.writeShort(val - 256);
-        } else {
-            output.writeByte(MagnesiumValue.QNAME_REF_4B);
-            output.writeInt(val);
-        }
-    }
-
-    // Write a lookup table reference, which table is being referenced is implied by the caller
-    private void writeRef(final int code) throws IOException {
-        final int val = code;
-        if (val < 256) {
-            output.writeByte(MagnesiumValue.STRING_REF_1B);
-            output.writeByte(val);
-        } else if (val < 65792) {
-            output.writeByte(MagnesiumValue.STRING_REF_2B);
-            output.writeShort(val - 256);
-        } else {
-            output.writeByte(MagnesiumValue.STRING_REF_4B);
-            output.writeInt(val);
-        }
-    }
-
-    // Write a lookup module table reference, which table is being referenced is implied by the caller
-    private void writeModuleRef(final int code) throws IOException {
-        final int val = code;
-        if (val < 256) {
-            output.writeByte(MagnesiumValue.MODREF_1B);
-            output.writeByte(val);
-        } else if (val < 65792) {
-            output.writeByte(MagnesiumValue.MODREF_2B);
-            output.writeShort(val - 256);
-        } else {
-            output.writeByte(MagnesiumValue.MODREF_4B);
-            output.writeInt(val);
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataInput.java
deleted file mode 100644 (file)
index f6ab760..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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 static java.util.Objects.requireNonNull;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-import java.io.DataInput;
-import java.io.IOException;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-abstract class AbstractNormalizedNodeDataInput extends ForwardingDataInput implements NormalizedNodeDataInput {
-    // Visible for subclasses
-    final @NonNull DataInput input;
-
-    AbstractNormalizedNodeDataInput(final DataInput input) {
-        this.input = requireNonNull(input);
-    }
-
-    @Override
-    final DataInput delegate() {
-        return input;
-    }
-
-    @Override
-    public final SchemaPath readSchemaPath() throws IOException {
-        final boolean absolute = input.readBoolean();
-        final int size = input.readInt();
-
-        final Builder<QName> qnames = ImmutableList.builderWithExpectedSize(size);
-        for (int i = 0; i < size; ++i) {
-            qnames.add(readQName());
-        }
-        return SchemaPath.create(qnames.build(), absolute);
-    }
-
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataOutput.java
deleted file mode 100755 (executable)
index d8e021f..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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 static java.util.Objects.requireNonNull;
-
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.List;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-/**
- * Abstract base class for implementing {@link NormalizedNodeDataOutput} contract. This class uses
- * {@link NormalizedNodeStreamWriter} as an internal interface for performing the actual NormalizedNode writeout,
- * i.e. it will defer to a {@link NormalizedNodeWriter} instance.
- *
- * <p>
- * As such, this is an implementation detail not exposed from this package, hence implementations can rely on the
- * stream being initialized with a header and version.
- */
-abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOutput, NormalizedNodeStreamWriter {
-    // Visible for subclasses
-    final DataOutput output;
-
-    private NormalizedNodeWriter normalizedNodeWriter;
-    private boolean headerWritten;
-
-    AbstractNormalizedNodeDataOutput(final DataOutput output) {
-        this.output = requireNonNull(output);
-    }
-
-
-    private void ensureHeaderWritten() throws IOException {
-        if (!headerWritten) {
-            output.writeByte(TokenTypes.SIGNATURE_MARKER);
-            output.writeShort(streamVersion());
-            headerWritten = true;
-        }
-    }
-
-    @Override
-    public final void write(final int value) throws IOException {
-        ensureHeaderWritten();
-        output.write(value);
-    }
-
-    @Override
-    public final void write(final byte[] bytes) throws IOException {
-        ensureHeaderWritten();
-        output.write(bytes);
-    }
-
-    @Override
-    public final void write(final byte[] bytes, final int off, final int len) throws IOException {
-        ensureHeaderWritten();
-        output.write(bytes, off, len);
-    }
-
-    @Override
-    public final void writeBoolean(final boolean value) throws IOException {
-        ensureHeaderWritten();
-        output.writeBoolean(value);
-    }
-
-    @Override
-    public final void writeByte(final int value) throws IOException {
-        ensureHeaderWritten();
-        output.writeByte(value);
-    }
-
-    @Override
-    public final void writeShort(final int value) throws IOException {
-        ensureHeaderWritten();
-        output.writeShort(value);
-    }
-
-    @Override
-    public final void writeChar(final int value) throws IOException {
-        ensureHeaderWritten();
-        output.writeChar(value);
-    }
-
-    @Override
-    public final void writeInt(final int value) throws IOException {
-        ensureHeaderWritten();
-        output.writeInt(value);
-    }
-
-    @Override
-    public final void writeLong(final long value) throws IOException {
-        ensureHeaderWritten();
-        output.writeLong(value);
-    }
-
-    @Override
-    public final void writeFloat(final float value) throws IOException {
-        ensureHeaderWritten();
-        output.writeFloat(value);
-    }
-
-    @Override
-    public final void writeDouble(final double value) throws IOException {
-        ensureHeaderWritten();
-        output.writeDouble(value);
-    }
-
-    @Override
-    public final void writeBytes(final String str) throws IOException {
-        ensureHeaderWritten();
-        output.writeBytes(str);
-    }
-
-    @Override
-    public final void writeChars(final String str) throws IOException {
-        ensureHeaderWritten();
-        output.writeChars(str);
-    }
-
-    @Override
-    public final void writeUTF(final String str) throws IOException {
-        ensureHeaderWritten();
-        output.writeUTF(str);
-    }
-
-    @Override
-    public final void writeQName(final QName qname) throws IOException {
-        ensureHeaderWritten();
-        writeQNameInternal(qname);
-    }
-
-    @Override
-    public final void writeNormalizedNode(final NormalizedNode<?, ?> node) throws IOException {
-        ensureHeaderWritten();
-        if (normalizedNodeWriter == null) {
-            normalizedNodeWriter = NormalizedNodeWriter.forStreamWriter(this);
-        }
-        normalizedNodeWriter.write(node);
-    }
-
-    @Override
-    public final void writePathArgument(final PathArgument pathArgument) throws IOException {
-        ensureHeaderWritten();
-        writePathArgumentInternal(pathArgument);
-    }
-
-    @Override
-    public final void writeYangInstanceIdentifier(final YangInstanceIdentifier identifier) throws IOException {
-        ensureHeaderWritten();
-        writeYangInstanceIdentifierInternal(identifier);
-    }
-
-    @Override
-    public final void writeSchemaPath(final SchemaPath path) throws IOException {
-        ensureHeaderWritten();
-
-        output.writeBoolean(path.isAbsolute());
-        final List<QName> qnames = path.getPath();
-        output.writeInt(qnames.size());
-        for (QName qname : qnames) {
-            writeQNameInternal(qname);
-        }
-    }
-
-    @Override
-    public final void close() throws IOException {
-        flush();
-    }
-
-    @Override
-    public void flush() throws IOException {
-        if (output instanceof OutputStream) {
-            ((OutputStream)output).flush();
-        }
-    }
-
-    @Override
-    public final boolean startAnydataNode(final NodeIdentifier name, final Class<?> objectModel) throws IOException {
-        // FIXME: We do not support anydata nodes of any kind, yet
-        return false;
-    }
-
-    abstract short streamVersion();
-
-    abstract void writeQNameInternal(@NonNull QName qname) throws IOException;
-
-    abstract void writePathArgumentInternal(PathArgument pathArgument) throws IOException;
-
-    abstract void writeYangInstanceIdentifierInternal(YangInstanceIdentifier identifier) throws IOException;
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/CompatNormalizedNodeDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/CompatNormalizedNodeDataInput.java
new file mode 100644 (file)
index 0000000..63d253c
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * 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 static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ForwardingObject;
+import java.io.IOException;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+@Deprecated
+final class CompatNormalizedNodeDataInput extends ForwardingObject implements NormalizedNodeDataInput {
+    private final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput delegate;
+
+    CompatNormalizedNodeDataInput(
+        final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void readFully(final byte[] b) throws IOException {
+        try {
+            delegate.readFully(b);
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void readFully(final byte[] b, final int off, final int len) throws IOException {
+        try {
+            delegate.readFully(b, off, len);
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public int skipBytes(final int n) throws IOException {
+        try {
+            return delegate.skipBytes(n);
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public boolean readBoolean() throws IOException {
+        try {
+            return delegate.readBoolean();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public byte readByte() throws IOException {
+        try {
+            return delegate.readByte();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public int readUnsignedByte() throws IOException {
+        try {
+            return delegate.readUnsignedByte();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public short readShort() throws IOException {
+        try {
+            return delegate.readShort();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public int readUnsignedShort() throws IOException {
+        try {
+            return delegate.readUnsignedShort();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public char readChar() throws IOException {
+        try {
+            return delegate.readChar();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public int readInt() throws IOException {
+        try {
+            return delegate.readInt();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public long readLong() throws IOException {
+        try {
+            return delegate.readLong();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public float readFloat() throws IOException {
+        try {
+            return delegate.readFloat();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public double readDouble() throws IOException {
+        try {
+            return delegate.readDouble();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public String readLine() throws IOException {
+        try {
+            return delegate.readLine();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public String readUTF() throws IOException {
+        try {
+            return delegate.readUTF();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public void streamNormalizedNode(final NormalizedNodeStreamWriter writer) throws IOException {
+        try {
+            delegate.streamNormalizedNode(writer);
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public YangInstanceIdentifier readYangInstanceIdentifier() throws IOException {
+        try {
+            return delegate.readYangInstanceIdentifier();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public QName readQName() throws IOException {
+        try {
+            return delegate.readQName();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public PathArgument readPathArgument() throws IOException {
+        try {
+            return delegate.readPathArgument();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public SchemaPath readSchemaPath() throws IOException {
+        try {
+            return delegate.readSchemaPath();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+    }
+
+    @Override
+    public NormalizedNodeStreamVersion getVersion() throws IOException {
+        final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion version;
+        try {
+            version = delegate.getVersion();
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
+
+        switch (version) {
+            case LITHIUM:
+                return NormalizedNodeStreamVersion.LITHIUM;
+            case MAGNESIUM:
+                return NormalizedNodeStreamVersion.MAGNESIUM;
+            case NEON_SR2:
+                return NormalizedNodeStreamVersion.NEON_SR2;
+            case SODIUM_SR1:
+                return NormalizedNodeStreamVersion.SODIUM_SR1;
+            default:
+                throw new IOException("Unhandled version " + delegate.getVersion());
+        }
+    }
+
+    @Override
+    protected org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput delegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/CompatNormalizedNodeDataOutput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/CompatNormalizedNodeDataOutput.java
new file mode 100644 (file)
index 0000000..f80012a
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * 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 static java.util.Objects.requireNonNull;
+
+import com.google.common.collect.ForwardingObject;
+import java.io.IOException;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+@Deprecated
+final class CompatNormalizedNodeDataOutput extends ForwardingObject implements NormalizedNodeDataOutput {
+    private final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput delegate;
+
+    CompatNormalizedNodeDataOutput(
+        final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput delegate) {
+        this.delegate = requireNonNull(delegate);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void write(final int b) throws IOException {
+        delegate.write(b);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void write(final byte[] b) throws IOException {
+        delegate.write(b);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void write(final byte[] b, final int off, final int len) throws IOException {
+        delegate.write(b, off, len);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeBoolean(final boolean v) throws IOException {
+        delegate.writeBoolean(v);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeByte(final int v) throws IOException {
+        delegate.writeByte(v);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeShort(final int v) throws IOException {
+        delegate.writeShort(v);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeChar(final int v) throws IOException {
+        delegate.writeChar(v);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeInt(final int v) throws IOException {
+        delegate.writeInt(v);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeLong(final long v) throws IOException {
+        delegate.writeLong(v);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeFloat(final float v) throws IOException {
+        delegate.writeFloat(v);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeDouble(final double v) throws IOException {
+        delegate.writeDouble(v);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeBytes(final String s) throws IOException {
+        delegate.writeBytes(s);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeChars(final String s) throws IOException {
+        delegate.writeChars(s);
+    }
+
+    @Override
+    @SuppressWarnings("checkstyle:parameterName")
+    public void writeUTF(final String s) throws IOException {
+        delegate.writeUTF(s);
+    }
+
+    @Override
+    public void writeQName(final QName qname) throws IOException {
+        delegate.writeQName(qname);
+    }
+
+    @Override
+    public void writeNormalizedNode(final NormalizedNode<?, ?> normalizedNode) throws IOException {
+        delegate.writeNormalizedNode(normalizedNode);
+    }
+
+    @Override
+    public void writePathArgument(final PathArgument pathArgument) throws IOException {
+        delegate.writePathArgument(pathArgument);
+    }
+
+    @Override
+    public void writeYangInstanceIdentifier(final YangInstanceIdentifier identifier) throws IOException {
+        delegate.writeYangInstanceIdentifier(identifier);
+    }
+
+    @Override
+    public void writeSchemaPath(final SchemaPath path) throws IOException {
+        delegate.writeSchemaPath(path);
+    }
+
+    @Override
+    public void close() throws IOException {
+        delegate.close();
+    }
+
+    @Override
+    protected Object delegate() {
+        return delegate;
+    }
+}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ForwardingDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ForwardingDataInput.java
deleted file mode 100644 (file)
index 0ec7fbe..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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 org.eclipse.jdt.annotation.NonNull;
-
-// Not a ForwardingObject because delegate() can legally throw and we do not want redirect toString()
-abstract class ForwardingDataInput implements DataInput {
-
-    abstract @NonNull DataInput delegate() throws IOException;
-
-    @Override
-    @SuppressWarnings("checkstyle:parameterName")
-    public final void readFully(final byte[] b) throws IOException {
-        delegate().readFully(b);
-    }
-
-    @Override
-    @SuppressWarnings("checkstyle:parameterName")
-    public final void readFully(final byte[] b, final int off, final int len) throws IOException {
-        delegate().readFully(b, off, len);
-    }
-
-    @Override
-    @SuppressWarnings("checkstyle:parameterName")
-    public final int skipBytes(final int n) throws IOException {
-        return delegate().skipBytes(n);
-    }
-
-    @Override
-    public final boolean readBoolean() throws IOException {
-        return delegate().readBoolean();
-    }
-
-    @Override
-    public final byte readByte() throws IOException {
-        return delegate().readByte();
-    }
-
-    @Override
-    public final int readUnsignedByte() throws IOException {
-        return delegate().readUnsignedByte();
-    }
-
-    @Override
-    public final short readShort() throws IOException {
-        return delegate().readShort();
-    }
-
-    @Override
-    public final int readUnsignedShort() throws IOException {
-        return delegate().readUnsignedShort();
-    }
-
-    @Override
-    public final char readChar() throws IOException {
-        return delegate().readChar();
-    }
-
-    @Override
-    public final int readInt() throws IOException {
-        return delegate().readInt();
-    }
-
-    @Override
-    public final long readLong() throws IOException {
-        return delegate().readLong();
-    }
-
-    @Override
-    public final float readFloat() throws IOException {
-        return delegate().readFloat();
-    }
-
-    @Override
-    public final double readDouble() throws IOException {
-        return delegate().readDouble();
-    }
-
-    @Override
-    public final String readLine() throws IOException {
-        return delegate().readLine();
-    }
-
-    @Override
-    public final String readUTF() throws IOException {
-        return delegate().readUTF();
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ForwardingNormalizedNodeDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/ForwardingNormalizedNodeDataInput.java
deleted file mode 100644 (file)
index 72073c6..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.IOException;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-
-abstract class ForwardingNormalizedNodeDataInput extends ForwardingDataInput implements NormalizedNodeDataInput {
-
-    @Override
-    abstract @NonNull NormalizedNodeDataInput delegate() throws IOException;
-
-    @Override
-    public final void streamNormalizedNode(final NormalizedNodeStreamWriter writer) throws IOException {
-        delegate().streamNormalizedNode(writer);
-    }
-
-    @Override
-    public final NormalizedNode<?, ?> readNormalizedNode() throws IOException {
-        return delegate().readNormalizedNode();
-    }
-
-    @Override
-    public final NormalizedNode<?, ?> readNormalizedNode(final ReusableStreamReceiver receiver) throws IOException {
-        return delegate().readNormalizedNode(receiver);
-    }
-
-    @Override
-    public final YangInstanceIdentifier readYangInstanceIdentifier() throws IOException {
-        return delegate().readYangInstanceIdentifier();
-    }
-
-    @Override
-    public final QName readQName() throws IOException {
-        return delegate().readQName();
-    }
-
-    @Override
-    public final PathArgument readPathArgument() throws IOException {
-        return delegate().readPathArgument();
-    }
-
-    @Override
-    public final SchemaPath readSchemaPath() throws IOException {
-        return delegate().readSchemaPath();
-    }
-
-    @Override
-    public final NormalizedNodeStreamVersion getVersion() throws IOException {
-        return delegate().getVersion();
-    }
-}
index 2099e3d..5d83d51 100644 (file)
@@ -14,7 +14,10 @@ import java.io.IOException;
  * valid serialized data.
  *
  * @author Thomas Pantelis
+ * @deprecated Use {@link org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException}
+ *             instead.
  */
+@Deprecated(forRemoval = true)
 public class InvalidNormalizedNodeStreamException extends IOException {
     private static final long serialVersionUID = 1L;
 
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNode.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNode.java
deleted file mode 100644 (file)
index fbc2fe8..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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;
-
-/**
- * Stream constants identifying individual node types.
- */
-final class LithiumNode {
-    static final byte LEAF_NODE = 1;
-    static final byte LEAF_SET = 2;
-    static final byte LEAF_SET_ENTRY_NODE = 3;
-    static final byte CONTAINER_NODE = 4;
-    static final byte UNKEYED_LIST = 5;
-    static final byte UNKEYED_LIST_ITEM = 6;
-    static final byte MAP_NODE = 7;
-    static final byte MAP_ENTRY_NODE = 8;
-    static final byte ORDERED_MAP_NODE = 9;
-    static final byte CHOICE_NODE = 10;
-    static final byte AUGMENTATION_NODE = 11;
-    static final byte ANY_XML_NODE = 12;
-    static final byte END_NODE = 13;
-    static final byte ORDERED_LEAF_SET = 14;
-    static final byte YANG_MODELED_ANY_XML_NODE = 15;
-
-    private LithiumNode() {
-        throw new UnsupportedOperationException("utility class");
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNormalizedNodeInputStreamReader.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNormalizedNodeInputStreamReader.java
deleted file mode 100755 (executable)
index 871f371..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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 com.google.common.base.Strings;
-import java.io.DataInput;
-import java.io.IOException;
-import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-
-/**
- * Lithium (or Oxygen really) specialization of AbstractLithiumDataInput.
- */
-final class LithiumNormalizedNodeInputStreamReader extends AbstractLithiumDataInput {
-    LithiumNormalizedNodeInputStreamReader(final DataInput input) {
-        super(input);
-    }
-
-    @Override
-    public NormalizedNodeStreamVersion getVersion() {
-        return NormalizedNodeStreamVersion.LITHIUM;
-    }
-
-    @Override
-    public QName readQName() throws IOException {
-        // Read in the same sequence of writing
-        String localName = readCodedString();
-        String namespace = readCodedString();
-        String revision = Strings.emptyToNull(readCodedString());
-
-        return QNameFactory.create(localName, namespace, revision);
-    }
-
-    @Override
-    AugmentationIdentifier readAugmentationIdentifier() throws IOException {
-        return defaultReadAugmentationIdentifier();
-    }
-
-    @Override
-    NodeIdentifier readNodeIdentifier() throws IOException {
-        return new NodeIdentifier(readQName());
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNormalizedNodeOutputStreamWriter.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumNormalizedNodeOutputStreamWriter.java
deleted file mode 100644 (file)
index b14bc19..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2014, 2015 Cisco Systems, Inc. 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 org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-
-/**
- * NormalizedNodeOutputStreamWriter will be used by distributed datastore to send normalized node in
- * a stream.
- * A stream writer wrapper around this class will write node objects to stream in recursive manner.
- * for example - If you have a ContainerNode which has a two LeafNode as children, then
- * you will first call
- * {@link #startContainerNode(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier, int)},
- * then will call
- * {@link #leafNode(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier, Object)} twice
- * and then, {@link #endNode()} to end container node.
- *
- * <p>Based on the each node, the node type is also written to the stream, that helps in reconstructing the object,
- * while reading.
- */
-final class LithiumNormalizedNodeOutputStreamWriter extends AbstractLithiumDataOutput {
-    LithiumNormalizedNodeOutputStreamWriter(final DataOutput output) {
-        super(output);
-    }
-
-    @Override
-    short streamVersion() {
-        return TokenTypes.LITHIUM_VERSION;
-    }
-
-    @Override
-    void writeQNameInternal(final QName qname) throws IOException {
-        defaultWriteQName(qname);
-    }
-
-    @Override
-    void writeModule(final QNameModule module) throws IOException {
-        defaultWriteModule(module);
-    }
-
-    @Override
-    void writeAugmentationIdentifier(final AugmentationIdentifier aid) throws IOException {
-        defaultWriteAugmentationIdentifier(aid);
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumPathArgument.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumPathArgument.java
deleted file mode 100644 (file)
index 660e0a7..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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 org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-
-final class LithiumPathArgument {
-    static final byte AUGMENTATION_IDENTIFIER = 1;
-    static final byte NODE_IDENTIFIER = 2;
-    static final byte NODE_IDENTIFIER_WITH_VALUE = 3;
-    static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4;
-
-    private LithiumPathArgument() {
-        throw new UnsupportedOperationException("Utility class");
-    }
-
-    static byte getSerializablePathArgumentType(final PathArgument pathArgument) {
-        if (pathArgument instanceof NodeIdentifier) {
-            return NODE_IDENTIFIER;
-        } else if (pathArgument instanceof NodeIdentifierWithPredicates) {
-            return NODE_IDENTIFIER_WITH_PREDICATES;
-        } else if (pathArgument instanceof AugmentationIdentifier) {
-            return AUGMENTATION_IDENTIFIER;
-        } else if (pathArgument instanceof NodeWithValue) {
-            return NODE_IDENTIFIER_WITH_VALUE;
-        } else {
-            throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument);
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumTokens.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumTokens.java
deleted file mode 100644 (file)
index 27241e9..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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;
-
-/**
- * Tokens related to Lithium/NeonSR2 encoding.
- */
-final class LithiumTokens {
-    /**
-     * The value is a reference to a previously-defined entity, typically through {@link #IS_STRING_VALUE}.
-     */
-    static final byte IS_CODE_VALUE = 1;
-    /**
-     * The value is a String, which needs to be kept memoized for the purposes for being referenced by
-     * {@link #IS_CODE_VALUE}.
-     */
-    static final byte IS_STRING_VALUE = 2;
-    /**
-     * The value is an explicit null.
-     */
-    static final byte IS_NULL_VALUE = 3;
-
-    private LithiumTokens() {
-
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumValue.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumValue.java
deleted file mode 100644 (file)
index cd118ea..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. 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;
-
-final class LithiumValue {
-    // The String length threshold beyond which a String should be encoded as bytes
-    static final int STRING_BYTES_LENGTH_THRESHOLD = Short.MAX_VALUE / 4;
-
-    static final byte SHORT_TYPE = 1;
-    static final byte BYTE_TYPE = 2;
-    static final byte INT_TYPE = 3;
-    static final byte LONG_TYPE = 4;
-    static final byte BOOL_TYPE = 5;
-    static final byte QNAME_TYPE = 6;
-    static final byte BITS_TYPE = 7;
-    static final byte YANG_IDENTIFIER_TYPE = 8;
-    static final byte STRING_TYPE = 9;
-    static final byte BIG_INTEGER_TYPE = 10;
-    static final byte BIG_DECIMAL_TYPE = 11;
-    static final byte BINARY_TYPE = 12;
-    // Leaf nodes no longer allow null values. The "empty" type is now represented as
-    // org.opendaylight.yangtools.yang.common.Empty. This is kept for backwards compatibility.
-    @Deprecated
-    static final byte NULL_TYPE = 13;
-    static final byte STRING_BYTES_TYPE = 14;
-    static final byte EMPTY_TYPE = 15;
-
-    private LithiumValue() {
-        throw new UnsupportedOperationException("Utility class");
-    }
-}
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
deleted file mode 100644 (file)
index 74c8a69..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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
deleted file mode 100644 (file)
index a438268..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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");
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumNode.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumNode.java
deleted file mode 100644 (file)
index 30a35ab..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * 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;
-
-/**
- * Magnesium encoding Node types. Encoded as a single byte, split as follows:
- * <pre>
- *   7 6 5 4 3 2 1 0
- *  +-+-+-+-+-+-+-+-+
- *  | P | A |  Type |
- *  +-+-+-+-+-+-+-+-+
- * </pre>
- * The fields being:
- * <ul>
- *   <li>Bits 7 and 6 (most significant): predicate presence. Only valid for NODE_MAP_ENTRY and NODE_LEAF</li>
- *   <li>Bits 5 and 4: addressing mode</li>
- *   <li>Bits 3-0 (least significant) node type</li>
- * </ul>
- */
-// TODO: restructure this into some concrete examples
-//- a leaf referencing a previously-encoded NodeIdentifier would take
-//6 bytes:
-//  (byte)    NodeTypes.LEAF_NODE
-//  (byte)    TokenTypes.IS_QNAME_CODE
-//  (int)     code value
-//where as new tokens can do that in as few as 2 bytes:
-//  (byte)    NodeType.(NODE_LEAF | ADDR_LOOKUP_1B)
-//  (byte)    code value
-//with worst-case being 5 bytes:
-//  (byte)    NodeType.(NODE_LEAF | ADDR_LOOKUP_4B)
-//  (int)     code value
-//- a map entry node referencing previously-encoded QNames and a single
-//predicate would take a base of 15 bytes (not counting value object):
-//  (byte)    NodeTypes.MAP_ENTRY_NODE
-//  (byte)    TokenTypes.IS_QNAME_CODE
-//  (int)     code value
-//  (int)     size of predicates
-//  (byte)    TokenTypes.IS_QNAME_CODE
-//  (int)     code value
-//whereas new tokens can do that in as few as 3 bytes:
-//  (byte)    NodeType.(NODE_MAP_ENTRY | ADDR_LOOKUP_1B | PREDICATE_ONE)
-//  (byte)    code value
-//  (byte)    code value
-//this ability is maintained for up to 255 predicates with:
-//  (byte)    NodeType.(NODE_MAP_ENTRY | ADDR_LOOKUP_1B | PREDICATE_1B)
-//  (byte)    code value
-//  (byte)    size of predicates
-//  (byte)    code value [0-255]
-//- a leaf representing a key inside a map entry has the ability to skip
-//value encoding by being as simple as:
-//  (byte)    NodeTYpe.(NODE_LEAF | ADDR_LOOKUP_1B | PREDICATE_ONE)
-//  (byte)    code value
-//
-final class MagnesiumNode {
-    /**
-     * End of node marker. Does not support addressing modes.
-     */
-    static final byte NODE_END             = 0x00; // N/A
-    /**
-     * A leaf node. Encoding can specify {@link #PREDICATE_ONE}, which indicates the value is skipped as the encoder
-     * has emitted a parent MapNode, whose identifier contains the value.
-     */
-    static final byte NODE_LEAF            = 0x01;
-    static final byte NODE_CONTAINER       = 0x02;
-    static final byte NODE_LIST            = 0x03;
-    static final byte NODE_MAP             = 0x04;
-    static final byte NODE_MAP_ORDERED     = 0x05;
-    static final byte NODE_LEAFSET         = 0x06;
-    static final byte NODE_LEAFSET_ORDERED = 0x07;
-    static final byte NODE_CHOICE          = 0x08;
-    static final byte NODE_AUGMENTATION    = 0x09;
-    static final byte NODE_ANYXML          = 0x0A;
-    static final byte NODE_LIST_ENTRY      = 0x0B;
-    static final byte NODE_LEAFSET_ENTRY   = 0x0C;
-    static final byte NODE_MAP_ENTRY       = 0x0D;
-
-    // TODO: either implement or remove this coding. While Lithium has emit code, it lacks the code do read such nodes,
-    //       which most probably means we do not need to bother ...
-    static final byte NODE_ANYXML_MODELED  = 0x0E;
-    // 0x0F reserved for anydata
-    static final byte TYPE_MASK            = 0x0F;
-
-
-    /**
-     * Inherit identifier from parent. This addressing mode is applicable in:
-     * <ul>
-     *   <li>{@link #NODE_END}, where an identifier is not applicable
-     *   <li>{@link #NODE_LIST_ENTRY}, where the NodeIdentifier is inherited from parent {@link #NODE_LIST}</li>
-     *   <li>{@link #NODE_MAP_ENTRY}, where the NodeIdentifier is inherited from parent {@link #NODE_MAP} or
-     *       {@link #NODE_MAP_ORDERED}</li>
-     *   <li>{@link #NODE_LEAFSET_ENTRY}, where the QName inherited from parent and the value is inferred from the
-     *       next {@link MagnesiumValue} encoded</li>
-     * </ul>
-     */
-    static final byte ADDR_PARENT     = 0x00;
-    /**
-     * Define a new QName-based identifier constant. For {@link #NODE_AUGMENTATION} this is a set of QNames. Assign
-     * a new linear key to this constant.
-     */
-    static final byte ADDR_DEFINE     = 0x10;
-    /**
-     * Reference a previously {@link #ADDR_DEFINE}d identifier constant. This node byte is followed by an unsigned
-     * byte, which holds the linear key previously defined (i.e. 0-255).
-     */
-    static final byte ADDR_LOOKUP_1B  = 0x20;
-    /**
-     * Reference a previously {@link #ADDR_DEFINE}d identifier constant. This node byte is followed by a signed int,
-     * which holds the linear key previously defined.
-     */
-    static final byte ADDR_LOOKUP_4B  = 0x30;
-    static final byte ADDR_MASK       = ADDR_LOOKUP_4B;
-
-    /**
-     * Predicate encoding: no predicates are present in a {@link #NODE_MAP_ENTRY}.
-     */
-    static final byte PREDICATE_ZERO = 0x00;
-
-    /**
-     * Predicate encoding: a single predicate is present in a {@link #NODE_MAP_ENTRY}. In case of {@link #NODE_LEAF}
-     * encoded as part of a {@link #NODE_MAP_ENTRY} this bit indicates the <strong>value</strong> is not encoded and
-     * should be looked up from the map entry's predicates.
-     *
-     * <p>
-     * The predicate is encoded as a {@link #ADDR_DEFINE} or {@link #ADDR_LOOKUP_1B}/{@link #ADDR_LOOKUP_4B},
-     * followed by an encoded {@link MagnesiumValue}.
-     */
-    static final byte PREDICATE_ONE   = 0x40;
-
-    /**
-     * Predicate encoding: 0-255 predicates are present, as specified by the following {@code unsigned byte}. This
-     * encoding is expected to be exceedingly rare. This should not be used to encode 0 or 1 predicate, those cases
-     * should be encoded as:
-     * <ul>
-     *   <li>no PREDICATE_* set when there are no predicates (probably not valid anyway)</li>
-     *   <li><{@link #PREDICATE_ONE} if there is only one predicate</li>
-     * </ul>
-     */
-    static final byte PREDICATE_1B    = (byte) 0x80;
-
-    /**
-     * Predicate encoding 0 - {@link Integer#MAX_VALUE} predicates are present, as specified by the following
-     * {@code int}. This should not be used where 0-255 predicates are present.
-     */
-    static final byte PREDICATE_4B    = (byte) (PREDICATE_ONE | PREDICATE_1B);
-    static final byte PREDICATE_MASK  = PREDICATE_4B;
-
-    private MagnesiumNode() {
-
-    }
-}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumPathArgument.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumPathArgument.java
deleted file mode 100644 (file)
index e1022e0..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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;
-
-/**
- * Path Argument types used in Magnesium encoding. These are encoded as a single byte, three bits of which are reserved
- * for PathArgument type itself:
- * <pre>
- *   7 6 5 4 3 2 1 0
- *  +-+-+-+-+-+-+-+-+
- *  |         | Type|
- *  +-+-+-+-+-+-+-+-+
- * </pre>
- * There are five type defined:
- * <ul>
- *   <li>{@link #AUGMENTATION_IDENTIFIER}, which additionally holds the number of QName elements encoded:
- *     <pre>
- *        7 6 5 4 3 2 1 0
- *       +-+-+-+-+-+-+-+-+
- *       |  Count  |0 0 0|
- *       +-+-+-+-+-+-+-+-+
- *     </pre>
- *     Where count is coded as an unsigned integer, with {@link #AID_COUNT_1B} and {@link #AID_COUNT_2B} and
- *     {@link #AID_COUNT_4B} indicating extended coding with up to 4 additional bytes. This byte is followed by
- *     {@code count} {@link MagnesiumValue} QNames.
- *     <pre>
- *       7 6 5 4 3 2 1 0
- *      +-+-+-+-+-+-+-+-+
- *      |0 0 0| Q |0 0 1|
- *      +-+-+-+-+-+-+-+-+
- *     </pre>
- *     Where QName coding is achieved via {@link #QNAME_DEF}, {@link #QNAME_REF_1B}, {@link #QNAME_REF_2B} and
- *     {@link #QNAME_REF_4B}.
- *   </li>
- *   <li>{@link #NODE_IDENTIFIER_WITH_PREDICATES}, which encodes a QName same way NodeIdentifier does:
- *     <pre>
- *       7 6 5 4 3 2 1 0
- *      +-+-+-+-+-+-+-+-+
- *      | Size| Q |0 1 0|
- *      +-+-+-+-+-+-+-+-+
- *      </pre>
- *      but additionally encodes number of predicates contained using {@link #SIZE_0} through {@link #SIZE_4}. If that
- *      number cannot be expressed, {@link #SIZE_1B}, {@value #SIZE_2B} and {@link #SIZE_4B} indicate number and format
- *      of additional bytes that hold number of predicates.
- *
- *      <p>
- *      This is then followed by the specified number of QName/Object key/value pairs based on {@link MagnesiumValue}
- *      encoding.
- *   </li>
- *   <li>{@link #NODE_WITH_VALUE}, which encodes a QName same way NodeIdentifier does:
- *     <pre>
- *       7 6 5 4 3 2 1 0
- *      +-+-+-+-+-+-+-+-+
- *      |0 0 0| Q |0 1 1|
- *      +-+-+-+-+-+-+-+-+
- *     </pre>
- *     but is additionally followed by a single encoded value, as per {@link MagnesiumValue}.
- *   </li>
- *   <li>{@link #MOUNTPOINT_IDENTIFIER}, which encodes a QName same way NodeIdentifier does:
- *     <pre>
- *       7 6 5 4 3 2 1 0
- *      +-+-+-+-+-+-+-+-+
- *      |0 0 0| Q |1 0 0|
- *      +-+-+-+-+-+-+-+-+
- *     </pre>
- *   </li>
- * </ul>
- */
-final class MagnesiumPathArgument {
-    // 3 bits reserved for type...
-    static final byte AUGMENTATION_IDENTIFIER         = 0x00;
-    static final byte NODE_IDENTIFIER                 = 0x01;
-    static final byte NODE_IDENTIFIER_WITH_PREDICATES = 0x02;
-    static final byte NODE_WITH_VALUE                 = 0x03;
-    static final byte MOUNTPOINT_IDENTIFIER           = 0x04;
-
-    // ... leaving three values currently unused
-    // 0x05 reserved
-    // 0x06 reserved
-    // 0x07 reserved
-
-    static final byte TYPE_MASK                       = 0x07;
-
-    // In case of AUGMENTATION_IDENTIFIER, top 5 bits are used to encode the number of path arguments, except last three
-    // values. This means that up to AugmentationIdentifiers with up to 28 components have this length encoded inline,
-    // otherwise we encode them in following 1 (unsigned), 2 (unsigned) or 4 (signed) bytes
-    static final byte AID_COUNT_1B                    = (byte) 0xE8;
-    static final byte AID_COUNT_2B                    = (byte) 0xF0;
-    static final byte AID_COUNT_4B                    = (byte) 0xF8;
-    static final byte AID_COUNT_MASK                  = AID_COUNT_4B;
-    static final byte AID_COUNT_SHIFT                 = 3;
-
-    // For normal path path arguments we can either define a QName reference or follow a 1-4 byte reference.
-    static final byte QNAME_DEF                       = 0x00;
-    static final byte QNAME_REF_1B                    = 0x08; // Unsigned
-    static final byte QNAME_REF_2B                    = 0x10; // Unsigned
-    static final byte QNAME_REF_4B                    = 0x18; // Signed
-    static final byte QNAME_MASK                      = QNAME_REF_4B;
-
-    // For NodeIdentifierWithPredicates we also carry the number of subsequent path arguments. The case of 0-4 arguments
-    // is indicated directly, otherwise there is 1-4 bytes carrying the reference.
-    static final byte SIZE_0                          = 0x00;
-    static final byte SIZE_1                          = 0x20;
-    static final byte SIZE_2                          = 0x40;
-    static final byte SIZE_3                          = 0x60;
-    static final byte SIZE_4                          = (byte) 0x80;
-    static final byte SIZE_1B                         = (byte) 0xA0;
-    static final byte SIZE_2B                         = (byte) 0xC0;
-    static final byte SIZE_4B                         = (byte) 0xE0;
-    static final byte SIZE_MASK                       = SIZE_4B;
-    static final byte SIZE_SHIFT                      = 5;
-
-    private MagnesiumPathArgument() {
-
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumValue.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/MagnesiumValue.java
deleted file mode 100644 (file)
index 403578d..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * 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.math.BigDecimal;
-import java.math.BigInteger;
-import org.opendaylight.yangtools.yang.common.Empty;
-import org.opendaylight.yangtools.yang.common.Uint16;
-import org.opendaylight.yangtools.yang.common.Uint32;
-import org.opendaylight.yangtools.yang.common.Uint64;
-import org.opendaylight.yangtools.yang.common.Uint8;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-/**
- * Magnesium encoding value types. Serialized as a single byte.
- */
-/*
- * Note these constants are organized by their absolute value, which is slightly counter-intuitive when trying to make
- * sense of what is going on.
- *
- * TODO: create some sort of facility which would provide symbolic names for debugging and documentation purposes.
- */
-final class MagnesiumValue {
-    /**
-     * {@link Boolean#FALSE} value.
-     */
-    static final byte BOOLEAN_FALSE  = 0x00;
-    /**
-     * {@link Boolean#TRUE} value.
-     */
-    static final byte BOOLEAN_TRUE   = 0x01;
-    /**
-     * An {@link Empty} value.
-     */
-    static final byte EMPTY          = 0x02;
-    /**
-     * A Byte, followed by a byte holding the value.
-     */
-    static final byte INT8           = 0x03;
-    /**
-     * A Short, followed by a {@code short} holding the value.
-     */
-    static final byte INT16          = 0x04;
-    /**
-     * An Integer, followed by an {@code int} holding the value.
-     */
-    static final byte INT32          = 0x05;
-    /**
-     * A Long, followed by an {@code long} holding the value.
-     */
-    static final byte INT64          = 0x06;
-    /**
-     * A Uint8, followed by an {@code unsigned byte} holding the value.
-     */
-    static final byte UINT8          = 0x07;
-    /**
-     * A Uint16, followed by a {@code unsigned short} holding the value.
-     */
-    static final byte UINT16         = 0x08;
-    /**
-     * A Uint32, followed by an {@code unsigned int} holding the value.
-     */
-    static final byte UINT32         = 0x09;
-    /**
-     * A Uint64, followed by an {@code unsigned long} holding the value.
-     */
-    static final byte UINT64         = 0x0A;
-    /**
-     * A {@link String}, encoded through {@link DataOutput#writeUTF(String)}. Note this is generally true of any
-     * string with less then 16384 characters.
-     */
-    static final byte STRING_UTF     = 0x0B;
-    /**
-     * A {@link String}, encoded as an {@code unsigned short} followed by that many UTF8-encoded bytes.
-     */
-    static final byte STRING_2B      = 0x0C;
-    /**
-     * A {@link String}, encoded as an {@code int >= 0} followed by that many UTF8-encoded bytes.
-     */
-    static final byte STRING_4B      = 0x0D;
-    /**
-     * A {@link String}, encoded as an {@code int >= 0} followed by that many UTF16 characters, i.e. as produced by
-     * {@link DataOutput#writeChars(String)}.
-     */
-    static final byte STRING_CHARS   = 0x0E;
-    /**
-     * Utility 'reference coding' codepoint with {@code unsigned byte} offset. This is not a value type, but is used in
-     * context of various schema-related encodings like constant strings, QNameModule and similar.
-     */
-    static final byte STRING_REF_1B  = 0x0F;
-    /**
-     * Utility 'reference coding' codepoint with {@code unsigned short} offset. This is not a value type, but is used in
-     * context of various schema-related encodings like constant strings, QNameModule and similar.
-     */
-    static final byte STRING_REF_2B  = 0x10;
-    /**
-     * Utility 'reference coding' codepoint with {@code int} offset. This is not a value type, but is used in context of
-     * various schema-related encodings like constant strings, QNameModule and similar.
-     */
-    static final byte STRING_REF_4B  = 0x11;
-    /**
-     * A {@code byte[])}, encoded as a single {@code unsigned byte} followed by 128-383 bytes. Note that smaller
-     * arrays are encoded via {@link #BINARY_0} - {@link #BINARY_127} range.
-     */
-    static final byte BINARY_1B      = 0x12;
-    /**
-     * A {@code byte[])}, encoded as a single {@code unsigned short} followed by 384-65919 bytes. See also
-     * {@link #BINARY_1B}.
-     */
-    static final byte BINARY_2B      = 0x13;
-    /**
-     * A {@code byte[])}, encoded as a single {@code int} followed by that many bytes bytes. See also
-     * {@link #BINARY_2B}.
-     */
-    static final byte BINARY_4B      = 0x14;
-    /**
-     * A {@link YangInstanceIdentifier}, encoded as a single {@code int}, followed by that many components. See
-     * also {@link #YIID_0}, which offers optimized encoding for up to 31 components. Components are encoded using
-     * {@link MagnesiumPathArgument} coding.
-     */
-    static final byte YIID           = 0x15;
-    /**
-     * A QName literal. Encoded as QNameModule + String. This literal is expected to be memoized on receiver side, which
-     * assigns the next linear integer identifier. The sender will memoize it too and further references to this QName
-     * will be made via {@link #QNAME_REF_1B}, {@link #QNAME_REF_2B} or {@link #QNAME_REF_4B}.
-     *
-     * <p>
-     * Note that QNameModule (and String in this context) encoding works similarly -- it can only occur as part of a
-     * QName (coming from here or {@link MagnesiumPathArgument}) and is subject to the same memoization.
-     *
-     * <p>
-     * For example, given two QNames {@code foo = QName.create("foo", "abc")} and
-     * {@code bar = QName.create("foo", "def")}, if they are written in order {@code foo, bar, foo}, then the following
-     * events are emitted:
-     * <pre>
-     *   QNAME                (define QName, assign shorthand Q0)
-     *   STRING_UTF   "foo"   ("foo", assign shorthand S0, implies define QNameModule, assign shorthand M0)
-     *   STRING_EMPTY         (foo's non-existent revision)
-     *   STRING_UTF   "abc"   ("abc", assign shorthand S1)
-     *   QNAME                (define QName, assign shorthand Q1)
-     *   MODREF_1B    (byte)0 (reference M0)
-     *   STRING_UTF   "def"   ("def", assign shorthand S2)
-     *   QNAME_REF_1B (byte)0 (reference Q0)
-     * </pre>
-     */
-    // Design note: STRING_EMPTY is required to *NOT* establish a shortcut, as that is less efficient (and hence does
-    //              not make sense from the sender, the receiver or the serialization protocol itself.
-    static final byte QNAME          = 0x16;
-    /**
-     * Reference a QName previously defined via {@link #QNAME}. Reference number is encoded as {@code unsigned byte}.
-     */
-    static final byte QNAME_REF_1B   = 0x17;
-    /**
-     * Reference a QName previously defined via {@link #QNAME}. Reference number is encoded as {@code unsigned short}.
-     */
-    static final byte QNAME_REF_2B   = 0x18;
-    /**
-     * Reference a QName previously defined via {@link #QNAME}. Reference number is encoded as {@code int}.
-     */
-    static final byte QNAME_REF_4B   = 0x19;
-    /**
-     * Reference a previously defined QNameModule. Reference number is encoded as {@code unsigned byte}.
-     */
-    static final byte MODREF_1B      = 0x1A;
-    /**
-     * Reference a previously defined QNameModule. Reference number is encoded as {@code unsigned short}.
-     */
-    static final byte MODREF_2B      = 0x1B;
-    /**
-     * Reference a previously defined QNameModule. Reference number is encoded as {@code int}.
-     */
-    static final byte MODREF_4B      = 0x1C;
-
-    /**
-     * A {@link BigDecimal}, encoded through {@link DataOutput#writeUTF(String)}.
-     */
-    // This is legacy compatibility. At some point we will remove support for writing these.
-    static final byte BIGDECIMAL     = 0x1D;
-    /**
-     * A {@link BigInteger}, encoded through {@link DataOutput#writeUTF(String)}.
-     */
-    // This is legacy compatibility. At some point we will remove support for writing these.
-    static final byte BIGINTEGER     = 0x1E;
-
-    // 0x1F reserved
-
-    /**
-     * Byte value {@code 0}.
-     */
-    static final byte INT8_0         = 0x20;
-    /**
-     * Short value {@code 0}.
-     */
-    static final byte INT16_0        = 0x21;
-    /**
-     * Integer value {@code 0}.
-     */
-    static final byte INT32_0        = 0x22;
-    /**
-     * Long value {@code 0}.
-     */
-    static final byte INT64_0        = 0x23;
-    /**
-     * {@link Uint8#ZERO} value.
-     */
-    static final byte UINT8_0        = 0x24;
-    /**
-     * {@link Uint16#ZERO} value.
-     */
-    static final byte UINT16_0       = 0x25;
-    /**
-     * {@link Uint32#ZERO} value.
-     */
-    static final byte UINT32_0       = 0x26;
-    /**
-     * {@link Uint64#ZERO} value.
-     */
-    static final byte UINT64_0       = 0x27;
-    /**
-     * Empty String value ({@code ""}).
-     */
-    static final byte STRING_EMPTY   = 0x28;
-    /**
-     * {@link #INT32} with a 2-byte operand.
-     */
-    static final byte INT32_2B       = 0x29;
-    /**
-     * {@link #UINT32} with a 2-byte operand.
-     */
-    static final byte UINT32_2B      = 0x2A;
-    /**
-     * {@link #INT64} with a 4-byte operand.
-     */
-    static final byte INT64_4B       = 0x2B;
-    /**
-     * {@link #UINT64} with a 4-byte operand.
-     */
-    static final byte UINT64_4B      = 0x2C;
-
-    // 0x2D - 0x39 reserved
-
-    /**
-     * Empty bits value. This code point starts the range, where the number of bits can be extracted as
-     * {@code code & 0x1F)}. Last three values of this range are used to encode more than 28 entries.
-     */
-    static final byte BITS_0         = 0x40;
-    /**
-     * A bits value of up to 255 entries. Number of values is encoded as the following {@code unsigned byte}.
-     */
-    static final byte BITS_1B        = 0x5D;
-    /**
-     * A bits value of up to 65535 entries. Number of values is encoded as the following {@code unsigned short}.
-     */
-    static final byte BITS_2B        = 0x5E;
-    /**
-     * A bits value. Number of values is encoded as the following {@code int}.
-     */
-    static final byte BITS_4B        = 0x5F;
-
-    /**
-     * {@link YangInstanceIdentifier} with zero components. This code point starts the range ending with
-     * {@link #YIID_31}, where the number of components can be extracted as {@code code & 0x1F}. Identifiers with
-     * more than 31 components are encoded using {@link #YIID}.
-     */
-    static final byte YIID_0         = 0x60;
-    /**
-     * {@link YangInstanceIdentifier} with 31 components. See {@link #YIID_0}.
-     */
-    static final byte YIID_31        = 0x7F;
-
-    /**
-     * A {@code byte[]} with 0 bytes. This code point starts the range ending with {@link #BINARY_127}, where
-     * the number of bytes can be extracted as {@code code & 0x7F}. Arrays longer than 127 bytes are encoded using
-     * {@link #BINARY_1B}, {@link #BINARY_2B} and {@link #BINARY_4B} as needed.
-     */
-    static final byte BINARY_0       = (byte) 0x80;
-    /**
-     * A {@code byte[]} with 127 bytes. See {@link #BINARY_0}.
-     */
-    static final byte BINARY_127     = (byte) 0xFF;
-
-    private MagnesiumValue() {
-
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2NormalizedNodeInputStreamReader.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2NormalizedNodeInputStreamReader.java
deleted file mode 100644 (file)
index 80ec1b0..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * 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 static com.google.common.base.Verify.verify;
-
-import java.io.DataInput;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.opendaylight.controller.cluster.datastore.node.utils.QNameFactory;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-
-/**
- * Neon SR2 specialization of AbstractLithiumDataInput. Unlike its Lithium counterpart, this format uses coding for
- * QNameModules, QNames, NodeIdentifiers and AugmentationIdentifiers, thus reducing stream duplication.
- */
-final class NeonSR2NormalizedNodeInputStreamReader extends AbstractLithiumDataInput {
-    private final ArrayList<NodeIdentifier> codedNodeIdentifiers = new ArrayList<>();
-    private final List<AugmentationIdentifier> codedAugments = new ArrayList<>();
-    private final List<QNameModule> codedModules = new ArrayList<>();
-    private final List<QName> codedQNames = new ArrayList<>();
-
-    NeonSR2NormalizedNodeInputStreamReader(final DataInput input) {
-        super(input);
-    }
-
-    @Override
-    public NormalizedNodeStreamVersion getVersion() {
-        return NormalizedNodeStreamVersion.NEON_SR2;
-    }
-
-    @Override
-    public QName readQName() throws IOException {
-        final byte valueType = readByte();
-        switch (valueType) {
-            case NeonSR2Tokens.IS_QNAME_CODE:
-                return codedQName(readInt());
-            case NeonSR2Tokens.IS_QNAME_VALUE:
-                return rawQName();
-            default:
-                throw new IOException("Unhandled QName value type " + valueType);
-        }
-    }
-
-    @Override
-    AugmentationIdentifier readAugmentationIdentifier() throws IOException {
-        final byte valueType = readByte();
-        switch (valueType) {
-            case NeonSR2Tokens.IS_AUGMENT_CODE:
-                return codedAugmentId(readInt());
-            case NeonSR2Tokens.IS_AUGMENT_VALUE:
-                return rawAugmentId();
-            default:
-                throw new IOException("Unhandled QName value type " + valueType);
-        }
-    }
-
-    @Override
-    NodeIdentifier readNodeIdentifier() throws IOException {
-        // NodeIdentifier rides on top of QName, with this method really saying 'interpret next QName as NodeIdentifier'
-        // to do that we inter-mingle with readQName()
-        final byte valueType = readByte();
-        switch (valueType) {
-            case NeonSR2Tokens.IS_QNAME_CODE:
-                return codedNodeIdentifier(readInt());
-            case NeonSR2Tokens.IS_QNAME_VALUE:
-                return rawNodeIdentifier();
-            default:
-                throw new IOException("Unhandled QName value type " + valueType);
-        }
-    }
-
-    private QNameModule readModule() throws IOException {
-        final byte valueType = readByte();
-        switch (valueType) {
-            case NeonSR2Tokens.IS_MODULE_CODE:
-                return codedModule(readInt());
-            case NeonSR2Tokens.IS_MODULE_VALUE:
-                return rawModule();
-            default:
-                throw new IOException("Unhandled QName value type " + valueType);
-        }
-    }
-
-    private NodeIdentifier codedNodeIdentifier(final int code) throws IOException {
-        final NodeIdentifier existing = codedNodeIdentifiers.size() > code ? codedNodeIdentifiers.get(code) : null;
-        return existing != null ? existing : storeNodeIdentifier(code, codedQName(code));
-    }
-
-    private NodeIdentifier rawNodeIdentifier() throws IOException {
-        // Capture size before it incremented
-        final int code = codedQNames.size();
-        return storeNodeIdentifier(code, rawQName());
-    }
-
-    private NodeIdentifier storeNodeIdentifier(final int code, final QName qname) {
-        final NodeIdentifier ret = NodeIdentifier.create(qname);
-        final int size = codedNodeIdentifiers.size();
-
-        if (code >= size) {
-            // Null-fill others
-            codedNodeIdentifiers.ensureCapacity(code + 1);
-            for (int i = size; i < code; ++i) {
-                codedNodeIdentifiers.add(null);
-            }
-
-            codedNodeIdentifiers.add(ret);
-        } else {
-            final NodeIdentifier check = codedNodeIdentifiers.set(code, ret);
-            verify(check == null);
-        }
-
-        return ret;
-    }
-
-    private QName codedQName(final int code) throws IOException {
-        try {
-            return codedQNames.get(code);
-        } catch (IndexOutOfBoundsException e) {
-            throw new IOException("QName code " + code + " was not found", e);
-        }
-    }
-
-    private QName rawQName() throws IOException {
-        final String localName = readCodedString();
-        final QNameModule module = readModule();
-        final QName qname = QNameFactory.create(module, localName);
-        codedQNames.add(qname);
-        return qname;
-    }
-
-    private AugmentationIdentifier codedAugmentId(final int code) throws IOException {
-        try {
-            return codedAugments.get(code);
-        } catch (IndexOutOfBoundsException e) {
-            throw new IOException("QName set code " + code + " was not found", e);
-        }
-    }
-
-    private AugmentationIdentifier rawAugmentId() throws IOException {
-        final AugmentationIdentifier aid = defaultReadAugmentationIdentifier();
-        codedAugments.add(aid);
-        return aid;
-    }
-
-    private QNameModule codedModule(final int code) throws IOException {
-        try {
-            return codedModules.get(code);
-        } catch (IndexOutOfBoundsException e) {
-            throw new IOException("Module code " + code + " was not found", e);
-        }
-    }
-
-    private QNameModule rawModule() throws IOException {
-        final String namespace = readCodedString();
-        final String revision = readCodedString();
-        final QNameModule mod = QNameFactory.createModule(namespace, revision);
-        codedModules.add(mod);
-        return mod;
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2NormalizedNodeOutputStreamWriter.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2NormalizedNodeOutputStreamWriter.java
deleted file mode 100644 (file)
index 010b220..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * 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.util.HashMap;
-import java.util.Map;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
-
-/**
- * NormalizedNodeOutputStreamWriter will be used by distributed datastore to send normalized node in
- * a stream.
- * A stream writer wrapper around this class will write node objects to stream in recursive manner.
- * for example - If you have a ContainerNode which has a two LeafNode as children, then
- * you will first call
- * {@link #startContainerNode(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier, int)},
- * then will call
- * {@link #leafNode(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier, Object)} twice
- * and then, {@link #endNode()} to end container node.
- *
- * <p>Based on the each node, the node type is also written to the stream, that helps in reconstructing the object,
- * while reading.
- */
-final class NeonSR2NormalizedNodeOutputStreamWriter extends AbstractLithiumDataOutput {
-    private final Map<AugmentationIdentifier, Integer> aidCodeMap = new HashMap<>();
-    private final Map<QNameModule, Integer> moduleCodeMap = new HashMap<>();
-    private final Map<QName, Integer> qnameCodeMap = new HashMap<>();
-
-    NeonSR2NormalizedNodeOutputStreamWriter(final DataOutput output) {
-        super(output);
-    }
-
-    @Override
-    short streamVersion() {
-        return TokenTypes.NEON_SR2_VERSION;
-    }
-
-    @Override
-    void writeQNameInternal(final QName qname) throws IOException {
-        final Integer value = qnameCodeMap.get(qname);
-        if (value == null) {
-            // Fresh QName, remember it and emit as three strings
-            qnameCodeMap.put(qname, qnameCodeMap.size());
-            writeByte(NeonSR2Tokens.IS_QNAME_VALUE);
-            defaultWriteQName(qname);
-        } else {
-            // We have already seen this QName: write its code
-            writeByte(NeonSR2Tokens.IS_QNAME_CODE);
-            writeInt(value);
-        }
-    }
-
-    @Override
-    void writeAugmentationIdentifier(final AugmentationIdentifier aid) throws IOException {
-        final Integer value = aidCodeMap.get(aid);
-        if (value == null) {
-            // Fresh AugmentationIdentifier, remember it and emit as three strings
-            aidCodeMap.put(aid, aidCodeMap.size());
-            writeByte(NeonSR2Tokens.IS_AUGMENT_VALUE);
-            defaultWriteAugmentationIdentifier(aid);
-        } else {
-            // We have already seen this AugmentationIdentifier: write its code
-            writeByte(NeonSR2Tokens.IS_AUGMENT_CODE);
-            writeInt(value);
-        }
-    }
-
-    @Override
-    void writeModule(final QNameModule module) throws IOException {
-        final Integer value = moduleCodeMap.get(module);
-        if (value == null) {
-            // Fresh QNameModule, remember it and emit as three strings
-            moduleCodeMap.put(module, moduleCodeMap.size());
-            writeByte(NeonSR2Tokens.IS_MODULE_VALUE);
-            defaultWriteModule(module);
-        } else {
-            // We have already seen this QNameModule: write its code
-            writeByte(NeonSR2Tokens.IS_MODULE_CODE);
-            writeInt(value);
-        }
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2Tokens.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NeonSR2Tokens.java
deleted file mode 100644 (file)
index 9126747..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * 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;
-
-/**
- * Tokens used in Neon SR2 encoding. Note that Neon SR2 builds on top of Lithium, hence the token values must never
- * overlap.
- */
-final class NeonSR2Tokens {
-    static final byte IS_QNAME_CODE = 4;
-    static final byte IS_QNAME_VALUE = 5;
-    static final byte IS_AUGMENT_CODE = 6;
-    static final byte IS_AUGMENT_VALUE = 7;
-    static final byte IS_MODULE_CODE = 8;
-    static final byte IS_MODULE_VALUE = 9;
-
-    private NeonSR2Tokens() {
-
-    }
-}
index 8d05061..be391ef 100644 (file)
@@ -24,7 +24,10 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 /**
  * Interface for reading {@link NormalizedNode}s, {@link YangInstanceIdentifier}s, {@link PathArgument}s
  * and {@link SchemaPath}s.
+ *
+ * @deprecated Use {@link org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput} instead.
  */
+@Deprecated(forRemoval = true)
 @Beta
 public interface NormalizedNodeDataInput extends DataInput {
     /**
index 681553e..f285bb3 100644 (file)
@@ -21,7 +21,10 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 /**
  * Interface for emitting {@link NormalizedNode}s, {@link YangInstanceIdentifier}s, {@link PathArgument}s
  * and {@link SchemaPath}s.
+ *
+ * @deprecated Used {@link org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput} instead.
  */
+@Deprecated(forRemoval = true)
 @Beta
 public interface NormalizedNodeDataOutput extends AutoCloseable, DataOutput {
     void writeQName(@NonNull QName qname) throws IOException;
index 970b432..055721d 100644 (file)
@@ -14,6 +14,7 @@ import java.io.IOException;
 import org.eclipse.jdt.annotation.NonNull;
 
 @Beta
+@Deprecated(forRemoval = true)
 public final class NormalizedNodeInputOutput {
     private NormalizedNodeInputOutput() {
         throw new UnsupportedOperationException();
@@ -28,7 +29,12 @@ public final class NormalizedNodeInputOutput {
      * @throws IOException if an error occurs reading from the input
      */
     public static NormalizedNodeDataInput newDataInput(final @NonNull DataInput input) throws IOException {
-        return new VersionedNormalizedNodeDataInput(input).delegate();
+        try {
+            return new CompatNormalizedNodeDataInput(org.opendaylight.yangtools.yang.data.codec.binfmt
+                .NormalizedNodeDataInput.newDataInput(input));
+        } catch (org.opendaylight.yangtools.yang.data.codec.binfmt.InvalidNormalizedNodeStreamException e) {
+            throw new InvalidNormalizedNodeStreamException(e.getMessage(), e);
+        }
     }
 
     /**
@@ -39,7 +45,8 @@ public final class NormalizedNodeInputOutput {
      * @return a new {@link NormalizedNodeDataInput} instance
      */
     public static NormalizedNodeDataInput newDataInputWithoutValidation(final @NonNull DataInput input) {
-        return new VersionedNormalizedNodeDataInput(input);
+        return new CompatNormalizedNodeDataInput(org.opendaylight.yangtools.yang.data.codec.binfmt
+            .NormalizedNodeDataInput.newDataInputWithoutValidation(input));
     }
 
     /**
@@ -50,7 +57,7 @@ public final class NormalizedNodeInputOutput {
      * @return a new {@link NormalizedNodeDataOutput} instance
      */
     public static NormalizedNodeDataOutput newDataOutput(final @NonNull DataOutput output) {
-        return new MagnesiumDataOutput(output);
+        return newDataOutput(output, NormalizedNodeStreamVersion.MAGNESIUM);
     }
 
     /**
@@ -62,18 +69,6 @@ public final class NormalizedNodeInputOutput {
      */
     public static NormalizedNodeDataOutput newDataOutput(final @NonNull DataOutput output,
             final @NonNull NormalizedNodeStreamVersion version) {
-        switch (version) {
-            case LITHIUM:
-                return new LithiumNormalizedNodeOutputStreamWriter(output);
-            case NEON_SR2:
-                return new NeonSR2NormalizedNodeOutputStreamWriter(output);
-            case SODIUM_SR1:
-                return new SodiumSR1DataOutput(output);
-            case MAGNESIUM:
-                return new MagnesiumDataOutput(output);
-            default:
-                throw new IllegalStateException("Unhandled version " + version);
-        }
+        return new CompatNormalizedNodeDataOutput(version.toYangtools().newDataOutput(output));
     }
-
 }
index e8adc25..7bf2032 100644 (file)
@@ -14,10 +14,33 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
  * Enumeration of all stream versions this implementation supports on both input and output.
  */
 @Beta
+@Deprecated(forRemoval = true)
 @NonNullByDefault
 public enum NormalizedNodeStreamVersion {
-    LITHIUM,
-    NEON_SR2,
-    SODIUM_SR1,
-    MAGNESIUM;
+    LITHIUM {
+        @Override
+        public org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion toYangtools() {
+            return org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion.LITHIUM;
+        }
+    },
+    NEON_SR2 {
+        @Override
+        public org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion toYangtools() {
+            return org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion.NEON_SR2;
+        }
+    },
+    SODIUM_SR1 {
+        @Override
+        public org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion toYangtools() {
+            return org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion.SODIUM_SR1;
+        }
+    },
+    MAGNESIUM {
+        @Override
+        public org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion toYangtools() {
+            return org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion.MAGNESIUM;
+        }
+    };
+
+    public abstract org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion toYangtools();
 }
index 6735cdb..8e3944e 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
+import static org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion.MAGNESIUM;
+
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
@@ -15,6 +17,8 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 
 /**
  * Provides various utility methods for serialization and de-serialization.
@@ -35,15 +39,21 @@ public final class SerializationUtils {
         if (!in.readBoolean()) {
             return Optional.empty();
         }
-        return Optional.of(NormalizedNodeInputOutput.newDataInput(in).readNormalizedNode());
+        return Optional.of(NormalizedNodeDataInput.newDataInput(in).readNormalizedNode());
     }
 
     public static void writeNormalizedNode(final DataOutput out, final @Nullable NormalizedNode<?, ?> node)
             throws IOException {
+        writeNormalizedNode(out, MAGNESIUM, node);
+    }
+
+    public static void writeNormalizedNode(final DataOutput out,
+            final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion version,
+            final @Nullable NormalizedNode<?, ?> node) throws IOException {
         if (node != null) {
             out.writeBoolean(true);
 
-            try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out)) {
+            try (NormalizedNodeDataOutput stream = version.newDataOutput(out)) {
                 stream.writeNormalizedNode(node);
             }
         } else {
@@ -51,66 +61,76 @@ public final class SerializationUtils {
         }
     }
 
+    @Deprecated(forRemoval = true)
     public static void writeNormalizedNode(final DataOutput out, final NormalizedNodeStreamVersion version,
             final @Nullable NormalizedNode<?, ?> node) throws IOException {
-        if (node != null) {
-            out.writeBoolean(true);
-
-            try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out, version)) {
-                stream.writeNormalizedNode(node);
-            }
-        } else {
-            out.writeBoolean(false);
-        }
+        writeNormalizedNode(out, version.toYangtools(), node);
     }
 
     public static YangInstanceIdentifier readPath(final DataInput in) throws IOException {
-        return NormalizedNodeInputOutput.newDataInput(in).readYangInstanceIdentifier();
+        return NormalizedNodeDataInput.newDataInput(in).readYangInstanceIdentifier();
     }
 
     public static void writePath(final DataOutput out, final @NonNull YangInstanceIdentifier path)
             throws IOException {
-        try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out)) {
+        writePath(out, MAGNESIUM, path);
+    }
+
+    public static void writePath(final DataOutput out,
+            final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion version,
+            final @NonNull YangInstanceIdentifier path) throws IOException {
+        try (NormalizedNodeDataOutput stream = version.newDataOutput(out)) {
             stream.writeYangInstanceIdentifier(path);
         }
     }
 
+    @Deprecated(forRemoval = true)
     public static void writePath(final DataOutput out, final NormalizedNodeStreamVersion version,
             final @NonNull YangInstanceIdentifier path) throws IOException {
-        try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out, version)) {
-            stream.writeYangInstanceIdentifier(path);
-        }
+        writePath(out, version.toYangtools(), path);
     }
 
     public static <T> void readNodeAndPath(final DataInput in, final T instance, final Applier<T> applier)
             throws IOException {
-        final NormalizedNodeDataInput stream = NormalizedNodeInputOutput.newDataInput(in);
+        final NormalizedNodeDataInput stream = NormalizedNodeDataInput.newDataInput(in);
         NormalizedNode<?, ?> node = stream.readNormalizedNode();
         YangInstanceIdentifier path = stream.readYangInstanceIdentifier();
         applier.apply(instance, path, node);
     }
 
-    public static void writeNodeAndPath(final DataOutput out, final YangInstanceIdentifier path,
-            final NormalizedNode<?, ?> node) throws IOException {
-        try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out)) {
+    public static void writeNodeAndPath(final DataOutput out,
+            final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion version,
+            final YangInstanceIdentifier path, final NormalizedNode<?, ?> node) throws IOException {
+        try (NormalizedNodeDataOutput stream = version.newDataOutput(out)) {
             stream.writeNormalizedNode(node);
             stream.writeYangInstanceIdentifier(path);
         }
     }
 
+    public static void writeNodeAndPath(final DataOutput out, final YangInstanceIdentifier path,
+            final NormalizedNode<?, ?> node) throws IOException {
+        writeNodeAndPath(out, MAGNESIUM, path, node);
+    }
+
     public static <T> void readPathAndNode(final DataInput in, final T instance, final Applier<T> applier)
             throws IOException {
-        final NormalizedNodeDataInput stream = NormalizedNodeInputOutput.newDataInput(in);
+        final NormalizedNodeDataInput stream = NormalizedNodeDataInput.newDataInput(in);
         YangInstanceIdentifier path = stream.readYangInstanceIdentifier();
         NormalizedNode<?, ?> node = stream.readNormalizedNode();
         applier.apply(instance, path, node);
     }
 
-    public static void writePathAndNode(final DataOutput out, final YangInstanceIdentifier path,
-            final NormalizedNode<?, ?> node) throws IOException {
-        try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out)) {
+    public static void writePathAndNode(final DataOutput out,
+            final org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion version,
+            final YangInstanceIdentifier path, final NormalizedNode<?, ?> node) throws IOException {
+        try (NormalizedNodeDataOutput stream = version.newDataOutput(out)) {
             stream.writeYangInstanceIdentifier(path);
             stream.writeNormalizedNode(node);
         }
     }
+
+    public static void writePathAndNode(final DataOutput out, final YangInstanceIdentifier path,
+            final NormalizedNode<?, ?> node) throws IOException {
+        writePathAndNode(out, MAGNESIUM, path, node);
+    }
 }
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SodiumSR1DataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SodiumSR1DataInput.java
deleted file mode 100644 (file)
index d866411..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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 SodiumSR1DataInput extends AbstractMagnesiumDataInput {
-    SodiumSR1DataInput(final DataInput input) {
-        super(input);
-    }
-
-    @Override
-    public NormalizedNodeStreamVersion getVersion() {
-        return NormalizedNodeStreamVersion.SODIUM_SR1;
-    }
-
-    @Override
-    BigInteger readBigInteger() throws IOException {
-        // FIXME: use string -> BigInteger cache
-        return new BigInteger(input.readUTF());
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SodiumSR1DataOutput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SodiumSR1DataOutput.java
deleted file mode 100644 (file)
index 4c432d3..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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 SodiumSR1DataOutput extends AbstractMagnesiumDataOutput {
-    SodiumSR1DataOutput(final DataOutput output) {
-        super(output);
-    }
-
-    @Override
-    short streamVersion() {
-        return TokenTypes.SODIUM_SR1_VERSION;
-    }
-
-    @Override
-    void writeValue(final BigInteger value) throws IOException {
-        output.writeByte(MagnesiumValue.BIGINTEGER);
-        output.writeUTF(value.toString());
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/TokenTypes.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/TokenTypes.java
deleted file mode 100644 (file)
index e09c3e9..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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;
-
-final class TokenTypes {
-    private TokenTypes() {
-        throw new UnsupportedOperationException();
-    }
-
-    static final byte SIGNATURE_MARKER = (byte) 0xab;
-
-    /**
-     * Original stream version. Uses a per-stream dictionary for strings. QNames are serialized as three strings.
-     */
-    static final short LITHIUM_VERSION = 1;
-    /**
-     * Revised stream version. Unlike {@link #LITHIUM_VERSION}, QNames and QNameModules are using a per-stream
-     * dictionary, too.
-     */
-    static final short NEON_SR2_VERSION = 2;
-    /**
-     * 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;
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/VersionedNormalizedNodeDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/VersionedNormalizedNodeDataInput.java
deleted file mode 100644 (file)
index 68618fc..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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 static java.util.Objects.requireNonNull;
-
-import java.io.DataInput;
-import java.io.IOException;
-
-final class VersionedNormalizedNodeDataInput extends ForwardingNormalizedNodeDataInput {
-    private DataInput input;
-    private NormalizedNodeDataInput delegate;
-
-    VersionedNormalizedNodeDataInput(final DataInput input) {
-        this.input = requireNonNull(input);
-    }
-
-    @Override
-    NormalizedNodeDataInput delegate() throws IOException {
-        if (delegate != null) {
-            return delegate;
-        }
-
-        final byte marker = input.readByte();
-        if (marker != TokenTypes.SIGNATURE_MARKER) {
-            throw defunct("Invalid signature marker: %d", marker);
-        }
-
-        final short version = input.readShort();
-        final NormalizedNodeDataInput ret;
-        switch (version) {
-            case TokenTypes.LITHIUM_VERSION:
-                ret = new LithiumNormalizedNodeInputStreamReader(input);
-                break;
-            case TokenTypes.NEON_SR2_VERSION:
-                ret = new NeonSR2NormalizedNodeInputStreamReader(input);
-                break;
-            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);
-        }
-
-        setDelegate(ret);
-        return ret;
-    }
-
-    private InvalidNormalizedNodeStreamException defunct(final String format, final Object... args) {
-        final InvalidNormalizedNodeStreamException ret = new InvalidNormalizedNodeStreamException(
-            String.format(format, args));
-        // Make sure the stream is not touched
-        setDelegate(new ForwardingNormalizedNodeDataInput() {
-            @Override
-            NormalizedNodeDataInput delegate() throws IOException {
-                throw new InvalidNormalizedNodeStreamException("Stream is not usable", ret);
-            }
-        });
-        return ret;
-    }
-
-    private void setDelegate(final NormalizedNodeDataInput delegate) {
-        this.delegate = requireNonNull(delegate);
-        input = null;
-    }
-}
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumWriteObjectMappingTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/LithiumWriteObjectMappingTest.java
deleted file mode 100644 (file)
index dc38471..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. 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 static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class LithiumWriteObjectMappingTest {
-    @Test
-    public void testStringType() {
-        assertEquals(LithiumValue.STRING_TYPE, AbstractLithiumDataOutput.getSerializableType("foobar"));
-        final String largeString = largeString(LithiumValue.STRING_BYTES_LENGTH_THRESHOLD);
-        assertEquals(LithiumValue.STRING_BYTES_TYPE, AbstractLithiumDataOutput.getSerializableType(largeString));
-    }
-
-    private static String largeString(final int minSize) {
-        final int pow = (int) (Math.log(minSize * 2) / Math.log(2));
-        StringBuilder sb = new StringBuilder("X");
-        for (int i = 0; i < pow; i++) {
-            sb.append(sb);
-        }
-        return sb.toString();
-    }
-}
index f28250b..a1b9339 100644 (file)
@@ -13,7 +13,7 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeStreamVersion;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion;
 
 /**
  * Abstract base class for a versioned Externalizable message.
index fac45c7..38517aa 100644 (file)
@@ -11,12 +11,12 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 
 /**
  * DeleteModification store all the parameters required to delete a path from the data tree.
index b2007ed..0dbc480 100644 (file)
@@ -9,12 +9,12 @@ package org.opendaylight.controller.cluster.datastore.modification;
 
 import java.io.IOException;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
 
 /**
  * MergeModification stores all the parameters required to merge data into the specified path.
index eddfba2..59ca8eb 100644 (file)
@@ -5,16 +5,15 @@
  * 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.modification;
 
 import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 
 /**
  * Represents a modification to the data store.
index d974d7e..a755674 100644 (file)
@@ -18,12 +18,11 @@ import java.util.Collections;
 import java.util.List;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.cluster.datastore.messages.VersionedExternalizableMessage;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 import org.opendaylight.yangtools.yang.data.impl.schema.ReusableImmutableNormalizedNodeStreamWriter;
 
 /**
@@ -92,7 +91,7 @@ public class MutableCompositeModification extends VersionedExternalizableMessage
 
         int size = in.readInt();
         if (size > 0) {
-            final NormalizedNodeDataInput input = NormalizedNodeInputOutput.newDataInputWithoutValidation(in);
+            final NormalizedNodeDataInput input = NormalizedNodeDataInput.newDataInputWithoutValidation(in);
             final ReusableStreamReceiver receiver = ReusableImmutableNormalizedNodeStreamWriter.create();
 
             for (int i = 0; i < size; i++) {
@@ -123,7 +122,7 @@ public class MutableCompositeModification extends VersionedExternalizableMessage
         final int size = modifications.size();
         out.writeInt(size);
         if (size > 0) {
-            try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out, getStreamVersion())) {
+            try (NormalizedNodeDataOutput stream = getStreamVersion().newDataOutput(out)) {
                 for (Modification mod : modifications) {
                     out.writeByte(mod.getType());
                     mod.writeTo(stream);
index 4746952..dde0be7 100644 (file)
@@ -5,21 +5,20 @@
  * 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.modification;
 
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 
 /**
  * WriteModification stores all the parameters required to write data to the specified path.
index 53894de..60d70e4 100644 (file)
@@ -14,9 +14,6 @@ import java.io.DataOutput;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver;
@@ -25,6 +22,8 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNod
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNodes;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -100,7 +99,7 @@ public final class DataTreeCandidateInputOutput {
 
     public static DataTreeCandidate readDataTreeCandidate(final DataInput in, final ReusableStreamReceiver receiver)
             throws IOException {
-        final NormalizedNodeDataInput reader = NormalizedNodeInputOutput.newDataInput(in);
+        final NormalizedNodeDataInput reader = NormalizedNodeDataInput.newDataInput(in);
         final YangInstanceIdentifier rootPath = reader.readYangInstanceIdentifier();
         final byte type = reader.readByte();
 
@@ -178,8 +177,7 @@ public final class DataTreeCandidateInputOutput {
 
     public static void writeDataTreeCandidate(final DataOutput out, final DataTreeCandidate candidate)
             throws IOException {
-        try (NormalizedNodeDataOutput writer = NormalizedNodeInputOutput.newDataOutput(out,
-                PayloadVersion.current().getStreamVersion())) {
+        try (NormalizedNodeDataOutput writer = PayloadVersion.current().getStreamVersion().newDataOutput(out)) {
             writer.writeYangInstanceIdentifier(candidate.getRootPath());
 
             final DataTreeCandidateNode node = candidate.getRootNode();
index ad186b0..d21e198 100644 (file)
@@ -22,11 +22,10 @@ import java.io.ObjectOutput;
 import java.io.Serializable;
 import java.io.StreamCorruptedException;
 import java.util.Map;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeStreamVersion;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataOutput;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -66,7 +65,7 @@ public final class MetadataShardDataTreeSnapshot extends AbstractVersionedShardD
                 out.writeObject(m);
             }
             out.writeBoolean(true);
-            try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out, version)) {
+            try (NormalizedNodeDataOutput stream = version.newDataOutput(out)) {
                 stream.writeNormalizedNode(rootNode);
             }
         }
@@ -94,7 +93,7 @@ public final class MetadataShardDataTreeSnapshot extends AbstractVersionedShardD
                 throw new StreamCorruptedException("Unexpected missing root node");
             }
 
-            final NormalizedNodeDataInput stream = NormalizedNodeInputOutput.newDataInput(in);
+            final NormalizedNodeDataInput stream = NormalizedNodeDataInput.newDataInput(in);
             version = stream.getVersion();
             rootNode = stream.readNormalizedNode();
         }
index e709c81..eb94a70 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
index 6d19d9c..7a2b85f 100644 (file)
@@ -16,13 +16,13 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public final class ExecuteAction extends AbstractExecute<@NonNull ContainerNode> {
@@ -83,7 +83,7 @@ public final class ExecuteAction extends AbstractExecute<@NonNull ContainerNode>
 
         @Override
         public void readExternal(final ObjectInput in) throws IOException {
-            final NormalizedNodeDataInput stream = NormalizedNodeInputOutput.newDataInput(in);
+            final NormalizedNodeDataInput stream = NormalizedNodeDataInput.newDataInput(in);
             final SchemaPath name = stream.readSchemaPath();
             final LogicalDatastoreType type = LogicalDatastoreType.readFrom(in);
             final YangInstanceIdentifier path = stream.readYangInstanceIdentifier();
index cfa0c89..020b966 100644 (file)
@@ -15,11 +15,11 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public final class ExecuteRpc extends AbstractExecute<@Nullable NormalizedNode<?, ?>> {
@@ -65,7 +65,7 @@ public final class ExecuteRpc extends AbstractExecute<@Nullable NormalizedNode<?
 
         @Override
         public void readExternal(final ObjectInput in) throws IOException {
-            final NormalizedNodeDataInput stream = NormalizedNodeInputOutput.newDataInput(in);
+            final NormalizedNodeDataInput stream = NormalizedNodeDataInput.newDataInput(in);
             final SchemaPath type = SchemaPath.ROOT.createChild(stream.readQName());
             final NormalizedNode<?, ?> input = stream.readOptionalNormalizedNode().orElse(null);
             executeRpc = new ExecuteRpc(type, input);
index 3c96859..af9a55f 100644 (file)
@@ -19,12 +19,12 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMActionInstance;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,7 +69,7 @@ public final class ActionRoutingTable extends AbstractRoutingTable<ActionRouting
             LOG.debug("deserializing ActionRoutingTable");
             opsInvoker = JavaSerializer.currentSystem().value().provider().resolveActorRef((String) in.readObject());
 
-            final NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(in);
+            final NormalizedNodeDataInput nnin = NormalizedNodeDataInput.newDataInput(in);
             final int size = nnin.readInt();
             actions = new ArrayList<>(size);
             for (int i = 0; i < size; ++i) {
index 8d67b3b..702d045 100644 (file)
@@ -19,10 +19,10 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput;
 
 public final class RoutingTable extends AbstractRoutingTable<RoutingTable, DOMRpcIdentifier> {
     private static final class Proxy implements Externalizable {
@@ -60,7 +60,7 @@ public final class RoutingTable extends AbstractRoutingTable<RoutingTable, DOMRp
         public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
             opsInvoker = JavaSerializer.currentSystem().value().provider().resolveActorRef((String) in.readObject());
 
-            final NormalizedNodeDataInput nnin = NormalizedNodeInputOutput.newDataInput(in);
+            final NormalizedNodeDataInput nnin = NormalizedNodeDataInput.newDataInput(in);
             final int size = nnin.readInt();
             rpcs = new ArrayList<>(size);
             for (int i = 0; i < size; ++i) {

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.