BUG-7033: Fix commit exception due to pipe-lining
[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         FINISH_COMMIT_PENDING,
29
30         ABORTED,
31         COMMITTED,
32         FAILED,
33     }
34
35     ShardDataTreeCohort() {
36         // Prevent foreign instantiation
37     }
38
39     // FIXME: This leaks internal state generated in preCommit,
40     // should be result of canCommit
41     abstract DataTreeCandidateTip getCandidate();
42
43     abstract DataTreeModification getDataTreeModification();
44
45     // FIXME: Should return rebased DataTreeCandidateTip
46     @VisibleForTesting
47     public abstract void canCommit(FutureCallback<Void> callback);
48
49     @VisibleForTesting
50     public abstract void preCommit(FutureCallback<DataTreeCandidate> callback);
51
52     @VisibleForTesting
53     public abstract void abort(FutureCallback<Void> callback);
54
55     @VisibleForTesting
56     public abstract void commit(FutureCallback<UnsignedLong> callback);
57
58     public abstract boolean isFailed();
59
60     public abstract State getState();
61 }

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