All versioned callers have been converted to use appropriate
stream versions, this patch bumps the default unversioned stream
to Sodium version.
Since we're changing the serialization format for ExecuteRpc,
make sure we fully embrace writer/reader, so that we get better
instantiation.
JIRA: CONTROLLER-1888
Change-Id: I17deeda1a49394600a5b0f93bd46d3b2c812123c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
protected abstract short streamVersion();
protected abstract short streamVersion();
- protected abstract void writeQName(QName qname) throws IOException;
-
protected abstract void writeString(String string) throws IOException;
@Override
protected abstract void writeString(String string) throws IOException;
@Override
import java.io.IOException;
import org.eclipse.jdt.annotation.NonNull;
import java.io.IOException;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.QName;
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.NormalizedNode;
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.NormalizedNode;
return delegate().readYangInstanceIdentifier();
}
return delegate().readYangInstanceIdentifier();
}
+ @Override
+ public final QName readQName() throws IOException {
+ return delegate().readQName();
+ }
+
@Override
public final PathArgument readPathArgument() throws IOException {
return delegate().readPathArgument();
@Override
public final PathArgument readPathArgument() throws IOException {
return delegate().readPathArgument();
- QName readQName() throws IOException {
+ @Override
+ public QName readQName() throws IOException {
// Read in the same sequence of writing
String localName = readCodedString();
String namespace = readCodedString();
// Read in the same sequence of writing
String localName = readCodedString();
String namespace = readCodedString();
- protected void writeQName(final QName qname) throws IOException {
+ public void writeQName(final QName qname) throws IOException {
writeString(qname.getLocalName());
writeModule(qname.getModule());
}
writeString(qname.getLocalName());
writeModule(qname.getModule());
}
import com.google.common.annotations.Beta;
import java.io.DataInput;
import java.io.IOException;
import com.google.common.annotations.Beta;
import java.io.DataInput;
import java.io.IOException;
+import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.QName;
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.NormalizedNode;
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.NormalizedNode;
YangInstanceIdentifier readYangInstanceIdentifier() throws IOException;
YangInstanceIdentifier readYangInstanceIdentifier() throws IOException;
+ @NonNull QName readQName() throws IOException;
+
PathArgument readPathArgument() throws IOException;
SchemaPath readSchemaPath() throws IOException;
PathArgument readPathArgument() throws IOException;
SchemaPath readSchemaPath() throws IOException;
* @throws IOException if the version cannot be ascertained
*/
NormalizedNodeStreamVersion getVersion() throws IOException;
* @throws IOException if the version cannot be ascertained
*/
NormalizedNodeStreamVersion getVersion() throws IOException;
+
+ default Optional<NormalizedNode<?, ?>> readOptionalNormalizedNode() throws IOException {
+ return readBoolean() ? Optional.of(readNormalizedNode()) : Optional.empty();
+ }
import java.io.IOException;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import java.io.IOException;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.common.QName;
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.NormalizedNode;
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.NormalizedNode;
*/
@Beta
public interface NormalizedNodeDataOutput extends AutoCloseable, DataOutput {
*/
@Beta
public interface NormalizedNodeDataOutput extends AutoCloseable, DataOutput {
+ void writeQName(@NonNull QName qname) throws IOException;
+
void writeNormalizedNode(@NonNull NormalizedNode<?, ?> normalizedNode) throws IOException;
void writePathArgument(PathArgument pathArgument) throws IOException;
void writeNormalizedNode(@NonNull NormalizedNode<?, ?> normalizedNode) throws IOException;
void writePathArgument(PathArgument pathArgument) throws IOException;
* <p>Based on the each node, the node type is also written to the stream, that helps in reconstructing the object,
* while reading.
*/
* <p>Based on the each node, the node type is also written to the stream, that helps in reconstructing the object,
* while reading.
*/
-// FIXME: CONTROLLER-1888: switch this to Sodium once we have a corresponding datastore version
-class NormalizedNodeOutputStreamWriter extends LithiumNormalizedNodeOutputStreamWriter {
+class NormalizedNodeOutputStreamWriter extends SodiumNormalizedNodeOutputStreamWriter {
NormalizedNodeOutputStreamWriter(final DataOutput output) {
super(output);
}
NormalizedNodeOutputStreamWriter(final DataOutput output) {
super(output);
}
- QName readQName() throws IOException {
+ public QName readQName() throws IOException {
final byte valueType = readByte();
switch (valueType) {
case TokenTypes.IS_QNAME_CODE:
final byte valueType = readByte();
switch (valueType) {
case TokenTypes.IS_QNAME_CODE:
- protected final void writeQName(final QName qname) throws IOException {
+ public final void writeQName(final QName qname) throws IOException {
final Integer value = qnameCodeMap.get(qname);
if (value == null) {
// Fresh QName, remember it and emit as three strings
final Integer value = qnameCodeMap.get(qname);
if (value == null) {
// Fresh QName, remember it and emit as three strings
import java.io.Serializable;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import java.io.Serializable;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
+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.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
- // FIXME: QName is a WritableObject
- out.writeObject(executeRpc.getRpc());
- SerializationUtils.writeNormalizedNode(out, executeRpc.getInputNormalizedNode());
+ try (NormalizedNodeDataOutput stream = NormalizedNodeInputOutput.newDataOutput(out)) {
+ stream.writeQName(executeRpc.getRpc());
+ stream.writeOptionalNormalizedNode(executeRpc.getInputNormalizedNode());
+ }
}
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
}
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
- // FIXME: QName is a WritableObject
- QName qname = (QName) in.readObject();
- executeRpc = new ExecuteRpc(SerializationUtils.readNormalizedNode(in).orElse(null), qname);
+ final NormalizedNodeDataInput stream = NormalizedNodeInputOutput.newDataInput(in);
+ final QName qname = stream.readQName();
+ executeRpc = new ExecuteRpc(stream.readOptionalNormalizedNode().orElse(null), qname);
}
private Object readResolve() {
}
private Object readResolve() {