Speed up DatastoreContextIntrospector a bit
[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 java.util.Optional;
13 import java.util.SortedSet;
14 import org.opendaylight.controller.cluster.datastore.messages.AbstractRead;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import scala.concurrent.Future;
18
19 /*
20  * FIXME: why do we need this interface? It should be possible to integrate it with
21  *        AbstractTransactionContext, which is the only implementation anyway.
22  */
23 interface TransactionContext {
24     void closeTransaction();
25
26     Future<ActorSelection> readyTransaction(Boolean havePermit, Optional<SortedSet<String>> participatingShardNames);
27
28     <T> void executeRead(AbstractRead<T> readCmd, SettableFuture<T> promise, Boolean havePermit);
29
30     void executeDelete(YangInstanceIdentifier path, Boolean havePermit);
31
32     void executeMerge(YangInstanceIdentifier path, NormalizedNode<?, ?> data, Boolean havePermit);
33
34     void executeWrite(YangInstanceIdentifier path, NormalizedNode<?, ?> data, Boolean havePermit);
35
36     Future<Object> directCommit(Boolean havePermit);
37
38     /**
39      * Invoked by {@link TransactionContextWrapper} when it has finished handing
40      * off operations to this context. From this point on, the context is responsible
41      * for throttling operations.
42      *
43      * <p>
44      * Implementations can rely on the wrapper calling this operation in a synchronized
45      * block, so they do not need to ensure visibility of this state transition themselves.
46      */
47     void operationHandOffComplete();
48
49     /**
50      * A TransactionContext that uses operation limiting should return true else false.
51      *
52      * @return true if operation limiting is used, false otherwise
53      */
54     boolean usesOperationLimiting();
55
56     short getTransactionVersion();
57 }