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.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import scala.concurrent.Future;
20 * FIXME: why do we need this interface? It should be possible to integrate it with
21 * AbstractTransactionContext, which is the only implementation anyway.
23 interface TransactionContext {
24 void closeTransaction();
26 Future<ActorSelection> readyTransaction(Boolean havePermit, Optional<SortedSet<String>> participatingShardNames);
28 <T> void executeRead(AbstractRead<T> readCmd, SettableFuture<T> promise, Boolean havePermit);
30 void executeDelete(YangInstanceIdentifier path, Boolean havePermit);
32 void executeMerge(YangInstanceIdentifier path, NormalizedNode<?, ?> data, Boolean havePermit);
34 void executeWrite(YangInstanceIdentifier path, NormalizedNode<?, ?> data, Boolean havePermit);
36 Future<Object> directCommit(Boolean havePermit);
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.
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.
47 void operationHandOffComplete();
50 * A TransactionContext that uses operation limiting should return true else false.
52 * @return true if operation limiting is used, false otherwise
54 boolean usesOperationLimiting();
56 short getTransactionVersion();