*
* <h2>Examples</h2>
*
- * Following is an example model with comments describing what notifications
- * you would receive based on the scope you specify, when you are
- * registering for changes on container a.
+ * Following is an example model with comments describing what notifications you would receive
+ * based on the scope you specify, when you are registering for changes on container a.
*
* <pre>
* container a // scope BASE, ONE, SUBTREE
* id "b" // scope SUBTREE
* </pre>
*
- * Following is an example model with comments describing what notifications
- * you would receive based on the scope you specify, when you are
- * registering for changes on list list (without specifying concrete item in
- * the list).
+ * Following is an example model with comments describing what notifications you would receive
+ * based on the scope you specify, when you are registering for changes on list list (without
+ * specifying concrete item in the list).
*
* <pre>
* list list // scope BASE, ONE, SUBTREE
* </pre>
*
*
- * @see http://www.idevelopment.info/data/LDAP/LDAP_Resources/
- * SEARCH_Setting_the_SCOPE_Parameter.shtml
+ * See <a href=
+ * "http://www.idevelopment.info/data/LDAP/LDAP_Resources/SEARCH_Setting_the_SCOPE_Parameter.shtml"
+ * >LDAP Scope</a> for scope reference.
*/
public enum DataChangeScope {
package org.opendaylight.controller.md.sal.common.api.data;
import java.util.EventListener;
-
import org.opendaylight.yangtools.concepts.Path;
/**
public interface AsyncDataChangeListener<P extends Path<P>, D> extends EventListener {
/**
*
- * Invoked when there is data change for the particular path, which was used to
- * register this listener.
+ * Invoked when there is data change for the particular path, which was used to register this
+ * listener.
* <p>
- * This method may be also invoked during registration of the listener if
- * there is any preexisting data in the conceptual data tree for supplied path.
- * This initial event will contain all preexisting data as created.
+ * This method may be also invoked during registration of the listener if there is any
+ * preexisting data in the conceptual data tree for supplied path. This initial event will
+ * contain all preexisting data as created.
*
* <p>
* <b>Note</b>: This method may be invoked from a shared thread pool.
+ * <ul>
* <li>Implementations <b>SHOULD NOT</b> perform CPU-intensive operations on the calling thread.
- * <li>Implementations <b>MUST NOT block the calling thread</b> - to do so could lead to deadlock
- * scenarios.
+ * <li>Implementations <b>MUST NOT block the calling thread</b> - to do so could lead to
+ * deadlock scenarios.
+ * </ul>
*
- *<br>
+ * <br>
*
- * @param change
- * Data Change Event being delivered.
+ * @param change Data Change Event being delivered.
*/
void onDataChanged(AsyncDataChangeEvent<P, D> change);
}
* @param <D>
* Type of data (payload), which represents data payload
*
- * @see org.opendaylight.controller.md.sal.binding.api.ReadTransaction
- * @see org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction
*/
public interface AsyncReadTransaction<P extends Path<P>, D> extends AsyncTransaction<P, D> {
--- /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 com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+/**
+ * Write transaction provides mutation capabilities for a data tree.
+ *
+ * <p>
+ * Initial state of write transaction is a stable snapshot of the current data tree.
+ * The state is captured when the transaction is created and its state and underlying
+ * data tree are not affected by other concurrently running transactions.
+ * <p>
+ * Write transactions are isolated from other concurrent write transactions. All
+ * writes are local to the transaction and represent only a proposal of state
+ * change for the data tree and it is not visible to any other concurrently running
+ * transaction.
+ * <p>
+ * Applications make changes to the local data tree in the transaction by via the
+ * <b>put</b>, <b>merge</b>, and <b>delete</b> operations.
+ *
+ * <h2>Put operation</h2>
+ * Stores a piece of data at a specified path. This acts as an add / replace
+ * operation, which is to say that whole subtree will be replaced by the
+ * specified data.
+ * <p>
+ * Performing the following put operations:
+ *
+ * <pre>
+ * 1) container { list [ a ] }
+ * 2) container { list [ b ] }
+ * </pre>
+ *
+ * will result in the following data being present:
+ *
+ * <pre>
+ * container { list [ b ] }
+ * </pre>
+ * <h2>Merge operation</h2>
+ * Merges a piece of data with the existing data at a specified path. Any pre-existing data
+ * which is not explicitly overwritten will be preserved. This means that if you store a container,
+ * its child lists will be merged.
+ * <p>
+ * Performing the following merge operations:
+ *
+ * <pre>
+ * 1) container { list [ a ] }
+ * 2) container { list [ b ] }
+ * </pre>
+ *
+ * will result in the following data being present:
+ *
+ * <pre>
+ * container { list [ a, b ] }
+ * </pre>
+ *
+ * This also means that storing the container will preserve any
+ * augmentations which have been attached to it.
+ *
+ * <h2>Delete operation</h2>
+ * Removes a piece of data from a specified path.
+ * <p>
+ * After applying changes to the local data tree, applications publish the changes proposed in the
+ * transaction by calling {@link #submit} on the transaction. This seals the transaction
+ * (preventing any further writes using this transaction) and submits it to be
+ * processed and applied to global conceptual data tree.
+ * <p>
+ * The transaction commit may fail due to a concurrent transaction modifying and committing data in
+ * an incompatible way. See {@link #submit} for more concrete commit failure examples.
+ * <p>
+ * <b>Implementation Note:</b> This interface is not intended to be implemented
+ * by users of MD-SAL, but only to be consumed by them.
+ *
+ * @param <P>
+ * Type of path (subtree identifier), which represents location in
+ * tree
+ * @param <D>
+ * Type of data (payload), which represents data payload
+ */
+public interface AsyncWriteTransaction<P extends Path<P>, D> extends AsyncTransaction<P, D> {
+ /**
+ * Cancels the transaction.
+ *
+ * Transactions can only be cancelled if it's status is
+ * {@link TransactionStatus#NEW} or {@link TransactionStatus#SUBMITED}
+ *
+ * Invoking cancel() on {@link TransactionStatus#FAILED} or
+ * {@link TransactionStatus#CANCELED} will have no effect, and transaction
+ * is considered cancelled.
+ *
+ * Invoking cancel() on finished transaction (future returned by {@link #submit()}
+ * already completed with {@link TransactionStatus#COMMITED}) will always
+ * fail (return false).
+ *
+ * @return <tt>false</tt> if the task could not be cancelled,
+ * typically because it has already completed normally;
+ * <tt>true</tt> otherwise
+ *
+ */
+ boolean cancel();
+
+ /**
+ * Removes a piece of data from specified path. This operation does not fail
+ * if the specified path does not exist.
+ *
+ * @param store
+ * Logical data store which should be modified
+ * @param path
+ * Data object path
+ * @throws IllegalStateException
+ * if the transaction is no longer {@link TransactionStatus#NEW}
+ */
+ void delete(LogicalDatastoreType store, P path);
+
+ /**
+ * Submits this transaction to be asynchronously applied to update the logical data tree. The
+ * returned CheckedFuture conveys the result of applying the data changes.
+ * <p>
+ * <b>Note:</b> It is strongly recommended to process the CheckedFuture result in an
+ * asynchronous manner rather than using the blocking get() method. See example usage below.
+ * <p>
+ * This call logically seals the transaction, which prevents the client from further changing
+ * data tree using this transaction. Any subsequent calls to
+ * <code>put(LogicalDatastoreType, Path, Object)</code>,
+ * <code>merge(LogicalDatastoreType, Path, Object)</code>,
+ * <code>delete(LogicalDatastoreType, Path)</code> will fail with {@link IllegalStateException}.
+ *
+ * The transaction is marked as {@link TransactionStatus#SUBMITED} and enqueued into the data
+ * store back-end for processing.
+ *
+ * <p>
+ * Whether or not the commit is successful is determined by versioning of the data tree and
+ * validation of registered commit participants if the transaction changes the data tree.
+ * <p>
+ * The effects of a successful commit of data depends on data change listeners (
+ * {@link AsyncDataChangeListener}) and commit participants that are registered with the data
+ * broker.
+ * <p>
+ * <h3>Example usage:</h3>
+ *
+ * <pre>
+ * private void doWrite( final int tries ) {
+ * WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
+ *
+ * MyDataObject data = ...;
+ * InstanceIdentifier<MyDataObject> path = ...;
+ * writeTx.put( LogicalDatastoreType.OPERATIONAL, path, data );
+ *
+ * Futures.addCallback( writeTx.submit(), new FutureCallback<Void>() {
+ * public void onSuccess( Void result ) {
+ * // succeeded
+ * }
+ *
+ * public void onFailure( Throwable t ) {
+ * if( t instanceof OptimisticLockFailedException ) {
+ * if( ( tries - 1 ) > 0 ) {
+ * // do retry
+ * doWrite( tries - 1 );
+ * } else {
+ * // out of retries
+ * }
+ * } else {
+ * // failed due to another type of TransactionCommitFailedException.
+ * }
+ * } );
+ * }
+ * ...
+ * doWrite( 2 );
+ * </pre>
+ *
+ * <h2>Failure scenarios</h2>
+ * <p>
+ * Transaction may fail because of multiple reasons, such as
+ * <ul>
+ * <li>Another transaction finished earlier and modified the same node in a non-compatible way
+ * (see below). In this case the returned future will fail with an
+ * {@link OptimisticLockFailedException}. It is the responsibility of the caller to create a new
+ * transaction and submit the same modification again in order to update data tree.
+ * <i><b>Warning</b>: In most cases, retrying after an OptimisticLockFailedException will result
+ * in a high probability of success. However, there are scenarios, albeit unusual, where any
+ * number of retries will not succeed. Therefore it is strongly recommended to limit the number
+ * of retries (2 or 3) to avoid an endless loop.</i></li>
+ * <li>Data change introduced by this transaction did not pass validation by commit handlers or
+ * data was incorrectly structured. Returned future will fail with a
+ * {@link DataValidationFailedException}. User should not retry to create new transaction with
+ * same data, since it probably will fail again.</li>
+ * </ul>
+ *
+ * <h3>Change compatibility</h3>
+ *
+ * There are several sets of changes which could be considered incompatible between two
+ * transactions which are derived from same initial state. Rules for conflict detection applies
+ * recursively for each subtree level.
+ *
+ * <h4>Change compatibility of leafs, leaf-list items</h4>
+ *
+ * Following table shows state changes and failures between two concurrent transactions, which
+ * are based on same initial state, Tx 1 completes successfully before Tx 2 is submitted.
+ *
+ * <table summary="Change compatibility of leaf values">
+ * <tr>
+ * <th>Initial state</th>
+ * <th>Tx 1</th>
+ * <th>Tx 2</th>
+ * <th>Result</th>
+ * </tr>
+ * <tr>
+ * <td>Empty</td>
+ * <td>put(A,1)</td>
+ * <td>put(A,2)</td>
+ * <td>Tx 2 will fail, state is A=1</td>
+ * </tr>
+ * <tr>
+ * <td>Empty</td>
+ * <td>put(A,1)</td>
+ * <td>merge(A,2)</td>
+ * <td>A=2</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>Empty</td>
+ * <td>merge(A,1)</td>
+ * <td>put(A,2)</td>
+ * <td>Tx 2 will fail, state is A=1</td>
+ * </tr>
+ * <tr>
+ * <td>Empty</td>
+ * <td>merge(A,1)</td>
+ * <td>merge(A,2)</td>
+ * <td>A=2</td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>A=0</td>
+ * <td>put(A,1)</td>
+ * <td>put(A,2)</td>
+ * <td>Tx 2 will fail, A=1</td>
+ * </tr>
+ * <tr>
+ * <td>A=0</td>
+ * <td>put(A,1)</td>
+ * <td>merge(A,2)</td>
+ * <td>A=2</td>
+ * </tr>
+ * <tr>
+ * <td>A=0</td>
+ * <td>merge(A,1)</td>
+ * <td>put(A,2)</td>
+ * <td>Tx 2 will fail, A=1</td>
+ * </tr>
+ * <tr>
+ * <td>A=0</td>
+ * <td>merge(A,1)</td>
+ * <td>merge(A,2)</td>
+ * <td>A=2</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>A=0</td>
+ * <td>delete(A)</td>
+ * <td>put(A,2)</td>
+ * <td>Tx 2 will fail, A does not exists</td>
+ * </tr>
+ * <tr>
+ * <td>A=0</td>
+ * <td>delete(A)</td>
+ * <td>merge(A,2)</td>
+ * <td>A=2</td>
+ * </tr>
+ * </table>
+ *
+ * <h4>Change compatibility of subtrees</h4>
+ *
+ * Following table shows state changes and failures between two concurrent transactions, which
+ * are based on same initial state, Tx 1 completes successfully before Tx 2 is submitted.
+ *
+ * <table summary="Change compatibility of containers">
+ * <tr>
+ * <th>Initial state</th>
+ * <th>Tx 1</th>
+ * <th>Tx 2</th>
+ * <th>Result</th>
+ * </tr>
+ *
+ * <tr>
+ * <td>Empty</td>
+ * <td>put(TOP,[])</td>
+ * <td>put(TOP,[])</td>
+ * <td>Tx 2 will fail, state is TOP=[]</td>
+ * </tr>
+ * <tr>
+ * <td>Empty</td>
+ * <td>put(TOP,[])</td>
+ * <td>merge(TOP,[])</td>
+ * <td>TOP=[]</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>Empty</td>
+ * <td>put(TOP,[FOO=1])</td>
+ * <td>put(TOP,[BAR=1])</td>
+ * <td>Tx 2 will fail, state is TOP=[FOO=1]</td>
+ * </tr>
+ * <tr>
+ * <td>Empty</td>
+ * <td>put(TOP,[FOO=1])</td>
+ * <td>merge(TOP,[BAR=1])</td>
+ * <td>TOP=[FOO=1,BAR=1]</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>Empty</td>
+ * <td>merge(TOP,[FOO=1])</td>
+ * <td>put(TOP,[BAR=1])</td>
+ * <td>Tx 2 will fail, state is TOP=[FOO=1]</td>
+ * </tr>
+ * <tr>
+ * <td>Empty</td>
+ * <td>merge(TOP,[FOO=1])</td>
+ * <td>merge(TOP,[BAR=1])</td>
+ * <td>TOP=[FOO=1,BAR=1]</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>put(TOP,[FOO=1])</td>
+ * <td>put(TOP,[BAR=1])</td>
+ * <td>Tx 2 will fail, state is TOP=[FOO=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>put(TOP,[FOO=1])</td>
+ * <td>merge(TOP,[BAR=1])</td>
+ * <td>state is TOP=[FOO=1,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>merge(TOP,[FOO=1])</td>
+ * <td>put(TOP,[BAR=1])</td>
+ * <td>Tx 2 will fail, state is TOP=[FOO=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>merge(TOP,[FOO=1])</td>
+ * <td>merge(TOP,[BAR=1])</td>
+ * <td>state is TOP=[FOO=1,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>delete(TOP)</td>
+ * <td>put(TOP,[BAR=1])</td>
+ * <td>Tx 2 will fail, state is empty store</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>delete(TOP)</td>
+ * <td>merge(TOP,[BAR=1])</td>
+ * <td>state is TOP=[BAR=1]</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>put(TOP/FOO,1)</td>
+ * <td>put(TOP/BAR,1])</td>
+ * <td>state is TOP=[FOO=1,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>put(TOP/FOO,1)</td>
+ * <td>merge(TOP/BAR,1)</td>
+ * <td>state is TOP=[FOO=1,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>merge(TOP/FOO,1)</td>
+ * <td>put(TOP/BAR,1)</td>
+ * <td>state is TOP=[FOO=1,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>merge(TOP/FOO,1)</td>
+ * <td>merge(TOP/BAR,1)</td>
+ * <td>state is TOP=[FOO=1,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>delete(TOP)</td>
+ * <td>put(TOP/BAR,1)</td>
+ * <td>Tx 2 will fail, state is empty store</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[]</td>
+ * <td>delete(TOP)</td>
+ * <td>merge(TOP/BAR,1]</td>
+ * <td>Tx 2 will fail, state is empty store</td>
+ * </tr>
+ *
+ * <tr>
+ * <td>TOP=[FOO=1]</td>
+ * <td>put(TOP/FOO,2)</td>
+ * <td>put(TOP/BAR,1)</td>
+ * <td>state is TOP=[FOO=2,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[FOO=1]</td>
+ * <td>put(TOP/FOO,2)</td>
+ * <td>merge(TOP/BAR,1)</td>
+ * <td>state is TOP=[FOO=2,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[FOO=1]</td>
+ * <td>merge(TOP/FOO,2)</td>
+ * <td>put(TOP/BAR,1)</td>
+ * <td>state is TOP=[FOO=2,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[FOO=1]</td>
+ * <td>merge(TOP/FOO,2)</td>
+ * <td>merge(TOP/BAR,1)</td>
+ * <td>state is TOP=[FOO=2,BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[FOO=1]</td>
+ * <td>delete(TOP/FOO)</td>
+ * <td>put(TOP/BAR,1)</td>
+ * <td>state is TOP=[BAR=1]</td>
+ * </tr>
+ * <tr>
+ * <td>TOP=[FOO=1]</td>
+ * <td>delete(TOP/FOO)</td>
+ * <td>merge(TOP/BAR,1]</td>
+ * <td>state is TOP=[BAR=1]</td>
+ * </tr>
+ * </table>
+ *
+ *
+ * <h3>Examples of failure scenarios</h3>
+ *
+ * <h4>Conflict of two transactions</h4>
+ *
+ * This example illustrates two concurrent transactions, which derived from same initial state
+ * of data tree and proposes conflicting modifications.
+ *
+ * <pre>
+ * txA = broker.newWriteTransaction(); // allocates new transaction, data tree is empty
+ * txB = broker.newWriteTransaction(); // allocates new transaction, data tree is empty
+ *
+ * txA.put(CONFIGURATION, PATH, A); // writes to PATH value A
+ * txB.put(CONFIGURATION, PATH, B) // writes to PATH value B
+ *
+ * ListenableFuture futureA = txA.submit(); // transaction A is sealed and submitted
+ * ListenebleFuture futureB = txB.submit(); // transaction B is sealed and submitted
+ * </pre>
+ *
+ * Commit of transaction A will be processed asynchronously and data tree will be updated to
+ * contain value <code>A</code> for <code>PATH</code>. Returned {@link ListenableFuture} will
+ * successfully complete once state is applied to data tree.
+ *
+ * Commit of Transaction B will fail, because previous transaction also modified path in a
+ * concurrent way. The state introduced by transaction B will not be applied. Returned
+ * {@link ListenableFuture} object will fail with {@link OptimisticLockFailedException}
+ * exception, which indicates to client that concurrent transaction prevented the submitted
+ * transaction from being applied. <br>
+ *
+ * @return a CheckFuture containing the result of the commit. The Future blocks until the commit
+ * operation is complete. A successful commit returns nothing. On failure, the Future
+ * will fail with a {@link TransactionCommitFailedException} or an exception derived
+ * from TransactionCommitFailedException.
+ *
+ * @throws IllegalStateException if the transaction is not {@link TransactionStatus#NEW}
+ */
+ CheckedFuture<Void,TransactionCommitFailedException> submit();
+
+ /**
+ * @deprecated Use {@link #submit()} instead.
+ */
+ @Deprecated
+ ListenableFuture<RpcResult<TransactionStatus>> commit();
+
+}
* the asynchronous nature of transaction submission this can lead to surprising
* results. If a thread executes the following sequence sufficiently quickly:
*
+ * <pre><code>
* AsyncWriteTransaction t1 = broker.newWriteOnlyTransaction();
* t1.put(id, data);
* t1.submit();
*
* AsyncReadTransaction t2 = broker.newReadOnlyTransaction();
- * Optional<?> maybeData = t2.read(id).get();
+ * Optional<?> maybeData = t2.read(id).get();
+ * </code></pre>
*
* it may happen, that it sees maybeData.isPresent() == false, simply because
* t1 has not completed the processes of being applied and t2 is actually
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>org.opendaylight.mdsal</groupId>
+ <artifactId>mdsal-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <relativePath>parent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>mdsal-common-agreggator</artifactId>
+ <name>md-sal</name> <!-- Used by Sonar to set project name -->
+ <packaging>pom</packaging>
+
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/mdsal.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/mdsal.git</developerConnection>
+ <url>https://wiki.opendaylight.org/view/MD-SAL:Main</url>
+ <tag>HEAD</tag>
+ </scm>
+
+ <modules>
+ <module>parent</module>
+ <module>artifacts</module>
+ <module>mdsal-common-api</module>
+ </modules>
+
+</project>
+++ /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 org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Write transaction provides mutation capabilities for a data tree.
- *
- * <p>
- * Initial state of write transaction is a stable snapshot of the current data tree.
- * The state is captured when the transaction is created and its state and underlying
- * data tree are not affected by other concurrently running transactions.
- * <p>
- * Write transactions are isolated from other concurrent write transactions. All
- * writes are local to the transaction and represent only a proposal of state
- * change for the data tree and it is not visible to any other concurrently running
- * transaction.
- * <p>
- * Applications make changes to the local data tree in the transaction by via the
- * <b>put</b>, <b>merge</b>, and <b>delete</b> operations.
- *
- * <h2>Put operation</h2>
- * Stores a piece of data at a specified path. This acts as an add / replace
- * operation, which is to say that whole subtree will be replaced by the
- * specified data.
- * <p>
- * Performing the following put operations:
- *
- * <pre>
- * 1) container { list [ a ] }
- * 2) container { list [ b ] }
- * </pre>
- *
- * will result in the following data being present:
- *
- * <pre>
- * container { list [ b ] }
- * </pre>
- * <h2>Merge operation</h2>
- * Merges a piece of data with the existing data at a specified path. Any pre-existing data
- * which is not explicitly overwritten will be preserved. This means that if you store a container,
- * its child lists will be merged.
- * <p>
- * Performing the following merge operations:
- *
- * <pre>
- * 1) container { list [ a ] }
- * 2) container { list [ b ] }
- * </pre>
- *
- * will result in the following data being present:
- *
- * <pre>
- * container { list [ a, b ] }
- * </pre>
- *
- * This also means that storing the container will preserve any
- * augmentations which have been attached to it.
- *
- * <h2>Delete operation</h2>
- * Removes a piece of data from a specified path.
- * <p>
- * After applying changes to the local data tree, applications publish the changes proposed in the
- * transaction by calling {@link #submit} on the transaction. This seals the transaction
- * (preventing any further writes using this transaction) and submits it to be
- * processed and applied to global conceptual data tree.
- * <p>
- * The transaction commit may fail due to a concurrent transaction modifying and committing data in
- * an incompatible way. See {@link #submit} for more concrete commit failure examples.
- * <p>
- * <b>Implementation Note:</b> This interface is not intended to be implemented
- * by users of MD-SAL, but only to be consumed by them.
- *
- * @param <P>
- * Type of path (subtree identifier), which represents location in
- * tree
- * @param <D>
- * Type of data (payload), which represents data payload
- */
-public interface AsyncWriteTransaction<P extends Path<P>, D> extends AsyncTransaction<P, D> {
- /**
- * Cancels the transaction.
- *
- * Transactions can only be cancelled if it's status is
- * {@link TransactionStatus#NEW} or {@link TransactionStatus#SUBMITED}
- *
- * Invoking cancel() on {@link TransactionStatus#FAILED} or
- * {@link TransactionStatus#CANCELED} will have no effect, and transaction
- * is considered cancelled.
- *
- * Invoking cancel() on finished transaction (future returned by {@link #submit()}
- * already completed with {@link TransactionStatus#COMMITED}) will always
- * fail (return false).
- *
- * @return <tt>false</tt> if the task could not be cancelled,
- * typically because it has already completed normally;
- * <tt>true</tt> otherwise
- *
- */
- boolean cancel();
-
- /**
- * Removes a piece of data from specified path. This operation does not fail
- * if the specified path does not exist.
- *
- * @param store
- * Logical data store which should be modified
- * @param path
- * Data object path
- * @throws IllegalStateException
- * if the transaction is no longer {@link TransactionStatus#NEW}
- */
- void delete(LogicalDatastoreType store, P path);
-
- /**
- * Submits this transaction to be asynchronously applied to update the logical data tree.
- * The returned CheckedFuture conveys the result of applying the data changes.
- * <p>
- * <b>Note:</b> It is strongly recommended to process the CheckedFuture result in an asynchronous
- * manner rather than using the blocking get() method. See example usage below.
- * <p>
- * This call logically seals the transaction, which prevents the client from
- * further changing data tree using this transaction. Any subsequent calls to
- * {@link #put(LogicalDatastoreType, Path, Object)},
- * {@link #merge(LogicalDatastoreType, Path, Object)} or
- * {@link #delete(LogicalDatastoreType, Path)} will fail with
- * {@link IllegalStateException}.
- *
- * The transaction is marked as {@link TransactionStatus#SUBMITED} and
- * enqueued into the data store back-end for processing.
- *
- * <p>
- * Whether or not the commit is successful is determined by versioning
- * of the data tree and validation of registered commit participants
- * ({@link AsyncConfigurationCommitHandler})
- * if the transaction changes the data tree.
- * <p>
- * The effects of a successful commit of data depends on data change listeners
- * ({@link AsyncDataChangeListener}) and commit participants
- * ({@link AsyncConfigurationCommitHandler}) that are registered with the data broker.
- * <p>
- * <h3>Example usage:</h3>
- * <pre>
- * private void doWrite( final int tries ) {
- * WriteTransaction writeTx = dataBroker.newWriteOnlyTransaction();
- *
- * MyDataObject data = ...;
- * InstanceIdentifier<MyDataObject> path = ...;
- * writeTx.put( LogicalDatastoreType.OPERATIONAL, path, data );
- *
- * Futures.addCallback( writeTx.submit(), new FutureCallback<Void>() {
- * public void onSuccess( Void result ) {
- * // succeeded
- * }
- *
- * public void onFailure( Throwable t ) {
- * if( t instanceof OptimisticLockFailedException ) {
- * if( ( tries - 1 ) > 0 ) {
- * // do retry
- * doWrite( tries - 1 );
- * } else {
- * // out of retries
- * }
- * } else {
- * // failed due to another type of TransactionCommitFailedException.
- * }
- * } );
- * }
- * ...
- * doWrite( 2 );
- * </pre>
- * <h2>Failure scenarios</h2>
- * <p>
- * Transaction may fail because of multiple reasons, such as
- * <ul>
- * <li>Another transaction finished earlier and modified the same node in a
- * non-compatible way (see below). In this case the returned future will fail with an
- * {@link OptimisticLockFailedException}. It is the responsibility of the
- * caller to create a new transaction and submit the same modification again in
- * order to update data tree. <i><b>Warning</b>: In most cases, retrying after an
- * OptimisticLockFailedException will result in a high probability of success.
- * However, there are scenarios, albeit unusual, where any number of retries will
- * not succeed. Therefore it is strongly recommended to limit the number of retries (2 or 3)
- * to avoid an endless loop.</i>
- * </li>
- * <li>Data change introduced by this transaction did not pass validation by
- * commit handlers or data was incorrectly structured. Returned future will
- * fail with a {@link DataValidationFailedException}. User should not retry to
- * create new transaction with same data, since it probably will fail again.
- * </li>
- * </ul>
- *
- * <h3>Change compatibility</h3>
- *
- * There are several sets of changes which could be considered incompatible
- * between two transactions which are derived from same initial state.
- * Rules for conflict detection applies recursively for each subtree
- * level.
- *
- * <h4>Change compatibility of leafs, leaf-list items</h4>
- *
- * Following table shows state changes and failures between two concurrent transactions,
- * which are based on same initial state, Tx 1 completes successfully
- * before Tx 2 is submitted.
- *
- * <table>
- * <tr><th>Initial state</th><th>Tx 1</th><th>Tx 2</th><th>Result</th></tr>
- * <tr><td>Empty</td><td>put(A,1)</td><td>put(A,2)</td><td>Tx 2 will fail, state is A=1</td></tr>
- * <tr><td>Empty</td><td>put(A,1)</td><td>merge(A,2)</td><td>A=2</td></tr>
- *
- * <tr><td>Empty</td><td>merge(A,1)</td><td>put(A,2)</td><td>Tx 2 will fail, state is A=1</td></tr>
- * <tr><td>Empty</td><td>merge(A,1)</td><td>merge(A,2)</td><td>A=2</td></tr>
- *
- *
- * <tr><td>A=0</td><td>put(A,1)</td><td>put(A,2)</td><td>Tx 2 will fail, A=1</td></tr>
- * <tr><td>A=0</td><td>put(A,1)</td><td>merge(A,2)</td><td>A=2</td></tr>
- * <tr><td>A=0</td><td>merge(A,1)</td><td>put(A,2)</td><td>Tx 2 will fail, A=1</td></tr>
- * <tr><td>A=0</td><td>merge(A,1)</td><td>merge(A,2)</td><td>A=2</td></tr>
- *
- * <tr><td>A=0</td><td>delete(A)</td><td>put(A,2)</td><td>Tx 2 will fail, A does not exists</td></tr>
- * <tr><td>A=0</td><td>delete(A)</td><td>merge(A,2)</td><td>A=2</td></tr>
- * </table>
- *
- * <h4>Change compatibility of subtrees</h4>
- *
- * Following table shows state changes and failures between two concurrent transactions,
- * which are based on same initial state, Tx 1 completes successfully
- * before Tx 2 is submitted.
- *
- * <table>
- * <tr><th>Initial state</th><th>Tx 1</th><th>Tx 2</th><th>Result</th></tr>
- *
- * <tr><td>Empty</td><td>put(TOP,[])</td><td>put(TOP,[])</td><td>Tx 2 will fail, state is TOP=[]</td></tr>
- * <tr><td>Empty</td><td>put(TOP,[])</td><td>merge(TOP,[])</td><td>TOP=[]</td></tr>
- *
- * <tr><td>Empty</td><td>put(TOP,[FOO=1])</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is TOP=[FOO=1]</td></tr>
- * <tr><td>Empty</td><td>put(TOP,[FOO=1])</td><td>merge(TOP,[BAR=1])</td><td>TOP=[FOO=1,BAR=1]</td></tr>
- *
- * <tr><td>Empty</td><td>merge(TOP,[FOO=1])</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is TOP=[FOO=1]</td></tr>
- * <tr><td>Empty</td><td>merge(TOP,[FOO=1])</td><td>merge(TOP,[BAR=1])</td><td>TOP=[FOO=1,BAR=1]</td></tr>
- *
- * <tr><td>TOP=[]</td><td>put(TOP,[FOO=1])</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is TOP=[FOO=1]</td></tr>
- * <tr><td>TOP=[]</td><td>put(TOP,[FOO=1])</td><td>merge(TOP,[BAR=1])</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>merge(TOP,[FOO=1])</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is TOP=[FOO=1]</td></tr>
- * <tr><td>TOP=[]</td><td>merge(TOP,[FOO=1])</td><td>merge(TOP,[BAR=1])</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>delete(TOP)</td><td>put(TOP,[BAR=1])</td><td>Tx 2 will fail, state is empty store</td></tr>
- * <tr><td>TOP=[]</td><td>delete(TOP)</td><td>merge(TOP,[BAR=1])</td><td>state is TOP=[BAR=1]</td></tr>
- *
- * <tr><td>TOP=[]</td><td>put(TOP/FOO,1)</td><td>put(TOP/BAR,1])</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>put(TOP/FOO,1)</td><td>merge(TOP/BAR,1)</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>merge(TOP/FOO,1)</td><td>put(TOP/BAR,1)</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>merge(TOP/FOO,1)</td><td>merge(TOP/BAR,1)</td><td>state is TOP=[FOO=1,BAR=1]</td></tr>
- * <tr><td>TOP=[]</td><td>delete(TOP)</td><td>put(TOP/BAR,1)</td><td>Tx 2 will fail, state is empty store</td></tr>
- * <tr><td>TOP=[]</td><td>delete(TOP)</td><td>merge(TOP/BAR,1]</td><td>Tx 2 will fail, state is empty store</td></tr>
- *
- * <tr><td>TOP=[FOO=1]</td><td>put(TOP/FOO,2)</td><td>put(TOP/BAR,1)</td><td>state is TOP=[FOO=2,BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>put(TOP/FOO,2)</td><td>merge(TOP/BAR,1)</td><td>state is TOP=[FOO=2,BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>merge(TOP/FOO,2)</td><td>put(TOP/BAR,1)</td><td>state is TOP=[FOO=2,BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>merge(TOP/FOO,2)</td><td>merge(TOP/BAR,1)</td><td>state is TOP=[FOO=2,BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>delete(TOP/FOO)</td><td>put(TOP/BAR,1)</td><td>state is TOP=[BAR=1]</td></tr>
- * <tr><td>TOP=[FOO=1]</td><td>delete(TOP/FOO)</td><td>merge(TOP/BAR,1]</td><td>state is TOP=[BAR=1]</td></tr>
- * </table>
- *
- *
- * <h3>Examples of failure scenarios</h3>
- *
- * <h4>Conflict of two transactions</h4>
- *
- * This example illustrates two concurrent transactions, which derived from
- * same initial state of data tree and proposes conflicting modifications.
- *
- * <pre>
- * txA = broker.newWriteTransaction(); // allocates new transaction, data tree is empty
- * txB = broker.newWriteTransaction(); // allocates new transaction, data tree is empty
- *
- * txA.put(CONFIGURATION, PATH, A); // writes to PATH value A
- * txB.put(CONFIGURATION, PATH, B) // writes to PATH value B
- *
- * ListenableFuture futureA = txA.submit(); // transaction A is sealed and submitted
- * ListenebleFuture futureB = txB.submit(); // transaction B is sealed and submitted
- * </pre>
- *
- * Commit of transaction A will be processed asynchronously and data tree
- * will be updated to contain value <code>A</code> for <code>PATH</code>.
- * Returned {@link ListenableFuture} will successfully complete once
- * state is applied to data tree.
- *
- * Commit of Transaction B will fail, because previous transaction also
- * modified path in a concurrent way. The state introduced by transaction B
- * will not be applied. Returned {@link ListenableFuture} object will fail
- * with {@link OptimisticLockFailedException} exception, which indicates to
- * client that concurrent transaction prevented the submitted transaction from being
- * applied.
- * <br>
- * @return a CheckFuture containing the result of the commit. The Future blocks until the
- * commit operation is complete. A successful commit returns nothing. On failure,
- * the Future will fail with a {@link TransactionCommitFailedException} or an exception
- * derived from TransactionCommitFailedException.
- *
- * @throws IllegalStateException
- * if the transaction is not {@link TransactionStatus#NEW}
- */
- CheckedFuture<Void,TransactionCommitFailedException> submit();
-
- /**
- * @deprecated Use {@link #submit()} instead.
- */
- @Deprecated
- ListenableFuture<RpcResult<TransactionStatus>> commit();
-
-}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </parent>
- <artifactId>sal-common-util</artifactId>
-
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>sal-common-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>concepts</artifactId>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-common</artifactId>
- </dependency>
-
- </dependencies>
- <scm>
- <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
- <tag>HEAD</tag>
- <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
- </scm>
-</project>
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications 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.util.jmx;
-
-import java.lang.management.ManagementFactory;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Abstract base for an MXBean implementation class.
- * <p>
- * This class is not intended for use outside of MD-SAL and its part of private
- * implementation (still exported as public to be reused across MD-SAL implementation
- * components) and may be removed in subsequent
- * releases.
- *
- * @author Thomas Pantelis
- */
-@Beta
-public abstract class AbstractMXBean {
-
- private static final Logger LOG = LoggerFactory.getLogger(AbstractMXBean.class);
-
- public static String BASE_JMX_PREFIX = "org.opendaylight.controller:";
-
- private final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
-
- private final String mBeanName;
- private final String mBeanType;
- private final String mBeanCategory;
-
- /**
- * Constructor.
- *
- * @param mBeanName Used as the <code>name</code> property in the bean's ObjectName.
- * @param mBeanType Used as the <code>type</code> property in the bean's ObjectName.
- * @param mBeanCategory Used as the <code>Category</code> property in the bean's ObjectName.
- */
- protected AbstractMXBean(@Nonnull String mBeanName, @Nonnull String mBeanType,
- @Nullable String mBeanCategory) {
- this.mBeanName = mBeanName;
- this.mBeanType = mBeanType;
- this.mBeanCategory = mBeanCategory;
- }
-
- private ObjectName getMBeanObjectName() throws MalformedObjectNameException {
- StringBuilder builder = new StringBuilder(BASE_JMX_PREFIX)
- .append("type=").append(getMBeanType());
-
- if(getMBeanCategory() != null) {
- builder.append(",Category=").append(getMBeanCategory());
- }
-
- builder.append(",name=").append(getMBeanName());
- return new ObjectName(builder.toString());
- }
-
- /**
- * Registers this bean with the platform MBean server with the domain defined by
- * {@link #BASE_JMX_PREFIX}.
- *
- * @return true is successfully registered, false otherwise.
- */
- public boolean registerMBean() {
- boolean registered = false;
- try {
- // Object to identify MBean
- final ObjectName mbeanName = this.getMBeanObjectName();
-
- LOG.debug("Register MBean {}", mbeanName);
-
- // unregistered if already registered
- if(server.isRegistered(mbeanName)) {
-
- LOG.debug("MBean {} found to be already registered", mbeanName);
-
- try {
- unregisterMBean(mbeanName);
- } catch(Exception e) {
-
- LOG.warn("unregister mbean {} resulted in exception {} ", mbeanName, e);
- }
- }
- server.registerMBean(this, mbeanName);
- registered = true;
-
- LOG.debug("MBean {} registered successfully", mbeanName.getCanonicalName());
- } catch(Exception e) {
-
- LOG.error("registration failed {}", e);
-
- }
- return registered;
- }
-
- /**
- * Unregisters this bean with the platform MBean server.
- *
- * @return true is successfully unregistered, false otherwise.
- */
- public boolean unregisterMBean() {
- boolean unregister = false;
- try {
- ObjectName mbeanName = this.getMBeanObjectName();
- unregisterMBean(mbeanName);
- unregister = true;
- } catch(Exception e) {
-
- LOG.error("Failed when unregistering MBean {}", e);
- }
-
- return unregister;
- }
-
- private void unregisterMBean(ObjectName mbeanName) throws MBeanRegistrationException,
- InstanceNotFoundException {
- server.unregisterMBean(mbeanName);
- }
-
- /**
- * Returns the <code>name</code> property of the bean's ObjectName.
- */
- public String getMBeanName() {
- return mBeanName;
- }
-
- /**
- * Returns the <code>type</code> property of the bean's ObjectName.
- */
- public String getMBeanType() {
- return mBeanType;
- }
-
- /**
- * Returns the <code>Category</code> property of the bean's ObjectName.
- */
- public String getMBeanCategory() {
- return mBeanCategory;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications 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.util.jmx;
-
-import java.util.List;
-
-import org.opendaylight.yangtools.util.concurrent.ListenerNotificationQueueStats;
-
-/**
- * MXBean interface for {@link QueuedNotificationManager} statistic metrics.
- *
- * @author Thomas Pantelis
- */
-public interface QueuedNotificationManagerMXBean {
-
- /**
- * Returns a list of stat instances for each current listener notification task in progress.
- */
- List<ListenerNotificationQueueStats> getCurrentListenerQueueStats();
-
- /**
- * Returns the configured maximum listener queue size.
- */
- int getMaxListenerQueueSize();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications 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.util.jmx;
-
-import java.util.List;
-
-import org.opendaylight.yangtools.util.concurrent.ListenerNotificationQueueStats;
-import org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager;
-
-import com.google.common.base.Preconditions;
-
-/**
- * Implementation of the QueuedNotificationManagerMXBean interface.
- *
- * <p>
- * This class is not intended for use outside of MD-SAL and its part of private
- * implementation (still exported as public to be reused across MD-SAL implementation
- * components) and may be removed in subsequent
- * releases.
- *
- * @author Thomas Pantelis
- */
-public class QueuedNotificationManagerMXBeanImpl extends AbstractMXBean
- implements QueuedNotificationManagerMXBean {
-
- private final QueuedNotificationManager<?,?> manager;
-
- public QueuedNotificationManagerMXBeanImpl( QueuedNotificationManager<?,?> manager,
- String mBeanName, String mBeanType, String mBeanCategory ) {
- super(mBeanName, mBeanType, mBeanCategory);
- this.manager = Preconditions.checkNotNull( manager );
- }
-
- @Override
- public List<ListenerNotificationQueueStats> getCurrentListenerQueueStats() {
- return manager.getListenerNotificationQueueStats();
- }
-
- @Override
- public int getMaxListenerQueueSize() {
- return manager.getMaxQueueCapacity();
- }
-
- public QueuedNotificationManagerStats toQueuedNotificationManagerStats() {
- return new QueuedNotificationManagerStats( getMaxListenerQueueSize(),
- getCurrentListenerQueueStats() );
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications 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.util.jmx;
-
-import java.beans.ConstructorProperties;
-import java.util.List;
-
-import org.opendaylight.yangtools.util.concurrent.ListenerNotificationQueueStats;
-
-/**
- * A bean class that holds various QueuedNotificationManager statistic metrics. This class is
- * suitable for mapping to the MXBean CompositeDataSupport type.
- *
- * <p>
- * This class is not intended for use outside of MD-SAL and its part of private
- * implementation (still exported as public to be reused across MD-SAL implementation
- * components) and may be removed in subsequent
- * releases.
- * @author Thomas Pantelis
- * @see QueuedNotificationManagerMXBeanImpl
- */
-public class QueuedNotificationManagerStats {
-
- private final int maxListenerQueueSize;
- private final List<ListenerNotificationQueueStats> currentListenerQueueStats;
-
- @ConstructorProperties({"maxListenerQueueSize","currentListenerQueueStats"})
- public QueuedNotificationManagerStats( int maxListenerQueueSize,
- List<ListenerNotificationQueueStats> currentListenerQueueStats ) {
- super();
- this.maxListenerQueueSize = maxListenerQueueSize;
- this.currentListenerQueueStats = currentListenerQueueStats;
- }
-
- public List<ListenerNotificationQueueStats> getCurrentListenerQueueStats() {
- return currentListenerQueueStats;
- }
-
- public int getMaxListenerQueueSize() {
- return maxListenerQueueSize;
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications 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.util.jmx;
-
-import java.beans.ConstructorProperties;
-
-/**
- * A bean class that holds various thread executor statistic metrics. This class is suitable for
- * mapping to the MXBean CompositeDataSupport type;
- *
- * @author Thomas Pantelis
- * @see ThreadExecutorStatsMXBeanImpl
- */
-public class ThreadExecutorStats {
-
- private final long activeThreadCount;
- private final long completedTaskCount;
- private final long currentQueueSize;
- private final long maxThreadPoolSize;
- private final long totalTaskCount;
- private final long largestThreadPoolSize;
- private final long maxQueueSize;
- private final long currentThreadPoolSize;
-
- // The following fields are defined as Long because they may be null if we can't a value
- // from the underlying executor.
- private final Long largestQueueSize;
- private final Long rejectedTaskCount;
-
- @ConstructorProperties({"activeThreadCount","currentThreadPoolSize","largestThreadPoolSize",
- "maxThreadPoolSize","currentQueueSize","largestQueueSize","maxQueueSize",
- "completedTaskCount","totalTaskCount","rejectedTaskCount"})
- public ThreadExecutorStats(long activeThreadCount, long currentThreadPoolSize,
- long largestThreadPoolSize, long maxThreadPoolSize, long currentQueueSize,
- Long largestQueueSize, long maxQueueSize, long completedTaskCount,
- long totalTaskCount, Long rejectedTaskCount) {
- this.activeThreadCount = activeThreadCount;
- this.currentThreadPoolSize = currentThreadPoolSize;
- this.largestQueueSize = largestQueueSize;
- this.largestThreadPoolSize = largestThreadPoolSize;
- this.maxThreadPoolSize = maxThreadPoolSize;
- this.currentQueueSize = currentQueueSize;
- this.maxQueueSize = maxQueueSize;
- this.completedTaskCount = completedTaskCount;
- this.totalTaskCount = totalTaskCount;
- this.rejectedTaskCount = rejectedTaskCount;
- }
-
- public long getActiveThreadCount() {
- return activeThreadCount;
- }
-
- public long getCompletedTaskCount() {
- return completedTaskCount;
- }
-
- public Long getRejectedTaskCount() {
- return rejectedTaskCount;
- }
-
- public long getCurrentQueueSize() {
- return currentQueueSize;
- }
-
- public Long getLargestQueueSize() {
- return largestQueueSize;
- }
-
- public long getMaxThreadPoolSize() {
- return maxThreadPoolSize;
- }
-
- public long getTotalTaskCount() {
- return totalTaskCount;
- }
-
- public long getLargestThreadPoolSize() {
- return largestThreadPoolSize;
- }
-
- public long getMaxQueueSize() {
- return maxQueueSize;
- }
-
- public long getCurrentThreadPoolSize() {
- return currentThreadPoolSize;
- }
-}
\ No newline at end of file
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications 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.util.jmx;
-
-/**
- * MXBean interface for thread executor statistic metrics.
- *
- * @author Thomas Pantelis
- */
-public interface ThreadExecutorStatsMXBean {
-
- /**
- * Returns the current thread pool size.
- */
- long getCurrentThreadPoolSize();
-
- /**
- * Returns the largest thread pool size.
- */
- long getLargestThreadPoolSize();
-
- /**
- * Returns the maximum thread pool size.
- */
- long getMaxThreadPoolSize();
-
- /**
- * Returns the current queue size.
- */
- long getCurrentQueueSize();
-
- /**
- * Returns the largest queue size, if available.
- */
- Long getLargestQueueSize();
-
- /**
- * Returns the maximum queue size.
- */
- long getMaxQueueSize();
-
- /**
- * Returns the active thread count.
- */
- long getActiveThreadCount();
-
- /**
- * Returns the completed task count.
- */
- long getCompletedTaskCount();
-
- /**
- * Returns the total task count.
- */
- long getTotalTaskCount();
-
- /**
- * Returns the rejected task count, if available.
- */
- Long getRejectedTaskCount();
-}
+++ /dev/null
-/*
- * Copyright (c) 2014 Brocade Communications 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.util.jmx;
-
-import com.google.common.base.Preconditions;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Executor;
-import java.util.concurrent.RejectedExecutionHandler;
-import java.util.concurrent.ThreadPoolExecutor;
-import javax.annotation.Nullable;
-import org.opendaylight.yangtools.util.concurrent.CountingRejectedExecutionHandler;
-import org.opendaylight.yangtools.util.concurrent.TrackingLinkedBlockingQueue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * MXBean implementation of the ThreadExecutorStatsMXBean interface that retrieves statistics
- * from a backing {@link java.util.concurrent.ExecutorService}.
- *
- * @author Thomas Pantelis
- */
-public class ThreadExecutorStatsMXBeanImpl extends AbstractMXBean
- implements ThreadExecutorStatsMXBean {
- private static final Logger LOG = LoggerFactory.getLogger(ThreadExecutorStatsMXBeanImpl.class);
- private final ThreadPoolExecutor executor;
-
- /**
- * Constructs an instance for the given {@link Executor}.
- *
- * @param executor the backing {@link Executor}
- * @param mBeanName Used as the <code>name</code> property in the bean's ObjectName.
- * @param mBeanType Used as the <code>type</code> property in the bean's ObjectName.
- * @param mBeanCategory Used as the <code>Category</code> property in the bean's ObjectName.
- */
- public ThreadExecutorStatsMXBeanImpl(final ThreadPoolExecutor executor, final String mBeanName,
- final String mBeanType, @Nullable final String mBeanCategory) {
- super(mBeanName, mBeanType, mBeanCategory);
- this.executor = Preconditions.checkNotNull(executor);
- }
-
- private static ThreadExecutorStatsMXBeanImpl createInternal(final Executor executor,
- final String mBeanName, final String mBeanType, final String mBeanCategory) {
- if (executor instanceof ThreadPoolExecutor) {
- final ThreadExecutorStatsMXBeanImpl ret = new ThreadExecutorStatsMXBeanImpl(
- (ThreadPoolExecutor) executor, mBeanName, mBeanType, mBeanCategory);
- return ret;
- }
-
- LOG.info("Executor {} is not supported", executor);
- return null;
- }
-
- /**
- * Creates a new bean if the backing executor is a ThreadPoolExecutor and registers it.
- *
- * @param executor the backing {@link Executor}
- * @param mBeanName Used as the <code>name</code> property in the bean's ObjectName.
- * @param mBeanType Used as the <code>type</code> property in the bean's ObjectName.
- * @param mBeanCategory Used as the <code>Category</code> property in the bean's ObjectName.
- * @return a registered ThreadExecutorStatsMXBeanImpl instance if the backing executor
- * is a ThreadPoolExecutor, otherwise null.
- */
- public static ThreadExecutorStatsMXBeanImpl create(final Executor executor, final String mBeanName,
- final String mBeanType, @Nullable final String mBeanCategory) {
- ThreadExecutorStatsMXBeanImpl ret = createInternal(executor, mBeanName, mBeanType, mBeanCategory);
- if(ret != null) {
- ret.registerMBean();
- }
-
- return ret;
- }
-
- /**
- * Creates a new bean if the backing executor is a ThreadPoolExecutor.
- *
- * @param executor the backing {@link Executor}
- * @return a ThreadExecutorStatsMXBeanImpl instance if the backing executor
- * is a ThreadPoolExecutor, otherwise null.
- */
- public static ThreadExecutorStatsMXBeanImpl create(final Executor executor) {
- return createInternal(executor, "", "", null);
- }
-
- @Override
- public long getCurrentThreadPoolSize() {
- return executor.getPoolSize();
- }
-
- @Override
- public long getLargestThreadPoolSize() {
- return executor.getLargestPoolSize();
- }
-
- @Override
- public long getMaxThreadPoolSize() {
- return executor.getMaximumPoolSize();
- }
-
- @Override
- public long getCurrentQueueSize() {
- return executor.getQueue().size();
- }
-
- @Override
- public Long getLargestQueueSize() {
- BlockingQueue<Runnable> queue = executor.getQueue();
- if(queue instanceof TrackingLinkedBlockingQueue) {
- return Long.valueOf(((TrackingLinkedBlockingQueue<?>)queue).getLargestQueueSize());
- }
-
- return null;
- }
-
- @Override
- public long getMaxQueueSize() {
- long queueSize = executor.getQueue().size();
- return executor.getQueue().remainingCapacity() + queueSize;
- }
-
- @Override
- public long getActiveThreadCount() {
- return executor.getActiveCount();
- }
-
- @Override
- public long getCompletedTaskCount() {
- return executor.getCompletedTaskCount();
- }
-
- @Override
- public long getTotalTaskCount() {
- return executor.getTaskCount();
- }
-
- @Override
- public Long getRejectedTaskCount() {
- RejectedExecutionHandler rejectedHandler = executor.getRejectedExecutionHandler();
- if(rejectedHandler instanceof CountingRejectedExecutionHandler) {
- return Long.valueOf(((CountingRejectedExecutionHandler)rejectedHandler)
- .getRejectedTaskCount());
- }
-
- return null;
- }
-
- /**
- * Returns a {@link ThreadExecutorStats} instance containing a snapshot of the statistic
- * metrics.
- */
- public ThreadExecutorStats toThreadExecutorStats() {
- return new ThreadExecutorStats(getActiveThreadCount(), getCurrentThreadPoolSize(),
- getLargestThreadPoolSize(), getMaxThreadPoolSize(), getCurrentQueueSize(),
- getLargestQueueSize(), getMaxQueueSize(), getCompletedTaskCount(),
- getTotalTaskCount(), getRejectedTaskCount());
- }
-}
+++ /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.sal.common.util;
-
-public final class Arguments {
-
- private Arguments() {
- throw new UnsupportedOperationException("Utility class");
- }
-
- /**
- * Checks if value is instance of provided class
- *
- *
- * @param value Value to check
- * @param type Type to check
- * @return Reference which was checked
- */
- @SuppressWarnings("unchecked")
- public static <T> T checkInstanceOf(Object value, Class<T> type) {
- if(!type.isInstance(value)) {
- throw new IllegalArgumentException(String.format("Value %s is not of type %s", value, type));
- }
- return (T) value;
- }
-}
+++ /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.sal.common.util;
-
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
-import org.opendaylight.yangtools.concepts.Path;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-
-/**
- * @deprecated Utility class for {@link DataCommitTransaction}, will be removed at the same time.
- */
-@Deprecated
-public class CommitHandlerTransactions {
-
- private static class AllwaysSuccessfulTransaction<P extends Path<P>,D> implements DataCommitTransaction<P, D> {
-
- private final DataModification<P, D> modification;
-
- public AllwaysSuccessfulTransaction(DataModification<P, D> modification) {
- this.modification = modification;
- }
- @Override
- public RpcResult<Void> rollback() throws IllegalStateException {
- return RpcResultBuilder.<Void>success().build();
- }
- @Override
- public RpcResult<Void> finish() throws IllegalStateException {
- return RpcResultBuilder.<Void>success().build();
- }
-
- @Override
- public DataModification<P, D> getModification() {
- return modification;
- }
- }
-
- public static final <P extends Path<P>,D> AllwaysSuccessfulTransaction<P, D> allwaysSuccessfulTransaction(DataModification<P, D> modification) {
- return new AllwaysSuccessfulTransaction<>(modification);
- }
-}
+++ /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.sal.common.util;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-/**
- * @deprecated Use {@link com.google.common.util.concurrent.Futures} instead.
- */
-@Deprecated
-public class Futures {
-
- private Futures() {
- }
-
- public static <T> Future<T> immediateFuture(T result) {
- return new ImmediateFuture<T>(result);
- }
-
- private static class ImmediateFuture<T> implements Future<T> {
-
- private final T result;
-
- public ImmediateFuture(T result) {
- this.result = result;
- }
-
- @Override
- public boolean cancel(boolean mayInterruptIfRunning) {
- return false;
- }
-
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- @Override
- public boolean isDone() {
- return true;
- }
-
- @Override
- public T get() throws InterruptedException, ExecutionException {
- return result;
- }
-
- @Override
- public T get(long timeout, TimeUnit unit) throws InterruptedException,
- ExecutionException, TimeoutException {
- return result;
- }
-
- }
-}
+++ /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.sal.common.util;
-
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
-
-/**
- * @deprecated Use {@link org.opendaylight.yangtools.yang.common.RpcResultBuilder}
- */
-@Deprecated
-public class RpcErrors {
-
- /**
- * @param applicationTag
- * @param tag
- * @param info
- * @param severity
- * @param message
- * @param errorType
- * @param cause
- * @return {@link RpcError} implementation
- */
- public static RpcError getRpcError(String applicationTag, String tag, String info,
- ErrorSeverity severity, String message, ErrorType errorType, Throwable cause) {
- RpcErrorTO ret = new RpcErrorTO(applicationTag, tag, info, severity, message,
- errorType, cause);
- return ret;
- }
-
- private static class RpcErrorTO implements RpcError {
-
- private final String applicationTag;
- private final String tag;
- private final String info;
- private final ErrorSeverity severity;
- private final String message;
- private final ErrorType errorType;
- private final Throwable cause;
-
- /**
- * @param applicationTag
- * @param tag
- * @param info
- * @param severity
- * @param message
- * @param errorType
- * @param cause
- */
- protected RpcErrorTO(String applicationTag, String tag, String info,
- ErrorSeverity severity, String message, ErrorType errorType, Throwable cause) {
- super();
- this.applicationTag = applicationTag;
- this.tag = tag;
- this.info = info;
- this.severity = severity;
- this.message = message;
- this.errorType = errorType;
- this.cause = cause;
- }
-
- @Override
- public String getApplicationTag() {
- return applicationTag;
- }
-
- @Override
- public String getInfo() {
- return info;
- }
-
- @Override
- public String getMessage() {
- return message;
- }
-
- @Override
- public ErrorSeverity getSeverity() {
- return severity;
- }
-
- @Override
- public String getTag() {
- return tag;
- }
-
- @Override
- public Throwable getCause() {
- return cause;
- }
-
- @Override
- public ErrorType getErrorType() {
- return errorType;
- }
- }
-}
+++ /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.sal.common.util;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.common.RpcError;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * @deprecated Use {@link org.opendaylight.yangtools.yang.common.RpcResultBuilder}
- */
-@Deprecated
-public class Rpcs {
-
- public static <T> RpcResult<T> getRpcResult(boolean successful) {
- RpcResult<T> ret = new RpcResultTO<T>(successful, null, ImmutableList.<RpcError>of());
- return ret;
- }
-
- public static <T> RpcResult<T> getRpcResult(boolean successful, T result,
- Collection<RpcError> errors) {
- RpcResult<T> ret = new RpcResultTO<T>(successful, result, errors);
- return ret;
- }
-
- public static <T> RpcResult<T> getRpcResult(boolean successful, Collection<RpcError> errors) {
- return new RpcResultTO<T>(successful, null, errors);
- }
-
- private static class RpcResultTO<T> implements RpcResult<T>, Serializable, Immutable {
- private static final long serialVersionUID = 1L;
- private final Collection<RpcError> errors;
- private final T result;
- private final boolean successful;
-
- public RpcResultTO(boolean successful, T result,
- Collection<RpcError> errors) {
- this.successful = successful;
- this.result = result;
- this.errors = ImmutableList.copyOf(errors);
- }
-
- @Override
- public boolean isSuccessful() {
- return successful;
- }
-
- @Override
- public T getResult() {
- return result;
- }
-
- @Override
- public Collection<RpcError> getErrors() {
- return errors;
- }
-
- }
-}
</scm>
<modules>
- <module>common/parent</module>
- <module>common/artifacts</module>
+ <module>common</module>
<module>binding</module>
<module>model</module>
</modules>