2 * Copyright (c) 2015 Brocade Communications 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
8 package org.opendaylight.controller.cluster.datastore.persisted;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableList;
13 import java.io.Serializable;
14 import java.util.List;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
20 * Stores a snapshot of the internal state of a data store.
22 * @author Thomas Pantelis
24 public final class DatastoreSnapshot implements Serializable {
26 private static final long serialVersionUID = 1L;
28 private final @NonNull String type;
29 private final ShardManagerSnapshot shardManagerSnapshot;
30 private final @NonNull ImmutableList<ShardSnapshot> shardSnapshots;
32 public DatastoreSnapshot(final @NonNull String type, final @Nullable ShardManagerSnapshot shardManagerSnapshot,
33 final @NonNull List<ShardSnapshot> shardSnapshots) {
34 this.type = requireNonNull(type);
35 this.shardManagerSnapshot = shardManagerSnapshot;
36 this.shardSnapshots = ImmutableList.copyOf(shardSnapshots);
39 public @NonNull String getType() {
43 public @Nullable ShardManagerSnapshot getShardManagerSnapshot() {
44 return shardManagerSnapshot;
47 public @NonNull List<ShardSnapshot> getShardSnapshots() {
48 return shardSnapshots;
52 private Object writeReplace() {
56 public static final class ShardSnapshot implements Serializable {
58 private static final long serialVersionUID = 1L;
60 private final @NonNull String name;
61 private final @NonNull Snapshot snapshot;
63 public ShardSnapshot(final @NonNull String name, final @NonNull Snapshot snapshot) {
64 this.name = requireNonNull(name);
65 this.snapshot = requireNonNull(snapshot);
68 public @NonNull String getName() {
72 public @NonNull Snapshot getSnapshot() {
77 private Object writeReplace() {