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.annotations.VisibleForTesting;
11 import com.google.common.base.MoreObjects;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.primitives.UnsignedLong;
14 import com.google.common.util.concurrent.FutureCallback;
15 import java.util.Optional;
16 import java.util.SortedSet;
17 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
18 import org.opendaylight.yangtools.concepts.Identifiable;
19 import org.opendaylight.yangtools.yang.common.Empty;
20 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
21 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateTip;
22 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeModification;
25 public abstract class ShardDataTreeCohort implements Identifiable<TransactionIdentifier> {
39 ShardDataTreeCohort() {
40 // Prevent foreign instantiation
43 // FIXME: This leaks internal state generated in preCommit,
44 // should be result of canCommit
45 abstract DataTreeCandidateTip getCandidate();
47 abstract DataTreeModification getDataTreeModification();
49 abstract Optional<SortedSet<String>> getParticipatingShardNames();
51 // FIXME: Should return rebased DataTreeCandidateTip
53 public abstract void canCommit(FutureCallback<Empty> callback);
56 public abstract void preCommit(FutureCallback<DataTreeCandidate> callback);
59 public abstract void abort(FutureCallback<Empty> callback);
62 public abstract void commit(FutureCallback<UnsignedLong> callback);
64 public abstract boolean isFailed();
66 public abstract State getState();
69 public final String toString() {
70 return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
73 ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
74 return toStringHelper.add("id", getIdentifier()).add("state", getState());