Resolved the merge conflicts. Implemented code review comments.
Removed empty lines within import sections of some files
Implemented some more code review comments.
Somebody had changed checkStyleViolationSeverity to warning, so it was ignoring the trailing white spaces.
Fixed the pom for dom-api and spi module + fix the code.
Change-Id: I1ea8b60c8b5910ea9f30963ada55ecbed3363a95
Signed-off-by: Brinda Jana <brinda.jana@nexusis.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
- <propertyExpansion>checkstyle.violationSeverity=warning</propertyExpansion>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
</plugin>
</plugins>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<scm>
<connection>scm:git:http://git.opendaylight.org/gerrit/mdsal.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/mdsal.git</developerConnection>
</site>
</distributionManagement>
-</project>
\ No newline at end of file
+</project>
package org.opendaylight.mdsal.dom.spi;
import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
/**
*
* @param <T> type of listener
*/
-public abstract class AbstractDOMDataTreeChangeListenerRegistration<T extends DOMDataTreeChangeListener> extends AbstractListenerRegistration<T> {
+public abstract class AbstractDOMDataTreeChangeListenerRegistration<T extends
+ DOMDataTreeChangeListener> extends AbstractListenerRegistration<T> {
protected AbstractDOMDataTreeChangeListenerRegistration(final T listener) {
super(listener);
}
import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
-
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
/**
* Abstract base class for {@link DOMRpcImplementationRegistration} implementations.
*/
-public abstract class AbstractDOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends AbstractObjectRegistration<T> implements DOMRpcImplementationRegistration<T> {
+public abstract class AbstractDOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends
+ AbstractObjectRegistration<T> implements DOMRpcImplementationRegistration<T> {
protected AbstractDOMRpcImplementationRegistration(final T instance) {
super(instance);
}
-}
+}
\ No newline at end of file
*/
package org.opendaylight.mdsal.dom.spi;
+import com.google.common.collect.ImmutableSet;
import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
-import com.google.common.collect.ImmutableSet;
-
/**
* Convenience abstract base class for {@link DOMRpcProviderService} implementations.
*/
public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService {
@Override
- public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
+ public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T>
+ registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
return registerRpcImplementation(implementation, ImmutableSet.copyOf(types));
}
}
* @param node Tree node
* @param registration Registration instance
*/
- protected final void removeRegistration(@Nonnull final RegistrationTreeNode<T> node, @Nonnull final T registration) {
+ protected final void removeRegistration(@Nonnull final RegistrationTreeNode<T> node,
+ @Nonnull final T registration) {
// Take the write lock
rwLock.writeLock().lock();
try {
/**
* Prefix table indexed by {@link DOMDataTreeIdentifier}.
- *
* Stores values in tree and provides lookup of closest ancestor
*
- *
* @param <V> Value type
*/
@Beta
public final class DOMDataTreePrefixTable<V> {
private static final Logger LOG = LoggerFactory.getLogger(DOMDataTreePrefixTable.class);
- private final Map<LogicalDatastoreType, DOMDataTreePrefixTableEntry<V>> roots = new EnumMap<>(LogicalDatastoreType.class);
+ private final Map<LogicalDatastoreType, DOMDataTreePrefixTableEntry<V>> roots =
+ new EnumMap<>(LogicalDatastoreType.class);
private DOMDataTreePrefixTable() {
}
/**
- *
* Lookups entry by provided {@link DOMDataTreeIdentifier}, if entry is not present returns
* closest non-null entry towards root or null if no entry towards root exists.
*
}
/**
- * Stores value associated to the prefix
+ * Stores value associated to the prefix.
*
* @param prefix DOM prefix of value
* @param value Value to be stored
* @throws IllegalStateException If value is already stored for provided prefix
*/
public void store(@Nonnull final DOMDataTreeIdentifier prefix, @Nonnull final V value) {
- DOMDataTreePrefixTableEntry<V> t = roots.get(prefix.getDatastoreType());
- if (t == null) {
- t = new DOMDataTreePrefixTableEntry<V>();
- roots.put(prefix.getDatastoreType(), t);
+ DOMDataTreePrefixTableEntry<V> domDataTreePrefixTableEntry = roots.get(prefix.getDatastoreType());
+ if (domDataTreePrefixTableEntry == null) {
+ domDataTreePrefixTableEntry = new DOMDataTreePrefixTableEntry<V>();
+ roots.put(prefix.getDatastoreType(), domDataTreePrefixTableEntry);
}
- t.store(prefix.getRootIdentifier(), value);
+ domDataTreePrefixTableEntry.store(prefix.getRootIdentifier(), value);
}
/**
* Removes value associated to the prefix.
- *
* Value is removed only and only if full prefix match for stored value. Removal of prefix does
* not remove child prefixes.
*
- * @param prefix
+ * @param prefix to be removed
*/
public void remove(@Nonnull final DOMDataTreeIdentifier prefix) {
final DOMDataTreePrefixTableEntry<V> t = roots.get(prefix.getDatastoreType());
* Listener which is notified when subscriptions changes and
* provides set of notification types for which currently
* subscriptions are in place.
- *
*/
@Beta
public interface DOMNotificationSubscriptionListener extends EventListener {
/**
- * Invoked when notification subscription changed
+ * Invoked when notification subscription changed.
*
- * @param currentTypes Set of notification types
- * for which listeners are registered.
+ * @param currentTypes Set of notification types for which listeners are registered.
*/
void onSubscriptionChanged(Set<SchemaPath> currentTypes);
-
}
public interface DOMNotificationSubscriptionListenerRegistry {
<L extends DOMNotificationSubscriptionListener> ListenerRegistration<L> registerSubscriptionListener(L listener);
-
}
*/
package org.opendaylight.mdsal.dom.spi;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import java.io.Serializable;
import java.util.Collections;
import java.util.Objects;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
*/
package org.opendaylight.mdsal.dom.spi;
+import com.google.common.collect.ForwardingObject;
+import java.util.Map;
+import javax.annotation.Nonnull;
import org.opendaylight.mdsal.common.api.TransactionChainListener;
-
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import com.google.common.collect.ForwardingObject;
-import java.util.Map;
-import javax.annotation.Nonnull;
-
/**
* Utility {@link DOMDataBroker} implementation which forwards all interface
*/
package org.opendaylight.mdsal.dom.spi;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
-
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import com.google.common.base.Optional;
import com.google.common.collect.ForwardingObject;
import com.google.common.util.concurrent.CheckedFuture;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
* Utility {@link DOMDataTreeReadTransaction} implementation which forwards all interface
* method invocation to a delegate instance.
*/
-public abstract class ForwardingDOMDataReadOnlyTransaction extends ForwardingObject implements DOMDataTreeReadTransaction {
+public abstract class ForwardingDOMDataReadOnlyTransaction extends ForwardingObject
+ implements DOMDataTreeReadTransaction {
@Override
@Nonnull
protected abstract DOMDataTreeReadTransaction delegate();
@Override
- public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ public CheckedFuture<Optional<NormalizedNode<?, ?>>,
+ ReadFailedException> read(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
return delegate().read(store, path);
}
@Override
- public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+ final YangInstanceIdentifier path) {
return delegate().exists(store, path);
}
*/
package org.opendaylight.mdsal.dom.spi;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-
import com.google.common.collect.ForwardingObject;
import com.google.common.util.concurrent.CheckedFuture;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
* Utility {@link DOMDataTreeWriteTransaction} implementation which forwards all interface
* method invocation to a delegate instance.
*/
-public abstract class ForwardingDOMDataWriteTransaction extends ForwardingObject implements DOMDataTreeWriteTransaction {
+public abstract class ForwardingDOMDataWriteTransaction extends ForwardingObject
+ implements DOMDataTreeWriteTransaction {
@Override
protected abstract @Nonnull DOMDataTreeWriteTransaction delegate();
}
@Override
- public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+ public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> data) {
delegate().put(store, path, data);
}
@Override
- public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
+ public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+ final NormalizedNode<?, ?> data) {
delegate().merge(store, path, data);
}
*/
package org.opendaylight.mdsal.dom.spi;
-import org.opendaylight.mdsal.dom.api.DOMNotification;
-import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
-
import com.google.common.collect.ForwardingObject;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.TimeUnit;
+import org.opendaylight.mdsal.dom.api.DOMNotification;
+import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
/**
* Utility implementations of {@link DOMNotificationPublishService} which forwards
* all requests to a delegate instance.
*/
-public abstract class ForwardingDOMNotificationPublishService extends ForwardingObject implements DOMNotificationPublishService {
+public abstract class ForwardingDOMNotificationPublishService extends
+ ForwardingObject implements DOMNotificationPublishService {
@Override
protected abstract DOMNotificationPublishService delegate();
@Override
- public ListenableFuture<? extends Object> putNotification(final DOMNotification notification) throws InterruptedException {
+ public ListenableFuture<? extends Object> putNotification(
+ final DOMNotification notification) throws InterruptedException {
return delegate().putNotification(notification);
}
}
@Override
- public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification, final long timeout,
+ public ListenableFuture<? extends Object> offerNotification(
+ final DOMNotification notification, final long timeout,
final TimeUnit unit) throws InterruptedException {
return delegate().offerNotification(notification, timeout, unit);
}
*/
package org.opendaylight.mdsal.dom.spi;
-import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
-import org.opendaylight.mdsal.dom.api.DOMNotificationService;
-
import com.google.common.collect.ForwardingObject;
import java.util.Collection;
+import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
+import org.opendaylight.mdsal.dom.api.DOMNotificationService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
*/
package org.opendaylight.mdsal.dom.spi;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.CheckedFuture;
+import javax.annotation.Nonnull;
import org.opendaylight.mdsal.dom.api.DOMRpcException;
import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
-
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
protected abstract @Nonnull DOMRpcImplementation delegate();
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier type, final NormalizedNode<?, ?> input) {
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
+ final DOMRpcIdentifier type, final NormalizedNode<?, ?> input) {
return delegate().invokeRpc(type, input);
}
}
*/
package org.opendaylight.mdsal.dom.spi;
+import com.google.common.collect.ForwardingObject;
+import java.util.Set;
+import javax.annotation.Nonnull;
import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
import org.opendaylight.mdsal.dom.api.DOMRpcImplementationRegistration;
import org.opendaylight.mdsal.dom.api.DOMRpcProviderService;
-import com.google.common.collect.ForwardingObject;
-import java.util.Set;
-import javax.annotation.Nonnull;
-
/**
* Utility class which implements {@link DOMRpcProviderService} by forwarding
* requests to a backing instance.
protected abstract @Nonnull DOMRpcProviderService delegate();
@Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
+ public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
+ final T implementation, final DOMRpcIdentifier... types) {
return delegate().registerRpcImplementation(implementation, types);
}
@Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final Set<DOMRpcIdentifier> types) {
+ public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
+ final T implementation, final Set<DOMRpcIdentifier> types) {
return delegate().registerRpcImplementation(implementation, types);
}
}
*/
package org.opendaylight.mdsal.dom.spi;
-import org.opendaylight.mdsal.dom.api.DOMRpcResult;
-
import com.google.common.collect.ForwardingObject;
import java.util.Collection;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
*/
package org.opendaylight.mdsal.dom.spi;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.CheckedFuture;
+import javax.annotation.Nonnull;
import org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener;
import org.opendaylight.mdsal.dom.api.DOMRpcException;
import org.opendaylight.mdsal.dom.api.DOMRpcResult;
import org.opendaylight.mdsal.dom.api.DOMRpcService;
-
-import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.CheckedFuture;
-import javax.annotation.Nonnull;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
protected abstract @Nonnull DOMRpcService delegate();
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
+ final SchemaPath type, final NormalizedNode<?, ?> input) {
return delegate().invokeRpc(type, input);
}
@Override
- public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T listener) {
+ public <T extends DOMRpcAvailabilityListener>
+ ListenerRegistration<T> registerRpcListener(final T listener) {
return delegate().registerRpcListener(listener);
}
}
*/
package org.opendaylight.mdsal.dom.spi;
+import com.google.common.collect.ForwardingObject;
+import javax.annotation.Nonnull;
import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
-import com.google.common.collect.ForwardingObject;
-import javax.annotation.Nonnull;
-
/**
* Utility {@link DOMTransactionChain} implementation which forwards all interface
* method invocation to a delegate instance.
*/
public final class RegistrationTreeSnapshot<T> implements AutoCloseable {
@SuppressWarnings("rawtypes")
- private static final AtomicIntegerFieldUpdater<RegistrationTreeSnapshot> CLOSED_UPDATER = AtomicIntegerFieldUpdater.newUpdater(RegistrationTreeSnapshot.class, "closed");
+ private static final AtomicIntegerFieldUpdater<RegistrationTreeSnapshot> CLOSED_UPDATER =
+ AtomicIntegerFieldUpdater.newUpdater(RegistrationTreeSnapshot.class, "closed");
private final RegistrationTreeNode<T> node;
private final Lock lock;
}
/**
- * Returns leaf QName in which RPC Route is stored
- *
- *
+ * Returns leaf QName in which RPC Route is stored.
* @return leaf QName in which RPC Route is stored
* @throws UnsupportedOperationException If RPC is not content routed.
- * ({@link #isContextBasedRouted()} returned <code>false</code>)
+ * ({@link #isContextBasedRouted()} returned <code>false</code>)
*/
public abstract QName getLeaf();
/**
- * Returns identity QName which represents RPC Routing context
- *
+ * Returns identity QName which represents RPC Routing context.
* @return identity QName which represents RPC Routing context
* @throws UnsupportedOperationException If RPC is not content routed.
- * ({@link #isContextBasedRouted()} returned <code>false</code>)
+ * ({@link #isContextBasedRouted()} returned <code>false</code>)
*/
public abstract QName getContext();
private static final class GlobalRpcStrategy extends RpcRoutingStrategy {
- public GlobalRpcStrategy(final QName identifier) {
+ GlobalRpcStrategy(final QName identifier) {
super(identifier);
}
package org.opendaylight.mdsal.dom.spi;
+import com.google.common.base.Optional;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap;
import org.opendaylight.mdsal.dom.api.DOMMountPoint;
import org.opendaylight.mdsal.dom.api.DOMService;
-
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import com.google.common.base.Optional;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
public class SimpleDOMMountPoint implements DOMMountPoint {
private final ClassToInstanceMap<DOMService> services;
private final SchemaContext schemaContext;
- public static final SimpleDOMMountPoint create(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
+ public static final SimpleDOMMountPoint create(final YangInstanceIdentifier identifier,
+ final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
return new SimpleDOMMountPoint(identifier, services, ctx);
}
- private SimpleDOMMountPoint(final YangInstanceIdentifier identifier, final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
+
+ private SimpleDOMMountPoint(final YangInstanceIdentifier identifier,
+ final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
this.identifier = identifier;
this.services = ImmutableClassToInstanceMap.copyOf(services);
this.schemaContext = ctx;
/**
* Abstract DOM Store Transaction.
- *
* Convenience super implementation of DOM Store transaction which provides common implementation of
* {@link #toString()} and {@link #getIdentifier()}.
- *
* It can optionally capture the context where it was allocated.
*
* @param <T> identifier type
*/
package org.opendaylight.mdsal.dom.spi.store;
-import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
-import org.opendaylight.mdsal.dom.spi.AbstractRegistrationTree;
-import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode;
-import org.opendaylight.mdsal.dom.spi.RegistrationTreeSnapshot;
-
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
import java.util.List;
import javax.annotation.Nonnull;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
+import org.opendaylight.mdsal.dom.spi.AbstractRegistrationTree;
+import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode;
+import org.opendaylight.mdsal.dom.spi.RegistrationTreeSnapshot;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
/**
* Abstract base class for {@link DOMStoreTreeChangePublisher} implementations.
*/
-public abstract class AbstractDOMStoreTreeChangePublisher extends AbstractRegistrationTree<AbstractDOMDataTreeChangeListenerRegistration<?>> implements DOMStoreTreeChangePublisher {
+public abstract class AbstractDOMStoreTreeChangePublisher
+ extends AbstractRegistrationTree<AbstractDOMDataTreeChangeListenerRegistration<?>>
+ implements DOMStoreTreeChangePublisher {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMStoreTreeChangePublisher.class);
/**
- * Callback for subclass to notify specified registrations of a candidate at a specified path. This method is guaranteed
+ * Callback for subclass to notify specified registrations
+ * of a candidate at a specified path. This method is guaranteed
* to be only called from within {@link #processCandidateTree(DataTreeCandidate)}.
- *
* @param registrations Registrations which are affected by the candidate node
* @param path Path of changed candidate node. Guaranteed to match the path specified by the registration
* @param node Candidate node
*/
- protected abstract void notifyListeners(@Nonnull Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations, @Nonnull YangInstanceIdentifier path, @Nonnull DataTreeCandidateNode node);
+ protected abstract void notifyListeners(
+ @Nonnull Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
+ @Nonnull YangInstanceIdentifier path, @Nonnull DataTreeCandidateNode node);
/**
- * Callback notifying the subclass that the specified registration is being closed and it's user no longer
- * wishes to receive notifications. This notification is invoked while the {@link org.opendaylight.yangtools.concepts.ListenerRegistration#close()}
- * method is executing. Subclasses can use this callback to properly remove any delayed notifications pending
+ * Callback notifying the subclass that the specified registration is being
+ * closed and it's user no longer
+ * wishes to receive notifications. This notification is invoked while
+ * the {@link org.opendaylight.yangtools.concepts.ListenerRegistration#close()}
+ * method is executing. Subclasses can use this callback to properly
+ * remove any delayed notifications pending
* towards the registration.
*
* @param registration Registration which is being closed
*/
- protected abstract void registrationRemoved(@Nonnull AbstractDOMDataTreeChangeListenerRegistration<?> registration);
+ protected abstract void registrationRemoved(
+ @Nonnull AbstractDOMDataTreeChangeListenerRegistration<?> registration);
/**
* Process a candidate tree with respect to registered listeners.
return;
}
- try (final RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot = takeSnapshot()) {
- final List<PathArgument> toLookup = ImmutableList.copyOf(candidate.getRootPath().getPathArguments());
+ try (final RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot
+ = takeSnapshot()) {
+ final List<PathArgument> toLookup
+ = ImmutableList.copyOf(candidate.getRootPath().getPathArguments());
lookupAndNotify(toLookup, 0, snapshot.getRootNode(), candidate);
}
}
@Override
- public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) {
+ public <L extends DOMDataTreeChangeListener> AbstractDOMDataTreeChangeListenerRegistration<L>
+ registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) {
// Take the write lock
takeLock();
try {
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node = findNodeFor(treeId.getPathArguments());
- final AbstractDOMDataTreeChangeListenerRegistration<L> reg = new AbstractDOMDataTreeChangeListenerRegistration<L>(listener) {
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node =
+ findNodeFor(treeId.getPathArguments());
+ final AbstractDOMDataTreeChangeListenerRegistration<L> reg =
+ new AbstractDOMDataTreeChangeListenerRegistration<L>(listener) {
@Override
protected void removeRegistration() {
AbstractDOMStoreTreeChangePublisher.this.removeRegistration(node, this);
}
}
- private void lookupAndNotify(final List<PathArgument> args, final int offset, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node, final DataTreeCandidate candidate) {
+ private void lookupAndNotify(final List<PathArgument> args,
+ final int offset, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node,
+ final DataTreeCandidate candidate) {
if (args.size() != offset) {
final PathArgument arg = args.get(offset);
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> exactChild = node.getExactChild(arg);
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> exactChild
+ = node.getExactChild(arg);
if (exactChild != null) {
lookupAndNotify(args, offset + 1, exactChild, candidate);
}
- for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> c : node.getInexactChildren(arg)) {
+ for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> c :
+ node.getInexactChildren(arg)) {
lookupAndNotify(args, offset + 1, c, candidate);
}
} else {
}
}
- private void notifyNode(final YangInstanceIdentifier path, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode, final DataTreeCandidateNode candNode) {
+ private void notifyNode(final YangInstanceIdentifier path,
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode,
+ final DataTreeCandidateNode candNode) {
if (candNode.getModificationType() == ModificationType.UNMODIFIED) {
LOG.debug("Skipping unmodified candidate {}", path);
return;
for (DataTreeCandidateNode candChild : candNode.getChildNodes()) {
if (candChild.getModificationType() != ModificationType.UNMODIFIED) {
- final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild = regNode.getExactChild(candChild.getIdentifier());
+ final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild =
+ regNode.getExactChild(candChild.getIdentifier());
if (regChild != null) {
notifyNode(path.node(candChild.getIdentifier()), regChild, candChild);
}
- for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc : regNode.getInexactChildren(candChild.getIdentifier())) {
+ for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc :
+ regNode.getInexactChildren(candChild.getIdentifier())) {
notifyNode(path.node(candChild.getIdentifier()), rc, candChild);
}
}
*/
package org.opendaylight.mdsal.dom.spi.store;
-import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
+
+import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Abstract implementation of the {@link DOMStoreTransactionChain} interface relying on {@link DataTreeSnapshot} supplier
+ * Abstract implementation of the {@link DOMStoreTransactionChain}
+ * interface relying on {@link DataTreeSnapshot} supplier
* and backend commit coordinator.
- *
* @param <T> transaction identifier type
*/
@Beta
-public abstract class AbstractSnapshotBackedTransactionChain<T> extends TransactionReadyPrototype<T> implements DOMStoreTransactionChain {
- private static abstract class State {
+public abstract class AbstractSnapshotBackedTransactionChain<T>
+ extends TransactionReadyPrototype<T> implements DOMStoreTransactionChain {
+ private abstract static class State {
/**
* Allocate a new snapshot.
*
@Override
protected DataTreeSnapshot getSnapshot() {
final DataTreeSnapshot ret = snapshot;
- Preconditions.checkState(ret != null, "Previous transaction %s is not ready yet", transaction.getIdentifier());
+ Preconditions.checkState(ret != null,
+ "Previous transaction %s is not ready yet", transaction.getIdentifier());
return ret;
}
void setSnapshot(final DataTreeSnapshot snapshot) {
final boolean success = SNAPSHOT_UPDATER.compareAndSet(this, null, snapshot);
- Preconditions.checkState(success, "Transaction %s has already been marked as ready", transaction.getIdentifier());
+ Preconditions.checkState(success,
+ "Transaction %s has already been marked as ready", transaction.getIdentifier());
}
}
}
@SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<AbstractSnapshotBackedTransactionChain, State> STATE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(AbstractSnapshotBackedTransactionChain.class, State.class, "state");
+ private static final AtomicReferenceFieldUpdater<AbstractSnapshotBackedTransactionChain, State>
+ STATE_UPDATER =
+ AtomicReferenceFieldUpdater.newUpdater(AbstractSnapshotBackedTransactionChain.class,
+ State.class, "state");
private static final Logger LOG = LoggerFactory.getLogger(AbstractSnapshotBackedTransactionChain.class);
private static final Shutdown CLOSED = new Shutdown("Transaction chain is closed");
private static final Shutdown FAILED = new Shutdown("Transaction chain has failed");
protected DOMStoreReadTransaction newReadOnlyTransaction(T transactionId) {
final Entry<State, DataTreeSnapshot> entry = getSnapshot();
- return SnapshotBackedTransactions.newReadTransaction(transactionId, getDebugTransactions(), entry.getValue());
+ return SnapshotBackedTransactions.newReadTransaction(transactionId,
+ getDebugTransactions(), entry.getValue());
}
@Override
do {
entry = getSnapshot();
- ret = new SnapshotBackedReadWriteTransaction<T>(transactionId, getDebugTransactions(), entry.getValue(), this);
+ ret = new SnapshotBackedReadWriteTransaction<T>(transactionId,
+ getDebugTransactions(), entry.getValue(), this);
} while (!recordTransaction(entry.getKey(), ret));
return ret;
do {
entry = getSnapshot();
- ret = new SnapshotBackedWriteTransaction<T>(transactionId, getDebugTransactions(), entry.getValue(), this);
+ ret = new SnapshotBackedWriteTransaction<T>(transactionId,
+ getDebugTransactions(), entry.getValue(), this);
} while (!recordTransaction(entry.getKey(), ret));
return ret;
if (allocated.getTransaction().equals(tx)) {
final boolean success = STATE_UPDATER.compareAndSet(this, localState, idleState);
if (!success) {
- LOG.warn("Transaction {} aborted, but chain {} state already transitioned from {} to {}, very strange",
+ LOG.warn("Transaction {} aborted, but chain {} s"
+ + "tate already transitioned from {} to {}, very strange",
tx, this, localState, state);
}
}
}
@Override
- protected final DOMStoreThreePhaseCommitCohort transactionReady(final SnapshotBackedWriteTransaction<T> tx, final DataTreeModification tree) {
+ protected final DOMStoreThreePhaseCommitCohort transactionReady(
+ final SnapshotBackedWriteTransaction<T> tx, final DataTreeModification tree) {
final State localState = state;
if (localState instanceof Allocated) {
final Allocated allocated = (Allocated)localState;
final DOMStoreWriteTransaction transaction = allocated.getTransaction();
- Preconditions.checkState(tx.equals(transaction), "Mis-ordered ready transaction %s last allocated was %s", tx, transaction);
+ Preconditions.checkState(tx.equals(transaction),
+ "Mis-ordered ready transaction %s last allocated was %s", tx, transaction);
allocated.setSnapshot(tree);
} else {
LOG.debug("Ignoring transaction {} readiness due to state {}", tx, localState);
final State localState = state;
do {
- Preconditions.checkState(!CLOSED.equals(localState), "Transaction chain {} has been closed", this);
+ Preconditions.checkState(!CLOSED.equals(localState),
+ "Transaction chain {} has been closed", this);
if (FAILED.equals(localState)) {
LOG.debug("Ignoring user close in failed state");
/**
* Notify the base logic that a previously-submitted transaction has been committed successfully.
- *
* @param transaction Transaction which completed successfully.
*/
protected final void onTransactionCommited(final SnapshotBackedWriteTransaction<T> transaction) {
}
if (!STATE_UPDATER.compareAndSet(this, localState, idleState)) {
- LOG.debug("Transaction chain {} has already transitioned from {} to {}, not making it idle", this, localState, state);
+ LOG.debug("Transaction chain {} has already transitioned from "
+ + "{} to {}, not making it idle", this, localState, state);
}
}
/**
* Notify the base logic that a previously-submitted transaction has failed.
- *
* @param transaction Transaction which failed.
* @param cause Failure cause
*/
- protected final void onTransactionFailed(final SnapshotBackedWriteTransaction<T> transaction, final Throwable cause) {
+ protected final void onTransactionFailed(
+ final SnapshotBackedWriteTransaction<T> transaction, final Throwable cause) {
LOG.debug("Transaction chain {} failed on transaction {}", this, transaction, cause);
state = FAILED;
}
/**
* Inquire as to whether transactions should record their allocation context.
- *
* @return True if allocation context should be recorded.
*/
protected abstract boolean getDebugTransactions();
/**
* Take a fresh {@link DataTreeSnapshot} from the backend.
- *
* @return A new snapshot.
*/
protected abstract DataTreeSnapshot takeSnapshot();
/**
* Create a cohort for driving the transaction through the commit process.
- *
* @param transaction Transaction handle
* @param modification {@link DataTreeModification} which needs to be applied to the backend
* @return A {@link DOMStoreThreePhaseCommitCohort} cohort.
*/
- protected abstract DOMStoreThreePhaseCommitCohort createCohort(final SnapshotBackedWriteTransaction<T> transaction, final DataTreeModification modification);
+ protected abstract DOMStoreThreePhaseCommitCohort createCohort(
+ final SnapshotBackedWriteTransaction<T> transaction, final DataTreeModification modification);
}
* <p>
* DOM Data Store provides transactional tree-like storage for YANG-modeled
* entities described by YANG schema and represented by {@link NormalizedNode}.
- *
* Read and write access to stored data is provided only via transactions
+ *
+ * <p>
* created using {@link #newReadOnlyTransaction()},
* {@link #newWriteOnlyTransaction()} and {@link #newReadWriteTransaction()}, or
* by creating {@link org.opendaylight.mdsal.common.api.TransactionChain}.
- *
*/
public interface DOMStore extends DOMStoreTransactionFactory {
/**
- *
* Creates new transaction chain.
*
+ * <p>
* Transactions in a chain need to be committed in sequence and each
* transaction should see the effects of previous transactions as if they
* happened.
*
+ * <p>
* See {@link DOMStoreTransactionChain} for more information.
*
* @return Newly created transaction chain.
*/
package org.opendaylight.mdsal.dom.spi.store;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
import org.opendaylight.mdsal.common.api.ReadFailedException;
-
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
public interface DOMStoreReadTransaction extends DOMStoreTransaction {
/**
- * Reads data from provided logical data store located at provided path
+ * Reads data from provided logical data store located at provided path.
*
* @param path
* Path which uniquely identifies subtree which client want to
/**
* 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
/**
* Initiates a pre-commit phase of associated transaction on datastore.
*
+ * <p>
* This message is valid only and only if and only if the participant responded
* on {@link #canCommit()} call with positive response.
*
import org.opendaylight.yangtools.concepts.Identifiable;
/**
- * DOM Data Store transaction
+ * DOM Data Store transaction.
*
+ * <p>
* See {@link DOMStoreReadTransaction}, {@link DOMStoreWriteTransaction} and {@link DOMStoreReadWriteTransaction}
* for specific transaction types.
- *
*/
public interface DOMStoreTransaction extends AutoCloseable, Identifiable<Object> {
/**
- * Unique identifier of the transaction
+ * Unique identifier of the transaction.
*/
@Override
- public Object getIdentifier();
+ Object getIdentifier();
@Override
void close();
-}
+}
\ No newline at end of file
/**
* Create a new read only transaction which will continue the chain. The
* previous write transaction has to be either READY or CANCELLED.
- *
* If previous write transaction was already commited to data store, new
* read-only transaction is same as obtained via {@link DOMStore#newReadOnlyTransaction()}
* and contains merged result of previous one and current state of data store.
- *
* Otherwise read-only transaction presents isolated view as if previous read-write
* transaction was successful. State which was introduced by other transactions
* outside this transaction chain after creation of previous transaction is not visible.
- *
* @return New transaction in the chain.
* @throws IllegalStateException
* if the previous transaction was not READY or CANCELLED, or
* Create a new read write transaction which will continue the chain. The
* previous read-write transaction has to be either COMMITED or CANCELLED.
*
+ * <p>
* If previous write transaction was already commited to data store, new
* read-write transaction is same as obtained via {@link DOMStore#newReadWriteTransaction()}
* and contains merged result of previous one and current state of data store.
*
+ * <p>
* Otherwise read-write transaction presents isolated view as if previous read-write
* transaction was successful. State which was introduced by other transactions
* outside this transaction chain after creation of previous transaction is not visible.
* Create a new write-only transaction which will continue the chain. The
* previous read-write transaction has to be either READY or CANCELLED.
*
- *
* @return New transaction in the chain.
* @throws IllegalStateException
* if the previous transaction was not READY or CANCELLED, or
/**
* Closes Transaction Chain.
*
+ * <p>
* Close method of transaction chain does not guarantee that
* last alocated transaction is ready or was submitted.
*
package org.opendaylight.mdsal.dom.spi.store;
/**
- * Factory for DOM Store Transactions
+ * Factory for DOM Store Transactions.
*
* <p>
* Factory provides method to construct read-only, read-write and write-only
public interface DOMStoreTransactionFactory {
/**
- *
- * Creates a read only transaction
+ * Creates a read only transaction.
*
* <p>
* Creates a new read-only transaction, which provides read access to
* snapshot of current state.
*
+ * <p>
* See {@link DOMStoreReadTransaction} for more information.
*
* @return new {@link DOMStoreReadTransaction}
* @throws IllegalStateException
* If state of factory prevents allocating new transaction.
- *
*/
DOMStoreReadTransaction newReadOnlyTransaction();
/**
- * Creates write only transaction
+ * Creates write only transaction.
*
* <p>
* See {@link DOMStoreWriteTransaction} for more information.
DOMStoreWriteTransaction newWriteOnlyTransaction();
/**
- * Creates Read-Write transaction
+ * Creates Read-Write transaction.
*
* <p>
* See {@link DOMStoreReadWriteTransaction} for more information.
* 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 YangInstanceIdentifier}.
+ *
* <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 data tree on path for which you are
* registering, you will receive initial data change event, which will
* contain all pre-existing data, marked as created. If the data at the supplied
* path does not exist, you will also receive initial data change event, which will
* contain empty data tree modification, marked as unmodified.
+ *
* <p>
* This method returns a {@link ListenerRegistration} object. To
* "unregister" your listener for changes call the {@link ListenerRegistration#close()}
* method on this 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 bundle shutdown can lead to stale listeners being still registered.
*
+ * @param treeId
+ * Data tree identifier of the subtree which should be watched for
+ * changes.
+ * @param listener
+ * Listener instance which is being registered
+ *
* @param treeId Data tree identifier of the subtree which should be watched for
* changes.
* @param listener Listener instance which is being registered
* @return Listener registration object, which may be used to unregister
- * your listener using {@link ListenerRegistration#close()} to stop
- * delivery of change events.
+ * your listener using {@link ListenerRegistration#close()} to stop
+ * delivery of change events.
*/
@Nonnull
- <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(@Nonnull YangInstanceIdentifier treeId, @Nonnull L listener);
+ <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
+ @Nonnull YangInstanceIdentifier treeId, @Nonnull L listener);
}
* Store a provided data at specified path. This acts as a add / replace operation, which is to
* say that whole subtree will be replaced by specified path.
*
+ * <p>
* If you need add or merge of current object with specified use
* {@link #merge(YangInstanceIdentifier, NormalizedNode)}
*
- *
- * @param path
+ * @param path YangInstanceIdentifier object to be written
* @param data Data object to be written
- *
* @throws IllegalStateException if the client code already sealed transaction and invoked
* {@link #ready()}
*/
* Store a provided data at specified path. This acts as a add / replace operation, which is to
* say that whole subtree will be replaced by specified path.
*
+ * <p>
* If you need add or merge of current object with specified use
* {@link #merge(YangInstanceIdentifier, NormalizedNode)}
*
- * @param path
+ * @param path YangInstanceIdentifier object to be merged
* @param data Data object to be written
- *
* @throws IllegalStateException if the client code already sealed transaction and invoked
* {@link #ready()}
*/
void merge(YangInstanceIdentifier path, NormalizedNode<?, ?> data);
/**
- *
* Deletes data and whole subtree located at provided path.
*
* @param path
void delete(YangInstanceIdentifier path);
/**
- *
* Seals transaction, and returns three-phase commit cohort associated
* with this transaction and DOM Store to be coordinated by coordinator.
*
* which forward most of their functionality to a backend {@link #delegate()}.
*/
@Beta
-public abstract class ForwardingDOMStoreThreePhaseCommitCohort extends ForwardingObject implements DOMStoreThreePhaseCommitCohort {
+public abstract class ForwardingDOMStoreThreePhaseCommitCohort
+ extends ForwardingObject implements DOMStoreThreePhaseCommitCohort {
+
@Override
protected abstract DOMStoreThreePhaseCommitCohort delegate();
import static com.google.common.base.Preconditions.checkNotNull;
-import org.opendaylight.mdsal.common.api.ReadFailedException;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
import org.slf4j.LoggerFactory;
/**
- *
- * Implementation of read-only transaction backed by {@link DataTreeSnapshot}
- *
* Implementation of read-only transaction backed by {@link DataTreeSnapshot} which delegates most
* of its calls to similar methods provided by underlying snapshot.
*
* @param <T> identifier type
*/
@Beta
-public final class SnapshotBackedReadTransaction<T> extends AbstractDOMStoreTransaction<T> implements DOMStoreReadTransaction {
+public final class SnapshotBackedReadTransaction<T> extends
+ AbstractDOMStoreTransaction<T> implements DOMStoreReadTransaction {
+
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadTransaction.class);
private volatile DataTreeSnapshot stableSnapshot;
stableSnapshot = null;
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
try {
return Futures.immediateCheckedFuture(snapshot.readNode(path));
- } catch (final Exception e) {
+ } catch (Exception e) {
LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
- return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e));
+ return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed", e));
}
}
try {
return Futures.immediateCheckedFuture(read(path).checkedGet().isPresent());
- } catch (final ReadFailedException e) {
+ } catch (ReadFailedException e) {
return Futures.immediateFailedCheckedFuture(e);
}
}
import static com.google.common.base.Preconditions.checkNotNull;
-import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-
-import org.opendaylight.mdsal.common.api.ReadFailedException;
import com.google.common.annotations.Beta;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
* @param <T> identifier type
*/
@Beta
-public final class SnapshotBackedReadWriteTransaction<T> extends SnapshotBackedWriteTransaction<T> implements DOMStoreReadWriteTransaction {
+public final class SnapshotBackedReadWriteTransaction<T> extends
+ SnapshotBackedWriteTransaction<T> implements DOMStoreReadWriteTransaction {
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedReadWriteTransaction.class);
SnapshotBackedReadWriteTransaction(final T identifier, final boolean debug,
super(identifier, debug, snapshot, readyImpl);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
final Optional<NormalizedNode<?, ?>> result;
+
try {
result = readSnapshotNode(path);
} catch (Exception e) {
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
try {
- return Futures.immediateCheckedFuture(
- read(path).checkedGet().isPresent());
+ return Futures.immediateCheckedFuture(read(path).checkedGet().isPresent());
} catch (ReadFailedException e) {
return Futures.immediateFailedCheckedFuture(e);
}
*/
package org.opendaylight.mdsal.dom.spi.store;
-import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
-
import com.google.common.annotations.Beta;
+import org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction.TransactionReadyPrototype;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
/**
/**
* Creates a new read-only transaction.
- *
* @param identifier Transaction Identifier
* @param debug Enable transaction debugging
* @param snapshot Snapshot which will be modified.
*/
- public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier, final boolean debug, final DataTreeSnapshot snapshot) {
+ public static <T> SnapshotBackedReadTransaction<T> newReadTransaction(final T identifier,
+ final boolean debug, final DataTreeSnapshot snapshot) {
return new SnapshotBackedReadTransaction<T>(identifier, debug, snapshot);
}
* @param snapshot Snapshot which will be modified.
* @param readyImpl Implementation of ready method.
*/
- public static <T> SnapshotBackedReadWriteTransaction<T> newReadWriteTransaction(final T identifier, final boolean debug,
- final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
+ public static <T> SnapshotBackedReadWriteTransaction<T> newReadWriteTransaction(final T identifier,
+ final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
return new SnapshotBackedReadWriteTransaction<T>(identifier, debug, snapshot, readyImpl);
}
* @param snapshot Snapshot which will be modified.
* @param readyImpl Implementation of ready method.
*/
- public static <T> SnapshotBackedWriteTransaction<T> newWriteTransaction(final T identifier, final boolean debug,
- final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
+ public static <T> SnapshotBackedWriteTransaction<T> newWriteTransaction(final T identifier,
+ final boolean debug, final DataTreeSnapshot snapshot, final TransactionReadyPrototype<T> readyImpl) {
return new SnapshotBackedWriteTransaction<T>(identifier, debug, snapshot, readyImpl);
}
}
* @param <T> Identifier type
*/
@Beta
-public class SnapshotBackedWriteTransaction<T> extends AbstractDOMStoreTransaction<T> implements DOMStoreWriteTransaction {
+public class SnapshotBackedWriteTransaction<T> extends AbstractDOMStoreTransaction<T>
+ implements DOMStoreWriteTransaction {
+
private static final Logger LOG = LoggerFactory.getLogger(SnapshotBackedWriteTransaction.class);
+
@SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction, TransactionReadyPrototype> READY_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class, TransactionReadyPrototype.class, "readyImpl");
+ private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction,
+ TransactionReadyPrototype> READY_UPDATER =
+ AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class,
+ TransactionReadyPrototype.class, "readyImpl");
+
@SuppressWarnings("rawtypes")
- private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction, DataTreeModification> TREE_UPDATER =
- AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class, DataTreeModification.class, "mutableTree");
+ private static final AtomicReferenceFieldUpdater<SnapshotBackedWriteTransaction,
+ DataTreeModification> TREE_UPDATER =
+ AtomicReferenceFieldUpdater.newUpdater(SnapshotBackedWriteTransaction.class,
+ DataTreeModification.class, "mutableTree");
// non-null when not ready
private volatile TransactionReadyPrototype<T> readyImpl;
LOG.debug("Write Tx: {} allocated with snapshot {}", identifier, snapshot);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
checkNotReady();
try {
tree.write(path, data);
// FIXME: Add checked exception
- } catch (final Exception e) {
+ } catch (Exception e) {
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
checkNotReady();
try {
tree.merge(path, data);
// FIXME: Add checked exception
- } catch (final Exception e) {
+ } catch (Exception e) {
LOG.error("Tx: {}, failed to write {}:{} in {}", getIdentifier(), path, data, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void delete(final YangInstanceIdentifier path) {
checkNotReady();
try {
tree.delete(path);
// FIXME: Add checked exception
- } catch (final Exception e) {
+ } catch (Exception e) {
LOG.error("Tx: {}, failed to delete {} in {}", getIdentifier(), path, tree, e);
// Rethrow original ones if they are subclasses of RuntimeException
// or Error
return readyImpl == null ? null : mutableTree.readNode(path);
}
- private final void checkNotReady() {
- checkState(readyImpl != null, "Transaction %s is no longer open. No further modifications allowed.", getIdentifier());
+ private void checkNotReady() {
+ checkState(readyImpl != null,
+ "Transaction %s is no longer open. No further modifications allowed.", getIdentifier());
}
@Override
}
/**
- * Prototype implementation of {@link SnapshotBackedWriteTransaction#ready()}
+ * Prototype implementation of {@link SnapshotBackedWriteTransaction#ready()}.
*
+ * <p>
* This class is intended to be implemented by Transaction factories responsible for allocation
* of {@link org.opendaylight.mdsal.dom.spi.store.SnapshotBackedWriteTransaction} and
* providing underlying logic for applying implementation.
/**
* Returns a commit coordinator associated with supplied transactions.
- *
* This call must not fail.
*
* @param tx
* Modified data tree which has been constructed.
* @return DOMStoreThreePhaseCommitCohort associated with transaction
*/
- protected abstract DOMStoreThreePhaseCommitCohort transactionReady(SnapshotBackedWriteTransaction<T> tx, DataTreeModification tree);
+ protected abstract DOMStoreThreePhaseCommitCohort transactionReady(
+ SnapshotBackedWriteTransaction<T> tx, DataTreeModification tree);
}
-}
\ No newline at end of file
+}
+++ /dev/null
-/*\r
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.mdsal.dom.spi.store;
\ No newline at end of file
@Nonnull
@Override
- public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation
- (@Nonnull T implementation, @Nonnull Set<DOMRpcIdentifier> rpcs) {
+ public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(
+ @Nonnull T implementation, @Nonnull Set<DOMRpcIdentifier> rpcs) {
return domRpcImplementationRegistration;
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
+@SuppressWarnings("checkstyle:IllegalCatch")
public class SnapshotBackedReadTransactionTest {
private static final DataTreeSnapshot DATA_TREE_SNAPSHOT = mock(DataTreeSnapshot.class);
assertTrue((Boolean) snapshotBackedReadTransaction.exists(YangInstanceIdentifier.EMPTY).get());
assertEquals(optional, snapshotBackedReadTransaction.read(YangInstanceIdentifier.EMPTY).get());
-
final Field stableSnapshotField = SnapshotBackedReadTransaction.class.getDeclaredField("stableSnapshot");
stableSnapshotField.setAccessible(true);
assertNull(stableSnapshot);
}
+ @SuppressWarnings("checkstyle:IllegalThrows")
@Test(expected = ReadFailedException.class)
public void readTestWithException() throws Throwable {
snapshotBackedReadTransaction.close();
}
}
+ @SuppressWarnings("checkstyle:IllegalThrows")
@Test(expected = ReadFailedException.class)
public void readNodeTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_SNAPSHOT).readNode(any());
}
}
+ @SuppressWarnings("checkstyle:IllegalThrows")
@Test(expected = ReadFailedException.class)
- public void existsTestWithException() throws Throwable {
+ public void existsTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_SNAPSHOT).readNode(any());
try {
private static final DataTreeSnapshot DATA_TREE_SNAPSHOT = mock(DataTreeSnapshot.class);
private static final DataTreeModification DATA_TREE_MODIFICATION = mock(DataTreeModification.class);
- private static final TransactionReadyPrototype TRANSACTION_READY_PROTOTYPE = mock(TransactionReadyPrototype.class);
+ private static final TransactionReadyPrototype TRANSACTION_READY_PROTOTYPE = mock(TransactionReadyPrototype.class);
private SnapshotBackedReadWriteTransaction snapshotBackedReadWriteTransaction;
@Before
assertEquals(optional, snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.EMPTY).get());
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
@Test(expected = ReadFailedException.class)
public void readTestWithNullException() throws Throwable {
doReturn(null).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.EMPTY);
}
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
@Test(expected = ReadFailedException.class)
public void readNodeTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_MODIFICATION).readNode(any());
}
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
@Test(expected = ReadFailedException.class)
public void existsTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_MODIFICATION).readNode(any());
throw e.getCause();
}
}
-}
\ No newline at end of file
+}
new Object(), false, dataTreeSnapshot, transactionReadyPrototype));
}
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
@Test(expected = UnsupportedOperationException.class)
public void constructorTest() throws Throwable {
Constructor<SnapshotBackedTransactions> constructor = SnapshotBackedTransactions.class.getDeclaredConstructor();