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 akka.actor.ActorSelection;
11 import com.google.common.util.concurrent.SettableFuture;
12 import java.util.Optional;
13 import java.util.SortedSet;
14 import org.opendaylight.controller.cluster.datastore.messages.AbstractRead;
15 import org.opendaylight.controller.cluster.datastore.modification.AbstractModification;
16 import scala.concurrent.Future;
19 * FIXME: why do we need this interface? It should be possible to integrate it with
20 * AbstractTransactionContext, which is the only implementation anyway.
22 interface TransactionContext {
23 void closeTransaction();
25 Future<ActorSelection> readyTransaction(Boolean havePermit, Optional<SortedSet<String>> participatingShardNames);
27 void executeModification(AbstractModification modification, Boolean havePermit);
29 <T> void executeRead(AbstractRead<T> readCmd, SettableFuture<T> promise, Boolean havePermit);
31 Future<Object> directCommit(Boolean havePermit);
34 * Invoked by {@link TransactionContextWrapper} when it has finished handing
35 * off operations to this context. From this point on, the context is responsible
36 * for throttling operations.
39 * Implementations can rely on the wrapper calling this operation in a synchronized
40 * block, so they do not need to ensure visibility of this state transition themselves.
42 void operationHandOffComplete();
45 * A TransactionContext that uses operation limiting should return true else false.
47 * @return true if operation limiting is used, false otherwise
49 boolean usesOperationLimiting();
51 short getTransactionVersion();