2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.cluster.raft.utils;
11 import akka.dispatch.Futures;
12 import akka.japi.Option;
13 import akka.persistence.SelectedSnapshot;
14 import akka.persistence.SnapshotMetadata;
15 import akka.persistence.SnapshotSelectionCriteria;
16 import akka.persistence.snapshot.japi.SnapshotStore;
17 import org.opendaylight.controller.cluster.raft.Snapshot;
18 import scala.concurrent.Future;
21 public class MockSnapshotStore extends SnapshotStore {
23 private static Snapshot mockSnapshot;
24 private static String persistenceId;
26 public static void setMockSnapshot(Snapshot s) {
30 public static void setPersistenceId(String pId) {
35 public Future<Option<SelectedSnapshot>> doLoadAsync(String s, SnapshotSelectionCriteria snapshotSelectionCriteria) {
36 if (mockSnapshot == null) {
37 return Futures.successful(Option.<SelectedSnapshot>none());
40 SnapshotMetadata smd = new SnapshotMetadata(persistenceId, 1, 12345);
41 SelectedSnapshot selectedSnapshot =
42 new SelectedSnapshot(smd, mockSnapshot);
43 return Futures.successful(Option.some(selectedSnapshot));
47 public Future<Void> doSaveAsync(SnapshotMetadata snapshotMetadata, Object o) {
52 public void onSaved(SnapshotMetadata snapshotMetadata) throws Exception {
57 public void doDelete(SnapshotMetadata snapshotMetadata) throws Exception {
62 public void doDelete(String s, SnapshotSelectionCriteria snapshotSelectionCriteria) throws Exception {