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 com.google.common.util.concurrent.Futures;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
14 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public class ForeignShardThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort {
20 private static final Logger LOG = LoggerFactory.getLogger(ForeignShardThreePhaseCommitCohort.class);
22 private final DOMDataTreeIdentifier prefix;
23 private final ForeignShardModificationContext shard;
25 public ForeignShardThreePhaseCommitCohort(final DOMDataTreeIdentifier prefix,
26 final ForeignShardModificationContext shard) {
32 public ListenableFuture<Boolean> canCommit() {
33 LOG.debug("Validating transaction on foreign shard {}", prefix);
34 return shard.validate();
38 public ListenableFuture<Void> preCommit() {
39 LOG.debug("Preparing transaction on foreign shard {}", prefix);
40 return shard.prepare();
44 public ListenableFuture<Void> abort() {
45 // FIXME abort on the shard
46 return Futures.immediateFuture(null);
50 public ListenableFuture<Void> commit() {
51 LOG.debug("Submitting transaction on foreign shard {}", prefix);
52 return shard.submit();