2 * Copyright (c) 2016 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
8 package org.opendaylight.controller.cluster.datastore.persisted;
10 import com.google.common.annotations.Beta;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import java.util.Optional;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18 * Abstract base class for snapshots of the ShardDataTree.
20 * @author Robert Varga
23 public abstract class ShardDataTreeSnapshot {
24 ShardDataTreeSnapshot() {
25 // Hidden to prevent subclassing from outside of this package
28 public static ShardDataTreeSnapshot deserialize(final ObjectInput in) throws IOException {
29 final ShardDataTreeSnapshot ret = AbstractVersionedShardDataTreeSnapshot.versionedDeserialize(in);
31 // Make sure we consume all bytes, otherwise something went very wrong
32 final int bytesLeft = in.available();
34 throw new IOException("Deserialization left " + bytesLeft + " in the buffer");
42 * Get the root data node contained in this snapshot.
44 * @return An optional root node.
46 public abstract Optional<NormalizedNode<?, ?>> getRootNode();
48 public abstract void serialize(ObjectOutput out) throws IOException;