BUG-5280: add CommitTransactionPayload
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / DataTreeCandidatePayload.java
index 8da70c2e29cc8a7c5019873e19dfe55ab9ea4f04..25a7ee86229dcccf7b42a4c2d0eae1561c43ae12 100644 (file)
@@ -14,14 +14,20 @@ import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.AbstractMap.SimpleImmutableEntry;
+import java.util.Map.Entry;
+import java.util.Optional;
+import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
 import org.opendaylight.controller.cluster.datastore.persisted.DataTreeCandidateInputOutput;
+import org.opendaylight.controller.cluster.datastore.persisted.DataTreeCandidateSupplier;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-final class DataTreeCandidatePayload extends Payload implements Externalizable {
-    private static final Logger LOG = LoggerFactory.getLogger(DataTreeCandidatePayload.class);
+/**
+ * @deprecated Deprecated in Boron in favor of CommitTransactionPayload
+ */
+@Deprecated
+final class DataTreeCandidatePayload extends Payload implements DataTreeCandidateSupplier, Externalizable {
     private static final long serialVersionUID = 1L;
 
     private transient byte[] serialized;
@@ -34,6 +40,10 @@ final class DataTreeCandidatePayload extends Payload implements Externalizable {
         this.serialized = Preconditions.checkNotNull(serialized);
     }
 
+    /**
+     * @deprecated Use CommitTransactionPayload instead
+     */
+    @Deprecated
     static DataTreeCandidatePayload create(final DataTreeCandidate candidate) {
         final ByteArrayDataOutput out = ByteStreams.newDataOutput();
         try {
@@ -46,8 +56,10 @@ final class DataTreeCandidatePayload extends Payload implements Externalizable {
     }
 
 
-    DataTreeCandidate getCandidate() throws IOException {
-        return DataTreeCandidateInputOutput.readDataTreeCandidate(ByteStreams.newDataInput(serialized));
+    @Override
+    public Entry<Optional<TransactionIdentifier>, DataTreeCandidate> getCandidate() throws IOException {
+        return new SimpleImmutableEntry<>(Optional.empty(),
+                DataTreeCandidateInputOutput.readDataTreeCandidate(ByteStreams.newDataInput(serialized)));
     }
 
     @Override