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>> {
18 final void applySnapshot(@Nonnull final ShardDataTreeSnapshotMetadata<?> snapshot) {
19 Verify.verify(getSupportedType().isInstance(snapshot), "Snapshot %s misrouted to handler of %s", snapshot,
21 doApplySnapshot(getSupportedType().cast(snapshot));
24 abstract void reset();
26 abstract void doApplySnapshot(@Nonnull T snapshot);
28 abstract @Nonnull Class<T> getSupportedType();
30 abstract @Nullable T toSnapshot();
33 abstract void onTransactionCommitted(TransactionIdentifier txId);
35 abstract void onHistoryCreated(LocalHistoryIdentifier historyId);
37 abstract void onHistoryClosed(LocalHistoryIdentifier historyId);
39 abstract void onHistoryPurged(LocalHistoryIdentifier historyId);