X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FSerializedDOMDataBroker.java;h=887d11260ba0bc20f22d451187059fa7f7e019f5;hb=aaea3e9a92ae9d6fac04c4a065db4b35cbca9ed0;hp=ad23e3a72bc9242878e3b13faba6727ed474fa65;hpb=64db87e8fb5de25e68ba824ec2eaa17e3f217c96;p=controller.git diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java index ad23e3a72b..887d11260b 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/SerializedDOMDataBroker.java @@ -1,13 +1,16 @@ /* * Copyright (c) 2014 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.broker.impl; -import com.google.common.base.Preconditions; -import com.google.common.util.concurrent.CheckedFuture; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.Objects.requireNonNull; + +import com.google.common.base.Supplier; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; @@ -20,7 +23,6 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.sal.core.spi.data.DOMStore; import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.util.DurationStatisticsTracker; -import org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,28 +30,33 @@ import org.slf4j.LoggerFactory; * Implementation of blocking three phase commit coordinator, which which * supports coordination on multiple {@link DOMStoreThreePhaseCommitCohort}. * + *

* This implementation does not support cancellation of commit, * + *

* In order to advance to next phase of three phase commit all subtasks of * previous step must be finish. * + *

* This executor does not have an upper bound on subtask timeout. */ +@Deprecated(forRemoval = true) public class SerializedDOMDataBroker extends AbstractDOMDataBroker { private static final Logger LOG = LoggerFactory.getLogger(SerializedDOMDataBroker.class); private final DurationStatisticsTracker commitStatsTracker = DurationStatisticsTracker.createConcurrent(); private final ListeningExecutorService executor; /** - * * Construct DOMDataCommitCoordinator which uses supplied executor to * process commit coordinations. * - * @param executor + * @param datastores data stores + * @param executor executor service */ - public SerializedDOMDataBroker(final Map datastores, final ListeningExecutorService executor) { + public SerializedDOMDataBroker(final Map datastores, + final ListeningExecutorService executor) { super(datastores); - this.executor = Preconditions.checkNotNull(executor, "executor must not be null."); + this.executor = requireNonNull(executor, "executor must not be null."); } public DurationStatisticsTracker getCommitStatsTracker() { @@ -57,25 +64,22 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker { } @Override - protected CheckedFuture submit(final DOMDataWriteTransaction transaction, - final Collection cohorts) { - Preconditions.checkArgument(transaction != null, "Transaction must not be null."); - Preconditions.checkArgument(cohorts != null, "Cohorts must not be null."); + protected ListenableFuture commit(final DOMDataWriteTransaction transaction, + final Collection cohorts, final Supplier futureValueSupplier) { + checkArgument(transaction != null, "Transaction must not be null."); + checkArgument(cohorts != null, "Cohorts must not be null."); LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier()); - ListenableFuture commitFuture = null; + ListenableFuture commitFuture; try { - commitFuture = executor.submit(new CommitCoordinationTask(transaction, cohorts, - commitStatsTracker)); - } catch(RejectedExecutionException e) { - LOG.error("The commit executor's queue is full - submit task was rejected. \n" + - executor, e); - return Futures.immediateFailedCheckedFuture( - new TransactionCommitFailedException( - "Could not submit the commit task - the commit queue capacity has been exceeded.", e)); + commitFuture = executor.submit(new CommitCoordinationTask<>(transaction, cohorts, commitStatsTracker, + futureValueSupplier)); + } catch (RejectedExecutionException e) { + LOG.error("The commit executor {} queue is full - submit task was rejected. \n", executor, e); + commitFuture = Futures.immediateFailedFuture(new TransactionCommitFailedException( + "Could not submit the commit task - the commit queue capacity has been exceeded.", e)); } - return MappingCheckedFuture.create(commitFuture, - TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER); + return commitFuture; } }