X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fpersisted%2FDatastoreSnapshot.java;fp=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fpersisted%2FDatastoreSnapshot.java;h=3c5e86b21d6abfb49bcbd7d331de73aeba9ded8d;hp=0000000000000000000000000000000000000000;hb=2f77e92af7a68b4a97dbfb709c6cc9b11a49878a;hpb=d796a8de8b208ca24bb57aebfc689f8be8bc2c7b diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DatastoreSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DatastoreSnapshot.java new file mode 100644 index 0000000000..3c5e86b21d --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DatastoreSnapshot.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.cluster.datastore.persisted; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.io.Serializable; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Stores a snapshot of the internal state of a data store. + * + * @author Thomas Pantelis + */ +public class DatastoreSnapshot implements Serializable { + private static final long serialVersionUID = 1L; + + private final String type; + private final byte[] shardManagerSnapshot; + private final List shardSnapshots; + + @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Stores a reference to an externally mutable byte[] " + + "object but this is OK since this class is merely a DTO and does not process byte[] internally. " + + "Also it would be inefficient to create a return copy as the byte[] could be large.") + public DatastoreSnapshot(@Nonnull String type, @Nullable byte[] shardManagerSnapshot, + @Nonnull List shardSnapshots) { + this.type = Preconditions.checkNotNull(type); + this.shardManagerSnapshot = shardManagerSnapshot; + this.shardSnapshots = ImmutableList.copyOf(Preconditions.checkNotNull(shardSnapshots)); + } + + @Nonnull + public String getType() { + return type; + } + + @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but " + + "this is OK since this class is merely a DTO and does not process byte[] internally. " + + "Also it would be inefficient to create a return copy as the byte[] could be large.") + @Nullable + public byte[] getShardManagerSnapshot() { + return shardManagerSnapshot; + } + + @Nonnull + public List getShardSnapshots() { + return shardSnapshots; + } + + public static class ShardSnapshot implements Serializable { + private static final long serialVersionUID = 1L; + + private final String name; + private final byte[] snapshot; + + public ShardSnapshot(@Nonnull String name, @Nonnull byte[] snapshot) { + this.name = Preconditions.checkNotNull(name); + this.snapshot = Preconditions.checkNotNull(snapshot); + } + + @Nonnull + public String getName() { + return name; + } + + @SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Exposes a mutable object stored in a field but " + + "this is OK since this class is merely a DTO and does not process byte[] internally. " + + "Also it would be inefficient to create a return copy as the byte[] could be large.") + @Nonnull + public byte[] getSnapshot() { + return snapshot; + } + } +}