From: Tom Pantelis Date: Tue, 6 Mar 2018 04:23:21 +0000 (-0500) Subject: Fix checkstyle violations in sal-inmemory-datastore X-Git-Tag: release/fluorine~160 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=c5f3be93482d6b06d95ebf22b2ef2723fd813f89 Fix checkstyle violations in sal-inmemory-datastore Change-Id: I4e8dec800b8e5a2871e51ec4cd150f06c8af1bd1 Signed-off-by: Tom Pantelis --- diff --git a/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/controller/config/yang/config/legacy_entity_ownership_service_provider/LegacyEntityOwnershipServiceProviderModule.java b/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/controller/config/yang/config/legacy_entity_ownership_service_provider/LegacyEntityOwnershipServiceProviderModule.java index 5fe9ff99de..1d65c3bd92 100644 --- a/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/controller/config/yang/config/legacy_entity_ownership_service_provider/LegacyEntityOwnershipServiceProviderModule.java +++ b/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/controller/config/yang/config/legacy_entity_ownership_service_provider/LegacyEntityOwnershipServiceProviderModule.java @@ -18,17 +18,21 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipS 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); } @@ -46,6 +50,7 @@ public class LegacyEntityOwnershipServiceProviderModule extends AbstractLegacyEn 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(); diff --git a/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/controller/config/yang/config/legacy_entity_ownership_service_provider/LegacyEntityOwnershipServiceProviderModuleFactory.java b/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/controller/config/yang/config/legacy_entity_ownership_service_provider/LegacyEntityOwnershipServiceProviderModuleFactory.java index fe1a0bf94d..f24b7b6da8 100644 --- a/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/controller/config/yang/config/legacy_entity_ownership_service_provider/LegacyEntityOwnershipServiceProviderModuleFactory.java +++ b/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/controller/config/yang/config/legacy_entity_ownership_service_provider/LegacyEntityOwnershipServiceProviderModuleFactory.java @@ -13,20 +13,27 @@ import org.opendaylight.controller.config.spi.Module; 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; } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java index 35ea03d70e..2d1f041785 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModule.java @@ -8,6 +8,8 @@ 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; @@ -18,13 +20,16 @@ import org.opendaylight.controller.md.sal.dom.store.impl.jmx.InMemoryDataStoreSt * 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); } @@ -46,5 +51,4 @@ public class InMemoryConfigDataStoreProviderModule extends org.opendaylight.cont return dataStore; } - } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java index 8116708bb6..9c439b6069 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryConfigDataStoreProviderModuleFactory.java @@ -5,22 +5,12 @@ * 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 { } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java index bf323902aa..af81254ee5 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModule.java @@ -8,6 +8,8 @@ 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; @@ -18,13 +20,16 @@ import org.opendaylight.controller.md.sal.dom.store.impl.jmx.InMemoryDataStoreSt * 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); } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java index ec576a0176..535c0c8965 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/config/yang/inmemory_datastore_provider/InMemoryOperationalDataStoreProviderModuleFactory.java @@ -5,22 +5,12 @@ * 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 { } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java index f457e3b9e9..43b1c636e4 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DOMImmutableDataChangeEvent.java @@ -8,13 +8,11 @@ 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; @@ -24,7 +22,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public final class DOMImmutableDataChangeEvent implements AsyncDataChangeEvent> { - private static final RemoveEventFactory REMOVE_EVENT_FACTORY = new RemoveEventFactory(); private static final CreateEventFactory CREATE_EVENT_FACTORY = new CreateEventFactory(); @@ -36,8 +33,6 @@ public final class DOMImmutableDataChangeEvent implements private final Set removedPaths; private final DataChangeScope scope; - - private DOMImmutableDataChangeEvent(final Builder change) { original = change.before; updated = change.after; @@ -48,7 +43,7 @@ public final class DOMImmutableDataChangeEvent implements scope = change.scope; } - public static final Builder builder(final DataChangeScope scope) { + public static Builder builder(final DataChangeScope scope) { return new Builder(scope); } @@ -93,9 +88,7 @@ public final class DOMImmutableDataChangeEvent implements } /** - * 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 data); @@ -104,30 +97,31 @@ public final class DOMImmutableDataChangeEvent implements /** * Event factory which takes after state and creates event for it. * + *

* 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. * + *

* 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()}. * + *

* 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; @@ -178,10 +172,10 @@ public final class DOMImmutableDataChangeEvent implements 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; } @@ -193,7 +187,8 @@ public final class DOMImmutableDataChangeEvent implements private static final class RemoveEventFactory implements SimpleEventFactory { @Override - public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path, final NormalizedNode data) { + public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path, + final NormalizedNode data) { return builder(DataChangeScope.BASE) // .setBefore(data) // .addRemoved(path, data) // @@ -205,12 +200,12 @@ public final class DOMImmutableDataChangeEvent implements private static final class CreateEventFactory implements SimpleEventFactory { @Override - public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path, final NormalizedNode data) { + public DOMImmutableDataChangeEvent create(final YangInstanceIdentifier path, + final NormalizedNode data) { return builder(DataChangeScope.BASE) // .setAfter(data) // .addCreated(path, data) // .build(); } } - } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java index b26f43b2b7..7e8ee187e5 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeListenerRegistration.java @@ -13,7 +13,8 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public interface DataChangeListenerRegistration>> extends ListenerRegistration { +public interface DataChangeListenerRegistration>> extends ListenerRegistration { @Override L getInstance(); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java index 3582ff6ef1..af20e14c1c 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java @@ -50,18 +50,23 @@ import org.slf4j.LoggerFactory; /** * In-memory DOM Data Store * + *

* 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 implements DOMStore, Identifiable, SchemaContextListener, AutoCloseable, DOMStoreTreeChangePublisher { +public class InMemoryDOMDataStore extends TransactionReadyPrototype + implements DOMStore, Identifiable, SchemaContextListener, AutoCloseable, DOMStoreTreeChangePublisher { private static final Logger LOG = LoggerFactory.getLogger(InMemoryDOMDataStore.class); - private static final Invoker, DOMImmutableDataChangeEvent> DCL_NOTIFICATION_MGR_INVOKER = + private static final Invoker, DOMImmutableDataChangeEvent> + DCL_NOTIFICATION_MGR_INVOKER = (listener, notification) -> { - final AsyncDataChangeListener> inst = listener.getInstance(); + final AsyncDataChangeListener> inst = + listener.getInstance(); if (inst != null) { inst.onDataChanged(notification); } @@ -71,7 +76,8 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl private final ListenerTree listenerTree = ListenerTree.create(); private final AtomicLong txCounter = new AtomicLong(0); - private final QueuedNotificationManager, DOMImmutableDataChangeEvent> dataChangeListenerNotificationManager; + private final QueuedNotificationManager, DOMImmutableDataChangeEvent> + dataChangeListenerNotificationManager; private final InMemoryDOMStoreTreeChangePublisher changePublisher; private final ExecutorService dataChangeListenerExecutor; private final boolean debugTransactions; @@ -95,7 +101,8 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl 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: @@ -124,17 +131,20 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl @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 @@ -148,13 +158,14 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl } @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); } } @@ -169,8 +180,8 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl } @Override - public >> ListenerRegistration registerChangeListener( - final YangInstanceIdentifier path, final L listener, final DataChangeScope scope) { + public >> ListenerRegistration + registerChangeListener(final YangInstanceIdentifier path, final L listener, final DataChangeScope scope) { /* * Make sure commit is not occurring right now. Listener has to be @@ -209,7 +220,8 @@ public class InMemoryDOMDataStore extends TransactionReadyPrototype impl } @Override - public synchronized ListenerRegistration registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) { + public synchronized ListenerRegistration 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. diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java index be89d53a69..20e4f4089f 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreConfigProperties.java @@ -10,12 +10,12 @@ package org.opendaylight.controller.md.sal.dom.store.impl; /** * 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; diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java index dde694207c..aad39987fa 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStoreFactory.java @@ -25,6 +25,8 @@ public final class InMemoryDOMDataStoreFactory { } /** + * Deprecated. + * * @deprecated Use {@link #create(String, DOMSchemaService)} instead. */ @Deprecated @@ -81,8 +83,8 @@ public final class InMemoryDOMDataStoreFactory { * 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, diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreThreePhaseCommitCohort.java index a77732a11f..deab29dc9c 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreThreePhaseCommitCohort.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreThreePhaseCommitCohort.java @@ -9,6 +9,7 @@ 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; @@ -34,10 +35,9 @@ class InMemoryDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommit private DataTreeCandidate candidate; private final Exception operationError; - public InMemoryDOMStoreThreePhaseCommitCohort(final InMemoryDOMDataStore store, - final SnapshotBackedWriteTransaction writeTransaction, - final DataTreeModification modification, - final Exception operationError) { + InMemoryDOMStoreThreePhaseCommitCohort(final InMemoryDOMDataStore store, + final SnapshotBackedWriteTransaction writeTransaction, final DataTreeModification modification, + final Exception operationError) { this.transaction = Preconditions.checkNotNull(writeTransaction); this.modification = Preconditions.checkNotNull(modification); this.store = Preconditions.checkNotNull(store); @@ -52,6 +52,7 @@ class InMemoryDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommit } @Override + @SuppressWarnings("checkstyle:IllegalCatch") public final ListenableFuture canCommit() { if (operationError != null) { return Futures.immediateFailedFuture(operationError); @@ -75,19 +76,21 @@ class InMemoryDOMStoreThreePhaseCommitCohort implements DOMStoreThreePhaseCommit // 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 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); } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java index e469a15958..bf125cf33c 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMStoreTreeChangePublisher.java @@ -29,18 +29,21 @@ import org.slf4j.LoggerFactory; final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChangePublisher { private static final Invoker, 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, DataTreeCandidate> notificationManager; + private final QueuedNotificationManager, 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< @@ -49,7 +52,8 @@ final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChan } @Override - protected void notifyListeners(final Collection> registrations, final YangInstanceIdentifier path, final DataTreeCandidateNode node) { + protected void notifyListeners(final Collection> registrations, + final YangInstanceIdentifier path, final DataTreeCandidateNode node) { final DataTreeCandidate candidate = DataTreeCandidates.newDataTreeCandidate(path, node); for (AbstractDOMDataTreeChangeListenerRegistration reg : registrations) { @@ -59,13 +63,15 @@ final class InMemoryDOMStoreTreeChangePublisher extends AbstractDOMStoreTreeChan } @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 } - ListenerRegistration registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) { + ListenerRegistration registerTreeChangeListener( + final YangInstanceIdentifier treeId, final L listener, final DataTreeSnapshot snapshot) { final AbstractDOMDataTreeChangeListenerRegistration reg = registerTreeChangeListener(treeId, listener); final Optional> node = snapshot.readNode(YangInstanceIdentifier.EMPTY); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java index 6b2e4d51c5..22654d0ea9 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeEventsTask.java @@ -32,8 +32,8 @@ import org.slf4j.LoggerFactory; /** * Resolve Data Change Events based on modifications and listeners * - * Computes data change events for all affected registered listeners in data - * tree. + *

+ * Computes data change events for all affected registered listeners in data tree. */ @Beta public final class ResolveDataChangeEventsTask { @@ -52,8 +52,9 @@ public final class ResolveDataChangeEventsTask { /** * Resolves and submits notification tasks to the specified manager. */ - public synchronized void resolve(final NotificationManager, DOMImmutableDataChangeEvent> manager) { - try (final RegistrationTreeSnapshot> w = listenerRoot.takeSnapshot()) { + public synchronized void resolve(final NotificationManager, + DOMImmutableDataChangeEvent> manager) { + try (RegistrationTreeSnapshot> w = listenerRoot.takeSnapshot()) { // Defensive: reset internal state collectedEvents = ArrayListMultimap.create(); @@ -65,7 +66,8 @@ public final class ResolveDataChangeEventsTask { * Convert to tasks, but be mindful of multiple values -- those indicate multiple * wildcard matches, which need to be merged. */ - for (Entry, Collection> e : collectedEvents.asMap().entrySet()) { + for (Entry, Collection> e : + collectedEvents.asMap().entrySet()) { final Collection col = e.getValue(); final DOMImmutableDataChangeEvent event; @@ -87,7 +89,7 @@ public final class ResolveDataChangeEventsTask { } /** - * Resolves data change event for supplied node + * Resolves data change event for supplied node. * * @param path * Path to current node in tree @@ -116,31 +118,33 @@ public final class ResolveDataChangeEventsTask { // 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 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 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 beforeNode = (NormalizedNode)maybeBefore.get(); - resolveSameEventRecursivelly(state, beforeNode, DOMImmutableDataChangeEvent.getRemoveEventFactory()); - return true; - case UNMODIFIED: - return false; + @SuppressWarnings({ "unchecked", "rawtypes" }) + final NormalizedNode 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())); @@ -156,11 +160,14 @@ public final class ResolveDataChangeEventsTask { * 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> beforeCont = (NormalizedNodeContainer>) beforeData; + NormalizedNodeContainer> beforeCont = + (NormalizedNodeContainer>) beforeData; @SuppressWarnings("unchecked") - NormalizedNodeContainer> afterCont = (NormalizedNodeContainer>) afterData; + NormalizedNodeContainer> afterCont = + (NormalizedNodeContainer>) afterData; return resolveNodeContainerReplaced(state, beforeCont, afterCont); } @@ -172,7 +179,8 @@ public final class ResolveDataChangeEventsTask { } 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; @@ -205,7 +213,8 @@ public final class ResolveDataChangeEventsTask { * created. */ if (!beforeCont.getChild(childId).isPresent()) { - resolveSameEventRecursivelly(state.child(childId), afterChild, DOMImmutableDataChangeEvent.getCreateEventFactory()); + resolveSameEventRecursivelly(state.child(childId), afterChild, + DOMImmutableDataChangeEvent.getCreateEventFactory()); childChanged = true; } } @@ -247,7 +256,8 @@ public final class ResolveDataChangeEventsTask { // Node has children, so we will try to resolve it's children // changes. @SuppressWarnings("unchecked") - NormalizedNodeContainer> container = (NormalizedNodeContainer>) node; + NormalizedNodeContainer> container = + (NormalizedNodeContainer>) node; for (NormalizedNode child : container.getValue()) { final PathArgument childId = child.getIdentifier(); @@ -262,12 +272,15 @@ public final class ResolveDataChangeEventsTask { 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> maybeBefore = modification.getDataBefore(); final Optional> 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()); @@ -279,22 +292,24 @@ public final class ResolveDataChangeEventsTask { 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; } } @@ -302,7 +317,8 @@ public final class ResolveDataChangeEventsTask { 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); } @@ -310,7 +326,8 @@ public final class ResolveDataChangeEventsTask { 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); } } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java index 1547ad122a..a644dca91d 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java @@ -37,12 +37,14 @@ import org.slf4j.LoggerFactory; */ final class ResolveDataChangeState { private static final Logger LOG = LoggerFactory.getLogger(ResolveDataChangeState.class); + /** - * Inherited from all parents + * Inherited from all parents. */ private final Iterable inheritedSub; + /** - * Inherited from immediate parent + * Inherited from immediate parent. */ private final Collection inheritedOne; private final YangInstanceIdentifier nodeId; @@ -70,15 +72,17 @@ final class ResolveDataChangeState { 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; } } } @@ -100,9 +104,9 @@ final class ResolveDataChangeState { * * @param rootId root instance identifier * @param registrationTreeNode root node - * @return */ - public static ResolveDataChangeState initial(final YangInstanceIdentifier rootId, final RegistrationTreeNode> registrationTreeNode) { + public static ResolveDataChangeState initial(final YangInstanceIdentifier rootId, + final RegistrationTreeNode> registrationTreeNode) { return new ResolveDataChangeState(rootId, Collections.emptyList(), Collections.emptyList(), Collections.singletonList(registrationTreeNode)); } @@ -150,7 +154,7 @@ final class ResolveDataChangeState { } /** - * Get the current path + * Get the current path. * * @return Current path. */ @@ -195,8 +199,6 @@ final class ResolveDataChangeState { /** * Add an event to all current listeners. - * - * @param event */ public void addEvent(final DOMImmutableDataChangeEvent event) { // Subtree builders get always notified @@ -254,7 +256,8 @@ final class ResolveDataChangeState { LOG.trace("Collected events {}", map); } - private static Collection>> getListenerChildrenWildcarded(final Collection>> parentNodes, + private static Collection>> getListenerChildrenWildcarded( + final Collection>> parentNodes, final PathArgument child) { if (parentNodes.isEmpty()) { return Collections.emptyList(); @@ -269,7 +272,9 @@ final class ResolveDataChangeState { return result; } - private static void addChildNodes(final List>> result, final Collection>> parentNodes, final PathArgument childIdentifier) { + private static void addChildNodes(final List>> result, + final Collection>> parentNodes, + final PathArgument childIdentifier) { for (RegistrationTreeNode> node : parentNodes) { RegistrationTreeNode> child = node.getExactChild(childIdentifier); if (child != null) { diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/jmx/InMemoryDataStoreStats.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/jmx/InMemoryDataStoreStats.java index cb91b4c81a..f4af794b46 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/jmx/InMemoryDataStoreStats.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/jmx/InMemoryDataStoreStats.java @@ -24,14 +24,14 @@ public class InMemoryDataStoreStats implements AutoCloseable { 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(); } @@ -43,11 +43,11 @@ public class InMemoryDataStoreStats implements AutoCloseable { @Override public void close() throws Exception { - if(notificationExecutorStatsBean != null) { + if (notificationExecutorStatsBean != null) { notificationExecutorStatsBean.unregisterMBean(); } - if(notificationManagerStatsBean != null) { + if (notificationManagerStatsBean != null) { notificationManagerStatsBean.unregisterMBean(); } } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataChangeListenerRegistrationImpl.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataChangeListenerRegistrationImpl.java index 5c06b00a41..55b4ad2de4 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataChangeListenerRegistrationImpl.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/DataChangeListenerRegistrationImpl.java @@ -13,8 +13,9 @@ import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -abstract class DataChangeListenerRegistrationImpl>> extends AbstractListenerRegistration implements DataChangeListenerRegistration { - public DataChangeListenerRegistrationImpl(final T listener) { +abstract class DataChangeListenerRegistrationImpl>> extends AbstractListenerRegistration implements DataChangeListenerRegistration { + DataChangeListenerRegistrationImpl(final T listener) { super(listener); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java index da3e3b40bf..a67040e929 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java @@ -43,8 +43,9 @@ public final class ListenerTree extends AbstractRegistrationTree>> DataChangeListenerRegistration registerDataChangeListener(final YangInstanceIdentifier path, - final L listener, final DataChangeScope scope) { + public >> + DataChangeListenerRegistration registerDataChangeListener(final YangInstanceIdentifier path, + final L listener, final DataChangeScope scope) { // Take the write lock takeLock(); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java index a500f257d6..1146458171 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/AbstractDataChangeListenerTest.java @@ -67,7 +67,7 @@ public abstract class AbstractDataChangeListenerTest { @After public void tearDown() { - if( this.dclExecutorService != null ) { + if (this.dclExecutorService != null) { this.dclExecutorService.shutdownNow(); } } @@ -120,15 +120,15 @@ public abstract class AbstractDataChangeListenerTest { } - protected static void assertNotContains(final Collection set, final K... values) { + protected static void assertContains(final Map map, final K... values) { for (final K key : values) { - Assert.assertFalse(set.contains(key)); + Assert.assertTrue(map.containsKey(key)); } } - protected static void assertContains(final Map map, final K... values) { + protected static void assertNotContains(final Collection set, final K... values) { for (final K key : values) { - Assert.assertTrue(map.containsKey(key)); + Assert.assertFalse(set.contains(key)); } } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java index 63e1498c0e..ed17aa55cf 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DatastoreTestTask.java @@ -10,10 +10,11 @@ package org.opendaylight.controller.md.sal.dom.store.impl; 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; @@ -25,9 +26,6 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; 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; @@ -50,8 +48,8 @@ public class DatastoreTestTask { } public DatastoreTestTask changeListener(final YangInstanceIdentifier path, final DataChangeScope scope, - final AsyncDataChangeListener> changeListener) { - this.changeListener = changeListener; + final AsyncDataChangeListener> listener) { + this.changeListener = listener; this.changePath = path; this.changeScope = scope; return this; @@ -63,27 +61,27 @@ public class DatastoreTestTask { 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); } @@ -113,25 +111,16 @@ public class DatastoreTestTask { } } - public AsyncDataChangeEvent> 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> 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 ); } } @@ -156,8 +145,8 @@ public class DatastoreTestTask { private final class ChangeEventListener implements AsyncDataChangeListener> { - protected final SettableFuture>> receivedChange = SettableFuture - .create(); + protected final SettableFuture>> + receivedChange = SettableFuture.create(); @Override public void onDataChanged(final AsyncDataChangeEvent> change) { diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DefaultDataChangeListenerTestSuite.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DefaultDataChangeListenerTestSuite.java index c82fff3662..74014493fa 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DefaultDataChangeListenerTestSuite.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/DefaultDataChangeListenerTestSuite.java @@ -7,8 +7,6 @@ */ package org.opendaylight.controller.md.sal.dom.store.impl; -import java.util.concurrent.ExecutionException; - import org.junit.Test; /** @@ -23,7 +21,7 @@ public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataCha * * @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 { @@ -34,45 +32,44 @@ public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataCha 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 { @@ -83,8 +80,7 @@ public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataCha 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 { @@ -95,8 +91,7 @@ public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataCha 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 { @@ -108,8 +103,7 @@ public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataCha 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 { @@ -121,6 +115,5 @@ public abstract class DefaultDataChangeListenerTestSuite extends AbstractDataCha nestedListExistsRootDeleted(task); } - protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws InterruptedException, - ExecutionException; + protected abstract void nestedListExistsRootDeleted(DatastoreTestTask task) throws Exception; } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java index 5734f9ac5b..72e06d63a8 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDataStoreTest.java @@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals; 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; @@ -21,7 +22,6 @@ import org.junit.Before; 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; @@ -33,12 +33,10 @@ import org.opendaylight.controller.sal.core.spi.data.SnapshotBackedWriteTransact 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; @@ -65,20 +63,20 @@ public class InMemoryDataStoreTest { 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>> 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>> readTxContainer = readTx.read(TestModel.TEST_PATH); @@ -91,13 +89,13 @@ public class InMemoryDataStoreTest { 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>> writeTxContainer = writeTx.read(TestModel.TEST_PATH); @@ -118,72 +116,70 @@ public class InMemoryDataStoreTest { 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> afterCommitRead = domStore.newReadOnlyTransaction(). - read(TestModel.TEST_PATH ).get(); - assertEquals( "After commit read: isPresent", true, afterCommitRead.isPresent() ); + Optional> 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> 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> 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()); } @@ -191,15 +187,15 @@ public class InMemoryDataStoreTest { 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 exists = writeTx.exists(TestModel.TEST_PATH); @@ -213,7 +209,7 @@ public class InMemoryDataStoreTest { ready.commit().get(); DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); - assertNotNull( readTx ); + assertNotNull(readTx); exists = readTx.exists(TestModel.TEST_PATH); @@ -225,7 +221,7 @@ public class InMemoryDataStoreTest { public void testExistsForNonExistingData() throws Exception { DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction(); - assertNotNull( writeTx ); + assertNotNull(writeTx); CheckedFuture exists = writeTx.exists(TestModel.TEST_PATH); @@ -233,7 +229,7 @@ public class InMemoryDataStoreTest { assertEquals(false, exists.checkedGet()); DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction(); - assertNotNull( readTx ); + assertNotNull(readTx); exists = readTx.exists(TestModel.TEST_PATH); @@ -241,77 +237,72 @@ public class InMemoryDataStoreTest { 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 mockReady = Mockito.mock( TransactionReadyPrototype.class ); - DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadWriteTransaction("1", false, mockSnapshot, mockReady); + TransactionReadyPrototype 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(); @@ -319,10 +310,10 @@ public class InMemoryDataStoreTest { 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(); @@ -374,77 +365,68 @@ public class InMemoryDataStoreTest { 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); } @@ -457,12 +439,12 @@ public class InMemoryDataStoreTest { assertTestContainerWrite(txOne); assertTestContainerWrite(txTwo); - /** + /* * Commits transaction */ assertThreePhaseCommit(txOne.ready()); - /** + /* * Asserts that txTwo could not be commited */ assertFalse(txTwo.ready().canCommit().get()); @@ -477,10 +459,8 @@ public class InMemoryDataStoreTest { private static Optional> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx) throws InterruptedException, ExecutionException { - /** - * + /* * Writes /test in writeTx - * */ writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); @@ -497,5 +477,4 @@ public class InMemoryDataStoreTest { assertTrue(writeTxContainer.get().isPresent()); return writeTxContainer.get(); } - } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java index 43b339e506..7d496568c6 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/RootScopeSubtreeTest.java @@ -7,8 +7,6 @@ */ 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; @@ -22,7 +20,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { } @Override - public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), TOP_LEVEL, path(FOO), path(FOO, BAR)); @@ -31,8 +29,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { } @Override - public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -42,8 +39,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { } @Override - protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -53,8 +49,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { } @Override - protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -64,8 +59,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { } @Override - protected void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -75,7 +69,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { } @Override - protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO,BAZ)); @@ -85,7 +79,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { } @Override - protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO,BAR),path(FOO,BAZ)); @@ -95,7 +89,7 @@ public class RootScopeSubtreeTest extends DefaultDataChangeListenerTestSuite { } @Override - protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO_SIBLING)); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java index 9910039e2e..0b55980985 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/SchemaUpdateForTransactionTest.java @@ -8,9 +8,8 @@ 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; @@ -30,25 +29,20 @@ public class SchemaUpdateForTransactionTest { 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); } /** @@ -57,16 +51,14 @@ public class SchemaUpdateForTransactionTest { * then triggering update of global schema context * and then performing write (according to new module). * + *

* 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); @@ -78,15 +70,11 @@ public class SchemaUpdateForTransactionTest { // 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)); - } - } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestDCLExecutorService.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestDCLExecutorService.java index a01933c295..cbeff79d12 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestDCLExecutorService.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestDCLExecutorService.java @@ -13,7 +13,7 @@ import com.google.common.util.concurrent.MoreExecutors; 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 */ @@ -26,7 +26,7 @@ public class TestDCLExecutorService extends ForwardingExecutorService { private final ExecutorService postSetupExecutor; - public TestDCLExecutorService( final ExecutorService postSetupExecutor ) { + public TestDCLExecutorService(final ExecutorService postSetupExecutor) { this.postSetupExecutor = postSetupExecutor; } @@ -39,4 +39,4 @@ public class TestDCLExecutorService extends ForwardingExecutorService { // Test setup complete - switch to the real executor. currentExecutor = postSetupExecutor; } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java index 96749b037d..8e36a8c377 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/TestModel.java @@ -12,7 +12,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; 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"); @@ -39,6 +39,9 @@ public class TestModel { private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; + private TestModel() { + } + public static SchemaContext createTestContext() { return YangParserTestUtils.parseYangResource(DATASTORE_TEST_YANG); } diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java index ddbba76ae0..b9ce0accf8 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeBaseTest.java @@ -10,7 +10,6 @@ package org.opendaylight.controller.md.sal.dom.store.impl; 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; @@ -28,7 +27,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite } @Override - public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -38,7 +37,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite * 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()); @@ -46,8 +45,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite } @Override - public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); @@ -67,8 +65,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite } @Override - protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); @@ -83,8 +80,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite } @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, @@ -97,8 +93,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite } @Override - public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -115,7 +110,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite } @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], @@ -128,7 +123,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite } @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], @@ -141,7 +136,7 @@ public class WildcardedScopeBaseTest extends DefaultDataChangeListenerTestSuite } @Override - protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO_SIBLING)); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeOneTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeOneTest.java index 75f9fce612..02797c2761 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeOneTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeOneTest.java @@ -10,7 +10,6 @@ package org.opendaylight.controller.md.sal.dom.store.impl; 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; @@ -29,7 +28,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { } @Override - public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -44,8 +43,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { } @Override - public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); @@ -65,8 +63,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { } @Override - protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); @@ -81,8 +78,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { } @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, @@ -96,8 +92,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { } @Override - public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -110,7 +105,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { } @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], @@ -123,7 +118,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { } @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], @@ -136,7 +131,7 @@ public class WildcardedScopeOneTest extends DefaultDataChangeListenerTestSuite { } @Override - protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO_SIBLING)); diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeSubtreeTest.java b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeSubtreeTest.java index a7fa24f293..31a9f9c979 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeSubtreeTest.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/test/java/org/opendaylight/controller/md/sal/dom/store/impl/WildcardedScopeSubtreeTest.java @@ -11,8 +11,6 @@ import static org.junit.Assert.assertFalse; 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; @@ -30,7 +28,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui } @Override - public void putTopLevelOneNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + public void putTopLevelOneNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -42,8 +40,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui } @Override - public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + public void replaceTopLevelNestedChanged(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); @@ -56,8 +53,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui } @Override - protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void putTopLevelWithTwoNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); @@ -71,8 +67,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui } @Override - protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + protected void twoNestedExistsOneIsDeleted(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertNotNull(change); @@ -83,8 +78,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui } @Override - public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws InterruptedException, - ExecutionException { + public void nestedListExistsRootDeleted(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); @@ -96,7 +90,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui } @Override - protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + protected void existingOneNestedWriteAdditionalNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO,BAZ)); @@ -107,7 +101,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui } @Override - protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + protected void existingTopWriteTwoNested(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO,BAR),path(FOO,BAZ)); @@ -117,7 +111,7 @@ public class WildcardedScopeSubtreeTest extends DefaultDataChangeListenerTestSui } @Override - protected void existingTopWriteSibling(final DatastoreTestTask task) throws InterruptedException, ExecutionException { + protected void existingTopWriteSibling(final DatastoreTestTask task) throws Exception { AsyncDataChangeEvent> change = task.getChangeEvent(); assertContains(change.getCreatedData(), path(FOO_SIBLING));