X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Futils%2FSerializationUtils.java;h=79772fed5e23c9bad4cce7d71febc0ea5f367739;hb=87c8362c7501408b281f5ddc9b78ed7440280fa1;hp=bf9f8d803ac00f0e8ce2cbe983f81bfb9e9a44d0;hpb=bbaba878c38f381b0b924f89b29a1d0fcf6e2a2f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java index bf9f8d803a..79772fed5e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/SerializationUtils.java @@ -18,6 +18,8 @@ import java.io.DataOutputStream; import java.io.IOException; import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec; 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.NormalizedNodeInputStreamReader; import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeOutputStreamWriter; import org.opendaylight.controller.protobuff.messages.common.NormalizedNodeMessages; @@ -30,14 +32,14 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; * @author Thomas Pantelis */ public final class SerializationUtils { - public static ThreadLocal REUSABLE_WRITER_TL = new ThreadLocal<>(); - public static ThreadLocal REUSABLE_READER_TL = new ThreadLocal<>(); + public static final ThreadLocal REUSABLE_WRITER_TL = new ThreadLocal<>(); + public static final ThreadLocal REUSABLE_READER_TL = new ThreadLocal<>(); public static interface Applier { void apply(T instance, YangInstanceIdentifier path, NormalizedNode node); } - private static NormalizedNodeOutputStreamWriter streamWriter(DataOutput out) throws IOException { + private static NormalizedNodeDataOutput streamWriter(DataOutput out) throws IOException { NormalizedNodeOutputStreamWriter streamWriter = REUSABLE_WRITER_TL.get(); if(streamWriter == null) { streamWriter = new NormalizedNodeOutputStreamWriter(out); @@ -46,7 +48,7 @@ public final class SerializationUtils { return streamWriter; } - private static NormalizedNodeInputStreamReader streamReader(DataInput in) throws IOException { + private static NormalizedNodeDataInput streamReader(DataInput in) throws IOException { NormalizedNodeInputStreamReader streamWriter = REUSABLE_READER_TL.get(); if(streamWriter == null) { streamWriter = new NormalizedNodeInputStreamReader(in); @@ -60,7 +62,7 @@ public final class SerializationUtils { Preconditions.checkNotNull(path); Preconditions.checkNotNull(node); try { - NormalizedNodeOutputStreamWriter streamWriter = streamWriter(out); + NormalizedNodeDataOutput streamWriter = streamWriter(out); streamWriter.writeNormalizedNode(node); streamWriter.writeYangInstanceIdentifier(path); } catch (IOException e) { @@ -71,7 +73,7 @@ public final class SerializationUtils { public static void deserializePathAndNode(DataInput in, T instance, Applier applier) { try { - NormalizedNodeInputStreamReader streamReader = streamReader(in); + NormalizedNodeDataInput streamReader = streamReader(in); NormalizedNode node = streamReader.readNormalizedNode(); YangInstanceIdentifier path = streamReader.readYangInstanceIdentifier(); applier.apply(instance, path, node); @@ -84,7 +86,7 @@ public final class SerializationUtils { try { out.writeBoolean(node != null); if(node != null) { - NormalizedNodeOutputStreamWriter streamWriter = streamWriter(out); + NormalizedNodeDataOutput streamWriter = streamWriter(out); streamWriter.writeNormalizedNode(node); } } catch (IOException e) { @@ -104,7 +106,7 @@ public final class SerializationUtils { private static NormalizedNode tryDeserializeNormalizedNode(DataInput in) throws IOException { boolean present = in.readBoolean(); if(present) { - NormalizedNodeInputStreamReader streamReader = streamReader(in); + NormalizedNodeDataInput streamReader = streamReader(in); return streamReader.readNormalizedNode(); } @@ -139,7 +141,7 @@ public final class SerializationUtils { public static void serializePath(YangInstanceIdentifier path, DataOutput out) { Preconditions.checkNotNull(path); try { - NormalizedNodeOutputStreamWriter streamWriter = streamWriter(out); + NormalizedNodeDataOutput streamWriter = streamWriter(out); streamWriter.writeYangInstanceIdentifier(path); } catch (IOException e) { throw new IllegalArgumentException(String.format("Error serializing path %s", path), e); @@ -148,7 +150,7 @@ public final class SerializationUtils { public static YangInstanceIdentifier deserializePath(DataInput in) { try { - NormalizedNodeInputStreamReader streamReader = streamReader(in); + NormalizedNodeDataInput streamReader = streamReader(in); return streamReader.readYangInstanceIdentifier(); } catch (IOException e) { throw new IllegalArgumentException("Error deserializing path", e);