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=0dbd2a284def03ae2a722dc9b7fbef62e69dbe23;hp=9398171b202bd2f05a5d9028946ebe26d44ce175;hb=c796596b5c46b5203c30b143e6282662e66c5642;hpb=3f979acfb60c2ffb1ce70c5475bdfce8f8e7df01 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 index 9398171b20..0dbd2a284d 100644 --- 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 @@ -8,17 +8,16 @@ 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.cluster.access.concepts.TransactionIdentifier; +import org.opendaylight.controller.cluster.datastore.messages.AbstractRead; +import org.opendaylight.controller.cluster.datastore.modification.AbstractModification; 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; /** @@ -44,62 +43,22 @@ abstract class LocalTransactionContext extends AbstractTransactionContext { protected abstract DOMStoreReadTransaction getReadDelegate(); @Override - public void writeData(YangInstanceIdentifier path, NormalizedNode data) { + public void executeModification(AbstractModification modification) { incrementModificationCount(); if(operationError == null) { try { - getWriteDelegate().write(path, data); + modification.apply(getWriteDelegate()); } catch (Exception e) { operationError = e; } } - } @Override - public void mergeData(YangInstanceIdentifier path, NormalizedNode data) { - incrementModificationCount(); - if(operationError == null) { - try { - getWriteDelegate().merge(path, data); - } catch (Exception e) { - operationError = e; - } - } - } - - @Override - public void deleteData(YangInstanceIdentifier path) { - incrementModificationCount(); - if(operationError == null) { - try { - getWriteDelegate().delete(path); - } catch (Exception e) { - operationError = e; - } - } - } - - @Override - public void readData(YangInstanceIdentifier path, final SettableFuture>> proxyFuture) { - Futures.addCallback(getReadDelegate().read(path), new FutureCallback>>() { - @Override - public void onSuccess(final Optional> result) { - proxyFuture.set(result); - } - - @Override - public void onFailure(final Throwable t) { - proxyFuture.setException(t); - } - }); - } - - @Override - public void dataExists(YangInstanceIdentifier path, final SettableFuture proxyFuture) { - Futures.addCallback(getReadDelegate().exists(path), new FutureCallback() { + public void executeRead(AbstractRead readCmd, final SettableFuture proxyFuture) { + Futures.addCallback(readCmd.apply(getReadDelegate()), new FutureCallback() { @Override - public void onSuccess(final Boolean result) { + public void onSuccess(final T result) { proxyFuture.set(result); } @@ -112,11 +71,7 @@ abstract class LocalTransactionContext extends AbstractTransactionContext { private LocalThreePhaseCommitCohort ready() { logModificationCount(); - LocalThreePhaseCommitCohort cohort = readySupport.onTransactionReady(getWriteDelegate()); - if (operationError != null) { - cohort.setOperationError(operationError); - } - return cohort; + return readySupport.onTransactionReady(getWriteDelegate(), operationError); } @Override @@ -131,11 +86,6 @@ abstract class LocalTransactionContext extends AbstractTransactionContext { return cohort.initiateDirectCommit(); } - @Override - public boolean supportsDirectCommit() { - return true; - } - @Override public void closeTransaction() { txDelegate.close();