X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fstream%2FNormalizedNodeInputStreamReader.java;h=7753242fcad11d02d24ed61ac9c4e3d95216f53f;hp=03bd56eae74370a8631fca1985acad59a5d4271d;hb=8976f4ccffeba131a6f0fe1f44c7a088ef1132c8;hpb=3ee741416f6f67699392f8d9de9142f828d8981e diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java index 03bd56eae7..7753242fca 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java @@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory; * */ -public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamReader { +public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput, NormalizedNodeStreamReader { private static final Logger LOG = LoggerFactory.getLogger(NormalizedNodeInputStreamReader.class); @@ -75,12 +75,20 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamRead */ @Deprecated public NormalizedNodeInputStreamReader(final InputStream stream) throws IOException { - Preconditions.checkNotNull(stream); - input = new DataInputStream(stream); + this((DataInput) new DataInputStream(Preconditions.checkNotNull(stream))); } + /** + * @deprecated Use {@link NormalizedNodeInputOutput#newDataInput(DataInput)} instead. + */ + @Deprecated public NormalizedNodeInputStreamReader(final DataInput input) { + this(input, false); + } + + NormalizedNodeInputStreamReader(final DataInput input, final boolean versionChecked) { this.input = Preconditions.checkNotNull(input); + readSignatureMarker = !versionChecked; } @Override @@ -213,6 +221,13 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamRead return addLeafSetChildren(identifier.getNodeType(), Builders.leafSetBuilder().withNodeIdentifier(identifier)).build(); + case NodeTypes.ORDERED_LEAF_SET: + LOG.debug("Read leaf set node"); + ListNodeBuilder> orderedLeafSetBuilder = + Builders.orderedLeafSetBuilder().withNodeIdentifier(identifier); + orderedLeafSetBuilder = addLeafSetChildren(identifier.getNodeType(), orderedLeafSetBuilder); + return orderedLeafSetBuilder.build(); + default : return null; } @@ -327,6 +342,7 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamRead return new String(bytes, StandardCharsets.UTF_8); } + @Override public YangInstanceIdentifier readYangInstanceIdentifier() throws IOException { readSignatureMarkerAndVersionIfNeeded(); return readYangInstanceIdentifierInternal(); @@ -352,6 +368,7 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamRead return children; } + @Override public PathArgument readPathArgument() throws IOException { // read Type int type = input.readByte(); @@ -405,4 +422,94 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeStreamRead } return builder; } + + @Override + public void readFully(final byte[] b) throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + input.readFully(b); + } + + @Override + public void readFully(final byte[] b, final int off, final int len) throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + input.readFully(b, off, len); + } + + @Override + public int skipBytes(final int n) throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.skipBytes(n); + } + + @Override + public boolean readBoolean() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readBoolean(); + } + + @Override + public byte readByte() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readByte(); + } + + @Override + public int readUnsignedByte() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readUnsignedByte(); + } + + @Override + public short readShort() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readShort(); + } + + @Override + public int readUnsignedShort() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readUnsignedShort(); + } + + @Override + public char readChar() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readChar(); + } + + @Override + public int readInt() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readInt(); + } + + @Override + public long readLong() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readLong(); + } + + @Override + public float readFloat() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readFloat(); + } + + @Override + public double readDouble() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readDouble(); + } + + @Override + public String readLine() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readLine(); + } + + @Override + public String readUTF() throws IOException { + readSignatureMarkerAndVersionIfNeeded(); + return input.readUTF(); + } }