package org.opendaylight.controller.cluster.raft.base.messages;
-import java.io.Serializable;
+import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.cluster.raft.Snapshot;
-public class ApplySnapshot implements Serializable {
- private final Object snapshot;
+/**
+ * Internal message, issued by follower to its actor
+ */
+public class ApplySnapshot {
+ private static final Callback NOOP_CALLBACK = new Callback() {
+ @Override
+ public void onSuccess() {
+ // No-op
+ }
+
+ @Override
+ public void onFailure() {
+ // No-op
+ }
+ };
+
+ private final Snapshot snapshot;
+ private final Callback callback;
+
+ public ApplySnapshot(Snapshot snapshot) {
+ this(snapshot, NOOP_CALLBACK);
+ }
- public ApplySnapshot(Object snapshot) {
- this.snapshot = snapshot;
+ public ApplySnapshot(@Nonnull Snapshot snapshot, @Nonnull Callback callback) {
+ this.snapshot = Preconditions.checkNotNull(snapshot);
+ this.callback = Preconditions.checkNotNull(callback);
}
- public Object getSnapshot() {
+ @Nonnull
+ public Snapshot getSnapshot() {
return snapshot;
}
+
+ @Nonnull
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public interface Callback {
+ void onSuccess();
+
+ void onFailure();
+ }
}