Bug 7521: Convert Snapshot to store a State instance
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / base / messages / CaptureSnapshotReply.java
index 1e573014a9ed6596ae6af84df0f724a9e730c34c..cc981e5711ae5e2e356adf693dded5abe126e4fb 100644 (file)
@@ -7,22 +7,29 @@
  */
 package org.opendaylight.controller.cluster.raft.base.messages;
 
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import com.google.common.base.Preconditions;
+import java.io.OutputStream;
+import java.util.Optional;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
 
 public class CaptureSnapshotReply {
-    private final byte [] snapshot;
+    private final Snapshot.State snapshotState;
+    private final Optional<OutputStream> installSnapshotStream;
 
-    @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Stores a reference to an externally mutable byte[] "
-            + "object but this is OK since this class is merely a DTO and does not process byte[] internally. "
-            + "Also it would be inefficient to create a copy as the byte[] could be large.")
-    public CaptureSnapshotReply(byte [] snapshot) {
-        this.snapshot = snapshot;
+    public CaptureSnapshotReply(@Nonnull final Snapshot.State snapshotState,
+            @Nonnull final Optional<OutputStream> installSnapshotStream) {
+        this.snapshotState = Preconditions.checkNotNull(snapshotState);
+        this.installSnapshotStream = Preconditions.checkNotNull(installSnapshotStream);
     }
 
-    @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but "
-            + "this is OK since this class is merely a DTO and does not process the byte[] internally. "
-            + "Also it would be inefficient to create a return copy as the byte[] could be large.")
-    public byte [] getSnapshot() {
-        return snapshot;
+    @Nonnull
+    public Snapshot.State getSnapshotState() {
+        return snapshotState;
+    }
+
+    @Nonnull
+    public Optional<OutputStream> getInstallSnapshotStream() {
+        return installSnapshotStream;
     }
 }