--- /dev/null
+/*
+ * 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.common.api.data;
+
+/**
+ * A chain of transactions. Transactions in a chain need to be committed in sequence and each
+ * transaction should see the effects of previous transactions as if they happened. A chain
+ * makes no guarantees of atomicity, in fact transactions are committed as soon as possible.
+ */
+public interface TransactionChain<P/* extends Path<P> */, D> extends AutoCloseable {
+ /**
+ * Create a new transaction which will continue the chain. The previous transaction
+ * has to be either COMMITTED or CANCELLED.
+ *
+ * @return New transaction in the chain.
+ * @throws IllegalStateException if the previous transaction was not COMMITTED or CANCELLED.
+ * @throws TransactionChainClosedException if the chain has been closed.
+ */
+ DataModification<P, D> newTransaction();
+
+ @Override
+ void close();
+}
+
--- /dev/null
+/*
+ * 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.common.api.data;
+
+/**
+ * Exception thrown when an attempt is made to open a new transaction in a closed
+ * chain.
+ */
+public final class TransactionChainClosedException extends IllegalStateException {
+ private static final long serialVersionUID = 1L;
+
+ public TransactionChainClosedException(final String message) {
+ super(message);
+ }
+
+ public TransactionChainClosedException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 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.common.api.data;
+
+/**
+ * Interface for creating transaction chains.
+ */
+public interface TransactionChainFactory<P/* extends Path<P> */, D> {
+ /**
+ * Create a new transaction chain. The chain will be initialized to read
+ * from its backing datastore, with no outstanding transaction. Listener
+ * will be registered to handle chain-level events.
+ *
+ * @param listener Transaction chain event listener
+ * @return A new transaction chain.
+ */
+ TransactionChain<P, D> createTransactionChain(TransactionChainListener listener);
+}
+
--- /dev/null
+/*
+ * 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.common.api.data;
+
+import java.util.EventListener;
+
+/**
+ * Listener for transaction chain events.
+ */
+public interface TransactionChainListener extends EventListener {
+ /**
+ * Invoked if when a transaction in the chain fails. All other transactions are automatically cancelled by the time
+ * this notification is invoked. Implementations should invoke chain.close() to close the chain.
+ *
+ * @param chain Transaction chain which failed
+ * @param transaction Transaction which caused the chain to fail
+ * @param cause The cause of transaction failure
+ */
+ void onTransactionChainFailed(TransactionChain<?, ?> chain, DataModification<?, ?> transaction, Throwable cause);
+
+ /**
+ * Invoked when a transaction chain is completed. A transaction chain is considered completed when it has been
+ * closed and all its instructions have completed successfully.
+ *
+ * @param chain Transaction chain which completed
+ */
+ void onTransactionChainSuccessful(TransactionChain<?, ?> chain);
+}
+