Add support for reusable streaming
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / TransactionModification.java
index d71142201c2c25807e73fcd1e22128d16f5e7ca3..dcd05c35140eb4d4c4448554bb0aa3dd4c785c4b 100644 (file)
@@ -14,10 +14,12 @@ 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.impl.schema.ReusableImmutableNormalizedNodeStreamWriter;
 
 /**
  * An individual modification of a transaction's state. This class and its subclasses are not serializable, but rather
- * expose {@link #writeTo(NormalizedNodeDataOutput)} and {@link #readFrom(NormalizedNodeDataInput)} methods for explicit
+ * expose {@link #writeTo(NormalizedNodeDataOutput)} and
+ * {@link #readFrom(NormalizedNodeDataInput, ReusableImmutableNormalizedNodeStreamWriter)} methods for explicit
  * serialization. The reason for this is that they are usually transmitted in bulk, hence it is advantageous to reuse
  * a {@link NormalizedNodeDataOutput} instance to achieve better compression.
  *
@@ -51,15 +53,16 @@ public abstract class TransactionModification {
         out.writeYangInstanceIdentifier(path);
     }
 
-    static TransactionModification readFrom(final NormalizedNodeDataInput in) throws IOException {
+    static TransactionModification readFrom(final NormalizedNodeDataInput in,
+            final ReusableImmutableNormalizedNodeStreamWriter writer) throws IOException {
         final byte type = in.readByte();
         switch (type) {
             case TYPE_DELETE:
                 return new TransactionDelete(in.readYangInstanceIdentifier());
             case TYPE_MERGE:
-                return new TransactionMerge(in.readYangInstanceIdentifier(), in.readNormalizedNode());
+                return new TransactionMerge(in.readYangInstanceIdentifier(), in.readNormalizedNode(writer));
             case TYPE_WRITE:
-                return new TransactionWrite(in.readYangInstanceIdentifier(), in.readNormalizedNode());
+                return new TransactionWrite(in.readYangInstanceIdentifier(), in.readNormalizedNode(writer));
             default:
                 throw new IllegalArgumentException("Unhandled type " + type);
         }