Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / base / messages / ApplySnapshot.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.raft.base.messages;
9
10 import static java.util.Objects.requireNonNull;
11
12 import akka.dispatch.ControlMessage;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
15
16 /**
17  * Internal message, issued by follower to its actor.
18  */
19 public class ApplySnapshot implements ControlMessage {
20     private static final Callback NOOP_CALLBACK = new Callback() {
21         @Override
22         public void onSuccess() {
23             // No-op
24         }
25
26         @Override
27         public void onFailure() {
28             // No-op
29         }
30     };
31
32     private final Snapshot snapshot;
33     private final Callback callback;
34
35     public ApplySnapshot(@NonNull Snapshot snapshot) {
36         this(snapshot, NOOP_CALLBACK);
37     }
38
39     public ApplySnapshot(@NonNull Snapshot snapshot, @NonNull Callback callback) {
40         this.snapshot = requireNonNull(snapshot);
41         this.callback = requireNonNull(callback);
42     }
43
44     public @NonNull Snapshot getSnapshot() {
45         return snapshot;
46     }
47
48     public @NonNull Callback getCallback() {
49         return callback;
50     }
51
52     public interface Callback {
53         void onSuccess();
54
55         void onFailure();
56     }
57 }