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.shard.ForeignShardModificationContext;
15 import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class ForeignShardThreePhaseCommitCohort implements DOMStoreThreePhaseCommitCohort {
21 private static final Logger LOG = LoggerFactory.getLogger(ForeignShardThreePhaseCommitCohort.class);
23 private final DOMDataTreeIdentifier prefix;
24 private final ForeignShardModificationContext shard;
26 public ForeignShardThreePhaseCommitCohort(final DOMDataTreeIdentifier prefix,
27 final ForeignShardModificationContext shard) {
33 public ListenableFuture<Boolean> canCommit() {
34 LOG.debug("Validating transaction on foreign shard {}", prefix);
35 return shard.validate();
39 public ListenableFuture<Void> preCommit() {
40 LOG.debug("Preparing transaction on foreign shard {}", prefix);
41 return shard.prepare();
45 public ListenableFuture<Void> abort() {
46 // FIXME abort on the shard
47 return Futures.immediateFuture(null);
51 public ListenableFuture<Void> commit() {
52 LOG.debug("Submitting transaction on foreign shard {}", prefix);
53 return shard.submit();