Clean up of binding broker implementation
[controller.git] / opendaylight / sal / yang-prototype / sal / sal-core-api / src / main / java / org / opendaylight / controller / sal / core / api / data / DataCommitHandler.java
index f0cc02d3cebf019b8762136f95dfebffe2b6ce9e..fc1894a3d9100f2895048da54b9e9d4c927e4a71 100644 (file)
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.core.api.data;\r
-\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.sal.common.DataStoreIdentifier;\r
-import org.opendaylight.controller.sal.core.api.Provider;\r
-import org.opendaylight.controller.yang.common.RpcResult;\r
-\r
-\r
-/**\r
- * Two phase commit handler (cohort) of the two-phase commit protocol of data.\r
- * \r
- * <p>\r
- * The provider should expose the implementation of DataCommitHandler if it's\r
- * functionality depends on any subset of data stored in data repositories, in\r
- * order to participate in {@link DataBrokerService#commit(DataStoreIdentifier)\r
- * operation.\r
- * \r
- * <p>\r
- * Operations of two-phase commit handlers should not change data in data store,\r
- * this is responsibility of the coordinator (broker or some component of the\r
- * broker).\r
- * \r
- * The commit handlers are responsible for changing the internal state of the\r
- * provider to reflect the commited changes in data.\r
- * \r
- * <h3>Two-phase commit</h3>\r
- * \r
- * <h4>Commit Request Phase</h4>\r
- * \r
- * <ol>\r
- * <li> <code>Consumer</code> edits data by invocation of\r
- * <code>DataBrokerService.editCandidateData(DataStoreIdentifier, CompositeNodeModification)</code>\r
- * <li> <code>Consumer</code> starts a commit by invoking\r
- * <code>DataBrokerService.commit(DataStoreIdentifier)</code>\r
- * <li> <code>Broker</code> retrieves a list of all registered\r
- * <code>DataCommitHandlers</code>\r
- * <li>For each <code>DataCommitHandler</code>\r
- * <ol>\r
- * <li><code>Broker</code> invokes a\r
- * <code>DataCommitHandler.requestCommit(DataStoreIdentifier)</code> operation.\r
- * <li><code>DataCommitHandler</code> returns a <code>RpcResult</code> with\r
- * <code>CommitTransaction</code>\r
- * <li>If the result was successful, broker adds <code>CommitTransaction</code>\r
- * to the list of opened transactions. If not, brokers stops a commit request\r
- * phase and starts a rollback phase.\r
- * </ol>\r
- * <li><code>Broker</code> starts a commit finish phase\r
- * </ol>\r
- * \r
- * <h4>Commit Finish Phase</h4>\r
- * \r
- * <ol>\r
- * <li>For each <code>CommitTransaction</code> from Commit Request phase\r
- * <ol>\r
- * <li><code>Broker</code> broker invokes a\r
- * <code>CommitTransaction.finish()</code>\r
- * <li>The provider finishes a commit (applies the change) and returns an\r
- * <code>RpcResult</code>.\r
- * </ol>\r
- * <li>\r
- * <ul>\r
- * <li>If all returned results means successful, the brokers end two-phase\r
- * commit by returning a success commit result to the Consumer.\r
- * <li>If error occured, the broker starts a commit rollback phase.\r
- * </ul>\r
- * </ol>\r
- * \r
- * <h4>Commit Rollback Phase</h4>\r
- * <li>For each <code>CommitTransaction</code> from Commit Request phase\r
- * <ol>\r
- * <li><code>Broker</code>\r
- * \r
- * broker invokes a {@link CommitTransaction#finish()}\r
- * <li>The provider rollbacks a commit and returns an {@link RpcResult} of\r
- * rollback. </ol>\r
- * <li>Broker returns a error result to the consumer.\r
- * \r
- * \r
- * <h3>Registration of functionality</h3>\r
- * The registration could be done by :\r
- * <ul>\r
- * <li>returning an instance of implementation in the return value of\r
- * {@link Provider#getProviderFunctionality()}\r
- * <li>passing an instance of implementation and {@link DataStoreIdentifier} of\r
- * rpc as arguments to the\r
- * {@link DataProviderService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)}\r
- * </ul>\r
- * \r
- * \r
- */\r
-public interface DataCommitHandler extends Provider.ProviderFunctionality {\r
-\r
-    /**\r
-     * A set of Data Stores supported by implementation.\r
-     * \r
-     * The set of {@link DataStoreIdentifier}s which identifies target data\r
-     * stores which are supported by this commit handler. This set is used, when\r
-     * {@link Provider} is registered to the SAL, to register and expose the\r
-     * commit handler functionality to affected data stores.\r
-     * \r
-     * @return Set of Data Store identifiers\r
-     */\r
-    Set<DataStoreIdentifier> getSupportedDataStores();\r
-\r
-    /**\r
-     * The provider (commit handler) starts a commit transaction.\r
-     * \r
-     * <p>\r
-     * The commit handler (provider) prepares an commit scenario, rollback\r
-     * scenario and validates data.\r
-     * \r
-     * <p>\r
-     * If the provider is aware that at this point the commit would not be\r
-     * successful, the transaction is not created, but list of errors which\r
-     * prevented the start of transaction are returned.\r
-     * \r
-     * @param store\r
-     * @return Transaction object representing this commit, errors otherwise.\r
-     */\r
-    RpcResult<CommitTransaction> requestCommit(DataStoreIdentifier store);\r
-\r
-    public interface CommitTransaction {\r
-        /**\r
-         * \r
-         * @return Data store affected by the transaction\r
-         */\r
-        DataStoreIdentifier getDataStore();\r
-\r
-        /**\r
-         * Returns the handler associated with this transaction.\r
-         * \r
-         * @return Handler\r
-         */\r
-        DataCommitHandler getHandler();\r
-\r
-        /**\r
-         * \r
-         * Finishes a commit.\r
-         * \r
-         * The provider (commit handler) should apply all changes to its state\r
-         * which are a result of data change-\r
-         * \r
-         * @return\r
-         */\r
-        RpcResult<Void> finish() throws IllegalStateException;\r
-\r
-        /**\r
-         * Rollbacks a commit.\r
-         * \r
-         * @return\r
-         * @throws IllegalStateException\r
-         *             If the method is invoked after {@link #finish()}\r
-         */\r
-        RpcResult<Void> rollback() throws IllegalStateException;\r
-    }\r
-}\r
+/*
+ * 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.sal.core.api.data;
+
+import java.util.Set;
+
+import org.opendaylight.controller.sal.common.DataStoreIdentifier;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+
+/**
+ * Two phase commit handler (cohort) of the two-phase commit protocol of data.
+ * 
+ * <p>
+ * The provider should expose the implementation of DataCommitHandler if it's
+ * functionality depends on any subset of data stored in data repositories, in
+ * order to participate in {@link DataBrokerService#commit(DataStoreIdentifier)
+ * operation.
+ * 
+ * <p>
+ * Operations of two-phase commit handlers should not change data in data store,
+ * this is responsibility of the coordinator (broker or some component of the
+ * broker).
+ * 
+ * The commit handlers are responsible for changing the internal state of the
+ * provider to reflect the commited changes in data.
+ * 
+ * <h3>Two-phase commit</h3>
+ * 
+ * <h4>Commit Request Phase</h4>
+ * 
+ * <ol>
+ * <li> <code>Consumer</code> edits data by invocation of
+ * <code>DataBrokerService.editCandidateData(DataStoreIdentifier, CompositeNodeModification)</code>
+ * <li> <code>Consumer</code> starts a commit by invoking
+ * <code>DataBrokerService.commit(DataStoreIdentifier)</code>
+ * <li> <code>Broker</code> retrieves a list of all registered
+ * <code>DataCommitHandlers</code>
+ * <li>For each <code>DataCommitHandler</code>
+ * <ol>
+ * <li><code>Broker</code> invokes a
+ * <code>DataCommitHandler.requestCommit(DataStoreIdentifier)</code> operation.
+ * <li><code>DataCommitHandler</code> returns a <code>RpcResult</code> with
+ * <code>CommitTransaction</code>
+ * <li>If the result was successful, broker adds <code>CommitTransaction</code>
+ * to the list of opened transactions. If not, brokers stops a commit request
+ * phase and starts a rollback phase.
+ * </ol>
+ * <li><code>Broker</code> starts a commit finish phase
+ * </ol>
+ * 
+ * <h4>Commit Finish Phase</h4>
+ * 
+ * <ol>
+ * <li>For each <code>CommitTransaction</code> from Commit Request phase
+ * <ol>
+ * <li><code>Broker</code> broker invokes a
+ * <code>CommitTransaction.finish()</code>
+ * <li>The provider finishes a commit (applies the change) and returns an
+ * <code>RpcResult</code>.
+ * </ol>
+ * <li>
+ * <ul>
+ * <li>If all returned results means successful, the brokers end two-phase
+ * commit by returning a success commit result to the Consumer.
+ * <li>If error occured, the broker starts a commit rollback phase.
+ * </ul>
+ * </ol>
+ * 
+ * <h4>Commit Rollback Phase</h4>
+ * <li>For each <code>CommitTransaction</code> from Commit Request phase
+ * <ol>
+ * <li><code>Broker</code>
+ * 
+ * broker invokes a {@link CommitTransaction#finish()}
+ * <li>The provider rollbacks a commit and returns an {@link RpcResult} of
+ * rollback. </ol>
+ * <li>Broker returns a error result to the consumer.
+ * 
+ * 
+ * <h3>Registration of functionality</h3>
+ * The registration could be done by :
+ * <ul>
+ * <li>returning an instance of implementation in the return value of
+ * {@link Provider#getProviderFunctionality()}
+ * <li>passing an instance of implementation and {@link DataStoreIdentifier} of
+ * rpc as arguments to the
+ * {@link DataProviderService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)}
+ * </ul>
+ * 
+ * 
+ */
+public interface DataCommitHandler extends Provider.ProviderFunctionality {
+
+    /**
+     * A set of Data Stores supported by implementation.
+     * 
+     * The set of {@link DataStoreIdentifier}s which identifies target data
+     * stores which are supported by this commit handler. This set is used, when
+     * {@link Provider} is registered to the SAL, to register and expose the
+     * commit handler functionality to affected data stores.
+     * 
+     * @return Set of Data Store identifiers
+     */
+    Set<DataStoreIdentifier> getSupportedDataStores();
+
+    /**
+     * The provider (commit handler) starts a commit transaction.
+     * 
+     * <p>
+     * The commit handler (provider) prepares an commit scenario, rollback
+     * scenario and validates data.
+     * 
+     * <p>
+     * If the provider is aware that at this point the commit would not be
+     * successful, the transaction is not created, but list of errors which
+     * prevented the start of transaction are returned.
+     * 
+     * @param store
+     * @return Transaction object representing this commit, errors otherwise.
+     */
+    RpcResult<CommitTransaction> requestCommit(DataStoreIdentifier store);
+
+    public interface CommitTransaction {
+        /**
+         * 
+         * @return Data store affected by the transaction
+         */
+        DataStoreIdentifier getDataStore();
+
+        /**
+         * Returns the handler associated with this transaction.
+         * 
+         * @return Handler
+         */
+        DataCommitHandler getHandler();
+
+        /**
+         * 
+         * Finishes a commit.
+         * 
+         * The provider (commit handler) should apply all changes to its state
+         * which are a result of data change-
+         * 
+         * @return
+         */
+        RpcResult<Void> finish() throws IllegalStateException;
+
+        /**
+         * Rollbacks a commit.
+         * 
+         * @return
+         * @throws IllegalStateException
+         *             If the method is invoked after {@link #finish()}
+         */
+        RpcResult<Void> rollback() throws IllegalStateException;
+    }
+}