package org.opendaylight.controller.cluster.datastore.messages;
-import com.google.protobuf.ByteString;
-import org.opendaylight.controller.cluster.datastore.node.NormalizedNodeToNodeCodec;
-import org.opendaylight.controller.protobuff.messages.transaction.ShardTransactionMessages;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class ReadDataReply implements SerializableMessage {
- public static final Class<ShardTransactionMessages.ReadDataReply> SERIALIZABLE_CLASS =
- ShardTransactionMessages.ReadDataReply.class;
+public class ReadDataReply extends VersionedExternalizableMessage {
+ private static final long serialVersionUID = 1L;
- private final NormalizedNode<?, ?> normalizedNode;
- private final SchemaContext schemaContext;
+ private NormalizedNode<?, ?> normalizedNode;
- public ReadDataReply(SchemaContext context,NormalizedNode<?, ?> normalizedNode){
+ public ReadDataReply() {
+ }
+ public ReadDataReply(NormalizedNode<?, ?> normalizedNode, short version) {
+ super(version);
this.normalizedNode = normalizedNode;
- this.schemaContext = context;
}
public NormalizedNode<?, ?> getNormalizedNode() {
}
@Override
- public Object toSerializable(){
- if(normalizedNode != null) {
- return ShardTransactionMessages.ReadDataReply.newBuilder()
- .setNormalizedNode(new NormalizedNodeToNodeCodec(schemaContext)
- .encode(normalizedNode).getNormalizedNode()).build();
- } else {
- return ShardTransactionMessages.ReadDataReply.newBuilder().build();
-
- }
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+ normalizedNode = SerializationUtils.deserializeNormalizedNode(in);
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ SerializationUtils.serializeNormalizedNode(normalizedNode, out);
}
- public static ReadDataReply fromSerializable(SchemaContext schemaContext,
- YangInstanceIdentifier id, Object serializable) {
- ShardTransactionMessages.ReadDataReply o = (ShardTransactionMessages.ReadDataReply) serializable;
- return new ReadDataReply(schemaContext, new NormalizedNodeToNodeCodec(schemaContext).decode(
- o.getNormalizedNode()));
+ public static ReadDataReply fromSerializable(Object serializable) {
+ return (ReadDataReply) serializable;
}
- public static ByteString getNormalizedNodeByteString(Object serializable){
- ShardTransactionMessages.ReadDataReply o = (ShardTransactionMessages.ReadDataReply) serializable;
- return ((ShardTransactionMessages.ReadDataReply) serializable).getNormalizedNode().toByteString();
+ public static boolean isSerializedType(Object message) {
+ return message instanceof ReadDataReply;
}
}