X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FInMemoryDOMStoreThreePhaseCommitCohort.java;h=f0e7abfb0ab371d98b6a91f1723db38da4d9d772;hb=refs%2Fchanges%2F87%2F69987%2F8;hp=dba71bff4c03cb1c86868a67f8bca097c3d284de;hpb=7fde47bbf398e73144edfd14437ca72fd12e1daa;p=controller.git diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreThreePhaseCommitCohort.java index dba71bff4c..f0e7abfb0a 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreThreePhaseCommitCohort.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreThreePhaseCommitCohort.java @@ -1,9 +1,18 @@ +/* + * Copyright (c) 2015 Cisco 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.md.sal.dom.store.impl; import static com.google.common.base.Preconditions.checkState; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.sal.core.spi.data.AbstractDOMStoreTransaction; @@ -16,6 +25,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailed import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Void is the only allowed value") class InMemoryDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort { private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreThreePhaseCommitCohort.class); private static final ListenableFuture SUCCESSFUL_FUTURE = Futures.immediateFuture(null); @@ -24,11 +34,16 @@ class InMemoryDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommit private final DataTreeModification modification; private final InMemoryDOMDataStore store; private DataTreeCandidate candidate; + private final Exception operationError; - public InMemoryDOMStoreThreePhaseCommitCohort(final InMemoryDOMDataStore store, final SnapshotBackedWriteTransaction writeTransaction, final DataTreeModification modification) { + public InMemoryDOMStoreThreePhaseCommitCohort(final InMemoryDOMDataStore store, + final SnapshotBackedWriteTransaction writeTransaction, + final DataTreeModification modification, + final Exception operationError) { this.transaction = Preconditions.checkNotNull(writeTransaction); this.modification = Preconditions.checkNotNull(modification); this.store = Preconditions.checkNotNull(store); + this.operationError = operationError; } private static void warnDebugContext(final AbstractDOMStoreTransaction transaction) { @@ -40,6 +55,10 @@ class InMemoryDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommit @Override public final ListenableFuture canCommit() { + if (operationError != null) { + return Futures.immediateFailedFuture(operationError); + } + try { store.validate(modification); LOG.debug("Store Transaction: {} can be committed", getTransaction().getIdentifier()); @@ -97,4 +116,5 @@ class InMemoryDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommit store.commit(candidate); return SUCCESSFUL_FUTURE; } -} \ No newline at end of file +} +