X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FLocalTransactionContext.java;h=5435bb548d5c58e91e2f20d07dc7895f97755df8;hp=3648b97eb68c11ff97e0a5c3897ed649430fd2db;hb=HEAD;hpb=0791cdd2ca719270a1b0c114bf863ba29d571ac0 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java deleted file mode 100644 index 3648b97eb6..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/LocalTransactionContext.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.cluster.datastore; - -import akka.actor.ActorSelection; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.SettableFuture; -import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import scala.concurrent.Future; - -/** - * Processes front-end transaction operations locally before being committed to the destination shard. - * Instances of this class are used when the destination shard is local to the caller. - * - * @author Thomas Pantelis - */ -abstract class LocalTransactionContext extends AbstractTransactionContext { - - private final DOMStoreTransaction txDelegate; - private final OperationCompleter completer; - - LocalTransactionContext(TransactionIdentifier identifier, DOMStoreTransaction txDelegate, OperationCompleter completer) { - super(identifier); - this.txDelegate = Preconditions.checkNotNull(txDelegate); - this.completer = Preconditions.checkNotNull(completer); - } - - protected abstract DOMStoreWriteTransaction getWriteDelegate(); - - protected abstract DOMStoreReadTransaction getReadDelegate(); - - @Override - public void writeData(YangInstanceIdentifier path, NormalizedNode data) { - incrementModificationCount(); - getWriteDelegate().write(path, data); - completer.onComplete(null, null); - } - - @Override - public void mergeData(YangInstanceIdentifier path, NormalizedNode data) { - incrementModificationCount(); - getWriteDelegate().merge(path, data); - completer.onComplete(null, null); - } - - @Override - public void deleteData(YangInstanceIdentifier path) { - incrementModificationCount(); - getWriteDelegate().delete(path); - completer.onComplete(null, null); - } - - @Override - public void readData(YangInstanceIdentifier path, final SettableFuture>> proxyFuture) { - Futures.addCallback(getReadDelegate().read(path), new FutureCallback>>() { - @Override - public void onSuccess(Optional> result) { - proxyFuture.set(result); - completer.onComplete(null, null); - } - - @Override - public void onFailure(Throwable t) { - proxyFuture.setException(t); - completer.onComplete(null, null); - } - }); - } - - @Override - public void dataExists(YangInstanceIdentifier path, final SettableFuture proxyFuture) { - Futures.addCallback(getReadDelegate().exists(path), new FutureCallback() { - @Override - public void onSuccess(Boolean result) { - proxyFuture.set(result); - completer.onComplete(null, null); - } - - @Override - public void onFailure(Throwable t) { - proxyFuture.setException(t); - completer.onComplete(null, null); - } - }); - } - - private LocalThreePhaseCommitCohort ready() { - logModificationCount(); - LocalThreePhaseCommitCohort ready = (LocalThreePhaseCommitCohort) getWriteDelegate().ready(); - completer.onComplete(null, null); - return ready; - } - - @Override - public Future readyTransaction() { - return ready().initiateCoordinatedCommit(); - } - - @Override - public Future directCommit() { - return ready().initiateDirectCommit(); - } - - @Override - public boolean supportsDirectCommit() { - return true; - } - - @Override - public void closeTransaction() { - txDelegate.close(); - } -}