Bug 3195: Cleanup on error paths and error handling
[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.base.Optional;
12 import com.google.common.util.concurrent.SettableFuture;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import scala.concurrent.Future;
16
17 /*
18  * FIXME: why do we need this interface? It should be possible to integrate it with
19  *        AbstractTransactionContext, which is the only implementation anyway.
20  */
21 interface TransactionContext {
22     void closeTransaction();
23
24     Future<ActorSelection> readyTransaction();
25
26     void writeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
27
28     void deleteData(YangInstanceIdentifier path);
29
30     void mergeData(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
31
32     void readData(final YangInstanceIdentifier path, SettableFuture<Optional<NormalizedNode<?, ?>>> proxyFuture);
33
34     void dataExists(YangInstanceIdentifier path, SettableFuture<Boolean> proxyFuture);
35
36     boolean supportsDirectCommit();
37
38     Future<Object> directCommit();
39
40     /**
41      * Invoked by {@link TransactionContextWrapper} when it has finished handing
42      * off operations to this context. From this point on, the context is responsible
43      * for throttling operations.
44      *
45      * Implementations can rely on the wrapper calling this operation in a synchronized
46      * block, so they do not need to ensure visibility of this state transition themselves.
47      */
48     void operationHandOffComplete();
49
50     /**
51      * A TransactionContext that uses Operation limiting should return true else false
52      * @return
53      */
54     boolean usesOperationLimiting();
55 }