Implemented code review comment. 2nd round code review comments are implemented.
Change-Id: Iaa93e0786c54d80aa8cba8289570dc281442a055
Signed-off-by: Brinda Jana <brinda.jana@nexusis.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=warning</propertyExpansion>
+ </configuration>
+ </plugin>
</plugins>
</build>
<scm>
* 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.mdsal.dom.api;
import org.opendaylight.mdsal.common.api.AsyncDataBroker;
import org.opendaylight.mdsal.common.api.TransactionChainFactory;
import org.opendaylight.mdsal.common.api.TransactionChainListener;
-
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
* Data Broker which provides data transaction and data change listener functionality
- * using {@link NormalizedNode} data format.
- *
- * This interface is type capture of generic interfaces and returns type captures
- * of results for client-code convenience.
- *
+ * using {@link NormalizedNode} data format. This interface is type capture of generic
+ * interfaces and returns type captures of results for client-code convenience.
*/
public interface DOMDataBroker extends
AsyncDataBroker<YangInstanceIdentifier, NormalizedNode<?, ?>>,
TransactionChainFactory<YangInstanceIdentifier, NormalizedNode<?, ?>>,
DOMExtensibleService<DOMDataBroker, DOMDataBrokerExtension> {
- /**
- * {@inheritDoc}
- */
@Override
DOMDataTreeReadTransaction newReadOnlyTransaction();
- /**
- * {@inheritDoc}
- */
@Override
DOMDataTreeWriteTransaction newWriteOnlyTransaction();
- /**
- * {@inheritDoc}
- */
@Override
DOMTransactionChain createTransactionChain(TransactionChainListener listener);
}
* and after compare as equal. Implementations of this interface are expected
* to recover from such events. Event producers are expected to exert reasonable
* effort to suppress such events.
- *
* In other words, it is completely acceptable to observe
* a {@link org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode},
* which reports a {@link org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType}
/**
* Registers a {@link DOMDataTreeChangeListener} to receive notifications when data changes
* under a given path in the conceptual data tree.
+ *
* <p>
* You are able to register for notifications for any node or subtree which can be represented
* using {@link DOMDataTreeIdentifier}.
- * <p>
*
+ * <p>
* You are able to register for data change notifications for a subtree or leaf even if it does
* not exist. You will receive notification once that node is created.
+ *
* <p>
* If there is any pre-existing data in the data tree for the path for which you are
* registering, you will receive an initial data change event, which will contain all
* <p>
* This method returns a {@link ListenerRegistration} object. To "unregister" your listener for
* changes call the {@link ListenerRegistration#close()} method on the returned object.
+ *
* <p>
* You MUST explicitly unregister your listener when you no longer want to receive
* notifications. This is especially true in OSGi environments, where failure to do so during
* @return Listener registration object, which may be used to unregister your listener using
* {@link ListenerRegistration#close()} to stop delivery of change events.
*/
- @Nonnull <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(@Nonnull DOMDataTreeIdentifier treeId, @Nonnull L listener);
+ @Nonnull <L extends DOMDataTreeChangeListener> ListenerRegistration<L>
+ registerDataTreeChangeListener(@Nonnull DOMDataTreeIdentifier treeId, @Nonnull L listener);
}
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
- *
* Commit cohort participating in commit of data modification, which can validate data tree
* modifications, with option to reject supplied modification, and with callbacks describing state
* of commit.
*
* <h2>Performance implications</h2>
- *
* {@link DOMDataTreeCommitCohort}s are hooked up into commit of data tree changes and MAY
* negatively affect performance of data broker / store.
- *
* Implementations of this interface are discouraged, unless you really need ability to veto data
* tree changes, or to provide external state change in sync with visibility of commited data.
*
- *
* <h2>Implementation requirements</h2>
- *
* <h3>Correctness assumptions</h3> Implementation SHOULD use only {@link DOMDataTreeCandidate} and
* provided {@link SchemaContext} for validation purposes.
- *
* Use of any other external mutable state is discouraged, implementation MUST NOT use any
* transaction related APIs on same data broker / data store instance during invocation of
* callbacks, except ones provided as argument. Note that this MAY BE enforced by some
* implementations of {@link DOMDataBroker} or DOMDataCommitCoordinator
- *
* Note that this may be enforced by some implementations of {@link DOMDataTreeCommitCohortRegistry}
* and such calls may fail.
- *
* <h3>Correct model usage</h3> If implementation is performing YANG-model driven validation
* implementation SHOULD use provided schema context.
- *
* Any other instance of {@link SchemaContext} obtained by other means, may not be valid for
* associated DOMDataTreeCandidate and it may lead to incorrect validation or processing of provided
* data.
- *
* <h3>DataTreeCandidate assumptions</h3> Implementation SHOULD NOT make any assumptions on
* {@link DOMDataTreeCandidate} being successfully committed until associated
* {@link PostCanCommitStep#preCommit()} and
* {@link org.opendaylight.mdsal.common.api.PostPreCommitStep#commit()} callback was invoked.
- *
- *
* <h2>Usage patterns</h2>
- *
* <h3>Data Tree Validator</h3>
- *
* Validator is implementation, which only validates {@link DOMDataTreeCandidate} and does not
* retain any state derived from edited data - does not care if {@link DOMDataTreeCandidate} was
* rejected afterwards or transaction was cancelled.
- *
* Implementation may opt-out from receiving {@code preCommit()}, {@code commit()}, {@code abort()}
* callbacks by returning {@link PostCanCommitStep#NOOP}.
*
- * TODO: Provide example and describe more usage patterns
- *
- * @author Tony Tkacik <ttkacik@cisco.com>
- *
+ * <p>
+ * @author Tony Tkacik
*/
+// TODO: Provide example and describe more usage patterns
@Beta
public interface DOMDataTreeCommitCohort {
/**
* Validates supplied data tree candidate and associates cohort-specific steps with data broker
* transaction.
- *
* If {@link DataValidationFailedException} is thrown by implementation, commit of supplied data
* will be prevented, with the DataBroker transaction providing the thrown exception as the
* cause of failure.
- *
* Note the implementations are expected to do validation and processing asynchronous.
- *
* Implementations SHOULD do processing fast, and are discouraged SHOULD NOT block on any
* external resources.
- *
* Implementation MUST NOT access any data transaction related APIs during invocation of
* callback. Note that this may be enforced by some implementations of
* {@link DOMDataTreeCommitCohortRegistry} and such calls may fail.
- *
* Implementation MAY opt-out from implementing other steps by returning
* {@link PostCanCommitStep#NOOP}. Otherwise implementation MUST return instance of
* {@link PostCanCommitStep}, which will be used to invoke
package org.opendaylight.mdsal.dom.api;
/**
- *
* Commit Cohort registry for {@link DOMDataTreeWriteTransaction}.
- *
* See {@link DOMDataTreeCommitCohort} for more details.
*
* @author Tony Tkacik <ttkacik@cisco.com>
* 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.mdsal.dom.api;
import com.google.common.util.concurrent.CheckedFuture;
* @return write cursor at the desired location.
* @throws IllegalStateException when there's an open cursor, or this transaction is closed already.
*/
- @Nullable
@Override
- DOMDataTreeWriteCursor createCursor(@Nonnull DOMDataTreeIdentifier path);
+ @Nullable DOMDataTreeWriteCursor createCursor(@Nonnull DOMDataTreeIdentifier path);
/**
* Cancels the transaction.
- *
* Transactions can only be cancelled if it was not yet submited.
- *
* Invoking cancel() on failed or already canceled will have no effect, and transaction is
* considered cancelled.
- *
* Invoking cancel() on finished transaction (future returned by {@link #submit()} already
* successfully completed) will always fail (return false).
*
/**
* 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.
- *
* This call logically seals the transaction, which prevents the client from further changing
* data tree using this transaction's cursor. Any subsequent calls to
* <code>createCursorCursor(DOMDataTreeIdentifier</code>
* or any of the cursor's methods will fail with {@link IllegalStateException}.
- *
* The transaction is marked as submitted and enqueued into the shard back-end for
* processing.
*
* @return Checked future informing of success/failure
*/
- CheckedFuture<Void,TransactionCommitFailedException> submit();
-
+ CheckedFuture<Void, TransactionCommitFailedException> submit();
}
* 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.mdsal.dom.api;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.Iterator;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.concepts.Path;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
* A unique identifier for a particular subtree. It is composed of the logical
* data store type and the instance identifier of the root node.
*/
-public final class DOMDataTreeIdentifier implements Immutable, Path<DOMDataTreeIdentifier>, Serializable, Comparable<DOMDataTreeIdentifier> {
+public final class DOMDataTreeIdentifier implements Immutable,
+ Path<DOMDataTreeIdentifier>, Serializable, Comparable<DOMDataTreeIdentifier> {
private static final long serialVersionUID = 1L;
private final YangInstanceIdentifier rootIdentifier;
private final LogicalDatastoreType datastoreType;
- public DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType, final YangInstanceIdentifier rootIdentifier) {
+ public DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType,
+ final YangInstanceIdentifier rootIdentifier) {
this.datastoreType = Preconditions.checkNotNull(datastoreType);
this.rootIdentifier = Preconditions.checkNotNull(rootIdentifier);
}
}
@Override
- public int compareTo(final DOMDataTreeIdentifier o) {
- int i = datastoreType.compareTo(o.datastoreType);
- if (i != 0) {
- return i;
+ public int compareTo(final DOMDataTreeIdentifier domDataTreeIdentifier) {
+ int cmp = datastoreType.compareTo(domDataTreeIdentifier.datastoreType);
+ if (cmp != 0) {
+ return cmp;
}
- final Iterator<PathArgument> mi = rootIdentifier.getPathArguments().iterator();
- final Iterator<PathArgument> oi = o.rootIdentifier.getPathArguments().iterator();
+ final Iterator<PathArgument> myIter = rootIdentifier.getPathArguments().iterator();
+ final Iterator<PathArgument> otherIter = domDataTreeIdentifier.rootIdentifier.getPathArguments().iterator();
- while (mi.hasNext()) {
- if (!oi.hasNext()) {
+ while (myIter.hasNext()) {
+ if (!otherIter.hasNext()) {
return 1;
}
- final PathArgument ma = mi.next();
- final PathArgument oa = oi.next();
- i = ma.compareTo(oa);
- if (i != 0) {
- return i;
+ final PathArgument myPathArg = myIter.next();
+ final PathArgument otherPathArg = otherIter.next();
+ cmp = myPathArg.compareTo(otherPathArg);
+ if (cmp != 0) {
+ return cmp;
}
}
- return oi.hasNext() ? -1 : 0;
+ return otherIter.hasNext() ? -1 : 0;
}
@Override
this.treeIdentifier = Preconditions.checkNotNull(treeIdentifier);
}
- public DOMDataTreeInaccessibleException(final DOMDataTreeIdentifier treeIdentifier, final String message, final Throwable cause) {
+ public DOMDataTreeInaccessibleException(final DOMDataTreeIdentifier treeIdentifier,
+ final String message, final Throwable cause) {
super(message);
this.treeIdentifier = Preconditions.checkNotNull(treeIdentifier);
}
* This includes all the subtrees this listener is subscribed to, even those
* which have not changed.
*/
- void onDataTreeChanged(@Nonnull Collection<DataTreeCandidate> changes, @Nonnull Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> subtrees);
+ void onDataTreeChanged(@Nonnull Collection<DataTreeCandidate> changes,
+ @Nonnull Map<DOMDataTreeIdentifier, NormalizedNode<?, ?>> subtrees);
/**
* Invoked when a subtree listening failure occurs. This can be triggered, for example, when a
* open. It needs to be either submitted or cancelled before another one can be open.
* Once a transaction is submitted, it will proceed to be committed asynchronously.
*
- * Each instance has an upper bound on the number of transactions which can be in-flight,
+ * <p>
+ * Each instance has an upper bound on the number of transactions which can be in-flight,
* once that capacity is exceeded, an attempt to create a new transaction will block
* until some transactions complete.
*
+ * <p>
* Each {@link DOMDataTreeProducer} can be in two logical states, bound and unbound,
* which define the lifecycle rules for when is it legal to create and submit transactions
* in relationship with {@link DOMDataTreeListener} callbacks.
*
+ * <p>
* When a producer is first created, it is unbound. In this state the producer can be
* accessed by any application thread to allocate or submit transactions, as long as
* the 'single open transaction' rule is maintained. The producer and any transaction
* object MUST NOT be accessed, directly or indirectly, from a {@link DOMDataTreeListener}
* callback.
*
- * When a producer is referenced in a call to {@link DOMDataTreeService#registerListener(DOMDataTreeListener, java.util.Collection, boolean, java.util.Collection)},
+ * <p>
+ * When a producer is referenced in a call to {@link DOMDataTreeService#registerListener(DOMDataTreeListener,
+ * Collection, boolean, Collection)},
* an attempt will be made to bind the producer to the specified {@link DOMDataTreeListener}.
* Such an attempt will fail the producer is already bound, or it has an open transaction.
* Once bound, the producer can only be accessed from within the {@link DOMDataTreeListener}
@Nonnull DOMDataTreeCursorAwareTransaction createTransaction(boolean isolated);
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*
+ * <p>
* When invoked on a {@link DOMDataTreeProducer}, this method has additional restrictions. There
* may not be an open transaction from this producer. The method needs to be invoked in
* appropriate context, e.g. bound or unbound.
*
+ * <p>
* Specified subtrees must be accessible by this producer. Accessible means they are a subset of
* the subtrees specified when the producer is instantiated. The set is further reduced as child
* producers are instantiated -- if you create a producer for /a and then a child for /a/b, /a/b
* is not accessible from the first producer.
- *
* Once this method returns successfully, this (parent) producer loses the ability to access the
* specified paths until the resulting (child) producer is shut down.
*
@Nonnull DOMDataTreeProducer createProducer(@Nonnull Collection<DOMDataTreeIdentifier> subtrees);
/**
- * {@inheritDoc}
+ * {@inheritDoc}.
*
* @throws DOMDataTreeProducerBusyException when there is an open transaction.
*/
/**
* Checks if data is available in the logical data store located at provided path.
- * <p>
*
+ * <p>
* Note: a successful result from this method makes no guarantee that a subsequent call to
* {@link #readNode(PathArgument)} will succeed. It is possible that the data resides in a data store on a remote
* node and, if that node goes down or a network failure occurs, a subsequent read would fail.
/**
* A transaction that provides read access to a logical data store.
+ *
* <p>
* For more information on usage and examples, please see the documentation in {@link AsyncReadTransaction}.
*/
/**
* Reads data from provided logical data store located at the provided path.
+ *
*<p>
* If the target is a subtree, then the whole subtree is read (and will be
* accessible from the returned data object).
/**
* Checks if data is available in the logical data store located at provided path.
- * <p>
*
+ * <p>
* Note: a successful result from this method makes no guarantee that a subsequent call to {@link #read}
* will succeed. It is possible that the data resides in a data store on a remote node and, if that
* node goes down or a network failure occurs, a subsequent read would fail. Another scenario is if
* with the data tree are split into data producers and consumers (listeners). Each
* of them operate on a set of subtrees, which need to be declared at instantiation time.
*
+ * <p>
* Returned instances are not thread-safe and expected to be used by a single thread
* at a time. Furthermore, producers may not be accessed from consumer callbacks
* unless they were specified when the listener is registered.
*
+ * <p>
* The service maintains a loop-free topology of producers and consumers. What this means
* is that a consumer is not allowed to access a producer, which affects any of the
* subtrees it is subscribed to. This restriction is in place to ensure the system does
* is free to merge the changes, so that a smaller number of them will be reported,
* possibly hiding some data transitions (like flaps).
*
+ * <p>
* If the listener wants to write into any producer, that producer has to be mentioned
* in the call to this method. Those producers will be bound exclusively to the
* registration, so that accessing them outside of this listener's callback will trigger
* an error. Any producers mentioned must be idle, e.g. they may not have an open
* transaction at the time this method is invoked.
*
+ * <p>
* Each listener instance can be registered at most once. Implementations of this
* interface have to guarantee that the listener's methods will not be invoked
* concurrently from multiple threads.
* single {@link DOMDataTreeIdentifier}. Based on those data tree identifiers, the
* shards are organized in a tree, where there is a logical parent/child relationship.
*
+ * <p>
* It is not allowed to attach two shards to the same data tree identifier, which means
* the mapping of each piece of information has an unambiguous home. When accessing
* the information, the shard with the longest matching data tree identifier is used,
* which is why this interface treats it is a prefix.
*
+ * <p>
* Whenever a parent/child relationship is changed, the parent is notified, so it can
* understand that a logical child has been attached.
*/
* @throws DOMDataTreeShardingConflictException if the prefix is already bound
*/
@Nonnull <T extends DOMDataTreeShard> ListenerRegistration<T> registerDataTreeShard(
- @Nonnull DOMDataTreeIdentifier prefix, @Nonnull T shard, @Nonnull DOMDataTreeProducer producer) throws DOMDataTreeShardingConflictException;
+ @Nonnull DOMDataTreeIdentifier prefix, @Nonnull T shard,
+ @Nonnull DOMDataTreeProducer producer) throws DOMDataTreeShardingConflictException;
}
import org.opendaylight.mdsal.common.api.AsyncWriteTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
* A transaction that provides mutation capabilities on a data tree.
+ *
* <p>
* For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
*/
-public interface DOMDataTreeWriteTransaction extends AsyncWriteTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>> {
+public interface DOMDataTreeWriteTransaction extends
+ AsyncWriteTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>> {
/**
* Stores a piece of data at the specified path. This acts as an add / replace
* operation, which is to say that whole subtree will be replaced by the specified data.
+ *
* <p>
* For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
+ *
* <p>
* If you need to make sure that a parent object exists but you do not want modify
* its pre-existing state by using put, consider using {@link #merge} instead.
* 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>
* For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
+ *
*<p>
* If you require an explicit replace operation, use {@link #put} instead.
*
*/
void merge(LogicalDatastoreType store, YangInstanceIdentifier path, NormalizedNode<?, ?> data);
- /**
- * {@inheritDoc}
- */
+
@Override
- public void delete(LogicalDatastoreType store, YangInstanceIdentifier path);
+ void delete(LogicalDatastoreType store, YangInstanceIdentifier path);
}
import java.util.Date;
/**
- * Generic event interface
+ * Generic event interface.
*/
public interface DOMEvent {
/**
- * Get the time of the event occurrence
+ * Get the time of the event occurrence.
*
* @return the event time
*/
* @param <E> Extension type
*/
@Beta
-public interface DOMExtensibleService<T extends DOMExtensibleService<T, E>, E extends DOMServiceExtension<T, E>> extends DOMService {
+public interface DOMExtensibleService<T extends DOMExtensibleService<T, E>,
+ E extends DOMServiceExtension<T, E>> extends DOMService {
/**
* Return a map of currently-supported extensions, along with accessor services
* which provide access to the specific functionality bound to this service.
* 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.mdsal.dom.api;
+import com.google.common.base.Optional;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
-import com.google.common.base.Optional;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public interface DOMMountPoint extends Identifiable<YangInstanceIdentifier> {
* Well-known value indicating that the implementation is currently not
* able to accept a notification.
*/
- ListenableFuture<Object> REJECTED = Futures.immediateFailedFuture(new DOMNotificationRejectedException("Unacceptable blocking conditions encountered"));
+ ListenableFuture<Object> REJECTED = Futures.immediateFailedFuture(
+ new DOMNotificationRejectedException("Unacceptable blocking conditions encountered"));
/**
* Publish a notification. The result of this method is a {@link ListenableFuture} which will
* complete once the notification has been delivered to all immediate registrants. The type of
* the object resulting from the future is not defined and implementations may use it to convey
* additional information related to the publishing process.
- *
* Abstract subclasses can refine the return type as returning a promise of a more specific
* type, e.g.:
- *
* public interface DeliveryStatus { int getListenerCount(); } ListenableFuture<? extends
* DeliveryStatus>[ putNotification(DOMNotification notification);
- *
* Once the Future succeeds, the resulting object can be queried for traits using instanceof,
* e.g:
- *
* // Can block when (for example) the implemention's ThreadPool queue is full Object o =
* service.putNotification(notif).get(); if (o instanceof DeliveryStatus) { DeliveryStatus ds =
* (DeliveryStatus)o; LOG.debug("Notification was received by {} listeners",
* ds.getListenerCount();); } }
- *
* In case an implementation is running out of resources, it can block the calling thread until
* enough resources become available to accept the notification for processing, or it is
* interrupted.
*
+ * <p>
* Caution: completion here means that the implementation has completed processing of the
* notification. This does not mean that all existing registrants have seen the notification.
* Most importantly, the delivery process at other cluster nodes may have not begun yet.
* @throws InterruptedException if interrupted while waiting
* @throws NullPointerException if notification is null.
*/
- @Nonnull ListenableFuture<? extends Object> putNotification(@Nonnull DOMNotification notification) throws InterruptedException;
+ @Nonnull ListenableFuture<? extends Object> putNotification(@Nonnull DOMNotification notification)
+ throws InterruptedException;
/**
* Attempt to publish a notification. The result of this method is a {@link ListenableFuture}
* null or a SchemaPath which does not represent a valid {@link DOMNotification} type.
* @throws NullPointerException if either of the arguments is null
*/
- <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(@Nonnull T listener, @Nonnull Collection<SchemaPath> types);
+ <T extends DOMNotificationListener> ListenerRegistration<T>
+ registerNotificationListener(@Nonnull T listener, @Nonnull Collection<SchemaPath> types);
/**
* Register a {@link DOMNotificationListener} to receive a set of notifications. As with other
* @throws NullPointerException if listener is null
*/
// FIXME: Java 8: provide a default implementation of this method.
- <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(@Nonnull T listener, SchemaPath... types);
+ <T extends DOMNotificationListener> ListenerRegistration<T>
+ registerNotificationListener(@Nonnull T listener, SchemaPath... types);
}
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
-import java.util.Collections;
import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
/**
* contexts concurrently.
*/
public abstract class DOMRpcIdentifier {
-
- private static final YangInstanceIdentifier GLOBAL_CONTEXT = YangInstanceIdentifier.create(Collections.<PathArgument>emptySet());
-
private static final class Global extends DOMRpcIdentifier {
private Global(final @Nonnull SchemaPath type) {
super(type);
@Override
public YangInstanceIdentifier getContextReference() {
- return GLOBAL_CONTEXT;
+ return YangInstanceIdentifier.EMPTY;
}
}
* @param contextReference Context reference, null means a global RPC identifier.
* @return A global RPC identifier, guaranteed to be non-null.
*/
- public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type, final @Nullable YangInstanceIdentifier contextReference) {
- if (contextReference == null || GLOBAL_CONTEXT.equals(contextReference)) {
+ public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type,
+ final @Nullable YangInstanceIdentifier contextReference) {
+ if (contextReference == null || contextReference.isEmpty()) {
return new Global(type);
} else {
return new Local(type, contextReference);
@Override
public final String toString() {
- return MoreObjects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference", getContextReference()).toString();
+ return MoreObjects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference",
+ getContextReference()).toString();
}
}
* or report a subclass of {@link DOMRpcException} reporting a transport
* error.
*/
- @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode<?, ?> input);
+ @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException>
+ invokeRpc(@Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode<?, ?> input);
}
super(String.format(format, args));
}
- public DOMRpcImplementationNotAvailableException(@Nonnull final Throwable cause, @Nonnull final String format, final Object... args) {
+ public DOMRpcImplementationNotAvailableException(@Nonnull final Throwable cause,
+ @Nonnull final String format, final Object... args) {
super(String.format(format, args), Preconditions.checkNotNull(cause));
}
}
* @throws NullPointerException if implementation or types is null
* @throws IllegalArgumentException if types is empty or contains a null element.
*/
- @Nonnull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(@Nonnull T implementation, @Nonnull DOMRpcIdentifier... rpcs);
+ @Nonnull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
+ registerRpcImplementation(@Nonnull T implementation, @Nonnull DOMRpcIdentifier... rpcs);
/**
* Register an {@link DOMRpcImplementation} object with this service.
* @throws NullPointerException if implementation or types is null
* @throws IllegalArgumentException if types is empty or contains a null element.
*/
- @Nonnull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(@Nonnull T implementation, @Nonnull Set<DOMRpcIdentifier> rpcs);
+ @Nonnull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
+ registerRpcImplementation(@Nonnull T implementation, @Nonnull Set<DOMRpcIdentifier> rpcs);
}
* or report a subclass of {@link DOMRpcException} reporting a transport
* error.
*/
- @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull SchemaPath type, @Nullable NormalizedNode<?, ?> input);
+ @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException>
+ invokeRpc(@Nonnull SchemaPath type, @Nullable NormalizedNode<?, ?> input);
/**
* Register a {@link DOMRpcAvailabilityListener} with this service to receive notifications
* about RPC implementations becoming (un)available. The listener will be invoked with the
* current implementations reported and will be kept uptodate as implementations come and go.
- *
* Users should note that using a listener does not necessarily mean that
* {@link #invokeRpc(SchemaPath, NormalizedNode)} will not report a failure due to
* {@link DOMRpcImplementationNotAvailableException} and need to be ready to handle it.
public interface DOMSchemaService extends DOMService {
/**
- * Returns session specific YANG schema context
- * @return
+ * Returns session specific YANG schema context.
+ *
+ * @return schemaContext
*/
SchemaContext getSessionContext();
/**
- * Returns global schema context
+ * Returns global schema context.
*
- * @return
+ * @return schemaContext
*/
SchemaContext getGlobalContext();
package org.opendaylight.mdsal.dom.api;
import org.opendaylight.mdsal.common.api.TransactionChain;
-
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
* A chain of DOM Data 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.
import static org.junit.Assert.assertNotNull;
+import com.google.common.util.concurrent.CheckedFuture;
+import java.net.URI;
+import java.util.Collections;
+import javax.annotation.Nonnull;
+import org.junit.Test;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-
-import org.opendaylight.mdsal.dom.api.DOMDataTreeCursor;
import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducer;
import org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeService;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import com.google.common.util.concurrent.CheckedFuture;
-import java.net.URI;
-import java.util.Collections;
-import javax.annotation.Nonnull;
-import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
* can be used.
*/
public abstract class AbstractDOMDataTreeServiceTestSuite {
- protected static final QNameModule TEST_MODULE = QNameModule.create(URI.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"), null);
+ protected static final QNameModule TEST_MODULE =
+ QNameModule.create(URI.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"), null);
protected static final YangInstanceIdentifier UNORDERED_CONTAINER_IID = YangInstanceIdentifier.create(
new NodeIdentifier(QName.create(TEST_MODULE, "lists")),
new NodeIdentifier(QName.create(TEST_MODULE, "unordered-container")));
- protected static final DOMDataTreeIdentifier UNORDERED_CONTAINER_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, UNORDERED_CONTAINER_IID);
+ protected static final DOMDataTreeIdentifier UNORDERED_CONTAINER_TREE
+ = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, UNORDERED_CONTAINER_IID);
/**
* Return a reference to the service used in this test. The instance
/**
* A simple unbound producer. It write some basic things into the data store based on the
* test model.
- * @throws DOMDataTreeProducerException
- * @throws TransactionCommitFailedException
+ *
+ * @throws DOMDataTreeProducerException when this exceptional condition happens
+ * @throws TransactionCommitFailedException when transaction commit fails
*/
-
@Test
public final void testBasicProducer() throws DOMDataTreeProducerException, TransactionCommitFailedException {
// Create a producer. It is an AutoCloseable resource, hence the try-with pattern
- try (final DOMDataTreeProducer prod = service().createProducer(Collections.singleton(UNORDERED_CONTAINER_TREE))) {
+ try (final DOMDataTreeProducer prod =
+ service().createProducer(Collections.singleton(UNORDERED_CONTAINER_TREE))) {
assertNotNull(prod);
final DOMDataTreeCursorAwareTransaction tx = prod.createTransaction(true);
assertNotNull(tx);
- final DOMDataTreeWriteCursor cursor = tx.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, UNORDERED_CONTAINER_IID));
+ final DOMDataTreeWriteCursor cursor =
+ tx.createCursor(new DOMDataTreeIdentifier(
+ LogicalDatastoreType.OPERATIONAL, UNORDERED_CONTAINER_IID));
assertNotNull(cursor);
cursor.write(UNORDERED_CONTAINER_IID.getLastPathArgument(), ImmutableContainerNodeBuilder.create().build());
cursor.close();
new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, TEST_LISTS)));
private static final DOMDataTreeIdentifier REF_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
REF_YII_IID);
- private static final DOMDataTreeIdentifier TEST_DIFF_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
- TEST_YII_IID);
+ private static final DOMDataTreeIdentifier
+ TEST_DIFF_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,TEST_YII_IID);
@Test
public void constructTest() {
public void equalsTest() {
assertTrue("Equals same", REF_TREE.equals(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
REF_YII_IID)));
- assertFalse("Different DataStoreType", REF_TREE.equals(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
+ assertFalse("Different DataStoreType", REF_TREE.equals(
+ new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
REF_YII_IID)));
assertTrue("Equals same instance", REF_TREE.equals(REF_TREE));
assertFalse("Different object", REF_TREE.equals(new Object()));
final YangInstanceIdentifier compareSecondIid = YangInstanceIdentifier.create(
new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, COMPARE_SECOND_LISTS)));
- assertEquals("Compare same to same", REF_TREE.compareTo(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ assertEquals("Compare same to same", REF_TREE.compareTo(
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
REF_YII_IID)), 0);
assertNotEquals("Compare same to same with different datastore", REF_TREE.compareTo(new DOMDataTreeIdentifier(
LogicalDatastoreType.CONFIGURATION, REF_YII_IID)), 0);
assertTrue("ToString", REF_TREE.toString().contains(REF_TREE.getRootIdentifier().toString()) && REF_TREE
.toString().contains(REF_TREE.getDatastoreType().toString()));
}
-}
\ No newline at end of file
+}
TEST_YI_ID);
@Test(expected = DOMDataTreeInaccessibleException.class)
- public void DOMDataTreeInaccessibleExceptionTest() throws Exception {
+ public void testDomDataTreeInaccessibleException() throws Exception {
final DOMDataTreeInaccessibleException testExc = new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE);
assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
assertNotNull(testExc.getTreeIdentifier());
}
@Test(expected = DOMDataTreeListeningException.class)
- public void DOMDataTreeListeningExceptionTest() throws Exception {
+ public void testDomDataTreeListeningException() throws Exception {
final DOMDataTreeListeningException testExc = new DOMDataTreeListeningException(TEST_MESSAGE);
assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
}
@Test(expected = DOMDataTreeLoopException.class)
- public void DOMDataTreeLoopExceptionTest() throws Exception {
+ public void testDomDataTreeLoopException() throws Exception {
final DOMDataTreeLoopException testExc = new DOMDataTreeLoopException(TEST_MESSAGE);
assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
}
@Test(expected = DOMDataTreeProducerBusyException.class)
- public void DOMDataTreeProducerBusyExceptionTest() throws Exception {
+ public void testDomDataTreeProducerBusyException() throws Exception {
final DOMDataTreeProducerBusyException testExc = new DOMDataTreeProducerBusyException(TEST_MESSAGE);
assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
}
@Test(expected = DOMDataTreeProducerException.class)
- public void DOMDataTreeProducerExceptionTest() throws Exception {
+ public void testDOMDataTreeProducerException() throws Exception {
final DOMDataTreeProducerException testExc = new DOMDataTreeProducerException(TEST_MESSAGE);
assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
}
@Test(expected = DOMDataTreeShardingConflictException.class)
- public void DOMDataTreeShardingConflictExceptionTest() throws Exception {
+ public void testDOMDataTreeShardingConflictException() throws Exception {
final DOMDataTreeShardingConflictException testExc = new DOMDataTreeShardingConflictException(TEST_MESSAGE);
assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
}
@Test(expected = DOMNotificationRejectedException.class)
- public void DOMNotificationRejectedExceptionTest() throws Exception {
+ public void testDomNotificationRejectedException() throws Exception {
final DOMNotificationRejectedException testExc = new DOMNotificationRejectedException(TEST_MESSAGE);
assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
}
@Test(expected = DOMRpcImplementationNotAvailableException.class)
- public void DOMRpcImplementationNotAvailableExceptionTest() throws Exception {
- final DOMRpcImplementationNotAvailableException testExc = new DOMRpcImplementationNotAvailableException(TEST_MESSAGE);
- assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+ public void testDomRpcImplementationNotAvailableException() throws Exception {
+ final DOMRpcImplementationNotAvailableException dompcImplementationNotAvailableException
+ = new DOMRpcImplementationNotAvailableException(TEST_MESSAGE);
+ assertTrue(dompcImplementationNotAvailableException.getMessage().contains(TEST_MESSAGE));
throw new DOMRpcImplementationNotAvailableException(new Throwable(), TEST_MESSAGE, new Object());
}