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 java.util.Collection;
12 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
13 import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo;
14 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
15 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
16 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
17 import scala.concurrent.Future;
20 * An {@link AbstractTransactionContextFactory} which produces TransactionContext instances for single
21 * transactions (ie not chained).
23 final class TransactionContextFactory extends AbstractTransactionContextFactory<LocalTransactionFactoryImpl> {
25 private TransactionContextFactory(final ActorContext actorContext) {
29 static TransactionContextFactory create(final ActorContext actorContext) {
30 return new TransactionContextFactory(actorContext);
38 protected TransactionIdentifier nextIdentifier() {
39 return TransactionIdentifier.create(getMemberName(), TX_COUNTER.getAndIncrement());
43 protected LocalTransactionFactoryImpl factoryForShard(final String shardName, final ActorSelection shardLeader, final DataTree dataTree) {
44 return new LocalTransactionFactoryImpl(getActorContext(), shardLeader, dataTree);
48 protected Future<PrimaryShardInfo> findPrimaryShard(final String shardName, TransactionIdentifier txId) {
49 return getActorContext().findPrimaryShardAsync(shardName);
53 protected <T> void onTransactionReady(final TransactionIdentifier transaction, final Collection<Future<T>> cohortFutures) {
54 // Transactions are disconnected, this is a no-op
57 DOMStoreTransactionChain createTransactionChain() {
58 return new TransactionChainProxy(this);
62 protected void onTransactionContextCreated(TransactionIdentifier transactionId) {