BUG-5280: add FrontendMetadata
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / TransactionContext.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 akka.actor.ActorSelection;
11 import com.google.common.util.concurrent.SettableFuture;
12 import org.opendaylight.controller.cluster.datastore.messages.AbstractRead;
13 import org.opendaylight.controller.cluster.datastore.modification.AbstractModification;
14 import scala.concurrent.Future;
15
16 /*
17  * FIXME: why do we need this interface? It should be possible to integrate it with
18  *        AbstractTransactionContext, which is the only implementation anyway.
19  */
20 interface TransactionContext {
21     void closeTransaction();
22
23     Future<ActorSelection> readyTransaction();
24
25     void executeModification(AbstractModification modification);
26
27     <T> void executeRead(AbstractRead<T> readCmd, SettableFuture<T> promise);
28
29     Future<Object> directCommit();
30
31     /**
32      * Invoked by {@link TransactionContextWrapper} when it has finished handing
33      * off operations to this context. From this point on, the context is responsible
34      * for throttling operations.
35      *
36      * Implementations can rely on the wrapper calling this operation in a synchronized
37      * block, so they do not need to ensure visibility of this state transition themselves.
38      */
39     void operationHandOffComplete();
40
41     /**
42      * A TransactionContext that uses Operation limiting should return true else false
43      * @return
44      */
45     boolean usesOperationLimiting();
46
47     short getTransactionVersion();
48 }