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, final ForeignShardModificationContext shard) {
31 public ListenableFuture<Boolean> canCommit() {
32 LOG.debug("Validating transaction on foreign shard {}", prefix);
33 return shard.validate();
37 public ListenableFuture<Void> preCommit() {
38 LOG.debug("Preparing transaction on foreign shard {}", prefix);
39 return shard.prepare();
43 public ListenableFuture<Void> abort() {
44 // FIXME abort on the shard
45 return Futures.immediateFuture(null);
49 public ListenableFuture<Void> commit() {
50 LOG.debug("Submitting transaction on foreign shard {}", prefix);
51 return shard.submit();