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.data.api.schema.tree.DataTreeCandidate;
20 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip;
21 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
24 public abstract class ShardDataTreeCohort implements Identifiable<TransactionIdentifier> {
38 ShardDataTreeCohort() {
39 // Prevent foreign instantiation
42 // FIXME: This leaks internal state generated in preCommit,
43 // should be result of canCommit
44 abstract DataTreeCandidateTip getCandidate();
46 abstract DataTreeModification getDataTreeModification();
48 abstract Optional<SortedSet<String>> getParticipatingShardNames();
50 // FIXME: Should return rebased DataTreeCandidateTip
52 public abstract void canCommit(FutureCallback<Void> callback);
55 public abstract void preCommit(FutureCallback<DataTreeCandidate> callback);
58 public abstract void abort(FutureCallback<Void> callback);
61 public abstract void commit(FutureCallback<UnsignedLong> callback);
63 public abstract boolean isFailed();
65 public abstract State getState();
68 public final String toString() {
69 return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
72 ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
73 return toStringHelper.add("id", getIdentifier()).add("state", getState());