throw new UnsupportedOperationException();
}
+ /**
+ * Creates a new {@link NormalizedNodeDataInput} instance that reads from the given input. This method first reads
+ * and validates that the input contains a valid NormalizedNode stream.
+ *
+ * @param input the DataInput to read from
+ * @return a new {@link NormalizedNodeDataInput} instance
+ * @throws IOException if an error occurs reading from the input
+ */
public static NormalizedNodeDataInput newDataInput(@Nonnull final DataInput input) throws IOException {
final byte marker = input.readByte();
if (marker != TokenTypes.SIGNATURE_MARKER) {
}
}
- public static NormalizedNodeDataOutput newDataOutput(@Nonnull final DataOutput output) throws IOException {
+ /**
+ * Creates a new {@link NormalizedNodeDataInput} instance that reads from the given input. This method does not
+ * perform any initial validation of the input stream.
+ *
+ * @param input the DataInput to read from
+ * @return a new {@link NormalizedNodeDataInput} instance
+ */
+ public static NormalizedNodeDataInput newDataInputWithoutValidation(@Nonnull final DataInput input) {
+ return new NormalizedNodeInputStreamReader(input, false);
+ }
+
+ /**
+ * Creates a new {@link NormalizedNodeDataOutput} instance that writes to the given output.
+ *
+ * @param output the DataOutput to write to
+ * @return a new {@link NormalizedNodeDataOutput} instance
+ */
+ public static NormalizedNodeDataOutput newDataOutput(@Nonnull final DataOutput output) {
return new NormalizedNodeOutputStreamWriter(output);
}
}
private boolean readSignatureMarker = true;
- /**
- * Constructs an instance.
- *
- * @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;
void apply(T instance, YangInstanceIdentifier path, NormalizedNode<?, ?> node);
}
- private static NormalizedNodeDataOutput streamWriter(DataOutput out) throws IOException {
+ private static NormalizedNodeDataOutput streamWriter(DataOutput out) {
NormalizedNodeDataOutput streamWriter = REUSABLE_WRITER_TL.get();
if (streamWriter == null) {
streamWriter = NormalizedNodeInputOutput.newDataOutput(out);
private void readObject(final ObjectInputStream stream)
throws IOException, ClassNotFoundException, URISyntaxException {
- NormalizedNodeDataInput reader = new NormalizedNodeInputStreamReader(stream);
+ NormalizedNodeDataInput reader = NormalizedNodeInputOutput.newDataInput(stream);
this.input = reader.readNormalizedNode();
}
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.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;
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
in.readShort(); // Read the version
- NormalizedNodeDataInput streamReader = new NormalizedNodeInputStreamReader(in);
+ NormalizedNodeDataInput streamReader = NormalizedNodeInputOutput.newDataInputWithoutValidation(in);
// Note: the scope passed to builder is not actually used.
Builder builder = DOMImmutableDataChangeEvent.builder(DataChangeScope.SUBTREE);
import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
import org.opendaylight.controller.cluster.datastore.messages.VersionedExternalizableMessage;
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.SerializationUtils;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
int size = in.readInt();
if (size > 1) {
- SerializationUtils.REUSABLE_READER_TL.set(new NormalizedNodeInputStreamReader(in));
+ SerializationUtils.REUSABLE_READER_TL.set(NormalizedNodeInputOutput.newDataInputWithoutValidation(in));
}
try {
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.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
}
public static DataTreeCandidate readDataTreeCandidate(final DataInput in) throws IOException {
- final NormalizedNodeDataInput reader = new NormalizedNodeInputStreamReader(in);
+ final NormalizedNodeDataInput reader = NormalizedNodeInputOutput.newDataInput(in);
final YangInstanceIdentifier rootPath = reader.readYangInstanceIdentifier();
final byte type = reader.readByte();