X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fstream%2FAbstractNormalizedNodeDataOutput.java;h=d54baf92fc43538be2c11ab2c23c945d16c41cb5;hb=42b82f3d3e936b78f66301bdc08f6b744bcc740b;hp=b096a445f387dca2d84a05159f370c6240dba27c;hpb=ba411b9ab99dc4420f2ba180a91a4e9a3af1d5d8;p=controller.git 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 index b096a445f3..d54baf92fc 100755 --- 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 @@ -39,6 +39,20 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * 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. + * + *

Based on the each node, the node type is also written to the stream, that helps in reconstructing the object, + * while reading. + */ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOutput, NormalizedNodeStreamWriter { private static final Logger LOG = LoggerFactory.getLogger(AbstractNormalizedNodeDataOutput.class); @@ -63,7 +77,7 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut protected abstract short streamVersion(); - protected abstract void writeString(String string) throws IOException; + abstract void writeString(@NonNull String string) throws IOException; @Override public final void write(final int value) throws IOException { @@ -348,14 +362,19 @@ abstract class AbstractNormalizedNodeDataOutput implements NormalizedNodeDataOut output.writeInt(pathArguments.size()); for (PathArgument pathArgument : pathArguments) { - writePathArgument(pathArgument); + writePathArgumentInternal(pathArgument); } } - @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", - justification = "The casts in the switch clauses are indirectly confirmed via the determination of 'type'.") @Override public void writePathArgument(final PathArgument pathArgument) throws IOException { + ensureHeaderWritten(); + writePathArgumentInternal(pathArgument); + } + + @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 { byte type = PathArgumentTypes.getSerializablePathArgumentType(pathArgument);