Hide NormalizedNodeOutputStreamWriter 47/34847/6
authorRobert Varga <rovarga@cisco.com>
Wed, 17 Feb 2016 15:17:32 +0000 (16:17 +0100)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 18 Feb 2016 18:49:53 +0000 (18:49 +0000)
This is an internal implementation class, hide it.

Change-Id: Ib79d5a48dcf967f832b7130b981e5c22a593ef80
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeOutputStreamWriter.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataTreeCandidatePayload.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.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/utils/SerializationUtils.java

index f68e86f..5eaa7fc 100644 (file)
@@ -28,14 +28,10 @@ import org.opendaylight.yangtools.yang.common.QName;
  * Based on the each node, the node type is also written to the stream, that helps in reconstructing the object,
  * while reading.
  */
-public class NormalizedNodeOutputStreamWriter extends AbstractNormalizedNodeDataOutput {
+final class NormalizedNodeOutputStreamWriter extends AbstractNormalizedNodeDataOutput {
     private final Map<String, Integer> stringCodeMap = new HashMap<>();
 
-    /**
-     * @deprecated Use {@link NormalizedNodeInputOutput#newDataOutput(DataOutput)} instead.
-     */
-    @Deprecated
-    public NormalizedNodeOutputStreamWriter(final DataOutput output) {
+    NormalizedNodeOutputStreamWriter(final DataOutput output) {
         super(output);
     }
 
index 5df291f..2108361 100644 (file)
@@ -21,7 +21,7 @@ import java.util.Collections;
 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.NormalizedNodeInputStreamReader;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
@@ -97,7 +97,7 @@ final class DataTreeCandidatePayload extends Payload implements Externalizable {
 
     static DataTreeCandidatePayload create(final DataTreeCandidate candidate) {
         final ByteArrayDataOutput out = ByteStreams.newDataOutput();
-        try (final NormalizedNodeOutputStreamWriter writer = new NormalizedNodeOutputStreamWriter(out)) {
+        try (final NormalizedNodeDataOutput writer = NormalizedNodeInputOutput.newDataOutput(out)) {
             writer.writeYangInstanceIdentifier(candidate.getRootPath());
 
             final DataTreeCandidateNode node = candidate.getRootNode();
index fe81e27..6867f46 100644 (file)
@@ -15,15 +15,15 @@ import java.io.ObjectOutput;
 import java.util.Map;
 import java.util.Set;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
+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.NormalizedNodeInputStreamReader;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent;
 import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.Builder;
 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.NormalizedNodeWriter;
 
 public class DataChanged implements Externalizable {
     private static final long serialVersionUID = 1L;
@@ -99,8 +99,7 @@ public class DataChanged implements Externalizable {
     public void writeExternal(ObjectOutput out) throws IOException {
         out.writeShort(DataStoreVersions.CURRENT_VERSION);
 
-        NormalizedNodeOutputStreamWriter streamWriter = new NormalizedNodeOutputStreamWriter(out);
-        NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(streamWriter);
+        NormalizedNodeDataOutput streamWriter = NormalizedNodeInputOutput.newDataOutput(out);
 
         // Write created data
 
@@ -108,7 +107,7 @@ public class DataChanged implements Externalizable {
         out.writeInt(createdData.size());
         for(Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> e: createdData.entrySet()) {
             streamWriter.writeYangInstanceIdentifier(e.getKey());
-            nodeWriter.write(e.getValue());
+            streamWriter.writeNormalizedNode(e.getValue());
         }
 
         // Write updated data
@@ -118,8 +117,8 @@ public class DataChanged implements Externalizable {
         out.writeInt(updatedData.size());
         for(Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> e: updatedData.entrySet()) {
             streamWriter.writeYangInstanceIdentifier(e.getKey());
-            nodeWriter.write(originalData.get(e.getKey()));
-            nodeWriter.write(e.getValue());
+            streamWriter.writeNormalizedNode(originalData.get(e.getKey()));
+            streamWriter.writeNormalizedNode(e.getValue());
         }
 
         // Write removed data
@@ -128,7 +127,7 @@ public class DataChanged implements Externalizable {
         out.writeInt(removed.size());
         for(YangInstanceIdentifier path: removed) {
             streamWriter.writeYangInstanceIdentifier(path);
-            nodeWriter.write(originalData.get(path));
+            streamWriter.writeNormalizedNode(originalData.get(path));
         }
 
         // Write original subtree
@@ -136,7 +135,7 @@ public class DataChanged implements Externalizable {
         NormalizedNode<?, ?> originalSubtree = change.getOriginalSubtree();
         out.writeBoolean(originalSubtree != null);
         if(originalSubtree != null) {
-            nodeWriter.write(originalSubtree);
+            streamWriter.writeNormalizedNode(originalSubtree);
         }
 
         // Write original subtree
@@ -144,7 +143,7 @@ public class DataChanged implements Externalizable {
         NormalizedNode<?, ?> updatedSubtree = change.getUpdatedSubtree();
         out.writeBoolean(updatedSubtree != null);
         if(updatedSubtree != null) {
-            nodeWriter.write(updatedSubtree);
+            streamWriter.writeNormalizedNode(updatedSubtree);
         }
     }
 }
index b594578..c3746e0 100644 (file)
@@ -14,8 +14,8 @@ import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter;
 import org.opendaylight.controller.cluster.datastore.utils.SerializationUtils;
 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
@@ -120,7 +120,7 @@ public class MutableCompositeModification implements CompositeModification {
         out.writeInt(modifications.size());
 
         if(modifications.size() > 1) {
-            SerializationUtils.REUSABLE_WRITER_TL.set(new NormalizedNodeOutputStreamWriter(out));
+            SerializationUtils.REUSABLE_WRITER_TL.set(NormalizedNodeInputOutput.newDataOutput(out));
         }
 
         try {
index 79772fe..b416b92 100644 (file)
@@ -20,8 +20,8 @@ import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCo
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.InvalidNormalizedNodeStreamException;
 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.NormalizedNodeInputStreamReader;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter;
 import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -32,7 +32,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
  * @author Thomas Pantelis
  */
 public final class SerializationUtils {
-    public static final ThreadLocal<NormalizedNodeOutputStreamWriter> REUSABLE_WRITER_TL = new ThreadLocal<>();
+    public static final ThreadLocal<NormalizedNodeDataOutput> REUSABLE_WRITER_TL = new ThreadLocal<>();
     public static final ThreadLocal<NormalizedNodeInputStreamReader> REUSABLE_READER_TL = new ThreadLocal<>();
 
     public static interface Applier<T> {
@@ -40,9 +40,9 @@ public final class SerializationUtils {
     }
 
     private static NormalizedNodeDataOutput streamWriter(DataOutput out) throws IOException {
-        NormalizedNodeOutputStreamWriter streamWriter = REUSABLE_WRITER_TL.get();
+        NormalizedNodeDataOutput streamWriter = REUSABLE_WRITER_TL.get();
         if(streamWriter == null) {
-            streamWriter = new NormalizedNodeOutputStreamWriter(out);
+            streamWriter = NormalizedNodeInputOutput.newDataOutput(out);
         }
 
         return streamWriter;