From c37d38386002ed12b279938051813f99a4de70ff Mon Sep 17 00:00:00 2001 From: janab Date: Tue, 23 Aug 2016 14:03:32 -0700 Subject: [PATCH] checkStyleViolationSeverity=error implemented for mdsal-dom-broker Resolved the merge conflicts. Implemented code review comments. Implemented another set of code review comments. Change-Id: I3eecb17342e4fd7f4736ca67bc57f01f91115c0f Signed-off-by: Brinda Jana (cherry picked from commit f2910f31928b7f29c7e3593065ba35460052c38f) --- dom/mdsal-dom-broker/pom.xml | 7 ++ .../dom/broker/AbstractDOMDataBroker.java | 51 +++++----- ...tractDOMForwardedCompositeTransaction.java | 12 +-- ...bstractDOMForwardedTransactionFactory.java | 36 ++++--- .../AbstractDOMRpcRoutingTableEntry.java | 29 +++--- .../dom/broker/CommitCoordinationTask.java | 49 +++++----- .../DOMDataBrokerTransactionChainImpl.java | 24 ++--- .../DOMForwardedReadOnlyTransaction.java | 9 +- .../broker/DOMForwardedWriteTransaction.java | 22 +++-- .../dom/broker/DOMMountPointServiceImpl.java | 16 ++-- .../dom/broker/DOMNotificationRouter.java | 96 ++++++++++++------- .../broker/DOMNotificationRouterEvent.java | 11 ++- .../mdsal/dom/broker/DOMRpcRouter.java | 50 ++++++---- .../mdsal/dom/broker/DOMRpcRoutingTable.java | 37 +++---- .../broker/GlobalDOMRpcRoutingTableEntry.java | 18 ++-- .../broker/RoutedDOMRpcRoutingTableEntry.java | 16 +++- .../dom/broker/SerializedDOMDataBroker.java | 30 +++--- .../mdsal/dom/broker/ShardRegistration.java | 3 +- .../mdsal/dom/broker/ShardedDOMDataTree.java | 26 +++-- .../ShardedDOMDataTreeListenerContext.java | 2 +- .../broker/ShardedDOMDataTreeProducer.java | 13 ++- .../ShardedDOMDataTreeWriteTransaction.java | 15 +-- .../ShardedDOMReadTransactionAdapter.java | 9 +- .../ShardedDOMTransactionChainAdapter.java | 6 +- .../ShardedDOMWriteTransactionAdapter.java | 3 +- .../TransactionChainReadTransaction.java | 14 +-- .../TransactionChainWriteTransaction.java | 10 +- ...ransactionCommitFailedExceptionMapper.java | 1 - .../UnknownDOMRpcRoutingTableEntry.java | 15 +-- .../osgi/OsgiBundleScanningSchemaService.java | 43 +++++---- .../broker/osgi/SchemaServiceActivator.java | 5 +- .../BlockingTransactionChainListener.java | 1 + .../mdsal/dom/broker/DOMBrokerTest.java | 37 +++---- .../dom/broker/DOMDataTreeListenerTest.java | 7 +- .../dom/broker/DOMNotificationRouterTest.java | 1 + .../dom/broker/DOMTransactionChainTest.java | 38 ++++---- .../GlobalDOMRpcRoutingTableEntryTest.java | 4 +- .../RoutedDOMRpcRoutingTableEntryTest.java | 1 + ...rdedDOMDataTreeProducerMultiShardTest.java | 63 +++++++----- .../broker/ShardedDOMDataTreeShardTest.java | 3 +- .../dom/broker/ShardedDOMDataTreeTest.java | 27 ++++-- .../ShardedDOMDataWriteTransactionTest.java | 9 +- .../ShardedDOMReadTransactionAdapterTest.java | 2 +- .../mdsal/dom/broker/TestCommitCohort.java | 9 +- .../mdsal/dom/broker/TestUtils.java | 6 +- .../OsgiBundleScanningSchemaServiceTest.java | 1 + .../osgi/SchemaServiceActivatorTest.java | 1 + 47 files changed, 518 insertions(+), 370 deletions(-) diff --git a/dom/mdsal-dom-broker/pom.xml b/dom/mdsal-dom-broker/pom.xml index 8fa80c37e4..5db13ac39a 100644 --- a/dom/mdsal-dom-broker/pom.xml +++ b/dom/mdsal-dom-broker/pom.xml @@ -80,6 +80,13 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMDataBroker.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMDataBroker.java index 67ec1e1206..115cb9805a 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMDataBroker.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMDataBroker.java @@ -9,10 +9,12 @@ package org.opendaylight.mdsal.dom.broker; import static com.google.common.base.Preconditions.checkState; -import org.opendaylight.mdsal.dom.spi.store.DOMStore; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher; - +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.EnumMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.common.api.TransactionChainListener; import org.opendaylight.mdsal.dom.api.DOMDataBroker; @@ -21,17 +23,15 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMTransactionChain; -import com.google.common.collect.ImmutableMap; -import java.util.Collections; -import java.util.EnumMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.atomic.AtomicLong; +import org.opendaylight.mdsal.dom.spi.store.DOMStore; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransactionFactory implements DOMDataBroker, AutoCloseable { +public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransactionFactory + implements DOMDataBroker, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMDataBroker.class); private final AtomicLong txNum = new AtomicLong(); @@ -51,15 +51,18 @@ public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransact } if (treeChange) { - extensions = ImmutableMap., DOMDataBrokerExtension>of(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { - @Override - public ListenerRegistration registerDataTreeChangeListener(final DOMDataTreeIdentifier treeId, final L listener) { - DOMStore publisher = getTxFactories().get(treeId.getDatastoreType()); - checkState(publisher != null, "Requested logical data store is not available."); - - return ((DOMStoreTreeChangePublisher)publisher).registerTreeChangeListener(treeId.getRootIdentifier(), listener); - } - }); + extensions = ImmutableMap., DOMDataBrokerExtension>of( + DOMDataTreeChangeService.class, new DOMDataTreeChangeService() { + @Override + public ListenerRegistration + registerDataTreeChangeListener(final DOMDataTreeIdentifier treeId, final L listener) { + DOMStore publisher = getTxFactories().get(treeId.getDatastoreType()); + checkState(publisher != null, "Requested logical data store is not available."); + + return ((DOMStoreTreeChangePublisher)publisher).registerTreeChangeListener( + treeId.getRootIdentifier(), listener); + } + }); } else { extensions = Collections.emptyMap(); } @@ -69,14 +72,15 @@ public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransact this.closeable = closeable; } + @SuppressWarnings("checkstyle:IllegalCatch") @Override public void close() { super.close(); - if(closeable != null) { + if (closeable != null) { try { closeable.close(); - } catch(Exception e) { + } catch (Exception e) { LOG.debug("Error closing instance", e); } } @@ -96,7 +100,8 @@ public abstract class AbstractDOMDataBroker extends AbstractDOMForwardedTransact public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) { checkNotClosed(); - final Map backingChains = new EnumMap<>(LogicalDatastoreType.class); + final Map backingChains = + new EnumMap<>(LogicalDatastoreType.class); for (Entry entry : getTxFactories().entrySet()) { backingChains.put(entry.getKey(), entry.getValue().createTransactionChain()); } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMForwardedCompositeTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMForwardedCompositeTransaction.java index d2b809369e..747ef3f4bf 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMForwardedCompositeTransaction.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMForwardedCompositeTransaction.java @@ -8,18 +8,18 @@ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction; - -import org.opendaylight.mdsal.common.api.AsyncTransaction; import com.google.common.base.Preconditions; import java.util.Collection; import java.util.Map; +import org.opendaylight.mdsal.common.api.AsyncTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; /** * Composite DOM Transaction backed by {@link DOMStoreTransaction}. * + *

* Abstract base for composite transaction, which provides access only to common * functionality as retrieval of subtransaction, close method and retrieval of * identifier. @@ -36,7 +36,6 @@ abstract class AbstractDOMForwardedCompositeTransaction * Provides an convenience common implementation for composite DOM Transactions, * where subtransaction is identified by {@link LogicalDatastoreType} type and * implementation of subtransaction is provided by @@ -53,7 +52,7 @@ abstract class AbstractDOMForwardedTransactionFactory * Callback invoked when {@link DOMDataTreeWriteTransaction#submit()} is invoked on transaction * created by this factory. * @@ -72,20 +72,24 @@ abstract class AbstractDOMForwardedTransactionFactory submit(final DOMDataTreeWriteTransaction transaction, + protected abstract CheckedFuture submit( + final DOMDataTreeWriteTransaction transaction, final Collection cohorts); /** - * Creates a new composite read-only transaction + * Creates a new composite read-only transaction. * + *

* Creates a new composite read-only transaction backed by one transaction per factory in * {@link #getTxFactories()}. * + *

* Subtransaction for reading is selected by supplied {@link LogicalDatastoreType} as parameter * for - * {@link DOMDataTreeReadTransaction#read(LogicalDatastoreType, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} - * . + * {@link DOMDataTreeReadTransaction#read(LogicalDatastoreType, + * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} * + *

* Id of returned transaction is retrieved via {@link #newTransactionIdentifier()}. * * @return New composite read-only transaction. @@ -112,17 +116,24 @@ abstract class AbstractDOMForwardedTransactionFactory *

  • - * {@link DOMDataTreeWriteTransaction#put(LogicalDatastoreType, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} + * {@link DOMDataTreeWriteTransaction#put(LogicalDatastoreType, + * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, + * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} * - backing subtransaction is selected by {@link LogicalDatastoreType}, - * {@link DOMStoreWriteTransaction#write(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} + * {@link DOMStoreWriteTransaction#write(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, + * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} * is invoked on selected subtransaction.
  • *
  • - * {@link DOMDataTreeWriteTransaction#merge(LogicalDatastoreType, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} + * {@link DOMDataTreeWriteTransaction#merge(LogicalDatastoreType, + * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, + * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} * - backing subtransaction is selected by {@link LogicalDatastoreType}, - * {@link DOMStoreWriteTransaction#merge(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} + * {@link DOMStoreWriteTransaction#merge(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, + * org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)} * is invoked on selected subtransaction.
  • *
  • - * {@link DOMDataTreeWriteTransaction#delete(LogicalDatastoreType, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} + * {@link DOMDataTreeWriteTransaction#delete(LogicalDatastoreType, + * org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} * - backing subtransaction is selected by {@link LogicalDatastoreType}, * {@link DOMStoreWriteTransaction#delete(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)} * is invoked on selected subtransaction. @@ -132,6 +143,7 @@ abstract class AbstractDOMForwardedTransactionFactory * * + *

    * Id of returned transaction is generated via {@link #newTransactionIdentifier()}. * * @return New composite write-only transaction associated with this factory. diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRpcRoutingTableEntry.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRpcRoutingTableEntry.java index 1daf52d4db..021dd96b11 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRpcRoutingTableEntry.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/AbstractDOMRpcRoutingTableEntry.java @@ -7,10 +7,6 @@ */ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.api.DOMRpcException; -import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; -import org.opendaylight.mdsal.dom.api.DOMRpcResult; - import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; @@ -20,6 +16,9 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.opendaylight.mdsal.dom.api.DOMRpcException; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -28,7 +27,8 @@ abstract class AbstractDOMRpcRoutingTableEntry { private final Map> impls; private final SchemaPath schemaPath; - protected AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath, final Map> impls) { + protected AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath, final Map> impls) { this.schemaPath = Preconditions.checkNotNull(schemaPath); this.impls = Preconditions.checkNotNull(impls); } @@ -54,12 +54,14 @@ abstract class AbstractDOMRpcRoutingTableEntry { } /** + * This method adds the given DOMRpcImplementation instance for the given list RPC identifiers. * - * @param implementation - * @param newRpcs List of new RPCs, must be mutable - * @return + * @param implementation the DOMRpcImplementation instance to add + * @param newRpcs the List of new RPCs that the DOMRpcImplementation provides, must be mutable + * @return a new instance of AbstractDOMRpcRoutingTableEntry with the additions */ - final AbstractDOMRpcRoutingTableEntry add(final DOMRpcImplementation implementation, final List newRpcs) { + final AbstractDOMRpcRoutingTableEntry add( + final DOMRpcImplementation implementation, final List newRpcs) { final Builder> vb = ImmutableMap.builder(); for (final Entry> ve : impls.entrySet()) { if (newRpcs.remove(ve.getKey())) { @@ -71,7 +73,7 @@ abstract class AbstractDOMRpcRoutingTableEntry { vb.put(ve); } } - for(final YangInstanceIdentifier ii : newRpcs) { + for (final YangInstanceIdentifier ii : newRpcs) { final ArrayList impl = new ArrayList<>(1); impl.add(implementation); vb.put(ii,impl); @@ -80,7 +82,8 @@ abstract class AbstractDOMRpcRoutingTableEntry { return newInstance(vb.build()); } - final AbstractDOMRpcRoutingTableEntry remove(final DOMRpcImplementation implementation, final List removed) { + final AbstractDOMRpcRoutingTableEntry remove( + final DOMRpcImplementation implementation, final List removed) { final Builder> vb = ImmutableMap.builder(); for (final Entry> ve : impls.entrySet()) { if (removed.remove(ve.getKey())) { @@ -101,5 +104,7 @@ abstract class AbstractDOMRpcRoutingTableEntry { } protected abstract CheckedFuture invokeRpc(final NormalizedNode input); - protected abstract AbstractDOMRpcRoutingTableEntry newInstance(final Map> impls); + + protected abstract AbstractDOMRpcRoutingTableEntry newInstance( + final Map> impls); } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/CommitCoordinationTask.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/CommitCoordinationTask.java index 694b8411a8..385697b9c2 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/CommitCoordinationTask.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/CommitCoordinationTask.java @@ -8,10 +8,6 @@ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; - -import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import com.google.common.util.concurrent.Futures; @@ -19,6 +15,9 @@ import com.google.common.util.concurrent.ListenableFuture; import java.util.Collection; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; +import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; +import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.util.DurationStatisticsTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,7 +27,7 @@ import org.slf4j.LoggerFactory; * support of cancellation. */ final class CommitCoordinationTask implements Callable { - private static enum Phase { + private enum Phase { canCommit, preCommit, doCommit, @@ -39,7 +38,7 @@ final class CommitCoordinationTask implements Callable { private final DurationStatisticsTracker commitStatTracker; private final DOMDataTreeWriteTransaction tx; - public CommitCoordinationTask(final DOMDataTreeWriteTransaction transaction, + CommitCoordinationTask(final DOMDataTreeWriteTransaction transaction, final Collection cohorts, final DurationStatisticsTracker commitStatTracker) { this.tx = Preconditions.checkNotNull(transaction, "transaction must not be null"); @@ -79,10 +78,10 @@ final class CommitCoordinationTask implements Callable { } /** - * * Invokes canCommit on underlying cohorts and blocks till * all results are returned. * + *

    * Valid state transition is from SUBMITTED to CAN_COMMIT, * if currentPhase is not SUBMITTED throws IllegalStateException. * @@ -104,11 +103,11 @@ final class CommitCoordinationTask implements Callable { } /** - * * Invokes canCommit on underlying cohorts and returns composite future * which will contains {@link Boolean#TRUE} only and only if * all cohorts returned true. * + *

    * Valid state transition is from SUBMITTED to CAN_COMMIT, * if currentPhase is not SUBMITTED throws IllegalStateException. * @@ -117,18 +116,18 @@ final class CommitCoordinationTask implements Callable { */ private ListenableFuture[] canCommitAll() { final ListenableFuture[] ops = new ListenableFuture[cohorts.size()]; - int i = 0; + int index = 0; for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) { - ops[i++] = cohort.canCommit(); + ops[index++] = cohort.canCommit(); } return ops; } /** - * * Invokes preCommit on underlying cohorts and blocks till * all results are returned. * + *

    * Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current * state is not CAN_COMMIT * throws IllegalStateException. @@ -140,7 +139,7 @@ final class CommitCoordinationTask implements Callable { private void preCommitBlocking() throws TransactionCommitFailedException { final ListenableFuture[] preCommitFutures = preCommitAll(); try { - for(final ListenableFuture future : preCommitFutures) { + for (final ListenableFuture future : preCommitFutures) { future.get(); } } catch (InterruptedException | ExecutionException e) { @@ -149,12 +148,11 @@ final class CommitCoordinationTask implements Callable { } /** - * * Invokes preCommit on underlying cohorts and returns future * which will complete once all preCommit on cohorts completed or * failed. * - * + *

    * Valid state transition is from CAN_COMMIT to PRE_COMMIT, if current * state is not CAN_COMMIT * throws IllegalStateException. @@ -164,18 +162,18 @@ final class CommitCoordinationTask implements Callable { */ private ListenableFuture[] preCommitAll() { final ListenableFuture[] ops = new ListenableFuture[cohorts.size()]; - int i = 0; + int index = 0; for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) { - ops[i++] = cohort.preCommit(); + ops[index++] = cohort.preCommit(); } return ops; } /** - * * Invokes commit on underlying cohorts and blocks till * all results are returned. * + *

    * Valid state transition is from PRE_COMMIT to COMMIT, if not throws * IllegalStateException. * @@ -186,7 +184,7 @@ final class CommitCoordinationTask implements Callable { private void commitBlocking() throws TransactionCommitFailedException { final ListenableFuture[] commitFutures = commitAll(); try { - for(final ListenableFuture future : commitFutures) { + for (final ListenableFuture future : commitFutures) { future.get(); } } catch (InterruptedException | ExecutionException e) { @@ -195,11 +193,11 @@ final class CommitCoordinationTask implements Callable { } /** - * * Invokes commit on underlying cohorts and returns future which * completes * once all commits on cohorts are completed. * + *

    * Valid state transition is from PRE_COMMIT to COMMIT, if not throws * IllegalStateException * @@ -207,9 +205,9 @@ final class CommitCoordinationTask implements Callable { */ private ListenableFuture[] commitAll() { final ListenableFuture[] ops = new ListenableFuture[cohorts.size()]; - int i = 0; + int index = 0; for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) { - ops[i++] = cohort.commit(); + ops[index++] = cohort.commit(); } return ops; } @@ -217,12 +215,14 @@ final class CommitCoordinationTask implements Callable { /** * Aborts transaction. * + *

    * Invokes {@link DOMStoreThreePhaseCommitCohort#abort()} on all * cohorts, blocks * for all results. If any of the abort failed throws * IllegalStateException, * which will contains originalCause as suppressed Exception. * + *

    * If aborts we're successful throws supplied exception * * @param originalCause @@ -236,7 +236,8 @@ final class CommitCoordinationTask implements Callable { * @throws IllegalStateException * if abort failed. */ - private void abortBlocking(final TransactionCommitFailedException originalCause) throws TransactionCommitFailedException { + private void abortBlocking(final TransactionCommitFailedException originalCause) + throws TransactionCommitFailedException { Exception cause = originalCause; try { abortAsyncAll().get(); @@ -259,9 +260,9 @@ final class CommitCoordinationTask implements Callable { private ListenableFuture abortAsyncAll() { final ListenableFuture[] ops = new ListenableFuture[cohorts.size()]; - int i = 0; + int index = 0; for (final DOMStoreThreePhaseCommitCohort cohort : cohorts) { - ops[i++] = cohort.abort(); + ops[index++] = cohort.abort(); } /* diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataBrokerTransactionChainImpl.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataBrokerTransactionChainImpl.java index ce3c203ea1..e30d39d6ec 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataBrokerTransactionChainImpl.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMDataBrokerTransactionChainImpl.java @@ -8,14 +8,6 @@ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; - -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.common.api.TransactionChainListener; -import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; -import org.opendaylight.mdsal.dom.api.DOMTransactionChain; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FutureCallback; @@ -25,6 +17,13 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.TransactionChainListener; +import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; +import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; +import org.opendaylight.mdsal.dom.api.DOMTransactionChain; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +35,7 @@ import org.slf4j.LoggerFactory; */ final class DOMDataBrokerTransactionChainImpl extends AbstractDOMForwardedTransactionFactory implements DOMTransactionChain { - private static enum State { + private enum State { RUNNING, CLOSING, CLOSED, @@ -57,6 +56,7 @@ final class DOMDataBrokerTransactionChainImpl extends AbstractDOMForwardedTransa private volatile int counter = 0; /** + *Constructor with args. * * @param chainId * ID of transaction chain @@ -71,7 +71,7 @@ final class DOMDataBrokerTransactionChainImpl extends AbstractDOMForwardedTransa * @throws NullPointerException * If any of arguments is null. */ - public DOMDataBrokerTransactionChainImpl(final long chainId, + DOMDataBrokerTransactionChainImpl(final long chainId, final Map chains, final AbstractDOMDataBroker broker, final TransactionChainListener listener) { super(chains); @@ -105,8 +105,8 @@ final class DOMDataBrokerTransactionChainImpl extends AbstractDOMForwardedTransa } @Override - public void onFailure(final Throwable t) { - transactionFailed(transaction, t); + public void onFailure(final Throwable throwable) { + transactionFailed(transaction, throwable); } }); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMForwardedReadOnlyTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMForwardedReadOnlyTransaction.java index 7f44782628..09777a23fa 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMForwardedReadOnlyTransaction.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMForwardedReadOnlyTransaction.java @@ -7,14 +7,13 @@ */ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; - -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.common.api.ReadFailedException; -import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; import com.google.common.base.Optional; import com.google.common.util.concurrent.CheckedFuture; import java.util.Map; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.ReadFailedException; +import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMForwardedWriteTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMForwardedWriteTransaction.java index 2295f5a314..6292f82e3a 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMForwardedWriteTransaction.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMForwardedWriteTransaction.java @@ -7,11 +7,6 @@ */ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; - -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; @@ -20,7 +15,11 @@ import java.util.Collection; import java.util.Map; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.slf4j.Logger; @@ -36,6 +35,7 @@ import org.slf4j.LoggerFactory; *

  • {@link #delete(LogicalDatastoreType, YangInstanceIdentifier)} *
  • {@link #merge(LogicalDatastoreType, YangInstanceIdentifier, NormalizedNode)} * + * *

    * {@link #submit()} will result in invocation of * {@link DOMDataCommitImplementation#submit(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction, Iterable)} @@ -48,8 +48,9 @@ import org.slf4j.LoggerFactory; class DOMForwardedWriteTransaction extends AbstractDOMForwardedCompositeTransaction implements DOMDataTreeWriteTransaction { @SuppressWarnings("rawtypes") - private static final AtomicReferenceFieldUpdater IMPL_UPDATER = - AtomicReferenceFieldUpdater.newUpdater(DOMForwardedWriteTransaction.class, AbstractDOMForwardedTransactionFactory.class, "commitImpl"); + private static final AtomicReferenceFieldUpdater IMPL_UPDATER = AtomicReferenceFieldUpdater.newUpdater( + DOMForwardedWriteTransaction.class, AbstractDOMForwardedTransactionFactory.class, "commitImpl"); @SuppressWarnings("rawtypes") private static final AtomicReferenceFieldUpdater FUTURE_UPDATER = AtomicReferenceFieldUpdater.newUpdater(DOMForwardedWriteTransaction.class, Future.class, "commitFuture"); @@ -68,6 +69,7 @@ class DOMForwardedWriteTransaction extends * set appropriately on {@link #submit()} and {@link #cancel()} via * {@link AtomicReferenceFieldUpdater#lazySet(Object, Object)}. * + *

    * Lazy set is safe for use because it is only referenced to in the * {@link #cancel()} slow path, where we will busy-wait for it. The * fast path gets the benefit of a store-store barrier instead of the @@ -82,7 +84,8 @@ class DOMForwardedWriteTransaction extends } @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, + final NormalizedNode data) { checkRunning(commitImpl); getSubtransaction(store).write(path, data); } @@ -94,7 +97,8 @@ class DOMForwardedWriteTransaction extends } @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, + final NormalizedNode data) { checkRunning(commitImpl); getSubtransaction(store).merge(path, data); } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java index 2888a2a07f..0968b1884a 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMMountPointServiceImpl.java @@ -8,18 +8,17 @@ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.spi.SimpleDOMMountPoint; - -import org.opendaylight.mdsal.dom.api.DOMMountPointListener; -import org.opendaylight.mdsal.dom.api.DOMMountPoint; -import org.opendaylight.mdsal.dom.api.DOMMountPointService; -import org.opendaylight.mdsal.dom.api.DOMService; import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.ClassToInstanceMap; import com.google.common.collect.MutableClassToInstanceMap; import java.util.HashMap; import java.util.Map; +import org.opendaylight.mdsal.dom.api.DOMMountPoint; +import org.opendaylight.mdsal.dom.api.DOMMountPointListener; +import org.opendaylight.mdsal.dom.api.DOMMountPointService; +import org.opendaylight.mdsal.dom.api.DOMService; +import org.opendaylight.mdsal.dom.spi.SimpleDOMMountPoint; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.util.ListenerRegistry; @@ -65,7 +64,8 @@ public class DOMMountPointServiceImpl implements DOMMountPointService { public ObjectRegistration registerMountPoint(final DOMMountPoint mountPoint) { synchronized (mountPoints) { - Preconditions.checkState(!mountPoints.containsKey(mountPoint.getIdentifier()), "Mount point already exists"); + Preconditions.checkState(!mountPoints.containsKey(mountPoint.getIdentifier()), + "Mount point already exists"); mountPoints.put(mountPoint.getIdentifier(), mountPoint); } notifyMountCreated(mountPoint.getIdentifier()); @@ -115,7 +115,7 @@ public class DOMMountPointServiceImpl implements DOMMountPointService { private final class MountRegistration implements ObjectRegistration { private final DOMMountPoint mountPoint; - public MountRegistration(final DOMMountPoint mountPoint) { + MountRegistration(final DOMMountPoint mountPoint) { this.mountPoint = mountPoint; } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouter.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouter.java index 5d6010d6e2..c1e4ac6a9a 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouter.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouter.java @@ -7,13 +7,6 @@ */ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener; -import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry; - -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.mdsal.dom.api.DOMNotificationListener; -import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService; -import org.opendaylight.mdsal.dom.api.DOMNotificationService; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; @@ -36,6 +29,12 @@ import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.mdsal.dom.api.DOMNotificationListener; +import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService; +import org.opendaylight.mdsal.dom.api.DOMNotificationService; +import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener; +import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.util.ListenerRegistry; @@ -47,14 +46,18 @@ import org.slf4j.LoggerFactory; * Joint implementation of {@link DOMNotificationPublishService} and {@link DOMNotificationService}. Provides * routing of notifications from publishers to subscribers. * + *

    * Internal implementation works by allocating a two-handler Disruptor. The first handler delivers notifications * to subscribed listeners and the second one notifies whoever may be listening on the returned future. Registration * state tracking is performed by a simple immutable multimap -- when a registration or unregistration occurs we * re-generate the entire map from scratch and set it atomically. While registrations/unregistrations synchronize * on this instance, notifications do not take any locks here. * - * The fully-blocking {@link #publish(long, DOMNotification, Collection)} and non-blocking {@link #offerNotification(DOMNotification)} - * are realized using the Disruptor's native operations. The bounded-blocking {@link #offerNotification(DOMNotification, long, TimeUnit)} + *

    + * The fully-blocking {@link #publish(long, DOMNotification, Collection)} + * and non-blocking {@link #offerNotification(DOMNotification)} + * are realized using the Disruptor's native operations. The bounded-blocking {@link + * #offerNotification(DOMNotification, long, TimeUnit)} * is realized by arming a background wakeup interrupt. */ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificationPublishService, @@ -62,15 +65,19 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouter.class); private static final ListenableFuture NO_LISTENERS = Futures.immediateFuture(null); - private static final WaitStrategy DEFAULT_STRATEGY = PhasedBackoffWaitStrategy.withLock(1L, 30L, TimeUnit.MILLISECONDS); - private static final EventHandler DISPATCH_NOTIFICATIONS = new EventHandler() { + private static final WaitStrategy DEFAULT_STRATEGY = PhasedBackoffWaitStrategy.withLock( + 1L, 30L, TimeUnit.MILLISECONDS); + private static final EventHandler DISPATCH_NOTIFICATIONS = + new EventHandler() { @Override - public void onEvent(final DOMNotificationRouterEvent event, final long sequence, final boolean endOfBatch) throws Exception { + public void onEvent(final DOMNotificationRouterEvent event, final long sequence, + final boolean endOfBatch) throws Exception { event.deliverNotification(); } }; - private static final EventHandler NOTIFY_FUTURE = new EventHandler() { + private static final EventHandler NOTIFY_FUTURE = + new EventHandler() { @Override public void onEvent(final DOMNotificationRouterEvent event, final long sequence, final boolean endOfBatch) { event.setFuture(); @@ -79,14 +86,17 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati private final Disruptor disruptor; private final ExecutorService executor; - private volatile Multimap> listeners = ImmutableMultimap.of(); - private final ListenerRegistry subscriptionListeners = ListenerRegistry.create(); + private volatile Multimap> listeners = ImmutableMultimap.of(); + private final ListenerRegistry subscriptionListeners = + ListenerRegistry.create(); @SuppressWarnings("unchecked") private DOMNotificationRouter(final ExecutorService executor, final int queueDepth, final WaitStrategy strategy) { this.executor = Preconditions.checkNotNull(executor); - disruptor = new Disruptor<>(DOMNotificationRouterEvent.FACTORY, queueDepth, executor, ProducerType.MULTI, strategy); + disruptor = new Disruptor<>(DOMNotificationRouterEvent.FACTORY, + queueDepth, executor, ProducerType.MULTI, strategy); disruptor.handleEventsWith(DISPATCH_NOTIFICATIONS); disruptor.after(DISPATCH_NOTIFICATIONS).handleEventsWith(NOTIFY_FUTURE); disruptor.start(); @@ -98,7 +108,8 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati return new DOMNotificationRouter(executor, queueDepth, DEFAULT_STRATEGY); } - public static DOMNotificationRouter create(final int queueDepth, final long spinTime, final long parkTime, final TimeUnit unit) { + public static DOMNotificationRouter create(final int queueDepth, final long spinTime, + final long parkTime, final TimeUnit unit) { final ExecutorService executor = Executors.newCachedThreadPool(); final WaitStrategy strategy = PhasedBackoffWaitStrategy.withLock(spinTime, parkTime, unit); @@ -106,25 +117,28 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati } @Override - public synchronized ListenerRegistration registerNotificationListener(final T listener, final Collection types) { + public synchronized ListenerRegistration registerNotificationListener( + final T listener, final Collection types) { final ListenerRegistration reg = new AbstractListenerRegistration(listener) { @Override protected void removeRegistration() { final ListenerRegistration me = this; synchronized (DOMNotificationRouter.this) { - replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, new Predicate>() { - @Override - public boolean apply(final ListenerRegistration input) { - return input != me; - } - }))); + replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, + new Predicate>() { + @Override + public boolean apply(final ListenerRegistration input) { + return input != me; + } + }))); } } }; if (!types.isEmpty()) { - final Builder> b = ImmutableMultimap.builder(); + final Builder> b = + ImmutableMultimap.builder(); b.putAll(listeners); for (final SchemaPath t : types) { @@ -138,14 +152,15 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati } @Override - public ListenerRegistration registerNotificationListener(final T listener, final SchemaPath... types) { + public ListenerRegistration registerNotificationListener( + final T listener, final SchemaPath... types) { return registerNotificationListener(listener, Arrays.asList(types)); } /** - * Swaps registered listeners and triggers notification update + * Swaps registered listeners and triggers notification update. * - * @param newListeners + * @param newListeners is used to notify listenerTypes changed */ private void replaceListeners( final Multimap> newListeners) { @@ -153,8 +168,10 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati notifyListenerTypesChanged(newListeners.keySet()); } + @SuppressWarnings("checkstyle:IllegalCatch") private void notifyListenerTypesChanged(final Set typesAfter) { - final List> listenersAfter =ImmutableList.copyOf(subscriptionListeners.getListeners()); + final List> listenersAfter = + ImmutableList.copyOf(subscriptionListeners.getListeners()); executor.submit(new Runnable() { @Override @@ -184,7 +201,8 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati return subscriptionListeners.registerWithType(listener); } - private ListenableFuture publish(final long seq, final DOMNotification notification, final Collection> subscribers) { + private ListenableFuture publish(final long seq, final DOMNotification notification, + final Collection> subscribers) { final DOMNotificationRouterEvent event = disruptor.get(seq); final ListenableFuture future = event.initialize(notification, subscribers); disruptor.getRingBuffer().publish(seq); @@ -192,8 +210,10 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati } @Override - public ListenableFuture putNotification(final DOMNotification notification) throws InterruptedException { - final Collection> subscribers = listeners.get(notification.getType()); + public ListenableFuture putNotification(final DOMNotification notification) + throws InterruptedException { + final Collection> subscribers = + listeners.get(notification.getType()); if (subscribers.isEmpty()) { return NO_LISTENERS; } @@ -202,10 +222,12 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati return publish(seq, notification, subscribers); } - private ListenableFuture tryPublish(final DOMNotification notification, final Collection> subscribers) { + @SuppressWarnings("checkstyle:IllegalCatch") + private ListenableFuture tryPublish(final DOMNotification notification, + final Collection> subscribers) { final long seq; try { - seq = disruptor.getRingBuffer().tryNext(); + seq = disruptor.getRingBuffer().tryNext(); } catch (final InsufficientCapacityException e) { return DOMNotificationPublishService.REJECTED; } @@ -215,7 +237,8 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati @Override public ListenableFuture offerNotification(final DOMNotification notification) { - final Collection> subscribers = listeners.get(notification.getType()); + final Collection> subscribers = + listeners.get(notification.getType()); if (subscribers.isEmpty()) { return NO_LISTENERS; } @@ -226,7 +249,8 @@ public final class DOMNotificationRouter implements AutoCloseable, DOMNotificati @Override public ListenableFuture offerNotification(final DOMNotification notification, final long timeout, final TimeUnit unit) throws InterruptedException { - final Collection> subscribers = listeners.get(notification.getType()); + final Collection> subscribers = + listeners.get(notification.getType()); if (subscribers.isEmpty()) { return NO_LISTENERS; } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java index 4f95770df0..e75adebfd2 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java @@ -7,14 +7,13 @@ */ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.mdsal.dom.api.DOMNotificationListener; - import com.google.common.base.Preconditions; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; import com.lmax.disruptor.EventFactory; import java.util.Collection; +import org.opendaylight.mdsal.dom.api.DOMNotification; +import org.opendaylight.mdsal.dom.api.DOMNotificationListener; import org.opendaylight.yangtools.concepts.ListenerRegistration; /** @@ -22,7 +21,8 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; * so they do have mutable state. */ final class DOMNotificationRouterEvent { - public static final EventFactory FACTORY = new EventFactory() { + public static final EventFactory FACTORY = + new EventFactory() { @Override public DOMNotificationRouterEvent newInstance() { return new DOMNotificationRouterEvent(); @@ -37,7 +37,8 @@ final class DOMNotificationRouterEvent { // Hidden on purpose, initialized in initialize() } - ListenableFuture initialize(final DOMNotification notification, final Collection> subscribers) { + ListenableFuture initialize(final DOMNotification notification, + final Collection> subscribers) { this.notification = Preconditions.checkNotNull(notification); this.subscribers = Preconditions.checkNotNull(subscribers); this.future = SettableFuture.create(); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRouter.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRouter.java index d3a1af2a2f..8cf276faa7 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRouter.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRouter.java @@ -17,12 +17,12 @@ import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.ThreadFactoryBuilder; import java.util.Collection; import java.util.Collections; -import java.util.concurrent.Executors; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ThreadFactory; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; import javax.annotation.concurrent.GuardedBy; import org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener; import org.opendaylight.mdsal.dom.api.DOMRpcException; @@ -35,25 +35,22 @@ import org.opendaylight.mdsal.dom.api.DOMRpcService; import org.opendaylight.mdsal.dom.spi.AbstractDOMRpcImplementationRegistration; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; import org.opendaylight.yangtools.yang.model.api.SchemaPath; public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcProviderService, SchemaContextListener { - private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat("DOMRpcRouter-listener-%s").setDaemon(true).build(); + private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder().setNameFormat( + "DOMRpcRouter-listener-%s").setDaemon(true).build(); private final ExecutorService listenerNotifier = Executors.newSingleThreadExecutor(THREAD_FACTORY); @GuardedBy("this") private Collection> listeners = Collections.emptyList(); private volatile DOMRpcRoutingTable routingTable = DOMRpcRoutingTable.EMPTY; - @Override - public DOMRpcImplementationRegistration registerRpcImplementation(final T implementation, final DOMRpcIdentifier... rpcs) { - return registerRpcImplementation(implementation, ImmutableSet.copyOf(rpcs)); - } - - private static Collection notPresentRpcs(final DOMRpcRoutingTable table, final Collection candidates) { + private static Collection notPresentRpcs(final DOMRpcRoutingTable table, + final Collection candidates) { return ImmutableSet.copyOf(Collections2.filter(candidates, new Predicate() { @Override public boolean apply(final DOMRpcIdentifier input) { @@ -62,7 +59,8 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP })); } - private synchronized void removeRpcImplementation(final DOMRpcImplementation implementation, final Set rpcs) { + private synchronized void removeRpcImplementation(final DOMRpcImplementation implementation, + final Set rpcs) { final DOMRpcRoutingTable oldTable = routingTable; final DOMRpcRoutingTable newTable = oldTable.remove(implementation, rpcs); @@ -87,7 +85,14 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP } @Override - public synchronized DOMRpcImplementationRegistration registerRpcImplementation(final T implementation, final Set rpcs) { + public DOMRpcImplementationRegistration registerRpcImplementation( + final T implementation, final DOMRpcIdentifier... rpcs) { + return registerRpcImplementation(implementation, ImmutableSet.copyOf(rpcs)); + } + + @Override + public synchronized DOMRpcImplementationRegistration + registerRpcImplementation(final T implementation, final Set rpcs) { final DOMRpcRoutingTable oldTable = routingTable; final DOMRpcRoutingTable newTable = oldTable.add(implementation, rpcs); @@ -120,7 +125,8 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP } @Override - public CheckedFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { + public CheckedFuture invokeRpc(final SchemaPath type, + final NormalizedNode input) { return routingTable.invokeRpc(type, input); } @@ -134,7 +140,8 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP } @Override - public synchronized ListenerRegistration registerRpcListener(final T listener) { + public synchronized ListenerRegistration registerRpcListener( + final T listener) { final ListenerRegistration ret = new AbstractListenerRegistration(listener) { @Override protected void removeRegistration() { @@ -152,12 +159,13 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP @Override public void run() { for (final Entry> e : capturedRpcs.entrySet()) { - listener.onRpcAvailable(Collections2.transform(e.getValue(), new Function() { - @Override - public DOMRpcIdentifier apply(final YangInstanceIdentifier input) { - return DOMRpcIdentifier.create(e.getKey(), input); - } - })); + listener.onRpcAvailable(Collections2.transform(e.getValue(), + new Function() { + @Override + public DOMRpcIdentifier apply(final YangInstanceIdentifier input) { + return DOMRpcIdentifier.create(e.getKey(), input); + } + })); } } }); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRoutingTable.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRoutingTable.java index 795a3f83ec..b25ababfc8 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRoutingTable.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMRpcRoutingTable.java @@ -7,12 +7,6 @@ */ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.api.DOMRpcException; -import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; -import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; -import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.mdsal.dom.api.DOMRpcResult; - import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; @@ -29,6 +23,11 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.opendaylight.mdsal.dom.api.DOMRpcException; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -41,15 +40,16 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; final class DOMRpcRoutingTable { - private static final QName CONTEXT_REFERENCE = QName.create("urn:opendaylight:yang:extension:yang-ext", "2013-07-09", "context-reference").intern(); + private static final QName CONTEXT_REFERENCE = QName.create("urn:opendaylight:yang:extension:yang-ext", + "2013-07-09", "context-reference").intern(); static final DOMRpcRoutingTable EMPTY = new DOMRpcRoutingTable(); private static final Function> EXTRACT_IDENTIFIERS = new Function>() { - @Override - public Set apply(final AbstractDOMRpcRoutingTableEntry input) { - return input.registeredIdentifiers(); - } + @Override + public Set apply(final AbstractDOMRpcRoutingTableEntry input) { + return input.registeredIdentifiers(); + } }; private final Map rpcs; private final SchemaContext schemaContext; @@ -59,12 +59,14 @@ final class DOMRpcRoutingTable { schemaContext = null; } - private DOMRpcRoutingTable(final Map rpcs, final SchemaContext schemaContext) { + private DOMRpcRoutingTable(final Map rpcs, + final SchemaContext schemaContext) { this.rpcs = Preconditions.checkNotNull(rpcs); this.schemaContext = schemaContext; } - private static ListMultimap decomposeIdentifiers(final Set rpcs) { + private static ListMultimap decomposeIdentifiers( + final Set rpcs) { final ListMultimap ret = LinkedListMultimap.create(); for (DOMRpcIdentifier i : rpcs) { ret.put(i.getType(), i.getContextReference()); @@ -157,7 +159,8 @@ final class DOMRpcRoutingTable { return null; } - private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath key, final Map> implementations) { + private static AbstractDOMRpcRoutingTableEntry createRpcEntry(final SchemaContext context, final SchemaPath key, + final Map> implementations) { final RpcDefinition rpcDef = findRpcDefinition(context, key); if (rpcDef != null) { final ContainerSchemaNode input = rpcDef.getInput(); @@ -165,7 +168,8 @@ final class DOMRpcRoutingTable { for (DataSchemaNode c : input.getChildNodes()) { for (UnknownSchemaNode extension : c.getUnknownSchemaNodes()) { if (CONTEXT_REFERENCE.equals(extension.getNodeType())) { - final YangInstanceIdentifier keyId = YangInstanceIdentifier.builder().node(c.getQName()).build(); + final YangInstanceIdentifier keyId = + YangInstanceIdentifier.builder().node(c.getQName()).build(); return new RoutedDOMRpcRoutingTableEntry(rpcDef, keyId, implementations); } } @@ -181,7 +185,8 @@ final class DOMRpcRoutingTable { CheckedFuture invokeRpc(final SchemaPath type, final NormalizedNode input) { final AbstractDOMRpcRoutingTableEntry entry = rpcs.get(type); if (entry == null) { - return Futures.immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", type)); + return Futures.immediateFailedCheckedFuture( + new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", type)); } return entry.invokeRpc(input); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/GlobalDOMRpcRoutingTableEntry.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/GlobalDOMRpcRoutingTableEntry.java index b63f2563b4..b6dda99a3b 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/GlobalDOMRpcRoutingTableEntry.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/GlobalDOMRpcRoutingTableEntry.java @@ -7,15 +7,14 @@ */ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.api.DOMRpcException; -import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; -import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; -import org.opendaylight.mdsal.dom.api.DOMRpcResult; - import com.google.common.base.Preconditions; import com.google.common.util.concurrent.CheckedFuture; import java.util.List; import java.util.Map; +import org.opendaylight.mdsal.dom.api.DOMRpcException; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; @@ -24,14 +23,16 @@ final class GlobalDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntr private static final YangInstanceIdentifier ROOT = YangInstanceIdentifier.builder().build(); private final DOMRpcIdentifier rpcId; - private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId, final Map> impls) { + private GlobalDOMRpcRoutingTableEntry(final DOMRpcIdentifier rpcId, final Map> impls) { super(rpcId.getType(), impls); this.rpcId = Preconditions.checkNotNull(rpcId); } // We do not need the RpcDefinition, but this makes sure we do not // forward something we don't know to be an RPC. - GlobalDOMRpcRoutingTableEntry(final RpcDefinition def, final Map> impls) { + GlobalDOMRpcRoutingTableEntry(final RpcDefinition def, final Map> impls) { super(def.getPath(), impls); this.rpcId = DOMRpcIdentifier.create(def.getPath()); } @@ -42,7 +43,8 @@ final class GlobalDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntr } @Override - protected GlobalDOMRpcRoutingTableEntry newInstance(final Map> impls) { + protected GlobalDOMRpcRoutingTableEntry newInstance(final Map> impls) { return new GlobalDOMRpcRoutingTableEntry(rpcId, impls); } } \ No newline at end of file diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/RoutedDOMRpcRoutingTableEntry.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/RoutedDOMRpcRoutingTableEntry.java index f5fbf27d93..040be370ad 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/RoutedDOMRpcRoutingTableEntry.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/RoutedDOMRpcRoutingTableEntry.java @@ -18,9 +18,9 @@ import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,13 +30,16 @@ final class RoutedDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntr private final DOMRpcIdentifier globalRpcId; private final YangInstanceIdentifier keyId; - private RoutedDOMRpcRoutingTableEntry(final DOMRpcIdentifier globalRpcId, final YangInstanceIdentifier keyId, final Map> impls) { + private RoutedDOMRpcRoutingTableEntry(final DOMRpcIdentifier globalRpcId, + final YangInstanceIdentifier keyId, + final Map> impls) { super(globalRpcId.getType(), impls); this.keyId = Preconditions.checkNotNull(keyId); this.globalRpcId = Preconditions.checkNotNull(globalRpcId); } - RoutedDOMRpcRoutingTableEntry(final RpcDefinition def, final YangInstanceIdentifier keyId, final Map> impls) { + RoutedDOMRpcRoutingTableEntry(final RpcDefinition def, final YangInstanceIdentifier keyId, + final Map> impls) { super(def.getPath(), impls); this.keyId = Preconditions.checkNotNull(keyId); this.globalRpcId = DOMRpcIdentifier.create(def.getPath()); @@ -78,12 +81,15 @@ final class RoutedDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntr if (impls != null) { return impls.get(0).invokeRpc(globalRpcId, input); } else { - return Futures.immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", getSchemaPath())); + return Futures.immediateFailedCheckedFuture( + new DOMRpcImplementationNotAvailableException("No implementation of RPC %s available", + getSchemaPath())); } } @Override - protected RoutedDOMRpcRoutingTableEntry newInstance(final Map> impls) { + protected RoutedDOMRpcRoutingTableEntry newInstance(final Map> impls) { return new RoutedDOMRpcRoutingTableEntry(globalRpcId, keyId, impls); } } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/SerializedDOMDataBroker.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/SerializedDOMDataBroker.java index 29ac230e79..b3a3a55be2 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/SerializedDOMDataBroker.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/SerializedDOMDataBroker.java @@ -8,12 +8,6 @@ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.spi.store.DOMStore; -import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; - -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; -import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; import com.google.common.base.Preconditions; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; @@ -22,6 +16,11 @@ import com.google.common.util.concurrent.ListeningExecutorService; import java.util.Collection; import java.util.Map; import java.util.concurrent.RejectedExecutionException; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; +import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStore; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreThreePhaseCommitCohort; import org.opendaylight.yangtools.util.DurationStatisticsTracker; import org.opendaylight.yangtools.util.concurrent.MappingCheckedFuture; import org.slf4j.Logger; @@ -31,11 +30,14 @@ import org.slf4j.LoggerFactory; * Implementation of blocking three phase commit coordinator, which which * supports coordination on multiple {@link DOMStoreThreePhaseCommitCohort}. * + *

    * This implementation does not support cancellation of commit, * + *

    * In order to advance to next phase of three phase commit all subtasks of * previous step must be finish. * + *

    * This executor does not have an upper bound on subtask timeout. */ public class SerializedDOMDataBroker extends AbstractDOMDataBroker { @@ -44,13 +46,14 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker { private final ListeningExecutorService executor; /** - * * Construct DOMDataCommitCoordinator which uses supplied executor to * process commit coordinations. * - * @param executor + * @param datastores the Map of backing DOMStore instances + * @param executor the ListeningExecutorService to use */ - public SerializedDOMDataBroker(final Map datastores, final ListeningExecutorService executor) { + public SerializedDOMDataBroker(final Map datastores, + final ListeningExecutorService executor) { super(datastores); this.executor = Preconditions.checkNotNull(executor, "executor must not be null."); } @@ -60,7 +63,8 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker { } @Override - protected CheckedFuture submit(final DOMDataTreeWriteTransaction transaction, + protected CheckedFuture submit( + final DOMDataTreeWriteTransaction transaction, final Collection cohorts) { Preconditions.checkArgument(transaction != null, "Transaction must not be null."); Preconditions.checkArgument(cohorts != null, "Cohorts must not be null."); @@ -70,9 +74,9 @@ public class SerializedDOMDataBroker extends AbstractDOMDataBroker { try { commitFuture = executor.submit(new CommitCoordinationTask(transaction, cohorts, commitStatsTracker)); - } catch(RejectedExecutionException e) { - LOG.error("The commit executor's queue is full - submit task was rejected. \n" + - executor, e); + } catch (RejectedExecutionException e) { + LOG.error("The commit executor's queue is full - submit task was rejected. \n" + + executor, e); return Futures.immediateFailedCheckedFuture( new TransactionCommitFailedException( "Could not submit the commit task - the commit queue capacity has been exceeded.", e)); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardRegistration.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardRegistration.java index 384f55e18e..82b730808e 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardRegistration.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardRegistration.java @@ -7,10 +7,9 @@ */ package org.opendaylight.mdsal.dom.broker; +import com.google.common.base.Preconditions; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMDataTreeShard; - -import com.google.common.base.Preconditions; import org.opendaylight.yangtools.concepts.AbstractListenerRegistration; final class ShardRegistration extends AbstractListenerRegistration { diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTree.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTree.java index 5ea7378fea..6f30d207f8 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTree.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTree.java @@ -60,11 +60,16 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree } @Override - public ListenerRegistration registerDataTreeShard(final DOMDataTreeIdentifier prefix, final T shard, final DOMDataTreeProducer producer) throws DOMDataTreeShardingConflictException { + public ListenerRegistration registerDataTreeShard( + final DOMDataTreeIdentifier prefix, final T shard, final DOMDataTreeProducer producer) + throws DOMDataTreeShardingConflictException { - final DOMDataTreeIdentifier firstSubtree = Iterables.getOnlyElement(((ShardedDOMDataTreeProducer) producer).getSubtrees()); - Preconditions.checkArgument(firstSubtree != null, "Producer that is used to verify namespace claim can only claim a single namespace"); - Preconditions.checkArgument(prefix.equals(firstSubtree), "Trying to register shard to a different namespace than the producer has claimed"); + final DOMDataTreeIdentifier firstSubtree = Iterables.getOnlyElement((( + ShardedDOMDataTreeProducer) producer).getSubtrees()); + Preconditions.checkArgument(firstSubtree != null, "Producer that is used to verify namespace claim can" + + " only claim a single namespace"); + Preconditions.checkArgument(prefix.equals(firstSubtree), "Trying to register shard to a different namespace" + + " than the producer has claimed"); final ShardRegistration reg; final ShardRegistration parentReg; @@ -120,7 +125,8 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree } @GuardedBy("this") - private DOMDataTreeProducer createProducer(final Collection subtrees, final Map shardMap) { + private DOMDataTreeProducer createProducer(final Collection subtrees, + final Map shardMap) { // Record the producer's attachment points final DOMDataTreeProducer ret = ShardedDOMDataTreeProducer.create(this, subtrees, shardMap); for (final DOMDataTreeIdentifier subtree : subtrees) { @@ -149,7 +155,8 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree return createProducer(subtrees, shardMap); } - synchronized DOMDataTreeProducer createProducer(final ShardedDOMDataTreeProducer parent, final Collection subtrees) { + synchronized DOMDataTreeProducer createProducer(final ShardedDOMDataTreeProducer parent, + final Collection subtrees) { Preconditions.checkNotNull(parent); final Map shardMap = new HashMap<>(); @@ -160,6 +167,7 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree return createProducer(subtrees, shardMap); } + @SuppressWarnings("checkstyle:IllegalCatch") @Override public synchronized ListenerRegistration registerListener(final T listener, final Collection subtrees, final boolean allowRxMerges, @@ -199,9 +207,9 @@ public final class ShardedDOMDataTree implements DOMDataTreeService, DOMDataTree }; } - private static void simpleLoopCheck(final Collection listen, final Set writes) - throws DOMDataTreeLoopException { - for(final DOMDataTreeIdentifier listenPath : listen) { + private static void simpleLoopCheck(final Collection listen, + final Set writes) throws DOMDataTreeLoopException { + for (final DOMDataTreeIdentifier listenPath : listen) { for (final DOMDataTreeIdentifier writePath : writes) { if (listenPath.contains(writePath)) { throw new DOMDataTreeLoopException(String.format( diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeListenerContext.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeListenerContext.java index 0c0b337f26..34a4f0b924 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeListenerContext.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeListenerContext.java @@ -68,7 +68,7 @@ class ShardedDOMDataTreeListenerContext implement private final LogicalDatastoreType type; - public StoreListener(LogicalDatastoreType type) { + StoreListener(LogicalDatastoreType type) { this.type = type; } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducer.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducer.java index 241f3d9931..029721b1a3 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducer.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducer.java @@ -85,12 +85,14 @@ class ShardedDOMDataTreeProducer implements DOMDataTreeProducer { idToShard = ImmutableMap.copyOf(shardMap); } - private BiMap mapIdsToProducer(final Multimap shardToId) { + private BiMap mapIdsToProducer(final Multimap shardToId) { final Builder idToProducerBuilder = ImmutableBiMap.builder(); for (final Entry> entry : shardToId.asMap().entrySet()) { if (entry.getKey() instanceof WriteableDOMDataTreeShard) { //create a single producer for all prefixes in a single shard - final DOMDataTreeShardProducer producer = ((WriteableDOMDataTreeShard) entry.getKey()).createProducer(entry.getValue()); + final DOMDataTreeShardProducer producer = ((WriteableDOMDataTreeShard) entry.getKey()) + .createProducer(entry.getValue()); // id mapped to producers for (final DOMDataTreeIdentifier id : entry.getValue()) { idToProducerBuilder.put(id, producer); @@ -125,9 +127,9 @@ class ShardedDOMDataTreeProducer implements DOMDataTreeProducer { } @GuardedBy("this") - private DOMDataTreeProducer lookupChild(final DOMDataTreeIdentifier s) { + private DOMDataTreeProducer lookupChild(final DOMDataTreeIdentifier domDataTreeIdentifier) { for (final Entry e : children.entrySet()) { - if (e.getKey().contains(s)) { + if (e.getKey().contains(domDataTreeIdentifier)) { return e.getValue(); } } @@ -150,7 +152,8 @@ class ShardedDOMDataTreeProducer implements DOMDataTreeProducer { // Check if part of the requested subtree is not delegated to a child. for (final DOMDataTreeIdentifier c : children.keySet()) { if (s.contains(c)) { - throw new IllegalArgumentException(String.format("Subtree %s cannot be delegated as it is superset of already-delegated %s", s, c)); + throw new IllegalArgumentException(String.format("Subtree %s cannot be delegated as it is" + + " superset of already-delegated %s", s, c)); } } } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java index e1ad2f9795..fb5c1315fe 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeWriteTransaction.java @@ -59,7 +59,8 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware final Map childProducers) { this.producer = Preconditions.checkNotNull(producer); idToTransaction = new HashMap<>(); - Preconditions.checkNotNull(idToProducer).forEach((id, prod) -> idToTransaction.put(id, prod.createTransaction())); + Preconditions.checkNotNull(idToProducer).forEach((id, prod) -> idToTransaction.put( + id, prod.createTransaction())); this.identifier = "SHARDED-DOM-" + COUNTER.getAndIncrement(); childProducers.forEach((id, prod) -> childBoundaries.add(id.getRootIdentifier())); } @@ -75,7 +76,8 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware return e.getValue(); } } - throw new IllegalArgumentException(String.format("Path %s is not accessible from transaction %s", prefix, this)); + throw new IllegalArgumentException(String.format("Path %s is not accessible from transaction %s", + prefix, this)); } @Override @@ -131,8 +133,8 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware } @Override - public void onFailure(final Throwable t) { - ret.setException(t); + public void onFailure(final Throwable exp) { + ret.setException(exp); } }); @@ -149,7 +151,7 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware private final DOMDataTreeWriteCursor delegate; private final Deque path = new LinkedList<>(); - public DelegatingCursor(final DOMDataTreeWriteCursor delegate, final DOMDataTreeIdentifier rootPosition) { + DelegatingCursor(final DOMDataTreeWriteCursor delegate, final DOMDataTreeIdentifier rootPosition) { this.delegate = delegate; path.addAll(rootPosition.getRootIdentifier().getPathArguments()); } @@ -219,7 +221,8 @@ final class ShardedDOMDataTreeWriteTransaction implements DOMDataTreeCursorAware childBoundaries.forEach(id -> { if (id.contains(yid)) { path.removeLast(); - throw new IllegalArgumentException("Path {" + yid + "} is not available to this cursor since it's already claimed by a child producer"); + throw new IllegalArgumentException("Path {" + yid + "} is not available to this cursor" + + " since it's already claimed by a child producer"); } }); path.removeLast(); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMReadTransactionAdapter.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMReadTransactionAdapter.java index c0f7ae1875..e04a0828ef 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMReadTransactionAdapter.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMReadTransactionAdapter.java @@ -95,7 +95,7 @@ public class ShardedDOMReadTransactionAdapter implements DOMDataTreeReadTransact } @Override - public void onFailure(final Throwable t) { + public void onFailure(final Throwable throwable) { reg.close(); } }); @@ -109,7 +109,7 @@ public class ShardedDOMReadTransactionAdapter implements DOMDataTreeReadTransact checkRunning(); LOG.debug("{}: Invoking exists at {}:{}", txIdentifier, store, path); final Function>, Boolean> transform = - optionalNode -> optionalNode.isPresent() ? Boolean.TRUE : Boolean.FALSE; + optionalNode -> optionalNode.isPresent() ? Boolean.TRUE : Boolean.FALSE; final ListenableFuture existsResult = Futures.transform(read(store, path), transform); return Futures.makeChecked(existsResult, ReadFailedException.MAPPER); } @@ -122,7 +122,7 @@ public class ShardedDOMReadTransactionAdapter implements DOMDataTreeReadTransact private final SettableFuture>> readResultFuture; - public ReadShardedListener(final SettableFuture>> future) { + ReadShardedListener(final SettableFuture>> future) { this.readResultFuture = Preconditions.checkNotNull(future); } @@ -151,8 +151,7 @@ public class ShardedDOMReadTransactionAdapter implements DOMDataTreeReadTransact // We chain all exceptions and return aggregated one readResultFuture.setException(new DOMDataTreeListeningException("Aggregated DOMDataTreeListening exception", - causes.stream().reduce((e1, e2) -> - { + causes.stream().reduce((e1, e2) -> { e1.addSuppressed(e2); return e1; }).get())); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMTransactionChainAdapter.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMTransactionChainAdapter.java index e6fa8bce3f..4ac02aad07 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMTransactionChainAdapter.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMTransactionChainAdapter.java @@ -97,7 +97,7 @@ public class ShardedDOMTransactionChainAdapter implements DOMTransactionChain { } @Override - public void onFailure(final Throwable t) { + public void onFailure(final Throwable throwable) { // We don't have to do nothing here, // tx should take car of it } @@ -160,8 +160,8 @@ public class ShardedDOMTransactionChainAdapter implements DOMTransactionChain { @Nonnull @Override - public ListenerRegistration - registerListener(@Nonnull final T listener, @Nonnull final Collection subtrees, + public ListenerRegistration registerListener( + @Nonnull final T listener, @Nonnull final Collection subtrees, final boolean allowRxMerges, @Nonnull final Collection producers) throws DOMDataTreeLoopException { return delegateTreeService.registerListener(listener, subtrees, allowRxMerges, producers); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMWriteTransactionAdapter.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMWriteTransactionAdapter.java index 2e610c4560..c12f49f18e 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMWriteTransactionAdapter.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/ShardedDOMWriteTransactionAdapter.java @@ -173,8 +173,7 @@ public class ShardedDOMWriteTransactionAdapter implements DOMDataTreeWriteTransa } private void closeProducers() { - producerMap.values().forEach(domDataTreeProducer -> - { + producerMap.values().forEach(domDataTreeProducer -> { try { domDataTreeProducer.close(); } catch (final DOMDataTreeProducerException e) { diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainReadTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainReadTransaction.java index 30e0235ff6..9afd26b3f4 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainReadTransaction.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainReadTransaction.java @@ -40,7 +40,7 @@ public class TransactionChainReadTransaction implements DOMDataTreeReadTransacti @Override public CheckedFuture>, ReadFailedException> read(final LogicalDatastoreType store, - final YangInstanceIdentifier path) { + final YangInstanceIdentifier path) { final SettableFuture>> readResult = SettableFuture.create(); Futures.addCallback(previousWriteTxFuture, new FutureCallback() { @@ -55,18 +55,18 @@ public class TransactionChainReadTransaction implements DOMDataTreeReadTransacti } @Override - public void onFailure(final Throwable t) { - txChain.transactionFailed(TransactionChainReadTransaction.this, t); - readResult.setException(t); + public void onFailure(final Throwable throwable) { + txChain.transactionFailed(TransactionChainReadTransaction.this, throwable); + readResult.setException(throwable); } }); } @Override - public void onFailure(final Throwable t) { + public void onFailure(final Throwable throwable) { // we don't have to notify txchain about this failure // failed write transaction should do this - readResult.setException(t); + readResult.setException(throwable); } }); @@ -77,7 +77,7 @@ public class TransactionChainReadTransaction implements DOMDataTreeReadTransacti public CheckedFuture exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) { final Function>, Boolean> transform = - optionalNode -> optionalNode.isPresent() ? Boolean.TRUE : Boolean.FALSE; + optionalNode -> optionalNode.isPresent() ? Boolean.TRUE : Boolean.FALSE; final ListenableFuture existsResult = Futures.transform(read(store, path), transform); return Futures.makeChecked(existsResult, ReadFailedException.MAPPER); } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainWriteTransaction.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainWriteTransaction.java index 187bb42690..cbf4fe30a5 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainWriteTransaction.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionChainWriteTransaction.java @@ -33,12 +33,14 @@ public class TransactionChainWriteTransaction implements DOMDataTreeWriteTransac @Override - public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path, + final NormalizedNode data) { delegateTx.put(store, path, data); } @Override - public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, final NormalizedNode data) { + public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path, + final NormalizedNode data) { delegateTx.merge(store, path, data); } @@ -63,8 +65,8 @@ public class TransactionChainWriteTransaction implements DOMDataTreeWriteTransac } @Override - public void onFailure(final Throwable t) { - txChain.transactionFailed(TransactionChainWriteTransaction.this, t); + public void onFailure(final Throwable throwable) { + txChain.transactionFailed(TransactionChainWriteTransaction.this, throwable); } }); diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionCommitFailedExceptionMapper.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionCommitFailedExceptionMapper.java index 8ed5eb2fe7..4818d8a847 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionCommitFailedExceptionMapper.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/TransactionCommitFailedExceptionMapper.java @@ -8,7 +8,6 @@ package org.opendaylight.mdsal.dom.broker; import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; - import org.opendaylight.yangtools.util.concurrent.ExceptionMapper; /** diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/UnknownDOMRpcRoutingTableEntry.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/UnknownDOMRpcRoutingTableEntry.java index 38c76bc284..0fae746b2c 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/UnknownDOMRpcRoutingTableEntry.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/UnknownDOMRpcRoutingTableEntry.java @@ -7,15 +7,14 @@ */ package org.opendaylight.mdsal.dom.broker; -import org.opendaylight.mdsal.dom.api.DOMRpcException; -import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; -import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.mdsal.dom.api.DOMRpcResult; - import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import java.util.List; import java.util.Map; +import org.opendaylight.mdsal.dom.api.DOMRpcException; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementation; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; @@ -23,7 +22,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; final class UnknownDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEntry { private final CheckedFuture unknownRpc; - UnknownDOMRpcRoutingTableEntry(final SchemaPath schemaPath, final Map> impls) { + UnknownDOMRpcRoutingTableEntry(final SchemaPath schemaPath, final Map> impls) { super(schemaPath, impls); unknownRpc = Futures.immediateFailedCheckedFuture( new DOMRpcImplementationNotAvailableException("SchemaPath %s is not resolved to an RPC", schemaPath)); @@ -35,7 +35,8 @@ final class UnknownDOMRpcRoutingTableEntry extends AbstractDOMRpcRoutingTableEnt } @Override - protected UnknownDOMRpcRoutingTableEntry newInstance(final Map> impls) { + protected UnknownDOMRpcRoutingTableEntry newInstance(final Map> impls) { return new UnknownDOMRpcRoutingTableEntry(getSchemaPath(), impls); } } \ No newline at end of file diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaService.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaService.java index 540a5d8239..0e544a8401 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaService.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaService.java @@ -8,6 +8,7 @@ package org.opendaylight.mdsal.dom.broker.osgi; import static com.google.common.base.Preconditions.checkState; + import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -37,7 +38,8 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OsgiBundleScanningSchemaService implements SchemaContextProvider, DOMSchemaService, ServiceTrackerCustomizer, AutoCloseable { +public class OsgiBundleScanningSchemaService implements SchemaContextProvider, DOMSchemaService, + ServiceTrackerCustomizer, AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(OsgiBundleScanningSchemaService.class); private final ListenerRegistry listeners = new ListenerRegistry<>(); @@ -54,14 +56,14 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D this.context = Preconditions.checkNotNull(context); } - public synchronized static OsgiBundleScanningSchemaService createInstance(final BundleContext ctx) { + public static synchronized OsgiBundleScanningSchemaService createInstance(final BundleContext ctx) { Preconditions.checkState(instance == null); instance = new OsgiBundleScanningSchemaService(ctx); instance.start(); return instance; } - public synchronized static OsgiBundleScanningSchemaService getInstance() { + public static synchronized OsgiBundleScanningSchemaService getInstance() { Preconditions.checkState(instance != null, "Global Instance was not instantiated"); return instance; } @@ -83,8 +85,10 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D checkState(context != null); LOG.debug("start() starting"); - listenerTracker = new ServiceTracker<>(context, SchemaContextListener.class, OsgiBundleScanningSchemaService.this); - bundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING | + listenerTracker = new ServiceTracker<>(context, SchemaContextListener.class, + OsgiBundleScanningSchemaService.this); + bundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING + | Bundle.STOPPING | Bundle.ACTIVE, scanner); bundleTracker.open(); @@ -113,9 +117,10 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D } @Override - public synchronized ListenerRegistration registerSchemaContextListener(final SchemaContextListener listener) { + public synchronized ListenerRegistration + registerSchemaContextListener(final SchemaContextListener listener) { final Optional potentialCtx = contextResolver.getSchemaContext(); - if(potentialCtx.isPresent()) { + if (potentialCtx.isPresent()) { listener.onGlobalContextUpdated(potentialCtx.get()); } return listeners.register(listener); @@ -135,6 +140,7 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D } } + @SuppressWarnings("checkstyle:IllegalCatch") private synchronized void updateContext(final SchemaContext snapshot) { final Object[] services = listenerTracker.getServices(); for (final ListenerRegistration listener : listeners) { @@ -156,6 +162,7 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D } } + @SuppressWarnings("checkstyle:IllegalCatch") private class BundleScanner implements BundleTrackerCustomizer> { @Override public Iterable addingBundle(final Bundle bundle, final BundleEvent event) { @@ -198,9 +205,10 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D * {@link #getYangStoreSnapshot()} will throw exception. There is no * rollback. */ - + @SuppressWarnings("checkstyle:IllegalCatch") @Override - public synchronized void removedBundle(final Bundle bundle, final BundleEvent event, final Iterable urls) { + public synchronized void removedBundle(final Bundle bundle, final BundleEvent event, + final Iterable urls) { for (final Registration url : urls) { try { url.close(); @@ -210,9 +218,10 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D } final int numUrls = Iterables.size(urls); - if(numUrls > 0 ) { - if(LOG.isDebugEnabled()) { - LOG.debug("removedBundle: {}, state: {}, # urls: {}", bundle.getSymbolicName(), bundle.getState(), numUrls); + if (numUrls > 0 ) { + if (LOG.isDebugEnabled()) { + LOG.debug("removedBundle: {}, state: {}, # urls: {}", bundle.getSymbolicName(), + bundle.getState(), numUrls); } tryToUpdateSchemaContext(); @@ -236,8 +245,8 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D return; } final Optional schema = contextResolver.getSchemaContext(); - if(schema.isPresent()) { - if(LOG.isDebugEnabled()) { + if (schema.isPresent()) { + if (LOG.isDebugEnabled()) { LOG.debug("Got new SchemaContext: # of modules {}", schema.get().getAllModuleIdentifiers().size()); } @@ -246,12 +255,14 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D } @Override - public void modifiedService(final ServiceReference reference, final SchemaContextListener service) { + public void modifiedService(final ServiceReference reference, + final SchemaContextListener service) { // NOOP } @Override - public void removedService(final ServiceReference reference, final SchemaContextListener service) { + public void removedService(final ServiceReference reference, + final SchemaContextListener service) { context.ungetService(reference); } } diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/SchemaServiceActivator.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/SchemaServiceActivator.java index 438ad76ac0..52af5814fa 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/SchemaServiceActivator.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/SchemaServiceActivator.java @@ -7,8 +7,8 @@ */ package org.opendaylight.mdsal.dom.broker.osgi; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; import java.util.Hashtable; +import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; @@ -22,7 +22,8 @@ public class SchemaServiceActivator implements BundleActivator { @Override public void start(final BundleContext context) { schemaService = OsgiBundleScanningSchemaService.createInstance(context); - schemaServiceReg = context.registerService(DOMSchemaService.class, schemaService, new Hashtable()); + schemaServiceReg = context.registerService(DOMSchemaService.class, + schemaService, new Hashtable()); } @Override diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/BlockingTransactionChainListener.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/BlockingTransactionChainListener.java index fbca99adaa..1529d30734 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/BlockingTransactionChainListener.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/BlockingTransactionChainListener.java @@ -15,6 +15,7 @@ import org.opendaylight.mdsal.common.api.TransactionChainListener; /** * Simple implementation of {@link TransactionChainListener} for testing. * + *

    * This transaction chain listener does not contain any logic, only update * futures ({@link #getFailFuture()} and {@link #getSuccessFuture()} when * transaction chain event is retrieved. diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMBrokerTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMBrokerTest.java index 4a82645974..ae5d6c098e 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMBrokerTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMBrokerTest.java @@ -68,7 +68,8 @@ public class DOMBrokerTest { operStore.onGlobalContextUpdated(schemaContext); configStore.onGlobalContextUpdated(schemaContext); - final ImmutableMap stores = ImmutableMap. builder() + final ImmutableMap stores = + ImmutableMap.builder() .put(CONFIGURATION, configStore) .put(OPERATIONAL, operStore) .build(); @@ -82,16 +83,16 @@ public class DOMBrokerTest { @After public void tearDown() { - if( executor != null ) { + if (executor != null ) { executor.shutdownNow(); } - if(futureExecutor != null) { + if (futureExecutor != null) { futureExecutor.shutdownNow(); } } - @Test(timeout=10000) + @Test(timeout = 10000) public void testTransactionIsolation() throws InterruptedException, ExecutionException { assertNotNull(domBroker); @@ -102,14 +103,12 @@ public class DOMBrokerTest { assertNotNull(writeTx); /** - * - * Writes /test in writeTx + * Writes /test in writeTx. * */ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); /** - * * Reads /test from readTx Read should return Absent. * */ @@ -118,12 +117,11 @@ public class DOMBrokerTest { assertFalse(readTxContainer.get().isPresent()); } - @Test(timeout=10000) + @Test(timeout = 10000) public void testTransactionCommit() throws InterruptedException, ExecutionException { final DOMDataTreeWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); assertNotNull(writeTx); /** - * * Writes /test in writeTx * */ @@ -136,7 +134,7 @@ public class DOMBrokerTest { assertTrue(afterCommitRead.isPresent()); } - @Test(expected=TransactionCommitFailedException.class) + @Test(expected = TransactionCommitFailedException.class) public void testRejectedCommit() throws Exception { commitExecutor.delegate = Mockito.mock( ExecutorService.class ); Mockito.doThrow( new RejectedExecutionException( "mock" ) ) @@ -153,6 +151,7 @@ public class DOMBrokerTest { writeTx.submit().checkedGet( 5, TimeUnit.SECONDS ); } + @SuppressWarnings("checkstyle:IllegalCatch") AtomicReference submitTxAsync( final DOMDataTreeWriteTransaction writeTx ) { final AtomicReference caughtEx = new AtomicReference<>(); new Thread() { @@ -161,7 +160,7 @@ public class DOMBrokerTest { try { writeTx.submit(); - } catch( final Throwable e ) { + } catch ( final Throwable e ) { caughtEx.set( e ); } } @@ -214,15 +213,19 @@ public class DOMBrokerTest { readRx.read(OPERATIONAL, TestModel.TEST_PATH).checkedGet(); } + @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"}) @Test public void closeTest() throws Exception { - final String TEST_EXCEPTION = "TestException"; + final String testException = "TestException"; + + domBroker.setCloseable(() -> { + throw new Exception(testException); + }); - domBroker.setCloseable(() -> { throw new Exception(TEST_EXCEPTION); }); - try{ + try { domBroker.close(); - }catch(final Exception e){ - assertTrue(e.getMessage().contains(TEST_EXCEPTION)); + } catch (final Exception e) { + assertTrue(e.getMessage().contains(testException)); } } @@ -230,7 +233,7 @@ public class DOMBrokerTest { ExecutorService delegate; - public CommitExecutorService( final ExecutorService delegate ) { + CommitExecutorService( final ExecutorService delegate ) { this.delegate = delegate; } diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMDataTreeListenerTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMDataTreeListenerTest.java index 6e734567aa..7e7150bf6d 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMDataTreeListenerTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMDataTreeListenerTest.java @@ -101,7 +101,8 @@ public class DOMDataTreeListenerTest { operStore.onGlobalContextUpdated(schemaContext); configStore.onGlobalContextUpdated(schemaContext); - final ImmutableMap stores = ImmutableMap.builder() + final ImmutableMap stores = ImmutableMap.builder() .put(CONFIGURATION, configStore) .put(OPERATIONAL, operStore) .build(); @@ -428,7 +429,7 @@ public class DOMDataTreeListenerTest { ExecutorService delegate; - public CommitExecutorService(final ExecutorService delegate) { + CommitExecutorService(final ExecutorService delegate) { this.delegate = delegate; } @@ -443,7 +444,7 @@ public class DOMDataTreeListenerTest { private final List> receivedChanges = new ArrayList<>(); private final CountDownLatch latch; - public TestDataTreeListener(final CountDownLatch latch) { + TestDataTreeListener(final CountDownLatch latch) { this.latch = latch; } diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterTest.java index 929aed96c9..90d2043ac6 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterTest.java @@ -34,6 +34,7 @@ public class DOMNotificationRouterTest extends TestUtils { assertNotNull(DOMNotificationRouter.create(1)); } + @SuppressWarnings("checkstyle:IllegalCatch") @Test public void complexTest() throws Exception { final DOMNotificationSubscriptionListener domNotificationSubscriptionListener = diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMTransactionChainTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMTransactionChainTest.java index 44f746c761..f957bab004 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMTransactionChainTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/DOMTransactionChainTest.java @@ -41,20 +41,24 @@ public class DOMTransactionChainTest { private AbstractDOMDataBroker domBroker; @Before - public void setupStore() throws Exception{ - final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService()); - final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService()); + public void setupStore() throws Exception { + final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", + MoreExecutors.newDirectExecutorService()); + final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", + MoreExecutors.newDirectExecutorService()); schemaContext = TestModel.createTestContext(); operStore.onGlobalContextUpdated(schemaContext); configStore.onGlobalContextUpdated(schemaContext); - final ImmutableMap stores = ImmutableMap. builder() // - .put(CONFIGURATION, configStore) // - .put(OPERATIONAL, operStore) // + final ImmutableMap stores = + ImmutableMap.builder() + .put(CONFIGURATION, configStore) + .put(OPERATIONAL, operStore) .build(); - final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); + final ListeningExecutorService executor = MoreExecutors.listeningDecorator( + Executors.newSingleThreadExecutor()); domBroker = new SerializedDOMDataBroker(stores, executor); } @@ -65,15 +69,13 @@ public class DOMTransactionChainTest { assertNotNull(txChain); /** - * We alocate new read-write transaction and write /test - * - * + * We alocate new read-write transaction and write /test. */ final DOMDataTreeWriteTransaction firstTx = allocateAndWrite(txChain); /** * First transaction is marked as ready, we are able to allocate chained - * transactions + * transactions. */ final ListenableFuture firstWriteTxFuture = firstTx.submit(); @@ -92,7 +94,6 @@ public class DOMTransactionChainTest { assertTestContainerExists(secondReadTx); /** - * * We alocate next transaction, which is still based on first one, but * is read-write. * @@ -106,7 +107,6 @@ public class DOMTransactionChainTest { assertCommitSuccessful(firstWriteTxFuture); /** - * * Allocates transaction from data store. * */ @@ -119,7 +119,7 @@ public class DOMTransactionChainTest { assertTestContainerExists(storeReadTx); /** - * third transaction is sealed and commited + * third transaction is sealed and commited. */ final ListenableFuture thirdDeleteTxFuture = thirdDeleteTx.submit(); assertCommitSuccessful(thirdDeleteTxFuture); @@ -132,6 +132,7 @@ public class DOMTransactionChainTest { listener.getSuccessFuture().get(1000, TimeUnit.MILLISECONDS); } + @SuppressWarnings("checkstyle:IllegalCatch") @Test public void testTransactionChainNotSealed() throws InterruptedException, ExecutionException, TimeoutException { final BlockingTransactionChainListener listener = new BlockingTransactionChainListener(); @@ -140,8 +141,6 @@ public class DOMTransactionChainTest { /** * We alocate new read-write transaction and write /test - * - * */ allocateAndWrite(txChain); @@ -180,9 +179,10 @@ public class DOMTransactionChainTest { future.get(); } - private static void assertTestContainerExists(final DOMDataTreeReadTransaction readTx) throws InterruptedException, - ExecutionException { - final ListenableFuture>> readFuture = readTx.read(OPERATIONAL, TestModel.TEST_PATH); + private static void assertTestContainerExists(final DOMDataTreeReadTransaction readTx) + throws InterruptedException, ExecutionException { + final ListenableFuture>> readFuture = + readTx.read(OPERATIONAL, TestModel.TEST_PATH); final Optional> readedData = readFuture.get(); assertTrue(readedData.isPresent()); } diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/GlobalDOMRpcRoutingTableEntryTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/GlobalDOMRpcRoutingTableEntryTest.java index 0536cb620c..f155f97bde 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/GlobalDOMRpcRoutingTableEntryTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/GlobalDOMRpcRoutingTableEntryTest.java @@ -45,11 +45,11 @@ public class GlobalDOMRpcRoutingTableEntryTest extends TestUtils { assertTrue(globalDOMRpcRoutingTableEntry.newInstance(rpcImplementations).getImplementations().containsValue( rpcImplementation)); - try{ + try { globalDOMRpcRoutingTableEntry.newInstance(rpcImplementations) .invokeRpc(TEST_CONTAINER).checkedGet(); fail("Expected DOMRpcImplementationNotAvailableException"); - }catch(DOMRpcImplementationNotAvailableException e){ + } catch (DOMRpcImplementationNotAvailableException e) { assertTrue(e.getMessage().contains(EXCEPTION_TEXT)); } } diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/RoutedDOMRpcRoutingTableEntryTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/RoutedDOMRpcRoutingTableEntryTest.java index 67194f9505..02c04ad785 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/RoutedDOMRpcRoutingTableEntryTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/RoutedDOMRpcRoutingTableEntryTest.java @@ -22,6 +22,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath; public class RoutedDOMRpcRoutingTableEntryTest extends TestUtils { + @SuppressWarnings("checkstyle:IllegalCatch") @Test public void basicTest() throws Exception { final RpcDefinition rpcDefinition = mock(RpcDefinition.class); diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducerMultiShardTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducerMultiShardTest.java index 83996f6cf1..46ab94cc36 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducerMultiShardTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeProducerMultiShardTest.java @@ -117,7 +117,7 @@ public class ShardedDOMDataTreeProducerMultiShardTest { dataTreeService = dataTree; } - @Test(expected=IllegalStateException.class) + @Test(expected = IllegalStateException.class) public void testTxReadyMultiples() throws Exception { final DOMDataTreeShardProducer producer = rootShard.createProducer(Collections.singletonList(TEST_ID)); final DOMDataTreeShardWriteTransaction transaction = producer.createTransaction(); @@ -132,7 +132,7 @@ public class ShardedDOMDataTreeProducerMultiShardTest { transaction.ready(); } - @Test(expected=IllegalStateException.class) + @Test(expected = IllegalStateException.class) public void testSubmitUnclosedCursor() throws Exception { final DOMDataTreeShardProducer producer = rootShard.createProducer(Collections.singletonList(TEST_ID)); final DOMDataTreeShardWriteTransaction transaction = producer.createTransaction(); @@ -151,7 +151,8 @@ public class ShardedDOMDataTreeProducerMultiShardTest { final DOMDataTreeListener mockedDataTreeListener = Mockito.mock(DOMDataTreeListener.class); doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap()); - dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_CONTAINER_ID), true, Collections.emptyList()); + dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_CONTAINER_ID), + true, Collections.emptyList()); final DOMDataTreeShardProducer producer = rootShard.createProducer(Collections.singletonList(TEST_ID)); final DOMDataTreeShardWriteTransaction transaction = producer.createTransaction(); @@ -179,11 +180,13 @@ public class ShardedDOMDataTreeProducerMultiShardTest { transaction.ready(); transaction.submit(); - verify(mockedDataTreeListener, timeout(1000).times(2)).onDataTreeChanged(captorForChanges.capture(), captorForSubtrees.capture()); + verify(mockedDataTreeListener, timeout(1000).times(2)).onDataTreeChanged( + captorForChanges.capture(), captorForSubtrees.capture()); final Collection capturedValue = captorForChanges.getValue(); assertTrue(capturedValue.size() == 1); - final ContainerNode dataAfter = (ContainerNode) capturedValue.iterator().next().getRootNode().getDataAfter().get(); + final ContainerNode dataAfter = + (ContainerNode) capturedValue.iterator().next().getRootNode().getDataAfter().get(); assertEquals(innerContainer, dataAfter); verifyNoMoreInteractions(mockedDataTreeListener); } @@ -193,23 +196,28 @@ public class ShardedDOMDataTreeProducerMultiShardTest { final DOMDataTreeListener mockedDataTreeListener = Mockito.mock(DOMDataTreeListener.class); doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap()); - dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_CONTAINER_ID), true, Collections.emptyList()); + dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_CONTAINER_ID), true, + Collections.emptyList()); final DOMDataTreeShardProducer producer = rootShard.createProducer(Collections.singletonList(TEST_ID)); final DOMDataTreeShardWriteTransaction transaction = producer.createTransaction(); writeCrossShardContainer(transaction); - verify(mockedDataTreeListener, timeout(1000).times(2)).onDataTreeChanged(captorForChanges.capture(), captorForSubtrees.capture()); + verify(mockedDataTreeListener, timeout(1000).times(2)).onDataTreeChanged( + captorForChanges.capture(), captorForSubtrees.capture()); final Collection capturedValue = captorForChanges.getValue(); assertTrue(capturedValue.size() == 1); - final ContainerNode dataAfter = (ContainerNode) capturedValue.iterator().next().getRootNode().getDataAfter().get(); - assertEquals(crossShardContainer.getChild(TestModel.INNER_CONTAINER_PATH.getLastPathArgument()).get(), dataAfter); + final ContainerNode dataAfter = + (ContainerNode) capturedValue.iterator().next().getRootNode().getDataAfter().get(); + assertEquals(crossShardContainer.getChild( + TestModel.INNER_CONTAINER_PATH.getLastPathArgument()).get(), dataAfter); final Map> capturedSubtrees = captorForSubtrees.getValue(); assertTrue(capturedSubtrees.size() == 1); assertTrue(capturedSubtrees.containsKey(INNER_CONTAINER_ID)); - assertEquals(crossShardContainer.getChild(TestModel.INNER_CONTAINER_PATH.getLastPathArgument()).get(), capturedSubtrees.get(INNER_CONTAINER_ID)); + assertEquals(crossShardContainer.getChild(TestModel.INNER_CONTAINER_PATH.getLastPathArgument()).get(), + capturedSubtrees.get(INNER_CONTAINER_ID)); verifyNoMoreInteractions(mockedDataTreeListener); } @@ -221,11 +229,13 @@ public class ShardedDOMDataTreeProducerMultiShardTest { final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1); innerShard.onGlobalContextUpdated(schemaContext); - final DOMDataTreeProducer shardRegProducer = dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID)); + final DOMDataTreeProducer shardRegProducer = + dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID)); innerShardReg = dataTreeService.registerDataTreeShard(INNER_CONTAINER_ID, innerShard, shardRegProducer); shardRegProducer.close(); - dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID), true, Collections.emptyList()); + dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(TEST_ID), + true, Collections.emptyList()); final DOMDataTreeShardProducer producer = rootShard.createProducer(Collections.singletonList(TEST_ID)); final DOMDataTreeShardWriteTransaction transaction = producer.createTransaction(); @@ -236,9 +246,11 @@ public class ShardedDOMDataTreeProducerMultiShardTest { .build(); //verify listeners have been notified - verify(mockedDataTreeListener, timeout(1000).times(4)).onDataTreeChanged(captorForChanges.capture(), captorForSubtrees.capture()); + verify(mockedDataTreeListener, timeout(1000).times(4)).onDataTreeChanged( + captorForChanges.capture(), captorForSubtrees.capture()); final List> capturedChanges = captorForChanges.getAllValues(); - final List>> capturedSubtrees = captorForSubtrees.getAllValues(); + final List>> capturedSubtrees = + captorForSubtrees.getAllValues(); final DataTreeCandidate firstNotificationCandidate = capturedChanges.get(2).iterator().next(); assertTrue(capturedSubtrees.get(2).size() == 1); @@ -258,7 +270,8 @@ public class ShardedDOMDataTreeProducerMultiShardTest { final DOMDataTreeListener mockedDataTreeListener = Mockito.mock(DOMDataTreeListener.class); doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap()); - dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_CONTAINER_ID), true, Collections.emptyList()); + dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_CONTAINER_ID), + true, Collections.emptyList()); final DOMDataTreeShardProducer producer = rootShard.createProducer(Collections.singletonList(TEST_ID)); final DOMDataTreeShardWriteTransaction transaction = producer.createTransaction(); @@ -288,11 +301,14 @@ public class ShardedDOMDataTreeProducerMultiShardTest { cursor.enter(TestModel.TEST_PATH.getLastPathArgument()); final LeafNode shardedValue1 = - ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.SHARDED_VALUE_1)).withValue("sharded value 1").build(); + ImmutableLeafNodeBuilder.create().withNodeIdentifier( + new NodeIdentifier(TestModel.SHARDED_VALUE_1)).withValue("sharded value 1").build(); final LeafNode shardedValue2 = - ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.SHARDED_VALUE_2)).withValue("sharded value 2").build(); + ImmutableLeafNodeBuilder.create().withNodeIdentifier( + new NodeIdentifier(TestModel.SHARDED_VALUE_2)).withValue("sharded value 2").build(); - final DataContainerNodeAttrBuilder containerNodeBuilder = ImmutableContainerNodeBuilder.create(); + final DataContainerNodeAttrBuilder containerNodeBuilder = + ImmutableContainerNodeBuilder.create(); final ContainerNode containerNode = containerNodeBuilder .withNodeIdentifier(new NodeIdentifier(TestModel.INNER_CONTAINER)) @@ -318,7 +334,8 @@ public class ShardedDOMDataTreeProducerMultiShardTest { final ContainerNode lowerShardContainer = ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new NodeIdentifier(TestModel.ANOTHER_SHARD_CONTAINER)) - .withChild(ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.ANOTHER_SHARD_VALUE)).build()) + .withChild(ImmutableLeafNodeBuilder.create().withNodeIdentifier( + new NodeIdentifier(TestModel.ANOTHER_SHARD_VALUE)).build()) .build(); cursor.write(TestModel.ANOTHER_SHARD_PATH.getLastPathArgument(), lowerShardContainer); @@ -336,9 +353,11 @@ public class ShardedDOMDataTreeProducerMultiShardTest { private ContainerNode createCrossShardContainer() { final LeafNode shardedValue1 = - ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.SHARDED_VALUE_1)).withValue("sharded value 1").build(); + ImmutableLeafNodeBuilder.create().withNodeIdentifier( + new NodeIdentifier(TestModel.SHARDED_VALUE_1)).withValue("sharded value 1").build(); final LeafNode shardedValue2 = - ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.SHARDED_VALUE_2)).withValue("sharded value 2").build(); + ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier( + TestModel.SHARDED_VALUE_2)).withValue("sharded value 2").build(); final ContainerNode lowerShardContainer = ImmutableContainerNodeBuilder.create() @@ -365,7 +384,7 @@ public class ShardedDOMDataTreeProducerMultiShardTest { return testContainer; } - private void writeCrossShardContainer(final DOMDataTreeShardWriteTransaction transaction) throws Exception{ + private void writeCrossShardContainer(final DOMDataTreeShardWriteTransaction transaction) throws Exception { final DOMDataTreeWriteCursor cursor = transaction.createCursor(ROOT_ID); cursor.write(TestModel.TEST_PATH.getLastPathArgument(), crossShardContainer); diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeShardTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeShardTest.java index b1c48761ee..73208c5177 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeShardTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeShardTest.java @@ -74,7 +74,8 @@ public class ShardedDOMDataTreeShardTest { @Test public void attachAndRemoveShard() throws DOMDataTreeShardingConflictException { doNothing().when(rootShard).onChildAttached(TEST_ID, childShard); - final ListenerRegistration reg = shardingService.registerDataTreeShard(TEST_ID, childShard, testProducer); + final ListenerRegistration reg = + shardingService.registerDataTreeShard(TEST_ID, childShard, testProducer); verify(rootShard, times(1)).onChildAttached(TEST_ID, childShard); doNothing().when(rootShard).onChildDetached(TEST_ID, childShard); diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeTest.java index 6cc21b8d05..35611e94a6 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeTest.java @@ -123,8 +123,10 @@ public class ShardedDOMDataTreeTest { final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1); innerShard.onGlobalContextUpdated(schemaContext); - final DOMDataTreeProducer shardRegProducer2 = dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID)); - ListenerRegistration innerShardReg = dataTreeService.registerDataTreeShard(INNER_CONTAINER_ID, innerShard, shardRegProducer2); + final DOMDataTreeProducer shardRegProducer2 = + dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID)); + ListenerRegistration innerShardReg = + dataTreeService.registerDataTreeShard(INNER_CONTAINER_ID, innerShard, shardRegProducer2); innerShardReg.close(); // try to register the shard again @@ -146,7 +148,8 @@ public class ShardedDOMDataTreeTest { final DOMDataTreeListener mockedDataTreeListener = Mockito.mock(DOMDataTreeListener.class); doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap()); - dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_CONTAINER_ID), true, Collections.emptyList()); + dataTreeService.registerListener(mockedDataTreeListener, Collections.singletonList(INNER_CONTAINER_ID), + true, Collections.emptyList()); final DOMDataTreeProducer producer = dataTreeService.createProducer(Collections.singletonList(ROOT_ID)); DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(false); @@ -173,12 +176,15 @@ public class ShardedDOMDataTreeTest { cursor.close(); tx.submit().checkedGet(); - verify(mockedDataTreeListener, timeout(1000).times(3)).onDataTreeChanged(captorForChanges.capture(), captorForSubtrees.capture()); + verify(mockedDataTreeListener, timeout(1000).times(3)).onDataTreeChanged(captorForChanges.capture(), + captorForSubtrees.capture()); final List> capturedValue = captorForChanges.getAllValues(); assertTrue(capturedValue.size() == 3); - final ContainerNode capturedChange = (ContainerNode) capturedValue.get(1).iterator().next().getRootNode().getDataAfter().get(); - final ContainerNode innerContainerVerify = (ContainerNode) crossShardContainer.getChild(TestModel.INNER_CONTAINER_PATH.getLastPathArgument()).get(); + final ContainerNode capturedChange = + (ContainerNode) capturedValue.get(1).iterator().next().getRootNode().getDataAfter().get(); + final ContainerNode innerContainerVerify = (ContainerNode) crossShardContainer.getChild( + TestModel.INNER_CONTAINER_PATH.getLastPathArgument()).get(); assertEquals(innerContainerVerify, capturedChange); verifyNoMoreInteractions(mockedDataTreeListener); @@ -203,7 +209,8 @@ public class ShardedDOMDataTreeTest { assertTrue(rootTx.cancel()); - final DOMDataTreeProducer innerContainerProducer = rootProducer.createProducer(Collections.singletonList(INNER_CONTAINER_ID)); + final DOMDataTreeProducer innerContainerProducer = rootProducer.createProducer( + Collections.singletonList(INNER_CONTAINER_ID)); rootTx = rootProducer.createTransaction(false); try { @@ -239,9 +246,11 @@ public class ShardedDOMDataTreeTest { private ContainerNode createCrossShardContainer() { final LeafNode shardedValue1 = - ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.SHARDED_VALUE_1)).withValue("sharded value 1").build(); + ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier( + TestModel.SHARDED_VALUE_1)).withValue("sharded value 1").build(); final LeafNode shardedValue2 = - ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(TestModel.SHARDED_VALUE_2)).withValue("sharded value 2").build(); + ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier( + TestModel.SHARDED_VALUE_2)).withValue("sharded value 2").build(); final ContainerNode lowerShardContainer = ImmutableContainerNodeBuilder.create() diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataWriteTransactionTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataWriteTransactionTest.java index dcc81475a6..c1b21438cc 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataWriteTransactionTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataWriteTransactionTest.java @@ -63,7 +63,8 @@ public class ShardedDOMDataWriteTransactionTest { final ShardedDOMDataTree shardedDOMDataTree = new ShardedDOMDataTree(); - final DOMDataTreeProducer shardRegProducer = shardedDOMDataTree.createProducer(Collections.singletonList(ROOT_ID)); + final DOMDataTreeProducer shardRegProducer = shardedDOMDataTree.createProducer( + Collections.singletonList(ROOT_ID)); shardedDOMDataTree.registerDataTreeShard(ROOT_ID, rootShard, shardRegProducer); shardRegProducer.close(); final YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.of(QName.create("test")); @@ -92,7 +93,8 @@ public class ShardedDOMDataWriteTransactionTest { cursor.close(); try { - transaction.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY)); + transaction.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, + YangInstanceIdentifier.EMPTY)); fail("Should have failed, config ds not available to this tx"); } catch (final IllegalArgumentException e) { assertTrue(e.getMessage().contains("not accessible")); @@ -102,7 +104,8 @@ public class ShardedDOMDataWriteTransactionTest { assertFalse(transaction.cancel()); final DOMDataTreeCursorAwareTransaction newTx = producer.createTransaction(false); - assertTrue("Transaction identifier incorrect " + transaction.getIdentifier(), ((String) transaction.getIdentifier()).contains("SHARDED-DOM-")); + assertTrue("Transaction identifier incorrect " + transaction.getIdentifier(), ( + (String) transaction.getIdentifier()).contains("SHARDED-DOM-")); assertNotEquals(transaction.getIdentifier(), newTx.getIdentifier()); } diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMReadTransactionAdapterTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMReadTransactionAdapterTest.java index 7c643b1d29..35105e89f5 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMReadTransactionAdapterTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMReadTransactionAdapterTest.java @@ -58,7 +58,7 @@ public class ShardedDOMReadTransactionAdapterTest { @Nonnull @Override public ListenerRegistration - registerListener(@Nonnull final T listener, @Nonnull final Collection subtrees, + registerListener(@Nonnull final T listener, @Nonnull final Collection subtrees, final boolean allowRxMerges, @Nonnull final Collection producers) throws DOMDataTreeLoopException { final Map> subtree = Maps.newHashMap(); diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/TestCommitCohort.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/TestCommitCohort.java index df6709ad9a..47ffb164f5 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/TestCommitCohort.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/TestCommitCohort.java @@ -16,11 +16,10 @@ public enum TestCommitCohort implements DOMStoreThreePhaseCommitCohort { ALLWAYS_SUCCESS(true, true, true, true), CAN_COMMIT_FAILED(false, false, false, true), PRE_COMMIT_FAILED(true, false, false, true), COMMIT_FAILED(true, true, false, true); - ; - - private TestCommitCohort(final boolean canCommit, final boolean preCommit, final boolean commit, final boolean abort) { + TestCommitCohort(final boolean canCommit, final boolean preCommit, + final boolean commit, final boolean abort) { this.canCommit = Futures.immediateFuture(canCommit); this.preCommit = immediate(canCommit, new IllegalStateException()); this.commit = immediate(commit, new IllegalStateException()); @@ -53,8 +52,8 @@ public enum TestCommitCohort implements DOMStoreThreePhaseCommitCohort { return commit; } - private static ListenableFuture immediate(final boolean isSuccess, final Exception e) { - return isSuccess ? Futures.immediateFuture(null) : Futures.immediateFailedFuture(e); + private static ListenableFuture immediate(final boolean isSuccess, final Exception except) { + return isSuccess ? Futures.immediateFuture(null) : Futures.immediateFailedFuture(except); } diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/TestUtils.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/TestUtils.java index 08ff36ec91..1a717d51c1 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/TestUtils.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/TestUtils.java @@ -40,7 +40,7 @@ abstract class TestUtils { private static final QName TOP_LEVEL_LIST_QNAME = QName.create(TOP_QNAME, "top-level-list"); private static final QName TOP_LEVEL_LIST_KEY_QNAME = QName.create(TOP_QNAME, "name"); - private final static MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create() + private static final MapEntryNode TOP_LEVEL_LIST_NODE = ImmutableMapEntryNodeBuilder.create() .withNodeIdentifier( new YangInstanceIdentifier.NodeIdentifierWithPredicates( TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE)) @@ -49,7 +49,7 @@ abstract class TestUtils { private static final DataContainerChild CHILD_LIST = ImmutableNodes.mapNodeBuilder(TestModel.TEST_QNAME) .withNodeIdentifier(NodeIdentifier.create(TestModel.TEST_QNAME)) - .withChild(topLevelListNormalized) + .withChild(TOP_LEVEL_LIST_NODE) .build(); static final NormalizedNode TEST_CONTAINER = Builders.containerBuilder() @@ -64,7 +64,7 @@ abstract class TestUtils { static final String EXCEPTION_TEXT = "TestRpcImplementationException"; - static TestRpcImplementation getTestRpcImplementation(){ + static TestRpcImplementation getTestRpcImplementation() { return new TestRpcImplementation(); } diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaServiceTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaServiceTest.java index ff59055105..a90cf14042 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaServiceTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaServiceTest.java @@ -48,6 +48,7 @@ public class OsgiBundleScanningSchemaServiceTest { assertEquals(bundleContext, osgiService.getContext()); } + @SuppressWarnings("checkstyle:IllegalCatch") @After public void destroyInstance() throws Exception { try { diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/osgi/SchemaServiceActivatorTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/osgi/SchemaServiceActivatorTest.java index a0751b60bc..196d2a6205 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/osgi/SchemaServiceActivatorTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/osgi/SchemaServiceActivatorTest.java @@ -62,6 +62,7 @@ public class SchemaServiceActivatorTest { verify(osgiBundle).close(); } + @SuppressWarnings("checkstyle:IllegalCatch") @After @Before public void destroyInstance() throws Exception { -- 2.36.6