6cb9badd8d3cd66a16ea1626f3e9983444484d1f
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / ShardDataTreeCohort.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.annotations.VisibleForTesting;
11 import com.google.common.primitives.UnsignedLong;
12 import com.google.common.util.concurrent.FutureCallback;
13 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
14 import org.opendaylight.yangtools.concepts.Identifiable;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
18
19 @VisibleForTesting
20 public abstract class ShardDataTreeCohort implements Identifiable<TransactionIdentifier> {
21     public enum State {
22         READY,
23         CAN_COMMIT_PENDING,
24         CAN_COMMIT_COMPLETE,
25         PRE_COMMIT_PENDING,
26         PRE_COMMIT_COMPLETE,
27         COMMIT_PENDING,
28
29         ABORTED,
30         COMMITTED,
31         FAILED,
32     }
33
34     ShardDataTreeCohort() {
35         // Prevent foreign instantiation
36     }
37
38     // FIXME: This leaks internal state generated in preCommit,
39     // should be result of canCommit
40     abstract DataTreeCandidateTip getCandidate();
41
42     abstract DataTreeModification getDataTreeModification();
43
44     // FIXME: Should return rebased DataTreeCandidateTip
45     @VisibleForTesting
46     public abstract void canCommit(FutureCallback<Void> callback);
47
48     @VisibleForTesting
49     public abstract void preCommit(FutureCallback<DataTreeCandidate> callback);
50
51     @VisibleForTesting
52     public abstract void abort(FutureCallback<Void> callback);
53
54     @VisibleForTesting
55     public abstract void commit(FutureCallback<UnsignedLong> callback);
56
57     public abstract boolean isFailed();
58
59     public abstract State getState();
60 }

©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.