Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / DatastoreSnapshot.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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.datastore.persisted;
9
10 import static java.util.Objects.requireNonNull;
11
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;
18
19 /**
20  * Stores a snapshot of the internal state of a data store.
21  *
22  * @author Thomas Pantelis
23  */
24 public final class DatastoreSnapshot implements Serializable {
25     @java.io.Serial
26     private static final long serialVersionUID = 1L;
27
28     private final @NonNull String type;
29     private final ShardManagerSnapshot shardManagerSnapshot;
30     private final @NonNull ImmutableList<ShardSnapshot> shardSnapshots;
31
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);
37     }
38
39     public @NonNull String getType() {
40         return type;
41     }
42
43     public @Nullable ShardManagerSnapshot getShardManagerSnapshot() {
44         return shardManagerSnapshot;
45     }
46
47     public @NonNull List<ShardSnapshot> getShardSnapshots() {
48         return shardSnapshots;
49     }
50
51     @java.io.Serial
52     private Object writeReplace() {
53         return new DS(this);
54     }
55
56     public static final class ShardSnapshot implements Serializable {
57         @java.io.Serial
58         private static final long serialVersionUID = 1L;
59
60         private final @NonNull String name;
61         private final @NonNull Snapshot snapshot;
62
63         public ShardSnapshot(final @NonNull String name, final @NonNull Snapshot snapshot) {
64             this.name = requireNonNull(name);
65             this.snapshot = requireNonNull(snapshot);
66         }
67
68         public @NonNull String getName() {
69             return name;
70         }
71
72         public @NonNull Snapshot getSnapshot() {
73             return snapshot;
74         }
75
76         @java.io.Serial
77         private Object writeReplace() {
78             return new DSS(this);
79         }
80     }
81 }