2 * Copyright (c) 2015 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;
10 import com.google.common.base.Verify;
11 import javax.annotation.Nonnull;
12 import javax.annotation.Nullable;
13 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
14 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
15 import org.opendaylight.controller.cluster.datastore.persisted.ShardDataTreeSnapshotMetadata;
17 abstract class ShardDataTreeMetadata<T extends ShardDataTreeSnapshotMetadata<T>> {
19 * Apply a recovered metadata snapshot.
21 * @param snapshot Metadata snapshot
23 final void applySnapshot(@Nonnull final ShardDataTreeSnapshotMetadata<?> snapshot) {
24 Verify.verify(getSupportedType().isInstance(snapshot), "Snapshot %s misrouted to handler of %s", snapshot,
26 doApplySnapshot(getSupportedType().cast(snapshot));
30 * Reset metadata to empty state.
32 abstract void reset();
35 * Apply a recovered metadata snapshot. This is not a public entrypoint, just an interface between the base class
38 * @param snapshot Metadata snapshot
40 abstract void doApplySnapshot(@Nonnull T snapshot);
43 * Return the type of metadata snapshot this object supports.
45 * @return Metadata type
48 abstract Class<T> getSupportedType();
51 * Take a snapshot of current metadata state.
53 * @return Metadata snapshot, or null if the metadata is empty.
56 abstract T toSnapshot();
60 abstract void onTransactionAborted(TransactionIdentifier txId);
62 abstract void onTransactionCommitted(TransactionIdentifier txId);
64 abstract void onTransactionPurged(TransactionIdentifier txId);
66 abstract void onHistoryCreated(LocalHistoryIdentifier historyId);
68 abstract void onHistoryClosed(LocalHistoryIdentifier historyId);
70 abstract void onHistoryPurged(LocalHistoryIdentifier historyId);