Address review comments
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeMetadata.java
1 /*
2  * Copyright (c) 2015 Cisco 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;
9
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;
16
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,
20             getSupportedType());
21         doApplySnapshot(getSupportedType().cast(snapshot));
22     }
23
24     abstract void reset();
25
26     abstract void doApplySnapshot(@Nonnull T snapshot);
27
28     abstract @Nonnull Class<T> getSupportedType();
29
30     abstract @Nullable T toSnapshot();
31
32     // Lifecycle events
33     abstract void onTransactionCommitted(TransactionIdentifier txId);
34     abstract void onHistoryClosed(LocalHistoryIdentifier historyId);
35     abstract void onHistoryPurged(LocalHistoryIdentifier historyId);
36 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.