2 * Copyright (c) 2016 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
9 package org.opendaylight.mdsal.dom.store.inmemory;
11 import java.util.Collection;
12 import java.util.concurrent.Callable;
13 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
14 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
15 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 class ShardSubmitCoordinationTask implements Callable<Void> {
21 private static final Logger LOG = LoggerFactory.getLogger(ShardSubmitCoordinationTask.class);
23 private final DOMDataTreeIdentifier rootShardPrefix;
24 private final ShardCanCommitCoordinationTask canCommitCoordinationTask;
25 private final ShardPreCommitCoordinationTask preCommitCoordinationTask;
26 private final ShardCommitCoordinationTask commitCoordinationTask;
29 ShardSubmitCoordinationTask(final DOMDataTreeIdentifier rootShardPrefix,
30 final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
31 this.rootShardPrefix = rootShardPrefix;
33 canCommitCoordinationTask = new ShardCanCommitCoordinationTask(rootShardPrefix, cohorts);
34 preCommitCoordinationTask = new ShardPreCommitCoordinationTask(rootShardPrefix, cohorts);
35 commitCoordinationTask = new ShardCommitCoordinationTask(rootShardPrefix, cohorts);
39 public Void call() throws TransactionCommitFailedException {
41 LOG.debug("Shard {}, CanCommit started", rootShardPrefix);
42 canCommitCoordinationTask.canCommitBlocking();
44 LOG.debug("Shard {}, PreCommit started", rootShardPrefix);
45 preCommitCoordinationTask.preCommitBlocking();
47 LOG.debug("Shard {}, commit started", rootShardPrefix);
48 commitCoordinationTask.commitBlocking();