import org.osgi.framework.BundleContext;
/**
+ * Deprecated.
+ *
* @deprecated Replaced by blueprint wiring
*/
@Deprecated
public class LegacyEntityOwnershipServiceProviderModule extends AbstractLegacyEntityOwnershipServiceProviderModule {
private BundleContext bundleContext;
- public LegacyEntityOwnershipServiceProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
+ public LegacyEntityOwnershipServiceProviderModule(ModuleIdentifier identifier,
+ DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public LegacyEntityOwnershipServiceProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
+ public LegacyEntityOwnershipServiceProviderModule(ModuleIdentifier identifier,
+ DependencyResolver dependencyResolver,
LegacyEntityOwnershipServiceProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
return Reflection.newProxy(AutoCloseableEntityOwnershipService.class, new AbstractInvocationHandler() {
@Override
+ @SuppressWarnings("checkstyle:AvoidHidingCauseException")
protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("close")) {
tracker.close();
import org.osgi.framework.BundleContext;
/**
+ * Deprecated.
+ *
* @deprecated Replaced by blueprint wiring
*/
@Deprecated
-public class LegacyEntityOwnershipServiceProviderModuleFactory extends AbstractLegacyEntityOwnershipServiceProviderModuleFactory {
+public class LegacyEntityOwnershipServiceProviderModuleFactory
+ extends AbstractLegacyEntityOwnershipServiceProviderModuleFactory {
@Override
- public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
- LegacyEntityOwnershipServiceProviderModule module = (LegacyEntityOwnershipServiceProviderModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+ public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+ BundleContext bundleContext) {
+ LegacyEntityOwnershipServiceProviderModule module = (LegacyEntityOwnershipServiceProviderModule)
+ super.createModule(instanceName, dependencyResolver, bundleContext);
module.setBundleContext(bundleContext);
return module;
}
@Override
- public Module createModule(String instanceName, DependencyResolver dependencyResolver, DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
- LegacyEntityOwnershipServiceProviderModule module = (LegacyEntityOwnershipServiceProviderModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+ public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+ DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
+ LegacyEntityOwnershipServiceProviderModule module = (LegacyEntityOwnershipServiceProviderModule)
+ super.createModule(instanceName, dependencyResolver, old, bundleContext);
module.setBundleContext(bundleContext);
return module;
}
package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
* The in-memory data store isn't used anymore. Deprecation notice in Carbon. Removal plan in Nitrogen.
*/
@Deprecated
-public class InMemoryConfigDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryConfigDataStoreProviderModule {
+public class InMemoryConfigDataStoreProviderModule extends AbstractInMemoryConfigDataStoreProviderModule {
- public InMemoryConfigDataStoreProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ public InMemoryConfigDataStoreProviderModule(final ModuleIdentifier identifier,
+ final DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public InMemoryConfigDataStoreProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.inmemory_datastore_provider.InMemoryConfigDataStoreProviderModule oldModule, final java.lang.AutoCloseable oldInstance) {
+ public InMemoryConfigDataStoreProviderModule(final ModuleIdentifier identifier,
+ final DependencyResolver dependencyResolver, final InMemoryConfigDataStoreProviderModule oldModule,
+ final AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
return dataStore;
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
-/*
-* Generated file
-*
-* Generated from: yang module name: opendaylight-inmemory-datastore-provider yang module local name: inmemory-config-datastore-provider
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Jun 19 17:10:42 PDT 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
/**
* The in-memory data store isn't used anymore. Deprecation notice in Carbon. Removal plan in Nitrogen.
*/
@Deprecated
-public class InMemoryConfigDataStoreProviderModuleFactory extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryConfigDataStoreProviderModuleFactory {
+public class InMemoryConfigDataStoreProviderModuleFactory extends AbstractInMemoryConfigDataStoreProviderModuleFactory {
}
package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreConfigProperties;
* The in-memory data store isn't used anymore. Deprecation notice in Carbon. Removal plan in Nitrogen.
*/
@Deprecated
-public class InMemoryOperationalDataStoreProviderModule extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryOperationalDataStoreProviderModule {
+public class InMemoryOperationalDataStoreProviderModule extends AbstractInMemoryOperationalDataStoreProviderModule {
- public InMemoryOperationalDataStoreProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ public InMemoryOperationalDataStoreProviderModule(final ModuleIdentifier identifier,
+ final DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public InMemoryOperationalDataStoreProviderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.inmemory_datastore_provider.InMemoryOperationalDataStoreProviderModule oldModule, final java.lang.AutoCloseable oldInstance) {
+ public InMemoryOperationalDataStoreProviderModule(final ModuleIdentifier identifier,
+ final DependencyResolver dependencyResolver, final InMemoryOperationalDataStoreProviderModule oldModule,
+ final AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
-/*
-* Generated file
-*
-* Generated from: yang module name: opendaylight-inmemory-datastore-provider yang module local name: inmemory-operational-datastore-provider
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Jun 19 17:10:42 PDT 2014
-*
-* Do not modify this file unless it is present under src/main directory
-*/
package org.opendaylight.controller.config.yang.inmemory_datastore_provider;
/**
* The in-memory data store isn't used anymore. Deprecation notice in Carbon. Removal plan in Nitrogen.
*/
@Deprecated
-public class InMemoryOperationalDataStoreProviderModuleFactory extends org.opendaylight.controller.config.yang.inmemory_datastore_provider.AbstractInMemoryOperationalDataStoreProviderModuleFactory {
-
+public class InMemoryOperationalDataStoreProviderModuleFactory
+ extends AbstractInMemoryOperationalDataStoreProviderModuleFactory {
}
package org.opendaylight.controller.md.sal.dom.store.impl;
import com.google.common.base.Preconditions;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
public final class DOMImmutableDataChangeEvent implements
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> {
-
private static final RemoveEventFactory REMOVE_EVENT_FACTORY = new RemoveEventFactory();
private static final CreateEventFactory CREATE_EVENT_FACTORY = new CreateEventFactory();
private final Set<YangInstanceIdentifier> removedPaths;
private final DataChangeScope scope;
-
-
private DOMImmutableDataChangeEvent(final Builder change) {
original = change.before;
updated = change.after;
scope = change.scope;
}
- public static final Builder builder(final DataChangeScope scope) {
+ public static Builder builder(final DataChangeScope scope) {
return new Builder(scope);
}
}
/**
- * Simple event factory which creates event based on path and data
- *
- *
+ * Simple event factory which creates event based on path and data.
*/
public interface SimpleEventFactory {
DOMImmutableDataChangeEvent create(YangInstanceIdentifier path, NormalizedNode<PathArgument,?> data);
/**
* Event factory which takes after state and creates event for it.
*
+ * <p>
* Factory for events based on path and after state.
* After state is set as {@link #getUpdatedSubtree()} and is path,
* state mapping is also present in {@link #getUpdatedData()}.
- *
- * @return
*/
- public static final SimpleEventFactory getCreateEventFactory() {
+ public static SimpleEventFactory getCreateEventFactory() {
return CREATE_EVENT_FACTORY;
}
/**
* Event factory which takes before state and creates event for it.
*
+ * <p>
* Factory for events based on path and after state.
* After state is set as {@link #getOriginalSubtree()} and is path,
* state mapping is also present in {@link #getOriginalSubtree()}.
*
+ * <p>
* Path is present in {@link #getRemovedPaths()}.
- * @return
*/
- public static final SimpleEventFactory getRemoveEventFactory() {
+ public static SimpleEventFactory getRemoveEventFactory() {
return REMOVE_EVENT_FACTORY;
}
- public static class Builder {
+
+ public static final class Builder {
public DataChangeScope scope;
private NormalizedNode<?, ?> after;
return this;
}
- public Builder addUpdated(final YangInstanceIdentifier path, final NormalizedNode<?, ?> before,
- final NormalizedNode<?, ?> after) {
- original.put(path, before);
- updated.put(path, after);
+ public Builder addUpdated(final YangInstanceIdentifier path, final NormalizedNode<?, ?> nodeBefore,
+ final NormalizedNode<?, ?> nodeAfter) {
+ original.put(path, nodeBefore);
+ updated.put(path, nodeAfter);
return this;
}
private static final class RemoveEventFactory implements SimpleEventFactory {
@Override
- public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path, final NormalizedNode<PathArgument, ?> data) {
+ public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path,
+ final NormalizedNode<PathArgument, ?> data) {
return builder(DataChangeScope.BASE) //
.setBefore(data) //
.addRemoved(path, data) //
private static final class CreateEventFactory implements SimpleEventFactory {
@Override
- public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path, final NormalizedNode<PathArgument, ?> data) {
+ public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path,
+ final NormalizedNode<PathArgument, ?> data) {
return builder(DataChangeScope.BASE) //
.setAfter(data) //
.addCreated(path, data) //
.build();
}
}
-
}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-public interface DataChangeListenerRegistration<L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> extends ListenerRegistration<L> {
+public interface DataChangeListenerRegistration<L extends AsyncDataChangeListener<YangInstanceIdentifier,
+ NormalizedNode<?, ?>>> extends ListenerRegistration<L> {
@Override
L getInstance();
/**
* In-memory DOM Data Store
*
+ * <p>
* Implementation of {@link DOMStore} which uses {@link DataTree} and other
* classes such as {@link SnapshotBackedWriteTransaction}.
- * {@link org.opendaylight.controller.sal.core.spi.data.SnapshotBackedReadTransaction} and {@link ResolveDataChangeEventsTask}
+ * {@link org.opendaylight.controller.sal.core.spi.data.SnapshotBackedReadTransaction} and
+ * {@link ResolveDataChangeEventsTask}
* to implement {@link DOMStore} contract.
*
*/
-public class InMemoryDOMDataStore extends TransactionReadyPrototype<String> implements DOMStore, Identifiable<String>, SchemaContextListener, AutoCloseable, DOMStoreTreeChangePublisher {
+public class InMemoryDOMDataStore extends TransactionReadyPrototype<String>
+ implements DOMStore, Identifiable<String>, SchemaContextListener, AutoCloseable, DOMStoreTreeChangePublisher {
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class);
- private static final Invoker<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> DCL_NOTIFICATION_MGR_INVOKER =
+ private static final Invoker<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent>
+ DCL_NOTIFICATION_MGR_INVOKER =
(listener, notification) -> {
- final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> inst = listener.getInstance();
+ final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> inst =
+ listener.getInstance();
if (inst != null) {
inst.onDataChanged(notification);
}
private final ListenerTree listenerTree = ListenerTree.create();
private final AtomicLong txCounter = new AtomicLong(0);
- private final QueuedNotificationManager<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> dataChangeListenerNotificationManager;
+ private final QueuedNotificationManager<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent>
+ dataChangeListenerNotificationManager;
private final InMemoryDOMStoreTreeChangePublisher changePublisher;
private final ExecutorService dataChangeListenerExecutor;
private final boolean debugTransactions;
new QueuedNotificationManager<>(this.dataChangeListenerExecutor,
DCL_NOTIFICATION_MGR_INVOKER, maxDataChangeListenerQueueSize,
"DataChangeListenerQueueMgr");
- changePublisher = new InMemoryDOMStoreTreeChangePublisher(this.dataChangeListenerExecutor, maxDataChangeListenerQueueSize);
+ changePublisher = new InMemoryDOMStoreTreeChangePublisher(this.dataChangeListenerExecutor,
+ maxDataChangeListenerQueueSize);
switch (type) {
case CONFIGURATION:
@Override
public DOMStoreReadTransaction newReadOnlyTransaction() {
- return SnapshotBackedTransactions.newReadTransaction(nextIdentifier(), debugTransactions, dataTree.takeSnapshot());
+ return SnapshotBackedTransactions.newReadTransaction(nextIdentifier(), debugTransactions,
+ dataTree.takeSnapshot());
}
@Override
public DOMStoreReadWriteTransaction newReadWriteTransaction() {
- return SnapshotBackedTransactions.newReadWriteTransaction(nextIdentifier(), debugTransactions, dataTree.takeSnapshot(), this);
+ return SnapshotBackedTransactions.newReadWriteTransaction(nextIdentifier(), debugTransactions,
+ dataTree.takeSnapshot(), this);
}
@Override
public DOMStoreWriteTransaction newWriteOnlyTransaction() {
- return SnapshotBackedTransactions.newWriteTransaction(nextIdentifier(), debugTransactions, dataTree.takeSnapshot(), this);
+ return SnapshotBackedTransactions.newWriteTransaction(nextIdentifier(), debugTransactions,
+ dataTree.takeSnapshot(), this);
}
@Override
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void close() {
ExecutorServiceUtil.tryGracefulShutdown(dataChangeListenerExecutor, 30, TimeUnit.SECONDS);
- if(closeable != null) {
+ if (closeable != null) {
try {
closeable.close();
- } catch(Exception e) {
+ } catch (Exception e) {
LOG.debug("Error closing instance", e);
}
}
}
@Override
- public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> registerChangeListener(
- final YangInstanceIdentifier path, final L listener, final DataChangeScope scope) {
+ public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L>
+ registerChangeListener(final YangInstanceIdentifier path, final L listener, final DataChangeScope scope) {
/*
* Make sure commit is not occurring right now. Listener has to be
}
@Override
- public synchronized <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) {
+ public synchronized <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
+ final YangInstanceIdentifier treeId, final L listener) {
/*
* Make sure commit is not occurring right now. Listener has to be
* registered and its state capture enqueued at a consistent point.
/**
* Holds configuration properties when creating an {@link InMemoryDOMDataStore} instance via the
- * {@link InMemoryDOMDataStoreFactory}
+ * {@link InMemoryDOMDataStoreFactory}.
*
* @author Thomas Pantelis
* @see InMemoryDOMDataStoreFactory
*/
-public class InMemoryDOMDataStoreConfigProperties {
+public final class InMemoryDOMDataStoreConfigProperties {
public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
}
/**
+ * Deprecated.
+ *
* @deprecated Use {@link #create(String, DOMSchemaService)} instead.
*/
@Deprecated
* default property values are used.
* @return an InMemoryDOMDataStore instance
*
- * @deprecated Use {@link #create(String, LogicalDatastoreType, SchemaService, boolean, InMemoryDOMDataStoreConfigProperties)}
- * instead.
+ * @deprecated Use {@link #create(String, LogicalDatastoreType, SchemaService, boolean,
+ * InMemoryDOMDataStoreConfigProperties)} instead.
*/
@Deprecated
public static InMemoryDOMDataStore create(final String name,
package org.opendaylight.controller.md.sal.dom.store.impl;
import static com.google.common.base.Preconditions.checkState;
+
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
private DataTreeCandidate candidate;
private final Exception operationError;
- public InMemoryDOMStoreThreePhaseCommitCohort(final InMemoryDOMDataStore store,
- final SnapshotBackedWriteTransaction<String> writeTransaction,
- final DataTreeModification modification,
- final Exception operationError) {
+ InMemoryDOMStoreThreePhaseCommitCohort(final InMemoryDOMDataStore store,
+ final SnapshotBackedWriteTransaction<String> writeTransaction, final DataTreeModification modification,
+ final Exception operationError) {
this.transaction = Preconditions.checkNotNull(writeTransaction);
this.modification = Preconditions.checkNotNull(modification);
this.store = Preconditions.checkNotNull(store);
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public final ListenableFuture<Boolean> canCommit() {
if (operationError != null) {
return Futures.immediateFailedFuture(operationError);
// precondition log, it should allow us to understand what went on.
LOG.trace("Store Tx: {} modifications: {} tree: {}", modification, store);
- return Futures.immediateFailedFuture(new TransactionCommitFailedException("Data did not pass validation.", e));
- } catch (Exception e) {
+ return Futures.immediateFailedFuture(new TransactionCommitFailedException(
+ "Data did not pass validation.", e));
+ } catch (RuntimeException e) {
LOG.warn("Unexpected failure in validation phase", e);
return Futures.immediateFailedFuture(e);
}
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public final ListenableFuture<Void> preCommit() {
try {
candidate = store.prepare(modification);
return SUCCESSFUL_FUTURE;
- } catch (Exception e) {
+ } catch (RuntimeException e) {
LOG.warn("Unexpected failure in pre-commit phase", e);
return Futures.immediateFailedFuture(e);
}
final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher {
private static final Invoker<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> MANAGER_INVOKER =
- (listener, notification) -> {
- // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it
- final DOMDataTreeChangeListener inst = listener.getInstance();
- if (inst != null) {
- inst.onDataTreeChanged(Collections.singletonList(notification));
- }
- };
+ (listener, notification) -> {
+ // FIXME: this is inefficient, as we could grab the entire queue for the listener and post it
+ final DOMDataTreeChangeListener inst = listener.getInstance();
+ if (inst != null) {
+ inst.onDataTreeChanged(Collections.singletonList(notification));
+ }
+ };
+
private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMStoreTreeChangePublisher.class);
- private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> notificationManager;
+ private final QueuedNotificationManager<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate>
+ notificationManager;
InMemoryDOMStoreTreeChangePublisher(final ExecutorService listenerExecutor, final int maxQueueSize) {
- notificationManager = new QueuedNotificationManager<>(listenerExecutor, MANAGER_INVOKER, maxQueueSize, "DataTreeChangeListenerQueueMgr");
+ notificationManager = new QueuedNotificationManager<>(listenerExecutor, MANAGER_INVOKER, maxQueueSize,
+ "DataTreeChangeListenerQueueMgr");
}
private InMemoryDOMStoreTreeChangePublisher(QueuedNotificationManager<
}
@Override
- protected void notifyListeners(final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations, final YangInstanceIdentifier path, final DataTreeCandidateNode node) {
+ protected void notifyListeners(final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> registrations,
+ final YangInstanceIdentifier path, final DataTreeCandidateNode node) {
final DataTreeCandidate candidate = DataTreeCandidates.newDataTreeCandidate(path, node);
for (AbstractDOMDataTreeChangeListenerRegistration<?> reg : registrations) {
}
@Override
- protected synchronized void registrationRemoved(final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
+ protected synchronized void registrationRemoved(
+ final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
LOG.debug("Closing registration {}", registration);
// FIXME: remove the queue for this registration and make sure we clear it
}
- <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) {
+ <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerTreeChangeListener(
+ final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) {
final AbstractDOMDataTreeChangeListenerRegistration<L> reg = registerTreeChangeListener(treeId, listener);
final Optional<NormalizedNode<?, ?>> node = snapshot.readNode(YangInstanceIdentifier.EMPTY);
/**
* Resolve Data Change Events based on modifications and listeners
*
- * Computes data change events for all affected registered listeners in data
- * tree.
+ * <p>
+ * Computes data change events for all affected registered listeners in data tree.
*/
@Beta
public final class ResolveDataChangeEventsTask {
/**
* Resolves and submits notification tasks to the specified manager.
*/
- public synchronized void resolve(final NotificationManager<DataChangeListenerRegistration<?>, DOMImmutableDataChangeEvent> manager) {
- try (final RegistrationTreeSnapshot<DataChangeListenerRegistration<?>> w = listenerRoot.takeSnapshot()) {
+ public synchronized void resolve(final NotificationManager<DataChangeListenerRegistration<?>,
+ DOMImmutableDataChangeEvent> manager) {
+ try (RegistrationTreeSnapshot<DataChangeListenerRegistration<?>> w = listenerRoot.takeSnapshot()) {
// Defensive: reset internal state
collectedEvents = ArrayListMultimap.create();
* Convert to tasks, but be mindful of multiple values -- those indicate multiple
* wildcard matches, which need to be merged.
*/
- for (Entry<DataChangeListenerRegistration<?>, Collection<DOMImmutableDataChangeEvent>> e : collectedEvents.asMap().entrySet()) {
+ for (Entry<DataChangeListenerRegistration<?>, Collection<DOMImmutableDataChangeEvent>> e :
+ collectedEvents.asMap().entrySet()) {
final Collection<DOMImmutableDataChangeEvent> col = e.getValue();
final DOMImmutableDataChangeEvent event;
}
/**
- * Resolves data change event for supplied node
+ * Resolves data change event for supplied node.
*
* @param path
* Path to current node in tree
// no before and after state is present
switch (type) {
- case SUBTREE_MODIFIED:
- return resolveSubtreeChangeEvent(state, node);
- case APPEARED:
- case WRITE:
- Preconditions.checkArgument(maybeAfter.isPresent(),
- "Modification at {} has type {} but no after-data", state.getPath(), type);
- if (!maybeBefore.isPresent()) {
- @SuppressWarnings({ "unchecked", "rawtypes" })
- final NormalizedNode<PathArgument, ?> afterNode = (NormalizedNode)maybeAfter.get();
- resolveSameEventRecursivelly(state, afterNode, DOMImmutableDataChangeEvent.getCreateEventFactory());
- return true;
- }
+ case SUBTREE_MODIFIED:
+ return resolveSubtreeChangeEvent(state, node);
+ case APPEARED:
+ case WRITE:
+ Preconditions.checkArgument(maybeAfter.isPresent(),
+ "Modification at {} has type {} but no after-data", state.getPath(), type);
+ if (!maybeBefore.isPresent()) {
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ final NormalizedNode<PathArgument, ?> afterNode = (NormalizedNode)maybeAfter.get();
+ resolveSameEventRecursivelly(state, afterNode, DOMImmutableDataChangeEvent.getCreateEventFactory());
+ return true;
+ }
- return resolveReplacedEvent(state, maybeBefore.get(), maybeAfter.get());
- case DISAPPEARED:
- case DELETE:
- Preconditions.checkArgument(maybeBefore.isPresent(),
- "Modification at {} has type {} but no before-data", state.getPath(), type);
+ return resolveReplacedEvent(state, maybeBefore.get(), maybeAfter.get());
+ case DISAPPEARED:
+ case DELETE:
+ Preconditions.checkArgument(maybeBefore.isPresent(),
+ "Modification at {} has type {} but no before-data", state.getPath(), type);
- @SuppressWarnings({ "unchecked", "rawtypes" })
- final NormalizedNode<PathArgument, ?> beforeNode = (NormalizedNode)maybeBefore.get();
- resolveSameEventRecursivelly(state, beforeNode, DOMImmutableDataChangeEvent.getRemoveEventFactory());
- return true;
- case UNMODIFIED:
- return false;
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ final NormalizedNode<PathArgument, ?> beforeNode = (NormalizedNode)maybeBefore.get();
+ resolveSameEventRecursivelly(state, beforeNode, DOMImmutableDataChangeEvent.getRemoveEventFactory());
+ return true;
+ case UNMODIFIED:
+ return false;
+ default:
+ break;
}
throw new IllegalStateException(String.format("Unhandled node state %s at %s", type, state.getPath()));
* resolution of changes on children level and can not
* shortcut resolution.
*/
- LOG.trace("Resolving subtree replace event for {} before {}, after {}", state.getPath(), beforeData, afterData);
+ LOG.trace("Resolving subtree replace event for {} before {}, after {}", state.getPath(), beforeData,
+ afterData);
@SuppressWarnings("unchecked")
- NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>> beforeCont = (NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>>) beforeData;
+ NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>> beforeCont =
+ (NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>>) beforeData;
@SuppressWarnings("unchecked")
- NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>> afterCont = (NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>>) afterData;
+ NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>> afterCont =
+ (NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>>) afterData;
return resolveNodeContainerReplaced(state, beforeCont, afterCont);
}
}
LOG.trace("Resolving leaf replace event for {} , before {}, after {}", state.getPath(), beforeData, afterData);
- DOMImmutableDataChangeEvent event = DOMImmutableDataChangeEvent.builder(DataChangeScope.BASE).addUpdated(state.getPath(), beforeData, afterData).build();
+ DOMImmutableDataChangeEvent event = DOMImmutableDataChangeEvent.builder(DataChangeScope.BASE)
+ .addUpdated(state.getPath(), beforeData, afterData).build();
state.addEvent(event);
state.collectEvents(beforeData, afterData, collectedEvents);
return true;
* created.
*/
if (!beforeCont.getChild(childId).isPresent()) {
- resolveSameEventRecursivelly(state.child(childId), afterChild, DOMImmutableDataChangeEvent.getCreateEventFactory());
+ resolveSameEventRecursivelly(state.child(childId), afterChild,
+ DOMImmutableDataChangeEvent.getCreateEventFactory());
childChanged = true;
}
}
// Node has children, so we will try to resolve it's children
// changes.
@SuppressWarnings("unchecked")
- NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>> container = (NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>>) node;
+ NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>> container =
+ (NormalizedNodeContainer<?, PathArgument, NormalizedNode<PathArgument, ?>>) node;
for (NormalizedNode<PathArgument, ?> child : container.getValue()) {
final PathArgument childId = child.getIdentifier();
state.collectEvents(event.getOriginalSubtree(), event.getUpdatedSubtree(), collectedEvents);
}
- private boolean resolveSubtreeChangeEvent(final ResolveDataChangeState state, final DataTreeCandidateNode modification) {
+ private boolean resolveSubtreeChangeEvent(final ResolveDataChangeState state,
+ final DataTreeCandidateNode modification) {
final Optional<NormalizedNode<?, ?>> maybeBefore = modification.getDataBefore();
final Optional<NormalizedNode<?, ?>> maybeAfter = modification.getDataAfter();
- Preconditions.checkArgument(maybeBefore.isPresent(), "Subtree change with before-data not present at path %s", state.getPath());
- Preconditions.checkArgument(maybeAfter.isPresent(), "Subtree change with after-data not present at path %s", state.getPath());
+ Preconditions.checkArgument(maybeBefore.isPresent(), "Subtree change with before-data not present at path %s",
+ state.getPath());
+ Preconditions.checkArgument(maybeAfter.isPresent(), "Subtree change with after-data not present at path %s",
+ state.getPath());
if (!state.needsProcessing()) {
LOG.trace("Not processing modified subtree {}", state.getPath());
final ResolveDataChangeState childState = state.child(childMod.getIdentifier());
switch (childMod.getModificationType()) {
- case APPEARED:
- case DELETE:
- case DISAPPEARED:
- case WRITE:
- if (resolveAnyChangeEvent(childState, childMod)) {
- scope = DataChangeScope.ONE;
- }
- break;
- case SUBTREE_MODIFIED:
- if (resolveSubtreeChangeEvent(childState, childMod) && scope == null) {
- scope = DataChangeScope.SUBTREE;
- }
- break;
- case UNMODIFIED:
- // no-op
- break;
+ case APPEARED:
+ case DELETE:
+ case DISAPPEARED:
+ case WRITE:
+ if (resolveAnyChangeEvent(childState, childMod)) {
+ scope = DataChangeScope.ONE;
+ }
+ break;
+ case SUBTREE_MODIFIED:
+ if (resolveSubtreeChangeEvent(childState, childMod) && scope == null) {
+ scope = DataChangeScope.SUBTREE;
+ }
+ break;
+ case UNMODIFIED:
+ // no-op
+ break;
+ default:
+ break;
}
}
final NormalizedNode<?, ?> after = maybeAfter.get();
if (scope != null) {
- DOMImmutableDataChangeEvent one = DOMImmutableDataChangeEvent.builder(scope).addUpdated(state.getPath(), before, after).build();
+ DOMImmutableDataChangeEvent one = DOMImmutableDataChangeEvent.builder(scope)
+ .addUpdated(state.getPath(), before, after).build();
state.addEvent(one);
}
return scope != null;
}
- public static ResolveDataChangeEventsTask create(final DataTreeCandidate candidate, final ListenerTree listenerTree) {
+ public static ResolveDataChangeEventsTask create(final DataTreeCandidate candidate,
+ final ListenerTree listenerTree) {
return new ResolveDataChangeEventsTask(candidate, listenerTree);
}
}
*/
final class ResolveDataChangeState {
private static final Logger LOG = LoggerFactory.getLogger(ResolveDataChangeState.class);
+
/**
- * Inherited from all parents
+ * Inherited from all parents.
*/
private final Iterable<Builder> inheritedSub;
+
/**
- * Inherited from immediate parent
+ * Inherited from immediate parent.
*/
private final Collection<Builder> inheritedOne;
private final YangInstanceIdentifier nodeId;
for (DataChangeListenerRegistration<?> l : n.getRegistrations()) {
final Builder b = DOMImmutableDataChangeEvent.builder(DataChangeScope.BASE);
switch (l.getScope()) {
- case BASE:
- base.put(l, b);
- break;
- case ONE:
- one.put(l, b);
- break;
- case SUBTREE:
- sub.put(l, b);
- break;
+ case BASE:
+ base.put(l, b);
+ break;
+ case ONE:
+ one.put(l, b);
+ break;
+ case SUBTREE:
+ sub.put(l, b);
+ break;
+ default:
+ break;
}
}
}
*
* @param rootId root instance identifier
* @param registrationTreeNode root node
- * @return
*/
- public static ResolveDataChangeState initial(final YangInstanceIdentifier rootId, final RegistrationTreeNode<DataChangeListenerRegistration<?>> registrationTreeNode) {
+ public static ResolveDataChangeState initial(final YangInstanceIdentifier rootId,
+ final RegistrationTreeNode<DataChangeListenerRegistration<?>> registrationTreeNode) {
return new ResolveDataChangeState(rootId, Collections.<Builder>emptyList(),
Collections.<Builder>emptyList(), Collections.singletonList(registrationTreeNode));
}
}
/**
- * Get the current path
+ * Get the current path.
*
* @return Current path.
*/
/**
* Add an event to all current listeners.
- *
- * @param event
*/
public void addEvent(final DOMImmutableDataChangeEvent event) {
// Subtree builders get always notified
LOG.trace("Collected events {}", map);
}
- private static Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> getListenerChildrenWildcarded(final Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> parentNodes,
+ private static Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> getListenerChildrenWildcarded(
+ final Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> parentNodes,
final PathArgument child) {
if (parentNodes.isEmpty()) {
return Collections.emptyList();
return result;
}
- private static void addChildNodes(final List<RegistrationTreeNode<DataChangeListenerRegistration<?>>> result, final Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> parentNodes, final PathArgument childIdentifier) {
+ private static void addChildNodes(final List<RegistrationTreeNode<DataChangeListenerRegistration<?>>> result,
+ final Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> parentNodes,
+ final PathArgument childIdentifier) {
for (RegistrationTreeNode<DataChangeListenerRegistration<?>> node : parentNodes) {
RegistrationTreeNode<DataChangeListenerRegistration<?>> child = node.getExactChild(childIdentifier);
if (child != null) {
private final AbstractMXBean notificationExecutorStatsBean;
private final QueuedNotificationManagerMXBeanImpl notificationManagerStatsBean;
- public InMemoryDataStoreStats(final String mBeanType, final QueuedNotificationManager<?, ?> manager) {
+ public InMemoryDataStoreStats(final String beanType, final QueuedNotificationManager<?, ?> manager) {
notificationManagerStatsBean = new QueuedNotificationManagerMXBeanImpl(manager,
- "notification-manager", mBeanType, null);
+ "notification-manager", beanType, null);
notificationManagerStatsBean.registerMBean();
notificationExecutorStatsBean = ThreadExecutorStatsMXBeanImpl.create(manager.getExecutor(),
- "notification-executor", mBeanType, null);
+ "notification-executor", beanType, null);
if (notificationExecutorStatsBean != null) {
notificationExecutorStatsBean.registerMBean();
}
@Override
public void close() throws Exception {
- if(notificationExecutorStatsBean != null) {
+ if (notificationExecutorStatsBean != null) {
notificationExecutorStatsBean.unregisterMBean();
}
- if(notificationManagerStatsBean != null) {
+ if (notificationManagerStatsBean != null) {
notificationManagerStatsBean.unregisterMBean();
}
}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-abstract class DataChangeListenerRegistrationImpl<T extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> extends AbstractListenerRegistration<T> implements DataChangeListenerRegistration<T> {
- public DataChangeListenerRegistrationImpl(final T listener) {
+abstract class DataChangeListenerRegistrationImpl<T extends AsyncDataChangeListener<YangInstanceIdentifier,
+ NormalizedNode<?, ?>>> extends AbstractListenerRegistration<T> implements DataChangeListenerRegistration<T> {
+ DataChangeListenerRegistrationImpl(final T listener) {
super(listener);
}
-}
\ No newline at end of file
+}
* @param scope Scope of triggering event.
* @return Listener registration
*/
- public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>> DataChangeListenerRegistration<L> registerDataChangeListener(final YangInstanceIdentifier path,
- final L listener, final DataChangeScope scope) {
+ public <L extends AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>>>
+ DataChangeListenerRegistration<L> registerDataChangeListener(final YangInstanceIdentifier path,
+ final L listener, final DataChangeScope scope) {
// Take the write lock
takeLock();
@After
public void tearDown() {
- if( this.dclExecutorService != null ) {
+ if (this.dclExecutorService != null) {
this.dclExecutorService.shutdownNow();
}
}
}
- protected static <K> void assertNotContains(final Collection<K> set, final K... values) {
+ protected static <K> void assertContains(final Map<K,?> map, final K... values) {
for (final K key : values) {
- Assert.assertFalse(set.contains(key));
+ Assert.assertTrue(map.containsKey(key));
}
}
- protected static <K> void assertContains(final Map<K,?> map, final K... values) {
+ protected static <K> void assertNotContains(final Collection<K> set, final K... values) {
for (final K key : values) {
- Assert.assertTrue(map.containsKey(key));
+ Assert.assertFalse(set.contains(key));
}
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.SettableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.SettableFuture;
-
public class DatastoreTestTask {
private final DOMStore store;
}
public DatastoreTestTask changeListener(final YangInstanceIdentifier path, final DataChangeScope scope,
- final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> changeListener) {
- this.changeListener = changeListener;
+ final AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> listener) {
+ this.changeListener = listener;
this.changePath = path;
this.changeScope = scope;
return this;
return this;
}
- public DatastoreTestTask setup(final WriteTransactionCustomizer setup) {
- this.setup = setup;
+ public DatastoreTestTask setup(final WriteTransactionCustomizer customizer) {
+ this.setup = customizer;
return this;
}
- public DatastoreTestTask test(final WriteTransactionCustomizer write) {
- this.write = write;
+ public DatastoreTestTask test(final WriteTransactionCustomizer customizer) {
+ this.write = customizer;
return this;
}
- public DatastoreTestTask read(final ReadTransactionVerifier read) {
- this.read = read;
+ public DatastoreTestTask read(final ReadTransactionVerifier customizer) {
+ this.read = customizer;
return this;
}
- public DatastoreTestTask cleanup(final WriteTransactionCustomizer cleanup) {
- this.cleanup = cleanup;
+ public DatastoreTestTask cleanup(final WriteTransactionCustomizer customizer) {
+ this.cleanup = customizer;
return this;
}
- public void run() throws InterruptedException, ExecutionException, TimeoutException {
+ public void run() throws Exception {
if (setup != null) {
execute(setup);
}
}
}
- public AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> getChangeEvent() {
- try {
- return internalListener.receivedChange.get(10, TimeUnit.SECONDS);
- } catch( Exception e ) {
- fail( "Error getting the AsyncDataChangeEvent from the Future: " + e );
- }
-
- // won't get here
- return null;
+ public AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> getChangeEvent() throws Exception {
+ return internalListener.receivedChange.get(10, TimeUnit.SECONDS);
}
- public void verifyNoChangeEvent() {
+ public void verifyNoChangeEvent() throws Exception {
try {
Object unexpected = internalListener.receivedChange.get(500, TimeUnit.MILLISECONDS);
- fail( "Got unexpected AsyncDataChangeEvent from the Future: " + unexpected );
- } catch( TimeoutException e ) {
+ fail("Got unexpected AsyncDataChangeEvent from the Future: " + unexpected);
+ } catch (TimeoutException e) {
// Expected
- } catch( Exception e ) {
- fail( "Error getting the AsyncDataChangeEvent from the Future: " + e );
}
}
private final class ChangeEventListener implements
AsyncDataChangeListener<YangInstanceIdentifier, NormalizedNode<?, ?>> {
- protected final SettableFuture<AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>>> receivedChange = SettableFuture
- .create();
+ protected final SettableFuture<AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>>>
+ receivedChange = SettableFuture.create();
@Override
public void onDataChanged(final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change) {
*/
package org.opendaylight.controller.md.sal.dom.store.impl;
-import java.util.concurrent.ExecutionException;
-
import org.junit.Test;
/**
*
* @param task Update task configuration as needed
*/
- abstract protected void customizeTask(DatastoreTestTask task);
+ protected abstract void customizeTask(DatastoreTestTask task);
@Test
public final void putTopLevelOneNested() throws Exception {
putTopLevelOneNested(task);
}
+ protected abstract void putTopLevelOneNested(DatastoreTestTask task) throws Exception;
+
@Test
public final void existingTopWriteSibling() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
- tx -> tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build()));
+ tx -> tx.write(path(FOO_SIBLING), topLevelList(FOO_SIBLING).build()));
customizeTask(task);
task.run();
existingTopWriteSibling(task);
}
- protected abstract void existingTopWriteSibling(DatastoreTestTask task) throws InterruptedException, ExecutionException;
-
+ protected abstract void existingTopWriteSibling(DatastoreTestTask task) throws Exception;
@Test
public final void existingTopWriteTwoNested() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO)).test(
- tx -> {
- tx.write(path(FOO,BAR), nestedList(BAR).build());
- tx.write(path(FOO,BAZ), nestedList(BAZ).build());
- });
+ tx -> {
+ tx.write(path(FOO,BAR), nestedList(BAR).build());
+ tx.write(path(FOO,BAZ), nestedList(BAZ).build());
+ });
customizeTask(task);
task.run();
existingTopWriteTwoNested(task);
}
- protected abstract void existingTopWriteTwoNested(DatastoreTestTask task) throws InterruptedException, ExecutionException;
+ protected abstract void existingTopWriteTwoNested(DatastoreTestTask task) throws Exception;
@Test
public final void existingOneNestedWriteAdditionalNested() throws Exception {
DatastoreTestTask task = newTestTask().setup(writeOneTopMultipleNested(FOO, BAR)).test(
- tx -> tx.write(path(FOO,BAZ), nestedList(BAZ).build()));
+ tx -> tx.write(path(FOO,BAZ), nestedList(BAZ).build()));
customizeTask(task);
task.run();
existingOneNestedWriteAdditionalNested(task);
}
- protected abstract void existingOneNestedWriteAdditionalNested(DatastoreTestTask task) throws InterruptedException, ExecutionException;
-
- protected abstract void putTopLevelOneNested(DatastoreTestTask task) throws Exception;
+ protected abstract void existingOneNestedWriteAdditionalNested(DatastoreTestTask task) throws Exception;
@Test
public final void replaceTopLevelNestedChanged() throws Exception {
replaceTopLevelNestedChanged(task);
}
- protected abstract void replaceTopLevelNestedChanged(DatastoreTestTask task) throws InterruptedException,
- ExecutionException;
+ protected abstract void replaceTopLevelNestedChanged(DatastoreTestTask task) throws Exception;
@Test
public final void putTopLevelWithTwoNested() throws Exception {
putTopLevelWithTwoNested(task);
}
- protected abstract void putTopLevelWithTwoNested(DatastoreTestTask task) throws InterruptedException,
- ExecutionException;
+ protected abstract void putTopLevelWithTwoNested(DatastoreTestTask task) throws Exception;
@Test
public final void twoNestedExistsOneIsDeleted() throws Exception {
twoNestedExistsOneIsDeleted(task);
}
- protected abstract void twoNestedExistsOneIsDeleted(DatastoreTestTask task) throws InterruptedException,
- ExecutionException;
+ protected abstract void twoNestedExistsOneIsDeleted(DatastoreTestTask task) throws Exception;
@Test
public final void nestedListExistsRootDeleted() throws Exception {
nestedListExistsRootDeleted(task);
}
- protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws InterruptedException,
- ExecutionException;
+ protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws Exception;
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeContainerBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
- /**
+ /*
* Writes /test in writeTx
*/
NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
writeTx.write(TestModel.TEST_PATH, testNode);
- /**
+ /*
* Reads /test from writeTx Read should return container.
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
assertEquals("read: isPresent", true, writeTxContainer.get().isPresent());
assertEquals("read: data", testNode, writeTxContainer.get().get());
- /**
+ /*
* Reads /test from readTx Read should return Absent.
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> readTxContainer = readTx.read(TestModel.TEST_PATH);
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
- /**
+ /*
* Writes /test in writeTx
*/
NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
writeTx.write(TestModel.TEST_PATH, testNode);
- /**
+ /*
* Reads /test from writeTx Read should return container.
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
public void testDelete() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
- assertNotNull( writeTx );
+ assertNotNull(writeTx);
// Write /test and commit
- writeTx.write( TestModel.TEST_PATH, ImmutableNodes.containerNode( TestModel.TEST_QNAME ) );
+ writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
- assertThreePhaseCommit( writeTx.ready() );
+ assertThreePhaseCommit(writeTx.ready());
- Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().
- read(TestModel.TEST_PATH ).get();
- assertEquals( "After commit read: isPresent", true, afterCommitRead.isPresent() );
+ Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
+ .get();
+ assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
// Delete /test and verify
writeTx = domStore.newWriteOnlyTransaction();
- writeTx.delete( TestModel.TEST_PATH );
+ writeTx.delete(TestModel.TEST_PATH);
- assertThreePhaseCommit( writeTx.ready() );
+ assertThreePhaseCommit(writeTx.ready());
- afterCommitRead = domStore.newReadOnlyTransaction().
- read(TestModel.TEST_PATH ).get();
- assertEquals( "After commit read: isPresent", false, afterCommitRead.isPresent() );
+ afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
+ assertEquals("After commit read: isPresent", false, afterCommitRead.isPresent());
}
@Test
public void testMerge() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
- assertNotNull( writeTx );
+ assertNotNull(writeTx);
ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier( new NodeIdentifier( TestModel.TEST_QNAME ) )
- .addChild( ImmutableNodes.mapNodeBuilder( TestModel.OUTER_LIST_QNAME )
- .addChild( ImmutableNodes.mapEntry( TestModel.OUTER_LIST_QNAME,
- TestModel.ID_QNAME, 1 ) ).build() ).build();
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build())
+ .build();
- writeTx.merge( TestModel.TEST_PATH, containerNode );
+ writeTx.merge(TestModel.TEST_PATH, containerNode);
- assertThreePhaseCommit( writeTx.ready() );
+ assertThreePhaseCommit(writeTx.ready());
- Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().
- read(TestModel.TEST_PATH ).get();
- assertEquals( "After commit read: isPresent", true, afterCommitRead.isPresent() );
- assertEquals( "After commit read: data", containerNode, afterCommitRead.get() );
+ Optional<NormalizedNode<?, ?>> afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH)
+ .get();
+ assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
+ assertEquals("After commit read: data", containerNode, afterCommitRead.get());
// Merge a new list entry node
writeTx = domStore.newWriteOnlyTransaction();
- assertNotNull( writeTx );
+ assertNotNull(writeTx);
containerNode = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier( new NodeIdentifier( TestModel.TEST_QNAME ) )
- .addChild( ImmutableNodes.mapNodeBuilder( TestModel.OUTER_LIST_QNAME )
- .addChild( ImmutableNodes.mapEntry( TestModel.OUTER_LIST_QNAME,
- TestModel.ID_QNAME, 1 ) )
- .addChild( ImmutableNodes.mapEntry( TestModel.OUTER_LIST_QNAME,
- TestModel.ID_QNAME, 2 ) ).build() ).build();
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
+ .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2)).build())
+ .build();
- writeTx.merge( TestModel.TEST_PATH, containerNode );
+ writeTx.merge(TestModel.TEST_PATH, containerNode);
- assertThreePhaseCommit( writeTx.ready() );
+ assertThreePhaseCommit(writeTx.ready());
- afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH ).get();
- assertEquals( "After commit read: isPresent", true, afterCommitRead.isPresent() );
- assertEquals( "After commit read: data", containerNode, afterCommitRead.get() );
+ afterCommitRead = domStore.newReadOnlyTransaction().read(TestModel.TEST_PATH).get();
+ assertEquals("After commit read: isPresent", true, afterCommitRead.isPresent());
+ assertEquals("After commit read: data", containerNode, afterCommitRead.get());
}
public void testExistsForExistingData() throws Exception {
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
- assertNotNull( writeTx );
+ assertNotNull(writeTx);
ContainerNode containerNode = ImmutableContainerNodeBuilder.create()
- .withNodeIdentifier( new NodeIdentifier( TestModel.TEST_QNAME ) )
- .addChild( ImmutableNodes.mapNodeBuilder( TestModel.OUTER_LIST_QNAME )
- .addChild( ImmutableNodes.mapEntry( TestModel.OUTER_LIST_QNAME,
- TestModel.ID_QNAME, 1 ) ).build() ).build();
+ .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
+ .addChild(ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ .addChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build())
+ .build();
- writeTx.merge( TestModel.TEST_PATH, containerNode );
+ writeTx.merge(TestModel.TEST_PATH, containerNode);
CheckedFuture<Boolean, ReadFailedException> exists =
writeTx.exists(TestModel.TEST_PATH);
ready.commit().get();
DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull( readTx );
+ assertNotNull(readTx);
exists =
readTx.exists(TestModel.TEST_PATH);
public void testExistsForNonExistingData() throws Exception {
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
- assertNotNull( writeTx );
+ assertNotNull(writeTx);
CheckedFuture<Boolean, ReadFailedException> exists =
writeTx.exists(TestModel.TEST_PATH);
assertEquals(false, exists.checkedGet());
DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull( readTx );
+ assertNotNull(readTx);
exists =
readTx.exists(TestModel.TEST_PATH);
assertEquals(false, exists.checkedGet());
}
- @Test(expected=ReadFailedException.class)
+ @Test(expected = ReadFailedException.class)
public void testExistsThrowsReadFailedException() throws Exception {
DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull( readTx );
+ assertNotNull(readTx);
readTx.close();
readTx.exists(TestModel.TEST_PATH).checkedGet();
}
-
-
- @Test(expected=ReadFailedException.class)
- public void testReadWithReadOnlyTransactionClosed() throws Throwable {
+ @Test(expected = ReadFailedException.class)
+ public void testReadWithReadOnlyTransactionClosed() throws Exception {
DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
- assertNotNull( readTx );
+ assertNotNull(readTx);
readTx.close();
- doReadAndThrowEx( readTx );
+ doReadAndThrowEx(readTx);
}
- @Test(expected=ReadFailedException.class)
- public void testReadWithReadOnlyTransactionFailure() throws Throwable {
+ @Test(expected = ReadFailedException.class)
+ public void testReadWithReadOnlyTransactionFailure() throws Exception {
- DataTreeSnapshot mockSnapshot = Mockito.mock( DataTreeSnapshot.class );
- Mockito.doThrow( new RuntimeException( "mock ex" ) ).when( mockSnapshot )
- .readNode( Mockito.any( YangInstanceIdentifier.class ) );
+ DataTreeSnapshot mockSnapshot = Mockito.mock(DataTreeSnapshot.class);
+ Mockito.doThrow(new RuntimeException("mock ex")).when(mockSnapshot)
+ .readNode(Mockito.any(YangInstanceIdentifier.class));
DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadTransaction("1", true, mockSnapshot);
- doReadAndThrowEx( readTx );
+ doReadAndThrowEx(readTx);
}
- @Test(expected=ReadFailedException.class)
- public void testReadWithReadWriteTransactionClosed() throws Throwable {
+ @Test(expected = ReadFailedException.class)
+ public void testReadWithReadWriteTransactionClosed() throws Exception {
DOMStoreReadTransaction readTx = domStore.newReadWriteTransaction();
- assertNotNull( readTx );
+ assertNotNull(readTx);
readTx.close();
- doReadAndThrowEx( readTx );
+ doReadAndThrowEx(readTx);
}
- @Test(expected=ReadFailedException.class)
- public void testReadWithReadWriteTransactionFailure() throws Throwable {
+ @Test(expected = ReadFailedException.class)
+ public void testReadWithReadWriteTransactionFailure() throws Exception {
- DataTreeSnapshot mockSnapshot = Mockito.mock( DataTreeSnapshot.class );
- DataTreeModification mockModification = Mockito.mock( DataTreeModification.class );
- Mockito.doThrow( new RuntimeException( "mock ex" ) ).when( mockModification )
- .readNode( Mockito.any( YangInstanceIdentifier.class ) );
- Mockito.doReturn( mockModification ).when( mockSnapshot ).newModification();
+ DataTreeSnapshot mockSnapshot = Mockito.mock(DataTreeSnapshot.class);
+ DataTreeModification mockModification = Mockito.mock(DataTreeModification.class);
+ Mockito.doThrow(new RuntimeException("mock ex")).when(mockModification)
+ .readNode(Mockito.any(YangInstanceIdentifier.class));
+ Mockito.doReturn(mockModification).when(mockSnapshot).newModification();
@SuppressWarnings("unchecked")
- TransactionReadyPrototype<String> mockReady = Mockito.mock( TransactionReadyPrototype.class );
- DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadWriteTransaction("1", false, mockSnapshot, mockReady);
+ TransactionReadyPrototype<String> mockReady = Mockito.mock(TransactionReadyPrototype.class);
+ DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadWriteTransaction("1", false, mockSnapshot,
+ mockReady);
- doReadAndThrowEx( readTx );
+ doReadAndThrowEx(readTx);
}
- private static void doReadAndThrowEx( final DOMStoreReadTransaction readTx ) throws Throwable {
- try {
- readTx.read(TestModel.TEST_PATH).get();
- } catch( ExecutionException e ) {
- throw e.getCause();
- }
+ private static void doReadAndThrowEx(final DOMStoreReadTransaction readTx) throws ReadFailedException {
+ readTx.read(TestModel.TEST_PATH).checkedGet();
}
- @Test(expected=IllegalStateException.class)
+ @Test(expected = IllegalStateException.class)
public void testWriteWithTransactionReady() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
writeTx.ready();
// Should throw ex
- writeTx.write( TestModel.TEST_PATH, ImmutableNodes.containerNode( TestModel.TEST_QNAME ) );
+ writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
}
- @Test(expected=IllegalStateException.class)
+ @Test(expected = IllegalStateException.class)
public void testReadyWithTransactionAlreadyReady() throws Exception {
DOMStoreWriteTransaction writeTx = domStore.newWriteOnlyTransaction();
DOMStoreTransactionChain txChain = domStore.createTransactionChain();
assertNotNull(txChain);
- /**
+ /*
* We alocate new read-write transaction and write /test
- *
- *
*/
DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
assertTestContainerWrite(firstTx);
- /**
+ /*
* First transaction is marked as ready, we are able to allocate chained
* transactions
*/
- DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready();
+ final DOMStoreThreePhaseCommitCohort firstWriteTxCohort = firstTx.ready();
- /**
+ /*
* We alocate chained transaction - read transaction, note first one is
* still not commited to datastore.
*/
DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
- /**
- *
+ /*
* We test if we are able to read data from tx, read should not fail
* since we are using chained transaction.
- *
- *
*/
assertTestContainerExists(secondReadTx);
- /**
- *
+ /*
* We alocate next transaction, which is still based on first one, but
* is read-write.
- *
*/
DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
- /**
+ /*
* We test existence of /test in third transaction container should
* still be visible from first one (which is still uncommmited).
- *
- *
*/
assertTestContainerExists(thirdDeleteTx);
- /**
+ /*
* We delete node in third transaction
*/
thirdDeleteTx.delete(TestModel.TEST_PATH);
- /**
+ /*
* third transaction is sealed.
*/
DOMStoreThreePhaseCommitCohort thirdDeleteTxCohort = thirdDeleteTx.ready();
- /**
+ /*
* We commit first transaction
- *
*/
assertThreePhaseCommit(firstWriteTxCohort);
// Alocates store transacion
DOMStoreReadTransaction storeReadTx = domStore.newReadOnlyTransaction();
- /**
+
+ /*
* We verify transaction is commited to store, container should exists
* in datastore.
*/
assertTestContainerExists(storeReadTx);
- /**
+
+ /*
* We commit third transaction
- *
*/
assertThreePhaseCommit(thirdDeleteTxCohort);
}
assertTestContainerWrite(txOne);
assertTestContainerWrite(txTwo);
- /**
+ /*
* Commits transaction
*/
assertThreePhaseCommit(txOne.ready());
- /**
+ /*
* Asserts that txTwo could not be commited
*/
assertFalse(txTwo.ready().canCommit().get());
private static Optional<NormalizedNode<?, ?>> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx)
throws InterruptedException, ExecutionException {
- /**
- *
+ /*
* Writes /test in writeTx
- *
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
assertTrue(writeTxContainer.get().isPresent());
return writeTxContainer.get();
}
-
}
*/
package org.opendaylight.controller.md.sal.dom.store.impl;
-import java.util.concurrent.ExecutionException;
-
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
}
@Override
- public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), TOP_LEVEL, path(FOO), path(FOO, BAR));
}
@Override
- public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- protected void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), path(FOO,BAZ));
}
@Override
- protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), path(FOO,BAR),path(FOO,BAZ));
}
@Override
- protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), path(FOO_SIBLING));
package org.opendaylight.controller.md.sal.dom.store.impl;
import static org.junit.Assert.assertNotNull;
-import com.google.common.base.Throwables;
+
import com.google.common.util.concurrent.MoreExecutors;
-import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
private InMemoryDOMDataStore domStore;
@Before
- public void setupStore() {
+ public void setupStore() throws Exception {
this.domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
loadSchemas(RockTheHouseInput.class);
}
- public void loadSchemas(final Class<?>... classes) {
- YangModuleInfo moduleInfo;
- try {
- final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
- for (final Class<?> clz : classes) {
- moduleInfo = BindingReflections.getModuleInfo(clz);
+ public void loadSchemas(final Class<?>... classes) throws Exception {
+ final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
+ for (final Class<?> clz : classes) {
+ YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(clz);
- context.registerModuleInfo(moduleInfo);
- }
- this.schemaContext = context.tryToCreateSchemaContext().get();
- this.domStore.onGlobalContextUpdated(this.schemaContext);
- } catch (final Exception e) {
- Throwables.propagateIfPossible(e);
+ context.registerModuleInfo(moduleInfo);
}
+ this.schemaContext = context.tryToCreateSchemaContext().get();
+ this.domStore.onGlobalContextUpdated(this.schemaContext);
}
/**
* then triggering update of global schema context
* and then performing write (according to new module).
*
+ * <p>
* If transaction between allocation and schema context was
* unmodified, it is safe to change its schema context
* to new one (e.g. it will be same as if allocated after
* schema context update.)
- *
- * @throws InterruptedException
- * @throws ExecutionException
*/
@Test
- public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException {
+ public void testTransactionSchemaUpdate() throws Exception {
assertNotNull(this.domStore);
// we trigger schema context update to contain Lists model
loadSchemas(RockTheHouseInput.class, Top.class);
- /**
- *
+ /*
* Writes /test in writeTx, this write should not fail
* with IllegalArgumentException since /test is in
* schema context.
- *
*/
writeTx.write(TOP_PATH, ImmutableNodes.containerNode(Top.QNAME));
-
}
-
}
import java.util.concurrent.ExecutorService;
/**
- * A forwarding Executor used by unit tests for DataChangeListener notifications
+ * A forwarding Executor used by unit tests for DataChangeListener notifications.
*
* @author Thomas Pantelis
*/
private final ExecutorService postSetupExecutor;
- public TestDCLExecutorService( final ExecutorService postSetupExecutor ) {
+ public TestDCLExecutorService(final ExecutorService postSetupExecutor) {
this.postSetupExecutor = postSetupExecutor;
}
// Test setup complete - switch to the real executor.
currentExecutor = postSetupExecutor;
}
-}
\ No newline at end of file
+}
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class TestModel {
+public final class TestModel {
public static final QName TEST_QNAME =
QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
+ private TestModel() {
+ }
+
public static SchemaContext createTestContext() {
return YangParserTestUtils.parseYangResource(DATASTORE_TEST_YANG);
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
}
@Override
- public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
* Created data must not contain nested-list item, since that is two-level deep.
*/
assertNotContains(change.getCreatedData(), TOP_LEVEL,path(FOO, BAR));
- assertContains(change.getCreatedData(), path(FOO) );
+ assertContains(change.getCreatedData(), path(FOO));
assertEmpty(change.getUpdatedData());
assertEmpty(change.getRemovedPaths());
}
@Override
- public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertNotNull(change);
}
@Override
- protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertNotNull(change);
}
@Override
- protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws Exception {
/*
* Base listener should be notified only and only if actual node changed its state,
}
@Override
- public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
+ protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws Exception {
/*
* One listener should be notified only and only if actual node changed its state,
* since deletion of nested child (in this case /nested-list/nested-list[foo],
}
@Override
- protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws Exception {
/*
* One listener should be notified only and only if actual node changed its state,
* since deletion of nested child (in this case /nested-list/nested-list[foo],
}
@Override
- protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), path(FOO_SIBLING));
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
}
@Override
- public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertNotNull(change);
}
@Override
- protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertNotNull(change);
}
@Override
- protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws Exception {
/*
* One listener should be notified only and only if actual node changed its state,
}
@Override
- public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) {
+ protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws Exception {
/*
* One listener should be notified only and only if actual node changed its state,
* since deletion of nested child (in this case /nested-list/nested-list[foo],
}
@Override
- protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws Exception {
/*
* One listener should be notified only and only if actual node changed its state,
* since deletion of nested child (in this case /nested-list/nested-list[foo],
}
@Override
- protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), path(FOO_SIBLING));
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.util.concurrent.ExecutionException;
-
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
}
@Override
- public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertNotNull(change);
}
@Override
- protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertNotNull(change);
}
@Override
- protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertNotNull(change);
}
@Override
- public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException,
- ExecutionException {
+ public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
}
@Override
- protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), path(FOO,BAZ));
}
@Override
- protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), path(FOO,BAR),path(FOO,BAZ));
}
@Override
- protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException {
+ protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception {
AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change = task.getChangeEvent();
assertContains(change.getCreatedData(), path(FOO_SIBLING));