From 2d60632f7cf63712e8357a3cf3fc40d83366e5e6 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 16 Nov 2017 03:34:13 +0100 Subject: [PATCH] Fix checkstyle reported by odlparent-3.0.0 Change-Id: I08c548fbbbef8527ad7b037b0def33d3c1c09bf6 Signed-off-by: Robert Varga --- ...ractDependentComponentFactoryMetadata.java | 1 + .../config/api/ValidationException.java | 2 +- .../constants/ConfigRegistryConstants.java | 2 +- .../api/osgi/WaitingServiceTracker.java | 2 +- .../controller/config/spi/AbstractModule.java | 14 +-- .../config/api/IdentityAttributeRefTest.java | 2 +- .../config/api/ValidationExceptionTest.java | 2 +- .../facade/xml/ConfigSubsystemFacade.java | 4 +- .../exception/ConfigHandlingException.java | 14 ++- .../AttributeIfcSwitchStatement.java | 1 + .../AbstractAttributeReadingStrategy.java | 1 + .../attributes/fromxml/ObjectXmlReader.java | 5 +- .../attributes/mapping/ObjectMapper.java | 1 + .../ArrayAttributeResolvingStrategy.java | 2 +- .../attributes/resolving/ObjectResolver.java | 1 + .../SimpleAttributeResolvingStrategy.java | 6 +- .../attributes/toxml/ObjectXmlWriter.java | 2 + .../toxml/SimpleAttributeWritingStrategy.java | 1 + .../xml/mapping/config/InstanceConfig.java | 4 +- .../facade/xml/osgi/YangStoreActivator.java | 4 +- .../facade/xml/osgi/YangStoreSnapshot.java | 6 +- .../strategy/DeleteEditConfigStrategy.java | 12 +- .../xml/strategy/MergeEditConfigStrategy.java | 2 +- .../MissingInstanceHandlingStrategy.java | 3 +- .../strategy/ReCreateEditConfigStrategy.java | 2 +- .../xml/transactions/TransactionProvider.java | 4 +- .../config/manager/impl/DeadlockMonitor.java | 12 +- .../impl/ServiceReferenceRegistryImpl.java | 2 +- .../DependencyResolverImpl.java | 2 + .../DependencyResolverManager.java | 1 + .../dynamicmbean/AbstractDynamicWrapper.java | 12 +- .../impl/jmx/JMXNotifierConfigRegistry.java | 2 +- .../osgi/mapping/ModuleInfoBundleTracker.java | 10 +- .../RefreshingSCPModuleInfoRegistry.java | 2 +- .../manager/impl/util/LookupBeansUtil.java | 2 +- .../impl/util/OsgiRegistrationUtil.java | 2 +- .../manager/impl/AbstractConfigTest.java | 2 +- .../osgi/ModuleFactoryBundleTrackerTest.java | 2 +- .../config/util/xml/DocumentedException.java | 8 ++ ...AbstractReadTransactionRequestProxyV1.java | 1 + .../concepts/AbstractEnvelopeProxy.java | 1 + .../AbstractResponseEnvelopeProxy.java | 1 + .../access/concepts/AbstractEnvelopeTest.java | 1 + .../client/ReconnectingClientConnection.java | 1 + .../access/client/AccessClientUtil.java | 5 +- .../access/client/ActorBehaviorTest.java | 2 +- .../access/client/ConnectionEntryMatcher.java | 2 +- .../md/sal/trace/dom/impl/TracingBroker.java | 2 + .../raft/FollowerLogInformationImpl.java | 16 +-- .../cluster/raft/GetSnapshotReplyActor.java | 13 +- .../cluster/raft/ImmutableElectionTerm.java | 10 +- .../cluster/raft/NoopProcedure.java | 4 +- .../controller/cluster/raft/RaftActor.java | 49 ++++---- .../cluster/raft/RaftActorContextImpl.java | 45 +++---- .../RaftActorServerConfigurationSupport.java | 118 +++++++++--------- .../cluster/raft/ReplicatedLogImpl.java | 6 +- .../cluster/raft/SnapshotManager.java | 47 +++---- .../raft/base/messages/SnapshotComplete.java | 2 +- .../raft/behaviors/AbstractLeader.java | 17 +-- .../client/messages/GetOnDemandRaftState.java | 2 +- .../cluster/raft/persisted/EmptyState.java | 2 +- .../cluster/raft/persisted/Snapshot.java | 13 +- .../AbstractRaftActorIntegrationTest.java | 72 +++++------ .../cluster/raft/MockRaftActor.java | 2 +- .../AbstractLeaderElectionScenarioTest.java | 8 +- .../cluster/raft/behaviors/LeaderTest.java | 8 +- .../cluster/raft/persisted/ByteState.java | 8 +- .../raft/utils/InMemorySnapshotStore.java | 28 ++--- .../cluster/common/actor/Dispatchers.java | 20 +-- .../cluster/messaging/MessageAssembler.java | 4 +- .../cluster/messaging/MessageSliceReply.java | 8 +- .../cluster/messaging/MessageSlicer.java | 2 +- .../cluster/messaging/SliceOptions.java | 4 +- .../cluster/reporting/MetricsReporter.java | 2 +- .../actor/MeteredBoundedMailboxTest.java | 2 +- .../cluster/datastore/util/TestModel.java | 13 +- .../messaging/AbstractMessagingTest.java | 16 +-- .../dds/AbstractDataStoreClientActor.java | 1 + .../dds/AbstractShardBackendResolver.java | 4 +- .../actors/dds/ClientTransaction.java | 4 +- .../databroker/actors/dds/ProxyHistory.java | 2 + .../DataChangeListenerRegistrationProxy.java | 17 +-- .../cluster/datastore/DatastoreContext.java | 21 ++-- .../datastore/DatastoreSnapshotRestore.java | 10 +- .../DebugThreePhaseCommitCohort.java | 4 +- .../DistributedDataStoreFactory.java | 2 +- .../RemoteTransactionContextSupport.java | 20 +-- .../controller/cluster/datastore/Shard.java | 6 +- .../ShardDataChangePublisherActor.java | 4 +- .../ShardDataTreeChangePublisherActor.java | 4 +- .../datastore/ShardSnapshotCohort.java | 2 +- .../datastore/config/ModuleConfig.java | 26 ++-- .../DistributedEntityOwnershipService.java | 2 +- .../EntityOwnershipListenerActor.java | 12 +- .../EntityOwnershipListenerSupport.java | 19 +-- .../EntityOwnerSelectionStrategyConfig.java | 9 +- .../identifiers/ShardIdentifier.java | 12 +- .../mbeans/shard/OnDemandShardStateCache.java | 17 +-- .../jmx/mbeans/shard/ShardMBeanFactory.java | 2 +- .../datastore/messages/DataChangedReply.java | 3 +- .../datastore/messages/GetShardDataTree.java | 2 +- .../datastore/messages/SuccessReply.java | 2 +- .../modification/CompositeModification.java | 5 +- .../AbstractIdentifiablePayload.java | 2 + .../AbstractShardManagerCreator.java | 4 +- .../shardmanager/ShardInformation.java | 22 ++-- .../ShardManagerGetSnapshotReplyActor.java | 18 +-- .../cluster/datastore/utils/ClusterUtils.java | 2 +- .../utils/NormalizedNodeAggregator.java | 2 +- .../DistributedShardChangePublisher.java | 3 +- .../DistributedShardedDOMDataTree.java | 1 + .../cluster/sharding/LookupTask.java | 8 +- .../sharding/RoleChangeListenerActor.java | 2 +- .../sharding/ShardedDataTreeActor.java | 8 +- .../sharding/messages/InitConfigListener.java | 2 +- .../impl/factory/AkkaConfigFactory.java | 6 +- .../osgi/BundleClassLoaderFactory.java | 6 +- .../QuarantinedMonitorActorPropsFactory.java | 6 +- .../ConcurrentDOMDataBrokerTest.java | 1 + .../actors/dds/AbstractClientHandleTest.java | 2 + .../AbstractDataStoreClientBehaviorTest.java | 3 +- .../dds/AbstractProxyTransactionTest.java | 4 + .../actors/dds/ClientLocalHistoryTest.java | 14 +-- .../LocalReadOnlyProxyTransactionTest.java | 3 +- .../databroker/actors/dds/TestUtils.java | 15 ++- .../actors/dds/TransactionTester.java | 2 +- .../AbstractTransactionProxyTest.java | 1 + ...reContextContextPropertiesUpdaterTest.java | 1 + .../cluster/datastore/MockIdentifiers.java | 4 + .../ThreePhaseCommitCohortProxyTest.java | 4 +- .../shardmanager/ShardManagerTest.java | 2 +- .../datastore/utils/ActorContextTest.java | 2 +- .../datastore/utils/ForwardingActor.java | 6 +- .../PruningDataTreeModificationTest.java | 1 + .../DistributedShardFrontendTest.java | 9 +- .../md/cluster/datastore/model/CarsModel.java | 15 ++- .../datastore/model/CompositeModel.java | 23 ++-- .../cluster/datastore/model/PeopleModel.java | 11 +- .../datastore/model/SchemaContextHelper.java | 6 +- .../md/cluster/datastore/model/TestModel.java | 7 +- .../impl/AbstractDOMRpcRoutingTableEntry.java | 19 +-- .../impl/DOMNotificationRouterEvent.java | 1 + .../dom/broker/impl/DOMRpcRoutingTable.java | 12 +- .../LegacyEntityOwnershipServiceAdapter.java | 30 ++--- .../md/sal/dom/broker/impl/DOMBrokerTest.java | 6 +- .../remote/rpc/RemoteDOMRpcFuture.java | 3 +- .../remote/rpc/RemoteRpcProviderFactory.java | 6 +- .../controller/remote/rpc/RpcManager.java | 5 +- .../remote/rpc/messages/ExecuteRpc.java | 2 +- .../rpc/registry/gossip/LocalBucket.java | 4 +- 150 files changed, 678 insertions(+), 566 deletions(-) diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java index 81b374d9fa..e823523e8e 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/AbstractDependentComponentFactoryMetadata.java @@ -80,6 +80,7 @@ abstract class AbstractDependentComponentFactoryMetadata implements DependentCom setFailure(failureMessage, null); } + @SuppressWarnings("checkstyle:hiddenField") protected void setFailure(final String failureMessage, final Throwable failureCause) { this.failureMessage = failureMessage; this.failureCause = failureCause; diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java index 83e83e9b17..760853e93b 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/ValidationException.java @@ -102,7 +102,7 @@ public class ValidationException extends Exception { this.message = message; } - public void setTrace(final String stackTrace) { + public void setStackTrace(final String stackTrace) { this.stackTrace = stackTrace; } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java index 08e6d18c64..de4b582abf 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.config.api.jmx.constants; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; -public class ConfigRegistryConstants { +public final class ConfigRegistryConstants { private ConfigRegistryConstants() { } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/osgi/WaitingServiceTracker.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/osgi/WaitingServiceTracker.java index 839612cb18..5cb99d34d4 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/osgi/WaitingServiceTracker.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/osgi/WaitingServiceTracker.java @@ -54,7 +54,7 @@ public final class WaitingServiceTracker implements AutoCloseable { return service; } catch (final InterruptedException e) { throw new ServiceNotFoundException( - String.format("Wait for OSGi service %s was interrrupted", serviceInterface)); + String.format("Wait for OSGi service %s was interrrupted", serviceInterface), e); } } diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/AbstractModule.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/AbstractModule.java index 12287c00f5..29a8ce3ebe 100644 --- a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/AbstractModule.java +++ b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/spi/AbstractModule.java @@ -126,23 +126,23 @@ public abstract class AbstractModule> protected abstract AutoCloseable createInstance(); @Override - public final boolean canReuse(final Module oldModule) { + public final boolean canReuse(final Module prevModule) { // Just cast into a specific instance // TODO unify this method with canReuseInstance (required Module interface to be // generic which requires quite a lot of changes) - return canReuseInstance && getClass().isInstance(oldModule) ? canReuseInstance((M) oldModule) : false; + return canReuseInstance && getClass().isInstance(prevModule) ? canReuseInstance((M) prevModule) : false; } /** * Users are welcome to override this method to provide custom logic for * advanced reusability detection. * - * @param oldModule + * @param prevModule * old instance of a Module * @return true if the old instance is reusable false if a new one should be * spawned */ - protected abstract boolean canReuseInstance(M oldModule); + protected abstract boolean canReuseInstance(M prevModule); /** * By default the oldInstance is returned since this method is by default called @@ -150,14 +150,14 @@ public abstract class AbstractModule> * Users are welcome to override this method to provide custom logic for * advanced reusability. * - * @param oldInstance + * @param prevInstance * old instance of a class wrapped by the module * @return reused instance */ - protected AutoCloseable reuseInstance(final AutoCloseable oldInstance) { + protected AutoCloseable reuseInstance(final AutoCloseable prevInstance) { // implement if instance reuse should be supported. Override canReuseInstance to // change the criteria. - return oldInstance; + return prevInstance; } /** diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java index b3c2d7461b..559e0663de 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/IdentityAttributeRefTest.java @@ -29,7 +29,7 @@ public class IdentityAttributeRefTest { @Test(expected = NullPointerException.class) public void testConstructor2() throws Exception { - IdentityAttributeRef attr = new IdentityAttributeRef(null); + new IdentityAttributeRef(null); } @Test diff --git a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java index 5f6db7291a..11b3f0be7e 100644 --- a/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java +++ b/opendaylight/config/config-api/src/test/java/org/opendaylight/controller/config/api/ValidationExceptionTest.java @@ -67,7 +67,7 @@ public class ValidationExceptionTest { public void testGetTrace() throws Exception { ValidationException.ExceptionMessageWithStackTrace exp = new ValidationException.ExceptionMessageWithStackTrace(); - exp.setTrace("trace"); + exp.setStackTrace("trace"); Assert.assertEquals(exp.getTrace(), "trace"); } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/ConfigSubsystemFacade.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/ConfigSubsystemFacade.java index c535b2184c..0f9e6f3ac0 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/ConfigSubsystemFacade.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/ConfigSubsystemFacade.java @@ -356,7 +356,7 @@ public class ConfigSubsystemFacade implements Closeable { } private Map> createModuleRuntimes( - final ConfigRegistryClient configRegistryClient, + final ConfigRegistryClient client, final Map> mbeanentries) { Map> retVal = new HashMap<>(); @@ -371,7 +371,7 @@ public class ConfigSubsystemFacade implements Closeable { Map cache = new HashMap<>(); RuntimeBeanEntry root = null; for (RuntimeBeanEntry rbe : mbe.getRuntimeBeans()) { - cache.put(rbe, new InstanceConfig(configRegistryClient, rbe.getYangPropertiesToTypesMap(), + cache.put(rbe, new InstanceConfig(client, rbe.getYangPropertiesToTypesMap(), mbe.getNullableDummyContainerName())); if (rbe.isRoot()) { root = rbe; diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/ConfigHandlingException.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/ConfigHandlingException.java index 2d8bcbb83b..50db588f6f 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/ConfigHandlingException.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/exception/ConfigHandlingException.java @@ -16,11 +16,21 @@ public class ConfigHandlingException extends DocumentedException { public ConfigHandlingException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity) { - this(message, errorType, errorTag, errorSeverity, Collections.emptyMap()); + this(message, null, errorType, errorTag, errorSeverity, Collections.emptyMap()); + } + + public ConfigHandlingException(final String message, final Exception cause, final ErrorType errorType, + final ErrorTag errorTag, final ErrorSeverity errorSeverity) { + this(message, cause, errorType, errorTag, errorSeverity, Collections.emptyMap()); } public ConfigHandlingException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity, final Map errorInfo) { - super(message, errorType, errorTag, errorSeverity, errorInfo); + this(message, null, errorType, errorTag, errorSeverity, errorInfo); + } + + public ConfigHandlingException(final String message, final Exception cause, final ErrorType errorType, + final ErrorTag errorTag, final ErrorSeverity errorSeverity, final Map errorInfo) { + super(message, cause, errorType, errorTag, errorSeverity, errorInfo); } } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/AttributeIfcSwitchStatement.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/AttributeIfcSwitchStatement.java index f5131c8752..36a41d0441 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/AttributeIfcSwitchStatement.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/AttributeIfcSwitchStatement.java @@ -24,6 +24,7 @@ public abstract class AttributeIfcSwitchStatement { private AttributeIfc lastAttribute; + @SuppressWarnings("checkstyle:avoidHidingCauseException") public T switchAttribute(final AttributeIfc attributeIfc) { this.lastAttribute = attributeIfc; diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/AbstractAttributeReadingStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/AbstractAttributeReadingStrategy.java index 4920cc563a..6d193118b5 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/AbstractAttributeReadingStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/AbstractAttributeReadingStrategy.java @@ -34,6 +34,7 @@ public abstract class AbstractAttributeReadingStrategy implements AttributeReadi abstract AttributeConfigElement readElementHook(List configNodes) throws DocumentedException; + @SuppressWarnings("checkstyle:hiddenField") protected Object postprocessNullableDefault(final String nullableDefault) { return nullableDefault; } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/ObjectXmlReader.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/ObjectXmlReader.java index 1878808f3f..4fa679645f 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/ObjectXmlReader.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/fromxml/ObjectXmlReader.java @@ -31,6 +31,7 @@ public class ObjectXmlReader extends AttributeIfcSwitchStatement> identityMap; + @SuppressWarnings("checkstyle:hiddenField") public Map prepareReading(final Map yangToAttrConfig, final Map> identityMap) { Map strategies = Maps.newHashMap(); @@ -43,8 +44,8 @@ public class ObjectXmlReader extends AttributeIfcSwitchStatement>> prepareMapping( final Map configDefinition, final EnumResolver enumResolver) { this.enumResolver = Preconditions.checkNotNull(enumResolver); diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ArrayAttributeResolvingStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ArrayAttributeResolvingStrategy.java index 7f085978a0..ec2b665b2f 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ArrayAttributeResolvingStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ArrayAttributeResolvingStrategy.java @@ -107,7 +107,7 @@ public final class ArrayAttributeResolvingStrategy extends AbstractAttributeReso try { return (Class) innerTypeClass.getField("TYPE").get(null); } catch (final IllegalAccessException | IllegalArgumentException | NoSuchFieldException e) { - throw new IllegalStateException("Unable to determine primitive type to " + innerTypeClass); + throw new IllegalStateException("Unable to determine primitive type to " + innerTypeClass, e); } } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ObjectResolver.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ObjectResolver.java index f1050b9df3..4fcdc1298c 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ObjectResolver.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/ObjectResolver.java @@ -33,6 +33,7 @@ public class ObjectResolver extends AttributeIfcSwitchStatement>> prepareResolving( final Map configDefinition, final EnumResolver enumResolver) { this.enumResolver = enumResolver; diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/SimpleAttributeResolvingStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/SimpleAttributeResolvingStrategy.java index 9a42e93d2e..12f48e3777 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/SimpleAttributeResolvingStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/resolving/SimpleAttributeResolvingStrategy.java @@ -83,7 +83,7 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS try { return parseObject(type, value); } catch (final DocumentedException e) { - throw new DocumentedException("Unable to resolve attribute " + attrName + " from " + value, + throw new DocumentedException("Unable to resolve attribute " + attrName + " from " + value, e, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } @@ -96,7 +96,7 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS return method.invoke(null, value); } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { LOG.trace("Error parsing object ", e); - throw new DocumentedException("Error parsing object.", DocumentedException.ErrorType.APPLICATION, + throw new DocumentedException("Error parsing object.", e, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } } @@ -141,7 +141,7 @@ final class SimpleAttributeResolvingStrategy extends AbstractAttributeResolvingS return Util.readDate(value); } catch (final ParseException e) { LOG.trace("Unable parse value {} due to ", value, e); - throw new DocumentedException("Unable to parse value " + value + " as date.", + throw new DocumentedException("Unable to parse value " + value + " as date.", e, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/toxml/ObjectXmlWriter.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/toxml/ObjectXmlWriter.java index a62b243eb7..a3a8b7aafa 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/toxml/ObjectXmlWriter.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/attributes/toxml/ObjectXmlWriter.java @@ -28,6 +28,7 @@ public class ObjectXmlWriter extends AttributeIfcSwitchStatement prepareWriting(final Map yangToAttrConfig, final Document document) { @@ -43,6 +44,7 @@ public class ObjectXmlWriter extends AttributeIfcSwitchStatement namespace) { Element typeElement = XmlUtil.createElement(document, key, namespace); diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java index b9e4bce94d..ff9a9f6ff7 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java @@ -171,7 +171,7 @@ public final class InstanceConfig { } catch (final DocumentedException e) { throw new DocumentedException("Error reading module " + typeElement.getTextContent() + " : " + nameElement.getTextContent() + " - Expected child node with name " - + nullableDummyContainerName + "." + e.getMessage()); + + nullableDummyContainerName + "." + e.getMessage(), e); } } // else 2 elements, no need to descend } @@ -189,7 +189,7 @@ public final class InstanceConfig { } catch (final DocumentedException e) { throw new DocumentedException( "Error reading module " + typeElement.getTextContent() + " : " + nameElement.getTextContent() - + " - " + e.getMessage(), + + " - " + e.getMessage(), e, e.getErrorType(), e.getErrorTag(), e.getErrorSeverity(), e.getErrorInfo()); } // TODO: add check for conflicts between global and local edit strategy diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreActivator.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreActivator.java index 0578b42701..016c944d80 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreActivator.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreActivator.java @@ -43,6 +43,7 @@ public class YangStoreActivator implements BundleActivator { private ServiceRegistration osgiRegistrayion; @Override + @SuppressWarnings("checkstyle:hiddenField") public void start(final BundleContext context) throws Exception { LOG.debug("ConfigPersister starting"); this.context = context; @@ -125,6 +126,7 @@ public class YangStoreActivator implements BundleActivator { } @Override + @SuppressWarnings("checkstyle:hiddenField") public void stop(final BundleContext context) throws Exception { if (this.configRegistryLookup != null) { this.configRegistryLookup.interrupt(); @@ -147,7 +149,7 @@ public class YangStoreActivator implements BundleActivator { private final YangStoreService yangStoreService; - private ConfigRegistryLookupThread(final YangStoreService yangStoreService) { + ConfigRegistryLookupThread(final YangStoreService yangStoreService) { super("config-registry-lookup"); this.yangStoreService = yangStoreService; } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreSnapshot.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreSnapshot.java index c4ca3e74db..ce34496810 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreSnapshot.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/osgi/YangStoreSnapshot.java @@ -72,7 +72,7 @@ public final class YangStoreSnapshot implements YangStoreContext, EnumResolver { } } - final Map> moduleMXBeanEntryMap = Maps.newHashMap(); + final Map> moduleMXBeanEntries = Maps.newHashMap(); final Map> qNamesToIdentitiesToModuleMXBeanEntries = new HashMap<>(); @@ -88,11 +88,11 @@ public final class YangStoreSnapshot implements YangStoreContext, EnumResolver { final Map namesToMBEs = Collections.unmodifiableMap(ModuleMXBeanEntry.create(module, qNamesToSIEs, schemaContext, typeProviderWrapper, packageName)); - moduleMXBeanEntryMap.put(module.getNamespace().toString(), namesToMBEs); + moduleMXBeanEntries.put(module.getNamespace().toString(), namesToMBEs); qNamesToIdentitiesToModuleMXBeanEntries.put(qName, namesToMBEs); } - this.moduleMXBeanEntryMap = Collections.unmodifiableMap(moduleMXBeanEntryMap); + this.moduleMXBeanEntryMap = Collections.unmodifiableMap(moduleMXBeanEntries); this.namesToIdentitiesToModuleMXBeanEntries = Collections.unmodifiableMap(qNamesToIdentitiesToModuleMXBeanEntries); } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/DeleteEditConfigStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/DeleteEditConfigStrategy.java index 08d9d21cdd..c1a1fd47a6 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/DeleteEditConfigStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/DeleteEditConfigStrategy.java @@ -24,8 +24,10 @@ public class DeleteEditConfigStrategy extends AbstractEditConfigStrategy { private static final Logger LOG = LoggerFactory.getLogger(DeleteEditConfigStrategy.class); @Override - void handleMissingInstance(Map configuration, ConfigTransactionClient ta, - String module, String instance, ServiceRegistryWrapper services) throws ConfigHandlingException { + void handleMissingInstance(final Map configuration, + final ConfigTransactionClient ta, final String module, final String instance, + final ServiceRegistryWrapper services) + throws ConfigHandlingException { throw new ConfigHandlingException( String.format("Unable to delete %s : %s , ServiceInstance not found", module, instance), DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, @@ -33,14 +35,14 @@ public class DeleteEditConfigStrategy extends AbstractEditConfigStrategy { } @Override - void executeStrategy(Map configuration, ConfigTransactionClient ta, ObjectName on, - ServiceRegistryWrapper services) throws ConfigHandlingException { + void executeStrategy(final Map configuration, final ConfigTransactionClient ta, + final ObjectName on, final ServiceRegistryWrapper services) throws ConfigHandlingException { try { ta.destroyModule(on); LOG.debug("ServiceInstance {} deleted successfully", on); } catch (InstanceNotFoundException e) { throw new ConfigHandlingException( - String.format("Unable to delete %s because of exception %s" + on, e.getMessage()), + String.format("Unable to delete %s because of exception %s" + on, e.getMessage()), e, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MergeEditConfigStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MergeEditConfigStrategy.java index ebd98f8c1f..02aa783cb1 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MergeEditConfigStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MergeEditConfigStrategy.java @@ -69,7 +69,7 @@ public class MergeEditConfigStrategy extends AbstractEditConfigStrategy { + "Error with attribute %s : %s ", on, configAttributeEntry.getKey(), - configAttributeEntry.getValue()), + configAttributeEntry.getValue()), e, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MissingInstanceHandlingStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MissingInstanceHandlingStrategy.java index 591595eaa5..637e837284 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MissingInstanceHandlingStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/MissingInstanceHandlingStrategy.java @@ -31,8 +31,7 @@ public class MissingInstanceHandlingStrategy extends AbstractEditConfigStrategy LOG.trace("New instance for {} {} created under name {}", module, instance, on); } catch (InstanceAlreadyExistsException e1) { throw new ConfigHandlingException(String.format("Unable to create instance for %s : %s.", module, instance), - DocumentedException.ErrorType.APPLICATION, - DocumentedException.ErrorTag.OPERATION_FAILED, + e1, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/ReCreateEditConfigStrategy.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/ReCreateEditConfigStrategy.java index 4000253e1d..776abdce40 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/ReCreateEditConfigStrategy.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/strategy/ReCreateEditConfigStrategy.java @@ -40,7 +40,7 @@ public class ReCreateEditConfigStrategy extends AbstractEditConfigStrategy { ta.reCreateModule(objectName); } catch (InstanceNotFoundException e) { throw new ConfigHandlingException(String.format("Unable to recreate instance for %s", objectName), - DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, + e, DocumentedException.ErrorType.APPLICATION, DocumentedException.ErrorTag.OPERATION_FAILED, DocumentedException.ErrorSeverity.ERROR); } } diff --git a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java index a40bac9b05..e255757dc1 100644 --- a/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/transactions/TransactionProvider.java @@ -133,7 +133,7 @@ public class TransactionProvider implements AutoCloseable { /** * Commit and notification send must be atomic. */ - public synchronized CommitStatus commitTransaction(final ConfigRegistryClient configRegistryClient) + public synchronized CommitStatus commitTransaction(final ConfigRegistryClient client) throws ValidationException, ConflictingVersionException { if (!getTransaction().isPresent()) { // making empty commit without prior opened transaction, just return commit @@ -144,7 +144,7 @@ public class TransactionProvider implements AutoCloseable { final Optional maybeTaON = getTransaction(); ObjectName taON = maybeTaON.get(); try { - CommitStatus status = configRegistryClient.commitConfig(taON); + CommitStatus status = client.commitConfig(taON); // clean up allOpenedTransactions.remove(candidateTx); candidateTx = null; diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DeadlockMonitor.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DeadlockMonitor.java index cad98b30f4..6115326632 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DeadlockMonitor.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DeadlockMonitor.java @@ -67,9 +67,9 @@ public class DeadlockMonitor implements AutoCloseable { return "DeadlockMonitor{" + transactionIdentifier + '}'; } - private class DeadlockMonitorRunnable extends Thread { + private final class DeadlockMonitorRunnable extends Thread { - private DeadlockMonitorRunnable() { + DeadlockMonitorRunnable() { super(DeadlockMonitor.this.toString()); } @@ -108,23 +108,23 @@ public class DeadlockMonitor implements AutoCloseable { } } - private static class ModuleIdentifierWithNanos { + private static final class ModuleIdentifierWithNanos { private static ModuleIdentifierWithNanos empty = new ModuleIdentifierWithNanos(); @Nullable private final ModuleIdentifier moduleIdentifier; private final long nanoTime; - private ModuleIdentifierWithNanos() { + ModuleIdentifierWithNanos() { this((ModuleIdentifier) null); } - private ModuleIdentifierWithNanos(final ModuleIdentifier moduleIdentifier) { + ModuleIdentifierWithNanos(final ModuleIdentifier moduleIdentifier) { this.moduleIdentifier = moduleIdentifier; nanoTime = System.nanoTime(); } - private ModuleIdentifierWithNanos(final ModuleIdentifierWithNanos copy) { + ModuleIdentifierWithNanos(final ModuleIdentifierWithNanos copy) { moduleIdentifier = copy.moduleIdentifier; nanoTime = copy.nanoTime; } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java index 51cef4d3ea..b682766f75 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java @@ -39,7 +39,7 @@ import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ServiceReferenceRegistryImpl +public final class ServiceReferenceRegistryImpl implements CloseableServiceReferenceReadableRegistry, SearchableServiceReferenceWritableRegistry { private static final Logger LOG = LoggerFactory.getLogger(ServiceReferenceRegistryImpl.class); diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java index e69aa8611a..f46113fb9a 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java @@ -272,6 +272,7 @@ public final class DependencyResolverImpl implements DependencyResolver, Compara } @Override + @SuppressWarnings("checkstyle:hiddenField") public Object getAttribute(final ObjectName name, final String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException { ObjectName newName = translateServiceRefIfPossible(name); @@ -281,6 +282,7 @@ public final class DependencyResolverImpl implements DependencyResolver, Compara } @Override + @SuppressWarnings("checkstyle:hiddenField") public T newMXBeanProxy(final ObjectName name, final Class interfaceClass) { ObjectName newName = translateServiceRefIfPossible(name); // add transaction name diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java index ada8a17532..1a2c6b7b22 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java @@ -132,6 +132,7 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut } @Override + @SuppressWarnings("checkstyle:avoidHidingCauseException") protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable { boolean isGetInstance = "getInstance".equals(method.getName()); diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java index e5bb549492..54f7946db5 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java @@ -110,17 +110,17 @@ public abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrappe * platform mbean server. Wait until this wrapper gets unregistered, in that * case unregister the module and remove listener. */ - private NotificationListener registerActualModule(final ObjectName objectNameInternal, + private NotificationListener registerActualModule(final ObjectName internalObjectName, final MBeanServer configMBeanServer) { try { - internalServer.registerMBean(module, objectNameInternal); + internalServer.registerMBean(module, internalObjectName); } catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | IllegalStateException e) { - throw new IllegalStateException("Error occured during mbean registration with name " + objectNameInternal, + throw new IllegalStateException("Error occured during mbean registration with name " + internalObjectName, e); } - NotificationListener listener = new ModuleNotificationListener(objectNameInternal, internalServer, + NotificationListener listener = new ModuleNotificationListener(internalObjectName, internalServer, configMBeanServer); try { configMBeanServer.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, listener, null, null); @@ -156,7 +156,7 @@ public abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrappe // inspect all exported interfaces ending with MXBean, extract getters & // setters into attribute holder - private Map buildMBeanInfo(final boolean writable, final ModuleIdentifier moduleIdentifier, + private Map buildMBeanInfo(final boolean writable, final ModuleIdentifier modId, final Set> jmxInterfaces, final ObjectName internalObjectName) { // internal variables for describing MBean elements @@ -187,7 +187,7 @@ public abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrappe try { setter = module.getClass().getMethod(method.getName(), method.getParameterTypes()); } catch (final NoSuchMethodException e) { - throw new RuntimeException("No such method on " + moduleIdentifier, e); + throw new RuntimeException("No such method on " + modId, e); } RequireInterface ifc = AttributeHolder.findRequireInterfaceAnnotation(setter, jmxInterfaces); String description = null; diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/JMXNotifierConfigRegistry.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/JMXNotifierConfigRegistry.java index a4fcdbbf8e..50cccc796f 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/JMXNotifierConfigRegistry.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/JMXNotifierConfigRegistry.java @@ -165,7 +165,7 @@ public class JMXNotifierConfigRegistry implements ConfigRegistryImplMXBean, Auto beanServer.unregisterMBean(ConfigJMXNotification.OBJECT_NAME); } catch (InstanceNotFoundException | MBeanRegistrationException e) { throw new IllegalStateException( - "Notifier: " + ConfigJMXNotification.OBJECT_NAME + " not found in JMX when closing"); + "Notifier: " + ConfigJMXNotification.OBJECT_NAME + " not found in JMX when closing", e); } } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java index 71fcd58400..cfbd95a39e 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java @@ -40,7 +40,7 @@ public final class ModuleInfoBundleTracker private final RefreshingSCPModuleInfoRegistry moduleInfoRegistry; - private BundleTracker>> bundleTracker; + private BundleTracker>> tracker; private boolean starting; public ModuleInfoBundleTracker(final RefreshingSCPModuleInfoRegistry moduleInfoRegistry) { @@ -51,7 +51,7 @@ public final class ModuleInfoBundleTracker LOG.debug("ModuleInfoBundleTracker open starting with bundleTracker {}", bundleTracker); if (bundleTracker != null) { - this.bundleTracker = bundleTracker; + this.tracker = bundleTracker; starting = true; bundleTracker.open(); @@ -66,9 +66,9 @@ public final class ModuleInfoBundleTracker @Override public void close() { - if (bundleTracker != null) { - bundleTracker.close(); - bundleTracker = null; + if (tracker != null) { + tracker.close(); + tracker = null; } } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java index 9871a04f42..97042f2c7d 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java @@ -79,7 +79,7 @@ public class RefreshingSCPModuleInfoRegistry implements ModuleInfoRegistry, Auto private class ObjectRegistrationWrapper implements ObjectRegistration { private final ObjectRegistration inner; - private ObjectRegistrationWrapper(final ObjectRegistration inner) { + ObjectRegistrationWrapper(final ObjectRegistration inner) { this.inner = inner; } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/LookupBeansUtil.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/LookupBeansUtil.java index fd1e37a98f..92184f4048 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/LookupBeansUtil.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/LookupBeansUtil.java @@ -12,7 +12,7 @@ import javax.management.InstanceNotFoundException; import javax.management.ObjectName; import org.opendaylight.controller.config.api.LookupRegistry; -public class LookupBeansUtil { +public final class LookupBeansUtil { private LookupBeansUtil() { } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java index 2642e56022..816f9c6ca0 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java @@ -20,7 +20,7 @@ import org.osgi.util.tracker.ServiceTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OsgiRegistrationUtil { +public final class OsgiRegistrationUtil { private static final Logger LOG = LoggerFactory.getLogger(OsgiRegistrationUtil.class); private OsgiRegistrationUtil() { diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigTest.java index c03c226978..628baeebab 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/AbstractConfigTest.java @@ -271,7 +271,7 @@ public abstract class AbstractConfigTest extends AbstractLockedPlatformMBeanServ * jmx proxy which will be wrapped and returned */ protected T rethrowCause(final T innerObject) { - @SuppressWarnings("unchecked") + @SuppressWarnings({ "unchecked", "checkstyle:avoidHidingCauseException" }) final T proxy = (T) Proxy.newProxyInstance(innerObject.getClass().getClassLoader(), innerObject.getClass().getInterfaces(), (proxy1, method, args) -> { try { diff --git a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTrackerTest.java b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTrackerTest.java index 7d48ad17ed..7f6253ea46 100644 --- a/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTrackerTest.java +++ b/opendaylight/config/config-manager/src/test/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTrackerTest.java @@ -154,7 +154,7 @@ public class ModuleFactoryBundleTrackerTest { static class NotExtendingTestingFactory { } - static class NoAccessConstructorTestingFactory extends TestingFactory { + static final class NoAccessConstructorTestingFactory extends TestingFactory { private NoAccessConstructorTestingFactory() { } } diff --git a/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/xml/DocumentedException.java b/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/xml/DocumentedException.java index cf96e2630d..6554c6fed5 100644 --- a/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/xml/DocumentedException.java +++ b/opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/xml/DocumentedException.java @@ -188,6 +188,14 @@ public class DocumentedException extends Exception { ); } + public DocumentedException(final String message, final Exception cause) { + this(message, cause, + DocumentedException.ErrorType.APPLICATION, + DocumentedException.ErrorTag.INVALID_VALUE, + DocumentedException.ErrorSeverity.ERROR + ); + } + public DocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag, final ErrorSeverity errorSeverity) { this(message, errorType, errorTag, errorSeverity, Collections. emptyMap()); diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestProxyV1.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestProxyV1.java index 49742d8341..88820bd1f5 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestProxyV1.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/commands/AbstractReadTransactionRequestProxyV1.java @@ -52,5 +52,6 @@ abstract class AbstractReadTransactionRequestProxyV1> implements Externa message = (T) in.readObject(); } + @SuppressWarnings("checkstyle:hiddenField") abstract Envelope createEnvelope(T wrappedNessage, long sessionId, long txSequence); final Object readResolve() { diff --git a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractResponseEnvelopeProxy.java b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractResponseEnvelopeProxy.java index 1dbb86bb2f..1e873b4bdf 100644 --- a/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractResponseEnvelopeProxy.java +++ b/opendaylight/md-sal/cds-access-api/src/main/java/org/opendaylight/controller/cluster/access/concepts/AbstractResponseEnvelopeProxy.java @@ -43,5 +43,6 @@ abstract class AbstractResponseEnvelopeProxy> extends A return createEnvelope(message, sessionId, txSequence, executionTimeNanos); } + @SuppressWarnings("checkstyle:hiddenField") abstract ResponseEnvelope createEnvelope(T message, long sessionId, long txSequence, long executionTimeNanos); } diff --git a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractEnvelopeTest.java b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractEnvelopeTest.java index f31054905e..3f56f08060 100644 --- a/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractEnvelopeTest.java +++ b/opendaylight/md-sal/cds-access-api/src/test/java/org/opendaylight/controller/cluster/access/concepts/AbstractEnvelopeTest.java @@ -47,5 +47,6 @@ public abstract class AbstractEnvelopeTest> { protected abstract E createEnvelope(); + @SuppressWarnings("checkstyle:hiddenField") protected abstract void doAdditionalAssertions(E envelope, E resolvedObject); } diff --git a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java index 6a3ba276fb..acf876b6ce 100644 --- a/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java +++ b/opendaylight/md-sal/cds-access-client/src/main/java/org/opendaylight/controller/cluster/access/client/ReconnectingClientConnection.java @@ -36,6 +36,7 @@ public final class ReconnectingClientConnection extends A } @Override + @SuppressWarnings("checkstyle:hiddenField") ClientActorBehavior lockedReconnect(final ClientActorBehavior current, final RequestException cause) { this.cause = Preconditions.checkNotNull(cause); LOG.warn("Skipping reconnect of already-reconnecting connection {}", this); diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AccessClientUtil.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AccessClientUtil.java index e31fc55917..92d310dddc 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AccessClientUtil.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AccessClientUtil.java @@ -22,7 +22,10 @@ import org.opendaylight.controller.cluster.access.concepts.ResponseEnvelope; /** * Util class to access package private members in cds-access-client for test purposes. */ -public class AccessClientUtil { +public final class AccessClientUtil { + private AccessClientUtil() { + throw new UnsupportedOperationException(); + } public static ClientActorContext createClientActorContext(final ActorSystem system, final ActorRef actor, final ClientIdentifier id, final String persistenceId) { diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java index 513253e669..598b598db8 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java @@ -180,7 +180,7 @@ public class ActorBehaviorTest { return Props.create(MockedActor.class, () -> new MockedActor(frontendId, initialBehavior)); } - private MockedActor(final FrontendIdentifier frontendId, final ClientActorBehavior initialBehavior) { + MockedActor(final FrontendIdentifier frontendId, final ClientActorBehavior initialBehavior) { super(frontendId); this.initialBehavior = initialBehavior; } diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ConnectionEntryMatcher.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ConnectionEntryMatcher.java index 7f40dc1b37..94948767ae 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ConnectionEntryMatcher.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ConnectionEntryMatcher.java @@ -14,7 +14,7 @@ import org.opendaylight.controller.cluster.access.concepts.Request; /** * Matcher checks, whether matched {@link ConnectionEntry} tracks provided {@link Request}. */ -class ConnectionEntryMatcher extends BaseMatcher { +final class ConnectionEntryMatcher extends BaseMatcher { private final Request request; diff --git a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java index 5f53dcc1d8..d6b1039631 100644 --- a/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java +++ b/opendaylight/md-sal/mdsal-trace/dom-impl/src/main/java/org/opendaylight/controller/md/sal/trace/dom/impl/TracingBroker.java @@ -147,6 +147,7 @@ public class TracingBroker implements TracingDOMDataBroker { return child.startsWith(parent.substring(parentOffset), childOffset); } + @SuppressWarnings("checkstyle:hiddenField") public boolean subtreesOverlap(YangInstanceIdentifier iid, LogicalDatastoreType store, AsyncDataBroker.DataChangeScope scope) { if (this.store != null && !this.store.equals(store)) { @@ -165,6 +166,7 @@ public class TracingBroker implements TracingDOMDataBroker { } } + @SuppressWarnings("checkstyle:hiddenField") public boolean eventIsOfInterest(YangInstanceIdentifier iid, LogicalDatastoreType store) { if (this.store != null && !this.store.equals(store)) { return false; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImpl.java index 8bd0cf3d34..25710880dd 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImpl.java @@ -55,7 +55,7 @@ public class FollowerLogInformationImpl implements FollowerLogInformation { * @param matchIndex the initial match index. * @param context the RaftActorContext. */ - public FollowerLogInformationImpl(PeerInfo peerInfo, long matchIndex, RaftActorContext context) { + public FollowerLogInformationImpl(final PeerInfo peerInfo, final long matchIndex, final RaftActorContext context) { this.nextIndex = context.getCommitIndex(); this.matchIndex = matchIndex; this.context = context; @@ -78,7 +78,8 @@ public class FollowerLogInformationImpl implements FollowerLogInformation { } @Override - public boolean setNextIndex(long nextIndex) { + @SuppressWarnings("checkstyle:hiddenField") + public boolean setNextIndex(final long nextIndex) { if (this.nextIndex != nextIndex) { this.nextIndex = nextIndex; return true; @@ -93,7 +94,8 @@ public class FollowerLogInformationImpl implements FollowerLogInformation { } @Override - public boolean setMatchIndex(long matchIndex) { + @SuppressWarnings("checkstyle:hiddenField") + public boolean setMatchIndex(final long matchIndex) { // If the new match index is the index of the entry currently being sliced, then we know slicing is complete // and the follower received the entry and responded so clear the slicedLogEntryIndex if (isLogEntrySlicingInProgress() && slicedLogEntryIndex == matchIndex) { @@ -184,7 +186,7 @@ public class FollowerLogInformationImpl implements FollowerLogInformation { } @Override - public void setPayloadVersion(short payloadVersion) { + public void setPayloadVersion(final short payloadVersion) { this.payloadVersion = payloadVersion; } @@ -194,7 +196,7 @@ public class FollowerLogInformationImpl implements FollowerLogInformation { } @Override - public void setRaftVersion(short raftVersion) { + public void setRaftVersion(final short raftVersion) { this.raftVersion = raftVersion; } @@ -205,7 +207,7 @@ public class FollowerLogInformationImpl implements FollowerLogInformation { } @Override - public void setLeaderInstallSnapshotState(@Nonnull LeaderInstallSnapshotState state) { + public void setLeaderInstallSnapshotState(@Nonnull final LeaderInstallSnapshotState state) { if (this.installSnapshotState == null) { this.installSnapshotState = Preconditions.checkNotNull(state); } @@ -219,7 +221,7 @@ public class FollowerLogInformationImpl implements FollowerLogInformation { } @Override - public void setSlicedLogEntryIndex(long index) { + public void setSlicedLogEntryIndex(final long index) { slicedLogEntryIndex = index; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/GetSnapshotReplyActor.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/GetSnapshotReplyActor.java index 203a61233d..89b454425e 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/GetSnapshotReplyActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/GetSnapshotReplyActor.java @@ -33,14 +33,14 @@ class GetSnapshotReplyActor extends UntypedActor { private final Params params; - private GetSnapshotReplyActor(Params params) { + GetSnapshotReplyActor(final Params params) { this.params = params; getContext().setReceiveTimeout(params.receiveTimeout); } @Override - public void onReceive(Object message) { + public void onReceive(final Object message) { if (message instanceof CaptureSnapshotReply) { Snapshot snapshot = Snapshot.create( ((CaptureSnapshotReply)message).getSnapshotState(), @@ -65,8 +65,9 @@ class GetSnapshotReplyActor extends UntypedActor { } } - public static Props props(CaptureSnapshot captureSnapshot, ElectionTerm electionTerm, ActorRef replyToActor, - Duration receiveTimeout, String id, ServerConfigurationPayload updatedPeerInfo) { + public static Props props(final CaptureSnapshot captureSnapshot, final ElectionTerm electionTerm, + final ActorRef replyToActor, final Duration receiveTimeout, final String id, + final ServerConfigurationPayload updatedPeerInfo) { return Props.create(GetSnapshotReplyActor.class, new Params(captureSnapshot, electionTerm, replyToActor, receiveTimeout, id, updatedPeerInfo)); } @@ -79,8 +80,8 @@ class GetSnapshotReplyActor extends UntypedActor { final String id; final ServerConfigurationPayload peerInformation; - Params(CaptureSnapshot captureSnapshot, ElectionTerm electionTerm, ActorRef replyToActor, - Duration receiveTimeout, String id, ServerConfigurationPayload peerInfo) { + Params(final CaptureSnapshot captureSnapshot, final ElectionTerm electionTerm, final ActorRef replyToActor, + final Duration receiveTimeout, final String id, final ServerConfigurationPayload peerInfo) { this.captureSnapshot = Preconditions.checkNotNull(captureSnapshot); this.electionTerm = Preconditions.checkNotNull(electionTerm); this.replyToActor = Preconditions.checkNotNull(replyToActor); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ImmutableElectionTerm.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ImmutableElectionTerm.java index 56cda0307c..5f7d08c08b 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ImmutableElectionTerm.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ImmutableElectionTerm.java @@ -12,11 +12,11 @@ package org.opendaylight.controller.cluster.raft; * * @author Thomas Pantelis */ -public class ImmutableElectionTerm implements ElectionTerm { +public final class ImmutableElectionTerm implements ElectionTerm { private final long currentTerm; private final String votedFor; - private ImmutableElectionTerm(long currentTerm, String votedFor) { + private ImmutableElectionTerm(final long currentTerm, final String votedFor) { this.currentTerm = currentTerm; this.votedFor = votedFor; } @@ -32,12 +32,12 @@ public class ImmutableElectionTerm implements ElectionTerm { } @Override - public void update(long newTerm, String newVotedFor) { + public void update(final long newTerm, final String newVotedFor) { throw new UnsupportedOperationException(); } @Override - public void updateAndPersist(long newTerm, String newVotedFor) { + public void updateAndPersist(final long newTerm, final String newVotedFor) { throw new UnsupportedOperationException(); } @@ -46,7 +46,7 @@ public class ImmutableElectionTerm implements ElectionTerm { return "ImmutableElectionTerm [currentTerm=" + currentTerm + ", votedFor=" + votedFor + "]"; } - public static ElectionTerm copyOf(ElectionTerm from) { + public static ElectionTerm copyOf(final ElectionTerm from) { return new ImmutableElectionTerm(from.getCurrentTerm(), from.getVotedFor()); } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/NoopProcedure.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/NoopProcedure.java index d494c88283..64794ca054 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/NoopProcedure.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/NoopProcedure.java @@ -16,7 +16,7 @@ import akka.japi.Procedure; * * @param the Procedure type */ -public class NoopProcedure implements Procedure { +public final class NoopProcedure implements Procedure { private static final NoopProcedure INSTANCE = new NoopProcedure<>(); @@ -29,7 +29,7 @@ public class NoopProcedure implements Procedure { } @Override - public void apply(Object notUsed) { + public void apply(final Object notUsed) { // nothing to do } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java index fd6eb17384..be38c17f4e 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java @@ -123,8 +123,8 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { private boolean shuttingDown; - protected RaftActor(String id, Map peerAddresses, - Optional configParams, short payloadVersion) { + protected RaftActor(final String id, final Map peerAddresses, + final Optional configParams, final short payloadVersion) { persistentProvider = new PersistentDataProvider(this); delegatingPersistenceProvider = new RaftActorDelegatingPersistentDataProvider(null, persistentProvider); @@ -157,7 +157,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } @Override - protected void handleRecover(Object message) { + protected void handleRecover(final Object message) { if (raftRecovery == null) { raftRecovery = newRaftActorRecoverySupport(); } @@ -183,7 +183,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { @VisibleForTesting @SuppressWarnings("checkstyle:IllegalCatch") - protected void changeCurrentBehavior(RaftActorBehavior newBehavior) { + protected void changeCurrentBehavior(final RaftActorBehavior newBehavior) { final RaftActorBehavior currentBehavior = getCurrentBehavior(); if (currentBehavior != null) { try { @@ -327,7 +327,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } private void initiateLeadershipTransfer(final RaftActorLeadershipTransferCohort.OnComplete onComplete, - @Nullable final String followerId, long newLeaderTimeoutInMillis) { + @Nullable final String followerId, final long newLeaderTimeoutInMillis) { LOG.debug("{}: Initiating leader transfer", persistenceId()); RaftActorLeadershipTransferCohort leadershipTransferInProgress = context.getRaftActorLeadershipTransferCohort(); @@ -336,12 +336,12 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { leadershipTransferInProgress.setNewLeaderTimeoutInMillis(newLeaderTimeoutInMillis); leadershipTransferInProgress.addOnComplete(new RaftActorLeadershipTransferCohort.OnComplete() { @Override - public void onSuccess(ActorRef raftActorRef) { + public void onSuccess(final ActorRef raftActorRef) { context.setRaftActorLeadershipTransferCohort(null); } @Override - public void onFailure(ActorRef raftActorRef) { + public void onFailure(final ActorRef raftActorRef) { context.setRaftActorLeadershipTransferCohort(null); } }); @@ -381,13 +381,13 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { if (context.hasFollowers()) { initiateLeadershipTransfer(new RaftActorLeadershipTransferCohort.OnComplete() { @Override - public void onSuccess(ActorRef raftActorRef) { + public void onSuccess(final ActorRef raftActorRef) { LOG.debug("{}: leader transfer succeeded - sending PoisonPill", persistenceId()); raftActorRef.tell(PoisonPill.getInstance(), raftActorRef); } @Override - public void onFailure(ActorRef raftActorRef) { + public void onFailure(final ActorRef raftActorRef) { LOG.debug("{}: leader transfer failed - sending PoisonPill", persistenceId()); raftActorRef.tell(PoisonPill.getInstance(), raftActorRef); } @@ -417,7 +417,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } } - private void switchBehavior(SwitchBehavior message) { + private void switchBehavior(final SwitchBehavior message) { if (!getRaftActorContext().getRaftPolicy().automaticElectionsEnabled()) { RaftState newState = message.getNewState(); if (newState == RaftState.Leader || newState == RaftState.Follower) { @@ -499,7 +499,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { return OnDemandRaftState.builder(); } - private void handleBehaviorChange(BehaviorState oldBehaviorState, RaftActorBehavior currentBehavior) { + private void handleBehaviorChange(final BehaviorState oldBehaviorState, final RaftActorBehavior currentBehavior) { RaftActorBehavior oldBehavior = oldBehaviorState.getBehavior(); if (oldBehavior != currentBehavior) { @@ -537,7 +537,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } } - private void handleApplyState(ApplyState applyState) { + private void handleApplyState(final ApplyState applyState) { long startTime = System.nanoTime(); Payload payload = applyState.getReplicatedLogEntry().getData(); @@ -560,7 +560,8 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { self().tell(applyState, self()); } - protected LeaderStateChanged newLeaderStateChanged(String memberId, String leaderId, short leaderPayloadVersion) { + protected LeaderStateChanged newLeaderStateChanged(final String memberId, final String leaderId, + final short leaderPayloadVersion) { return new LeaderStateChanged(memberId, leaderId, leaderPayloadVersion); } @@ -637,7 +638,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } @VisibleForTesting - void setCurrentBehavior(RaftActorBehavior behavior) { + void setCurrentBehavior(final RaftActorBehavior behavior) { context.setCurrentBehavior(behavior); } @@ -704,7 +705,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { return context; } - protected void updateConfigParams(ConfigParams configParams) { + protected void updateConfigParams(final ConfigParams configParams) { // obtain the RaftPolicy for oldConfigParams and the updated one. String oldRaftPolicy = context.getConfigParams().getCustomRaftPolicyImplementationClass(); @@ -736,11 +737,11 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { return delegatingPersistenceProvider.getDelegate(); } - public void setPersistence(DataPersistenceProvider provider) { + public void setPersistence(final DataPersistenceProvider provider) { delegatingPersistenceProvider.setDelegate(provider); } - protected void setPersistence(boolean persistent) { + protected void setPersistence(final boolean persistent) { DataPersistenceProvider currentPersistence = persistence(); if (persistent && (currentPersistence == null || !currentPersistence.isRecoveryApplicable())) { setPersistence(new PersistentDataProvider(this)); @@ -751,7 +752,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } } else if (!persistent && (currentPersistence == null || currentPersistence.isRecoveryApplicable())) { setPersistence(new NonPersistentDataProvider(this) { - /** + /* * The way snapshotting works is, *
    *
  1. RaftActor calls createSnapshot on the Shard @@ -763,7 +764,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { *
*/ @Override - public void saveSnapshot(Object object) { + public void saveSnapshot(final Object object) { // Make saving Snapshot successful // Committing the snapshot here would end up calling commit in the creating state which would // be a state violation. That's why now we send a message to commit the snapshot. @@ -786,7 +787,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { * Note that if the peerId does not match the list of peers passed to * this actor during construction an IllegalStateException will be thrown. */ - protected void setPeerAddress(String peerId, String peerAddress) { + protected void setPeerAddress(final String peerId, final String peerAddress) { context.setPeerAddress(peerId, peerAddress); } @@ -852,7 +853,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { * * @param operation the operation to run */ - protected void pauseLeader(Runnable operation) { + protected void pauseLeader(final Runnable operation) { operation.run(); } @@ -867,7 +868,7 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { } - protected void onLeaderChanged(String oldLeader, String newLeader) { + protected void onLeaderChanged(final String oldLeader, final String newLeader) { } private String getLeaderAddress() { @@ -908,13 +909,13 @@ public abstract class RaftActor extends AbstractUntypedPersistentActor { if (isLeader()) { initiateLeadershipTransfer(new RaftActorLeadershipTransferCohort.OnComplete() { @Override - public void onSuccess(ActorRef raftActorRef) { + public void onSuccess(final ActorRef raftActorRef) { LOG.debug("{}: leader transfer succeeded after change to non-voting", persistenceId()); ensureFollowerState(); } @Override - public void onFailure(ActorRef raftActorRef) { + public void onFailure(final ActorRef raftActorRef) { LOG.debug("{}: leader transfer failed after change to non-voting", persistenceId()); ensureFollowerState(); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java index 2296eabe27..19d796c936 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorContextImpl.java @@ -93,11 +93,11 @@ public class RaftActorContextImpl implements RaftActorContext { private RaftActorLeadershipTransferCohort leadershipTransferCohort; - public RaftActorContextImpl(ActorRef actor, ActorContext context, String id, - @Nonnull ElectionTerm termInformation, long commitIndex, long lastApplied, - @Nonnull Map peerAddresses, - @Nonnull ConfigParams configParams, @Nonnull DataPersistenceProvider persistenceProvider, - @Nonnull Consumer applyStateConsumer, @Nonnull Logger logger) { + public RaftActorContextImpl(final ActorRef actor, final ActorContext context, final String id, + @Nonnull final ElectionTerm termInformation, final long commitIndex, final long lastApplied, + @Nonnull final Map peerAddresses, + @Nonnull final ConfigParams configParams, @Nonnull final DataPersistenceProvider persistenceProvider, + @Nonnull final Consumer applyStateConsumer, @Nonnull final Logger logger) { this.actor = actor; this.context = context; this.id = id; @@ -118,7 +118,7 @@ public class RaftActorContextImpl implements RaftActorContext { } @VisibleForTesting - public void setPayloadVersion(short payloadVersion) { + public void setPayloadVersion(final short payloadVersion) { this.payloadVersion = payloadVersion; } @@ -127,17 +127,17 @@ public class RaftActorContextImpl implements RaftActorContext { return payloadVersion; } - public void setConfigParams(ConfigParams configParams) { + public void setConfigParams(final ConfigParams configParams) { this.configParams = configParams; } @Override - public ActorRef actorOf(Props props) { + public ActorRef actorOf(final Props props) { return context.actorOf(props); } @Override - public ActorSelection actorSelection(String path) { + public ActorSelection actorSelection(final String path) { return context.actorSelection(path); } @@ -177,7 +177,7 @@ public class RaftActorContextImpl implements RaftActorContext { return commitIndex; } - @Override public void setCommitIndex(long commitIndex) { + @Override public void setCommitIndex(final long commitIndex) { this.commitIndex = commitIndex; } @@ -187,14 +187,14 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - public void setLastApplied(long lastApplied) { + public void setLastApplied(final long lastApplied) { final Throwable stackTrace = log.isTraceEnabled() ? new Throwable() : null; log.debug("{}: Moving last applied index from {} to {}", id, this.lastApplied, lastApplied, stackTrace); this.lastApplied = lastApplied; } @Override - public void setReplicatedLog(ReplicatedLog replicatedLog) { + public void setReplicatedLog(final ReplicatedLog replicatedLog) { this.replicatedLog = replicatedLog; } @@ -224,12 +224,12 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - public PeerInfo getPeerInfo(String peerId) { + public PeerInfo getPeerInfo(final String peerId) { return peerInfoMap.get(peerId); } @Override - public String getPeerAddress(String peerId) { + public String getPeerAddress(final String peerId) { String peerAddress; PeerInfo peerInfo = peerInfoMap.get(peerId); if (peerInfo != null) { @@ -246,7 +246,7 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - public void updatePeerIds(ServerConfigurationPayload serverConfig) { + public void updatePeerIds(final ServerConfigurationPayload serverConfig) { votingMember = true; boolean foundSelf = false; Set currentPeers = new HashSet<>(this.getPeerIds()); @@ -285,13 +285,13 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - public void addToPeers(String peerId, String address, VotingState votingState) { + public void addToPeers(final String peerId, final String address, final VotingState votingState) { peerInfoMap.put(peerId, new PeerInfo(peerId, address, votingState)); numVotingPeers = -1; } @Override - public void removePeer(String name) { + public void removePeer(final String name) { if (getId().equals(name)) { votingMember = false; } else { @@ -300,7 +300,7 @@ public class RaftActorContextImpl implements RaftActorContext { } } - @Override public ActorSelection getPeerActorSelection(String peerId) { + @Override public ActorSelection getPeerActorSelection(final String peerId) { String peerAddress = getPeerAddress(peerId); if (peerAddress != null) { return actorSelection(peerAddress); @@ -309,7 +309,7 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - public void setPeerAddress(String peerId, String peerAddress) { + public void setPeerAddress(final String peerId, final String peerAddress) { PeerInfo peerInfo = peerInfoMap.get(peerId); if (peerInfo != null) { log.info("Peer address for peer {} set to {}", peerId, peerAddress); @@ -331,7 +331,7 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - public void setTotalMemoryRetriever(LongSupplier retriever) { + public void setTotalMemoryRetriever(final LongSupplier retriever) { totalMemoryRetriever = retriever == null ? JVM_MEMORY_RETRIEVER : retriever; } @@ -362,7 +362,7 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override - public ServerConfigurationPayload getPeerServerInfo(boolean includeSelf) { + public ServerConfigurationPayload getPeerServerInfo(final boolean includeSelf) { if (!isDynamicServerConfigurationInUse()) { return null; } @@ -435,8 +435,9 @@ public class RaftActorContextImpl implements RaftActorContext { } @Override + @SuppressWarnings("checkstyle:hiddenField") public void setRaftActorLeadershipTransferCohort( - @Nullable RaftActorLeadershipTransferCohort leadershipTransferCohort) { + @Nullable final RaftActorLeadershipTransferCohort leadershipTransferCohort) { this.leadershipTransferCohort = leadershipTransferCohort; } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java index 0014a6fce7..3f030d0ff0 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupport.java @@ -61,12 +61,12 @@ class RaftActorServerConfigurationSupport { private OperationState currentOperationState = IDLE; - RaftActorServerConfigurationSupport(RaftActor raftActor) { + RaftActorServerConfigurationSupport(final RaftActor raftActor) { this.raftActor = raftActor; this.raftContext = raftActor.getRaftActorContext(); } - boolean handleMessage(Object message, ActorRef sender) { + boolean handleMessage(final Object message, final ActorRef sender) { if (message instanceof AddServer) { onAddServer((AddServer) message, sender); return true; @@ -92,11 +92,11 @@ class RaftActorServerConfigurationSupport { } } - void onNewLeader(String leaderId) { + void onNewLeader(final String leaderId) { currentOperationState.onNewLeader(leaderId); } - private void onChangeServersVotingStatus(ChangeServersVotingStatus message, ActorRef sender) { + private void onChangeServersVotingStatus(final ChangeServersVotingStatus message, final ActorRef sender) { LOG.debug("{}: onChangeServersVotingStatus: {}, state: {}", raftContext.getId(), message, currentOperationState); @@ -122,7 +122,7 @@ class RaftActorServerConfigurationSupport { } } - private void onRemoveServer(RemoveServer removeServer, ActorRef sender) { + private void onRemoveServer(final RemoveServer removeServer, final ActorRef sender) { LOG.debug("{}: onRemoveServer: {}, state: {}", raftContext.getId(), removeServer, currentOperationState); boolean isSelf = removeServer.getServerId().equals(raftContext.getId()); if (isSelf && !raftContext.hasFollowers()) { @@ -138,7 +138,7 @@ class RaftActorServerConfigurationSupport { } } - private boolean onApplyState(ApplyState applyState) { + private boolean onApplyState(final ApplyState applyState) { Payload data = applyState.getReplicatedLogEntry().getData(); if (data instanceof ServerConfigurationPayload) { currentOperationState.onApplyState(applyState); @@ -149,7 +149,7 @@ class RaftActorServerConfigurationSupport { } /** - * The algorithm for AddServer is as follows: + * Add a server. The algorithm for AddServer is as follows: *
    *
  • Add the new server as a peer.
  • *
  • Add the new follower to the leader.
  • @@ -169,13 +169,13 @@ class RaftActorServerConfigurationSupport { *
  • Respond to caller with TIMEOUT.
  • *
*/ - private void onAddServer(AddServer addServer, ActorRef sender) { + private void onAddServer(final AddServer addServer, final ActorRef sender) { LOG.debug("{}: onAddServer: {}, state: {}", raftContext.getId(), addServer, currentOperationState); onNewOperation(new AddServerContext(addServer, sender)); } - private void onNewOperation(ServerOperationContext operationContext) { + private void onNewOperation(final ServerOperationContext operationContext) { if (raftActor.isLeader()) { currentOperationState.onNewOperation(operationContext); } else { @@ -202,7 +202,7 @@ class RaftActorServerConfigurationSupport { * Abstract base class for a server operation FSM state. Handles common behavior for all states. */ private abstract class OperationState { - void onNewOperation(ServerOperationContext operationContext) { + void onNewOperation(final ServerOperationContext operationContext) { // We're currently processing another operation so queue it to be processed later. LOG.debug("{}: Server operation already in progress - queueing {}", raftContext.getId(), @@ -211,15 +211,15 @@ class RaftActorServerConfigurationSupport { pendingOperationsQueue.add(operationContext); } - void onServerOperationTimeout(ServerOperationTimeout timeout) { + void onServerOperationTimeout(final ServerOperationTimeout timeout) { LOG.debug("onServerOperationTimeout should not be called in state {}", this); } - void onUnInitializedFollowerSnapshotReply(UnInitializedFollowerSnapshotReply reply) { + void onUnInitializedFollowerSnapshotReply(final UnInitializedFollowerSnapshotReply reply) { LOG.debug("onUnInitializedFollowerSnapshotReply was called in state {}", this); } - void onApplyState(ApplyState applyState) { + void onApplyState(final ApplyState applyState) { LOG.debug("onApplyState was called in state {}", this); } @@ -227,10 +227,10 @@ class RaftActorServerConfigurationSupport { } - void onNewLeader(String newLeader) { + void onNewLeader(final String newLeader) { } - protected void persistNewServerConfiguration(ServerOperationContext operationContext) { + protected void persistNewServerConfiguration(final ServerOperationContext operationContext) { raftContext.setDynamicServerConfigurationInUse(); ServerConfigurationPayload payload = raftContext.getPeerServerInfo( @@ -246,8 +246,8 @@ class RaftActorServerConfigurationSupport { sendReply(operationContext, ServerChangeStatus.OK); } - protected void operationComplete(ServerOperationContext operationContext, - @Nullable ServerChangeStatus replyStatus) { + protected void operationComplete(final ServerOperationContext operationContext, + @Nullable final ServerChangeStatus replyStatus) { if (replyStatus != null) { sendReply(operationContext, replyStatus); } @@ -266,7 +266,7 @@ class RaftActorServerConfigurationSupport { } } - protected void sendReply(ServerOperationContext operationContext, ServerChangeStatus status) { + protected void sendReply(final ServerOperationContext operationContext, final ServerChangeStatus status) { LOG.debug("{}: Returning {} for operation {}", raftContext.getId(), status, operationContext.getOperation()); @@ -274,11 +274,11 @@ class RaftActorServerConfigurationSupport { raftActor.self()); } - Cancellable newTimer(Object message) { + Cancellable newTimer(final Object message) { return newTimer(raftContext.getConfigParams().getElectionTimeOutInterval().$times(2), message); } - Cancellable newTimer(FiniteDuration timeout, Object message) { + Cancellable newTimer(final FiniteDuration timeout, final Object message) { return raftContext.getActorSystem().scheduler().scheduleOnce( timeout, raftContext.getActor(), message, raftContext.getActorSystem().dispatcher(), raftContext.getActor()); @@ -295,12 +295,12 @@ class RaftActorServerConfigurationSupport { */ private final class Idle extends OperationState { @Override - public void onNewOperation(ServerOperationContext operationContext) { + public void onNewOperation(final ServerOperationContext operationContext) { operationContext.newInitialOperationState(RaftActorServerConfigurationSupport.this).initiate(); } @Override - public void onApplyState(ApplyState applyState) { + public void onApplyState(final ApplyState applyState) { // Noop - we override b/c ApplyState is called normally for followers in the idle state. } } @@ -313,13 +313,13 @@ class RaftActorServerConfigurationSupport { private final Cancellable timer; private boolean timedOut = false; - Persisting(ServerOperationContext operationContext, Cancellable timer) { + Persisting(final ServerOperationContext operationContext, final Cancellable timer) { this.operationContext = operationContext; this.timer = timer; } @Override - public void onApplyState(ApplyState applyState) { + public void onApplyState(final ApplyState applyState) { // Sanity check - we could get an ApplyState from a previous operation that timed out so make // sure it's meant for us. if (operationContext.getContextId().equals(applyState.getIdentifier())) { @@ -332,7 +332,7 @@ class RaftActorServerConfigurationSupport { } @Override - public void onServerOperationTimeout(ServerOperationTimeout timeout) { + public void onServerOperationTimeout(final ServerOperationTimeout timeout) { LOG.warn("{}: Timeout occured while replicating the new server configuration for {}", raftContext.getId(), timeout.getLoggingContext()); @@ -347,7 +347,7 @@ class RaftActorServerConfigurationSupport { } @Override - public void onNewOperation(ServerOperationContext newOperationContext) { + public void onNewOperation(final ServerOperationContext newOperationContext) { if (timedOut) { sendReply(newOperationContext, ServerChangeStatus.PRIOR_REQUEST_CONSENSUS_TIMEOUT); } else { @@ -362,7 +362,7 @@ class RaftActorServerConfigurationSupport { private abstract class AddServerState extends OperationState { private final AddServerContext addServerContext; - AddServerState(AddServerContext addServerContext) { + AddServerState(final AddServerContext addServerContext) { this.addServerContext = addServerContext; } @@ -374,7 +374,7 @@ class RaftActorServerConfigurationSupport { return newTimer(new ServerOperationTimeout(addServerContext.getOperation().getNewServerId())); } - void handleInstallSnapshotTimeout(ServerOperationTimeout timeout) { + void handleInstallSnapshotTimeout(final ServerOperationTimeout timeout) { String serverId = timeout.getLoggingContext(); LOG.debug("{}: handleInstallSnapshotTimeout for new server {}", raftContext.getId(), serverId); @@ -399,7 +399,7 @@ class RaftActorServerConfigurationSupport { * snapshot capture, if necessary. */ private final class InitialAddServerState extends AddServerState implements InitialOperationState { - InitialAddServerState(AddServerContext addServerContext) { + InitialAddServerState(final AddServerContext addServerContext) { super(addServerContext); } @@ -451,13 +451,13 @@ class RaftActorServerConfigurationSupport { private final class InstallingSnapshot extends AddServerState { private final Cancellable installSnapshotTimer; - InstallingSnapshot(AddServerContext addServerContext, Cancellable installSnapshotTimer) { + InstallingSnapshot(final AddServerContext addServerContext, final Cancellable installSnapshotTimer) { super(addServerContext); this.installSnapshotTimer = Preconditions.checkNotNull(installSnapshotTimer); } @Override - public void onServerOperationTimeout(ServerOperationTimeout timeout) { + public void onServerOperationTimeout(final ServerOperationTimeout timeout) { handleInstallSnapshotTimeout(timeout); LOG.warn("{}: Timeout occured for new server {} while installing snapshot", raftContext.getId(), @@ -465,7 +465,7 @@ class RaftActorServerConfigurationSupport { } @Override - public void onUnInitializedFollowerSnapshotReply(UnInitializedFollowerSnapshotReply reply) { + public void onUnInitializedFollowerSnapshotReply(final UnInitializedFollowerSnapshotReply reply) { LOG.debug("{}: onUnInitializedFollowerSnapshotReply: {}", raftContext.getId(), reply); String followerId = reply.getFollowerId(); @@ -495,7 +495,7 @@ class RaftActorServerConfigurationSupport { private final class WaitingForPriorSnapshotComplete extends AddServerState { private final Cancellable snapshotTimer; - WaitingForPriorSnapshotComplete(AddServerContext addServerContext, Cancellable snapshotTimer) { + WaitingForPriorSnapshotComplete(final AddServerContext addServerContext, final Cancellable snapshotTimer) { super(addServerContext); this.snapshotTimer = Preconditions.checkNotNull(snapshotTimer); } @@ -522,7 +522,7 @@ class RaftActorServerConfigurationSupport { } @Override - public void onServerOperationTimeout(ServerOperationTimeout timeout) { + public void onServerOperationTimeout(final ServerOperationTimeout timeout) { handleInstallSnapshotTimeout(timeout); LOG.warn("{}: Timeout occured for new server {} while waiting for prior snapshot to complete", @@ -549,7 +549,7 @@ class RaftActorServerConfigurationSupport { private final ActorRef clientRequestor; private final Identifier contextId; - ServerOperationContext(T operation, ActorRef clientRequestor) { + ServerOperationContext(final T operation, final ActorRef clientRequestor) { this.operation = operation; this.clientRequestor = clientRequestor; contextId = new ServerOperationContextIdentifier(); @@ -567,10 +567,10 @@ class RaftActorServerConfigurationSupport { return clientRequestor; } - void operationComplete(RaftActor raftActor, boolean succeeded) { + void operationComplete(final RaftActor raftActor, final boolean succeeded) { } - boolean includeSelfInNewConfiguration(RaftActor raftActor) { + boolean includeSelfInNewConfiguration(final RaftActor raftActor) { return true; } @@ -585,17 +585,17 @@ class RaftActorServerConfigurationSupport { * Stores context information for an AddServer operation. */ private static class AddServerContext extends ServerOperationContext { - AddServerContext(AddServer addServer, ActorRef clientRequestor) { + AddServerContext(final AddServer addServer, final ActorRef clientRequestor) { super(addServer, clientRequestor); } @Override - Object newReply(ServerChangeStatus status, String leaderId) { + Object newReply(final ServerChangeStatus status, final String leaderId) { return new AddServerReply(status, leaderId); } @Override - InitialOperationState newInitialOperationState(RaftActorServerConfigurationSupport support) { + InitialOperationState newInitialOperationState(final RaftActorServerConfigurationSupport support) { return support.new InitialAddServerState(this); } @@ -608,7 +608,7 @@ class RaftActorServerConfigurationSupport { private abstract class RemoveServerState extends OperationState { private final RemoveServerContext removeServerContext; - protected RemoveServerState(RemoveServerContext removeServerContext) { + protected RemoveServerState(final RemoveServerContext removeServerContext) { this.removeServerContext = Preconditions.checkNotNull(removeServerContext); } @@ -620,7 +620,7 @@ class RaftActorServerConfigurationSupport { private final class InitialRemoveServerState extends RemoveServerState implements InitialOperationState { - protected InitialRemoveServerState(RemoveServerContext removeServerContext) { + protected InitialRemoveServerState(final RemoveServerContext removeServerContext) { super(removeServerContext); } @@ -639,23 +639,23 @@ class RaftActorServerConfigurationSupport { private static class RemoveServerContext extends ServerOperationContext { private final String peerAddress; - RemoveServerContext(RemoveServer operation, String peerAddress, ActorRef clientRequestor) { + RemoveServerContext(final RemoveServer operation, final String peerAddress, final ActorRef clientRequestor) { super(operation, clientRequestor); this.peerAddress = peerAddress; } @Override - Object newReply(ServerChangeStatus status, String leaderId) { + Object newReply(final ServerChangeStatus status, final String leaderId) { return new RemoveServerReply(status, leaderId); } @Override - InitialOperationState newInitialOperationState(RaftActorServerConfigurationSupport support) { + InitialOperationState newInitialOperationState(final RaftActorServerConfigurationSupport support) { return support.new InitialRemoveServerState(this); } @Override - void operationComplete(RaftActor raftActor, boolean succeeded) { + void operationComplete(final RaftActor raftActor, final boolean succeeded) { if (peerAddress != null) { raftActor.context().actorSelection(peerAddress).tell( new ServerRemoved(getOperation().getServerId()), raftActor.getSelf()); @@ -663,7 +663,7 @@ class RaftActorServerConfigurationSupport { } @Override - boolean includeSelfInNewConfiguration(RaftActor raftActor) { + boolean includeSelfInNewConfiguration(final RaftActor raftActor) { return !getOperation().getServerId().equals(raftActor.getId()); } @@ -676,24 +676,24 @@ class RaftActorServerConfigurationSupport { private static class ChangeServersVotingStatusContext extends ServerOperationContext { private final boolean tryToElectLeader; - ChangeServersVotingStatusContext(ChangeServersVotingStatus convertMessage, ActorRef clientRequestor, - boolean tryToElectLeader) { + ChangeServersVotingStatusContext(final ChangeServersVotingStatus convertMessage, final ActorRef clientRequestor, + final boolean tryToElectLeader) { super(convertMessage, clientRequestor); this.tryToElectLeader = tryToElectLeader; } @Override - InitialOperationState newInitialOperationState(RaftActorServerConfigurationSupport support) { + InitialOperationState newInitialOperationState(final RaftActorServerConfigurationSupport support) { return support.new ChangeServersVotingStatusState(this, tryToElectLeader); } @Override - Object newReply(ServerChangeStatus status, String leaderId) { + Object newReply(final ServerChangeStatus status, final String leaderId) { return new ServerChangeReply(status, leaderId); } @Override - void operationComplete(final RaftActor raftActor, boolean succeeded) { + void operationComplete(final RaftActor raftActor, final boolean succeeded) { // If this leader changed to non-voting we need to step down as leader so we'll try to transfer // leadership. boolean localServerChangedToNonVoting = Boolean.FALSE.equals(getOperation() @@ -714,8 +714,8 @@ class RaftActorServerConfigurationSupport { private final ChangeServersVotingStatusContext changeVotingStatusContext; private final boolean tryToElectLeader; - ChangeServersVotingStatusState(ChangeServersVotingStatusContext changeVotingStatusContext, - boolean tryToElectLeader) { + ChangeServersVotingStatusState(final ChangeServersVotingStatusContext changeVotingStatusContext, + final boolean tryToElectLeader) { this.changeVotingStatusContext = changeVotingStatusContext; this.tryToElectLeader = tryToElectLeader; } @@ -792,8 +792,8 @@ class RaftActorServerConfigurationSupport { private final ChangeServersVotingStatusContext operationContext; private final Cancellable timer; - WaitingForLeaderElected(ChangeServersVotingStatusContext operationContext, - ServerConfigurationPayload previousServerConfig) { + WaitingForLeaderElected(final ChangeServersVotingStatusContext operationContext, + final ServerConfigurationPayload previousServerConfig) { this.operationContext = operationContext; this.previousServerConfig = previousServerConfig; @@ -802,7 +802,7 @@ class RaftActorServerConfigurationSupport { } @Override - void onNewLeader(String newLeader) { + void onNewLeader(final String newLeader) { if (newLeader == null) { return; } @@ -826,7 +826,7 @@ class RaftActorServerConfigurationSupport { } @Override - void onServerOperationTimeout(ServerOperationTimeout timeout) { + void onServerOperationTimeout(final ServerOperationTimeout timeout) { LOG.warn("{}: Leader election timed out - cannot apply operation {}", raftContext.getId(), timeout.getLoggingContext()); @@ -877,7 +877,7 @@ class RaftActorServerConfigurationSupport { static class ServerOperationTimeout { private final String loggingContext; - ServerOperationTimeout(String loggingContext) { + ServerOperationTimeout(final String loggingContext) { this.loggingContext = Preconditions.checkNotNull(loggingContext, "loggingContext should not be null"); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImpl.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImpl.java index 7196fc5f12..764bce1ddb 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImpl.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImpl.java @@ -19,7 +19,7 @@ import org.opendaylight.controller.cluster.raft.persisted.Snapshot; /** * Implementation of ReplicatedLog used by the RaftActor. */ -class ReplicatedLogImpl extends AbstractReplicatedLogImpl { +final class ReplicatedLogImpl extends AbstractReplicatedLogImpl { private static final int DATA_SIZE_DIVIDER = 5; private final RaftActorContext context; @@ -54,7 +54,7 @@ class ReplicatedLogImpl extends AbstractReplicatedLogImpl { } @Override - public boolean shouldCaptureSnapshot(long logIndex) { + public boolean shouldCaptureSnapshot(final long logIndex) { final ConfigParams config = context.getConfigParams(); final long journalSize = logIndex + 1; final long dataThreshold = context.getTotalMemory() * config.getSnapshotDataThresholdPercentage() / 100; @@ -94,7 +94,7 @@ class ReplicatedLogImpl extends AbstractReplicatedLogImpl { @Override public boolean appendAndPersist(@Nonnull final ReplicatedLogEntry replicatedLogEntry, - @Nullable final Procedure callback, boolean doAsync) { + @Nullable final Procedure callback, final boolean doAsync) { context.getLogger().debug("{}: Append log entry and persist {} ", context.getId(), replicatedLogEntry); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java index 7ff47f93d9..dd9445e749 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java @@ -67,7 +67,7 @@ public class SnapshotManager implements SnapshotState { * @param context the RaftActorContext * @param logger the Logger */ - public SnapshotManager(RaftActorContext context, Logger logger) { + public SnapshotManager(final RaftActorContext context, final Logger logger) { this.context = context; this.log = logger; } @@ -82,17 +82,18 @@ public class SnapshotManager implements SnapshotState { } @Override - public boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower) { + public boolean captureToInstall(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex, + final String targetFollower) { return currentState.captureToInstall(lastLogEntry, replicatedToAllIndex, targetFollower); } @Override - public boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex) { + public boolean capture(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex) { return currentState.capture(lastLogEntry, replicatedToAllIndex); } @Override - public void apply(ApplySnapshot snapshot) { + public void apply(final ApplySnapshot snapshot) { currentState.apply(snapshot); } @@ -103,7 +104,7 @@ public class SnapshotManager implements SnapshotState { } @Override - public void commit(final long sequenceNumber, long timeStamp) { + public void commit(final long sequenceNumber, final long timeStamp) { currentState.commit(sequenceNumber, timeStamp); } @@ -117,7 +118,8 @@ public class SnapshotManager implements SnapshotState { return currentState.trimLog(desiredTrimIndex); } - void setCreateSnapshotConsumer(Consumer> createSnapshotProcedure) { + @SuppressWarnings("checkstyle:hiddenField") + void setCreateSnapshotConsumer(final Consumer> createSnapshotProcedure) { this.createSnapshotProcedure = createSnapshotProcedure; } @@ -126,7 +128,7 @@ public class SnapshotManager implements SnapshotState { } @Nonnull - public Snapshot.State convertSnapshot(ByteSource snapshotBytes) throws IOException { + public Snapshot.State convertSnapshot(final ByteSource snapshotBytes) throws IOException { return snapshotCohort.deserializeSnapshot(snapshotBytes); } @@ -154,7 +156,7 @@ public class SnapshotManager implements SnapshotState { * @param replicatedToAllIndex the index of the last entry replicated to all followers. * @return a new CaptureSnapshot instance. */ - public CaptureSnapshot newCaptureSnapshot(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex) { + public CaptureSnapshot newCaptureSnapshot(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex) { TermInformationReader lastAppliedTermInfoReader = lastAppliedTermInformationReader.init(context.getReplicatedLog(), context.getLastApplied(), lastLogEntry, hasFollowers()); @@ -192,20 +194,20 @@ public class SnapshotManager implements SnapshotState { } @Override - public boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex) { + public boolean capture(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex) { log.debug("capture should not be called in state {}", this); return false; } @Override - public boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, - String targetFollower) { + public boolean captureToInstall(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex, + final String targetFollower) { log.debug("captureToInstall should not be called in state {}", this); return false; } @Override - public void apply(ApplySnapshot snapshot) { + public void apply(final ApplySnapshot snapshot) { log.debug("apply should not be called in state {}", this); } @@ -216,7 +218,7 @@ public class SnapshotManager implements SnapshotState { } @Override - public void commit(final long sequenceNumber, long timeStamp) { + public void commit(final long sequenceNumber, final long timeStamp) { log.debug("commit should not be called in state {}", this); } @@ -273,7 +275,8 @@ public class SnapshotManager implements SnapshotState { } @SuppressWarnings("checkstyle:IllegalCatch") - private boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower) { + private boolean capture(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex, + final String targetFollower) { captureSnapshot = newCaptureSnapshot(lastLogEntry, replicatedToAllIndex); OutputStream installSnapshotStream = null; @@ -303,18 +306,18 @@ public class SnapshotManager implements SnapshotState { } @Override - public boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex) { + public boolean capture(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex) { return capture(lastLogEntry, replicatedToAllIndex, null); } @Override - public boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, - String targetFollower) { + public boolean captureToInstall(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex, + final String targetFollower) { return capture(lastLogEntry, replicatedToAllIndex, targetFollower); } @Override - public void apply(ApplySnapshot toApply) { + public void apply(final ApplySnapshot toApply) { SnapshotManager.this.applySnapshot = toApply; lastSequenceNumber = context.getPersistenceProvider().getLastSequenceNumber(); @@ -439,7 +442,7 @@ public class SnapshotManager implements SnapshotState { @Override @SuppressWarnings("checkstyle:IllegalCatch") - public void commit(final long sequenceNumber, long timeStamp) { + public void commit(final long sequenceNumber, final long timeStamp) { log.debug("{}: Snapshot success - sequence number: {}", persistenceId(), sequenceNumber); if (applySnapshot != null) { @@ -519,8 +522,8 @@ public class SnapshotManager implements SnapshotState { private long index; private long term; - LastAppliedTermInformationReader init(ReplicatedLog log, long originalIndex, ReplicatedLogEntry lastLogEntry, - boolean hasFollowers) { + LastAppliedTermInformationReader init(final ReplicatedLog log, final long originalIndex, + final ReplicatedLogEntry lastLogEntry, final boolean hasFollowers) { ReplicatedLogEntry entry = log.get(originalIndex); this.index = -1L; this.term = -1L; @@ -556,7 +559,7 @@ public class SnapshotManager implements SnapshotState { private long index; private long term; - ReplicatedToAllTermInformationReader init(ReplicatedLog log, long originalIndex) { + ReplicatedToAllTermInformationReader init(final ReplicatedLog log, final long originalIndex) { ReplicatedLogEntry entry = log.get(originalIndex); this.index = -1L; this.term = -1L; diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SnapshotComplete.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SnapshotComplete.java index cc20cf677a..4ac17053bc 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SnapshotComplete.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/SnapshotComplete.java @@ -14,7 +14,7 @@ import akka.dispatch.ControlMessage; * * @author Thomas Pantelis */ -public class SnapshotComplete implements ControlMessage { +public final class SnapshotComplete implements ControlMessage { public static final SnapshotComplete INSTANCE = new SnapshotComplete(); private SnapshotComplete() { diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java index a40e75f4c3..dc9cb23fac 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java @@ -57,7 +57,7 @@ import org.opendaylight.controller.cluster.raft.persisted.Snapshot; import scala.concurrent.duration.FiniteDuration; /** - * The behavior of a RaftActor when it is in the Leader state + * The behavior of a RaftActor when it is in the Leader state. * *

* Leaders: @@ -185,7 +185,7 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { } @VisibleForTesting - void setSnapshot(@Nullable final SnapshotHolder snapshotHolder) { + void setSnapshotHolder(@Nullable final SnapshotHolder snapshotHolder) { this.snapshotHolder = Optional.fromNullable(snapshotHolder); } @@ -493,7 +493,8 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { scheduleHeartBeat(context.getConfigParams().getHeartBeatInterval()); } else if (message instanceof SendInstallSnapshot) { SendInstallSnapshot sendInstallSnapshot = (SendInstallSnapshot) message; - setSnapshot(new SnapshotHolder(sendInstallSnapshot.getSnapshot(), sendInstallSnapshot.getSnapshotBytes())); + setSnapshotHolder(new SnapshotHolder(sendInstallSnapshot.getSnapshot(), + sendInstallSnapshot.getSnapshotBytes())); sendInstallSnapshot(); } else if (message instanceof Replicate) { replicate((Replicate) message); @@ -547,7 +548,7 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { if (!anyFollowersInstallingSnapshot()) { // once there are no pending followers receiving snapshots // we can remove snapshot from the memory - setSnapshot(null); + setSnapshotHolder(null); } wasLastChunk = true; @@ -724,8 +725,8 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { } } - private List getEntriesToSend(FollowerLogInformation followerLogInfo, - ActorSelection followerActor) { + private List getEntriesToSend(final FollowerLogInformation followerLogInfo, + final ActorSelection followerActor) { // Try to get all the entries in the journal but not exceeding the max data size for a single AppendEntries // message. int maxEntries = (int) context.getReplicatedLog().size(); @@ -794,8 +795,8 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior { return Collections.emptyList(); } - private void sendAppendEntriesToFollower(ActorSelection followerActor, List entries, - FollowerLogInformation followerLogInformation) { + private void sendAppendEntriesToFollower(final ActorSelection followerActor, final List entries, + final FollowerLogInformation followerLogInformation) { // In certain cases outlined below we don't want to send the actual commit index to prevent the follower from // possibly committing and applying conflicting entries (those with same index, different term) from a prior // term that weren't replicated to a majority, which would be a violation of raft. diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/GetOnDemandRaftState.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/GetOnDemandRaftState.java index a1083ebdf7..56ec83ee0a 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/GetOnDemandRaftState.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/GetOnDemandRaftState.java @@ -15,7 +15,7 @@ import akka.dispatch.ControlMessage; * * @author Thomas Pantelis */ -public class GetOnDemandRaftState implements ControlMessage { +public final class GetOnDemandRaftState implements ControlMessage { public static final GetOnDemandRaftState INSTANCE = new GetOnDemandRaftState(); private GetOnDemandRaftState() { diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/EmptyState.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/EmptyState.java index 40c90fbe94..aee90ace41 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/EmptyState.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/EmptyState.java @@ -12,7 +12,7 @@ package org.opendaylight.controller.cluster.raft.persisted; * * @author Thomas Pantelis */ -public class EmptyState implements Snapshot.State { +public final class EmptyState implements Snapshot.State { private static final long serialVersionUID = 1L; public static final EmptyState INSTANCE = new EmptyState(); diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/Snapshot.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/Snapshot.java index aa3500e33a..42a4a8de81 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/Snapshot.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/Snapshot.java @@ -22,6 +22,7 @@ import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payloa * * @author Thomas Pantelis */ +// Not final for mocking public class Snapshot implements Serializable { /** @@ -108,9 +109,9 @@ public class Snapshot implements Serializable { private final String electionVotedFor; private final ServerConfigurationPayload serverConfig; - private Snapshot(State state, List unAppliedEntries, long lastIndex, long lastTerm, - long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor, - ServerConfigurationPayload serverConfig) { + Snapshot(final State state, final List unAppliedEntries, final long lastIndex, + final long lastTerm, final long lastAppliedIndex, final long lastAppliedTerm, final long electionTerm, + final String electionVotedFor, final ServerConfigurationPayload serverConfig) { this.state = state; this.unAppliedEntries = unAppliedEntries; this.lastIndex = lastIndex; @@ -122,9 +123,9 @@ public class Snapshot implements Serializable { this.serverConfig = serverConfig; } - public static Snapshot create(State state, List entries, long lastIndex, long lastTerm, - long lastAppliedIndex, long lastAppliedTerm, long electionTerm, String electionVotedFor, - ServerConfigurationPayload serverConfig) { + public static Snapshot create(final State state, final List entries, final long lastIndex, + final long lastTerm, final long lastAppliedIndex, final long lastAppliedTerm, final long electionTerm, + final String electionVotedFor, final ServerConfigurationPayload serverConfig) { return new Snapshot(state, entries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, electionTerm, electionVotedFor, serverConfig); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java index 9d275e7f31..ef4151d03e 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java @@ -67,7 +67,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest private static final class MockIdentifier extends AbstractStringIdentifier { private static final long serialVersionUID = 1L; - protected MockIdentifier(String string) { + protected MockIdentifier(final String string) { super(string); } } @@ -76,7 +76,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest private final String peerId; private final String peerAddress; - public SetPeerAddress(String peerId, String peerAddress) { + public SetPeerAddress(final String peerId, final String peerAddress) { this.peerId = peerId; this.peerAddress = peerAddress; } @@ -95,20 +95,20 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest private final ActorRef collectorActor; private final Map, Predicate> dropMessages = new ConcurrentHashMap<>(); - private TestRaftActor(Builder builder) { + TestRaftActor(final Builder builder) { super(builder); this.collectorActor = builder.collectorActor; } - public void startDropMessages(Class msgClass) { + public void startDropMessages(final Class msgClass) { dropMessages.put(msgClass, msg -> true); } - void startDropMessages(Class msgClass, Predicate filter) { + void startDropMessages(final Class msgClass, final Predicate filter) { dropMessages.put(msgClass, filter); } - public void stopDropMessages(Class msgClass) { + public void stopDropMessages(final Class msgClass) { dropMessages.remove(msgClass); } @@ -118,7 +118,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest @SuppressWarnings({ "rawtypes", "unchecked", "checkstyle:IllegalCatch" }) @Override - public void handleCommand(Object message) { + public void handleCommand(final Object message) { if (message instanceof MockPayload) { MockPayload payload = (MockPayload) message; super.persistData(collectorActor, new MockIdentifier(payload.toString()), payload, false); @@ -154,7 +154,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest @Override @SuppressWarnings("checkstyle:IllegalCatch") - public void createSnapshot(ActorRef actorRef, Optional installSnapshotStream) { + public void createSnapshot(final ActorRef actorRef, final Optional installSnapshotStream) { MockSnapshotState snapshotState = new MockSnapshotState(new ArrayList<>(getState())); if (installSnapshotStream.isPresent()) { SerializationUtils.serialize(snapshotState, installSnapshotStream.get()); @@ -174,13 +174,13 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest public static class Builder extends AbstractBuilder { private ActorRef collectorActor; - public Builder collectorActor(ActorRef newCollectorActor) { - this.collectorActor = newCollectorActor; - return this; + Builder() { + super(TestRaftActor.class); } - private Builder() { - super(TestRaftActor.class); + public Builder collectorActor(final ActorRef newCollectorActor) { + this.collectorActor = newCollectorActor; + return this; } } } @@ -245,17 +245,17 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest return configParams; } - protected void waitUntilLeader(ActorRef actorRef) { + protected void waitUntilLeader(final ActorRef actorRef) { RaftActorTestKit.waitUntilLeader(actorRef); } - protected TestActorRef newTestRaftActor(String id, Map newPeerAddresses, - ConfigParams configParams) { + protected TestActorRef newTestRaftActor(final String id, final Map newPeerAddresses, + final ConfigParams configParams) { return newTestRaftActor(id, TestRaftActor.newBuilder().peerAddresses(newPeerAddresses != null ? newPeerAddresses : Collections.emptyMap()).config(configParams)); } - protected TestActorRef newTestRaftActor(String id, TestRaftActor.Builder builder) { + protected TestActorRef newTestRaftActor(final String id, final TestRaftActor.Builder builder) { builder.collectorActor(factory.createActor( MessageCollectorActor.props(), factory.generateActorId(id + "-collector"))).id(id); @@ -274,7 +274,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest throw lastEx; } - protected void killActor(TestActorRef actor) { + protected void killActor(final TestActorRef actor) { JavaTestKit testkit = new JavaTestKit(getSystem()); testkit.watch(actor); @@ -284,13 +284,13 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest testkit.unwatch(actor); } - protected void verifyApplyJournalEntries(ActorRef actor, final long expIndex) { + protected void verifyApplyJournalEntries(final ActorRef actor, final long expIndex) { MessageCollectorActor.expectFirstMatching(actor, ApplyJournalEntries.class, msg -> msg.getToIndex() == expIndex); } - protected void verifySnapshot(String prefix, Snapshot snapshot, long lastAppliedTerm, - long lastAppliedIndex, long lastTerm, long lastIndex) + protected void verifySnapshot(final String prefix, final Snapshot snapshot, final long lastAppliedTerm, + final long lastAppliedIndex, final long lastTerm, final long lastIndex) throws Exception { assertEquals(prefix + " Snapshot getLastAppliedTerm", lastAppliedTerm, snapshot.getLastAppliedTerm()); assertEquals(prefix + " Snapshot getLastAppliedIndex", lastAppliedIndex, snapshot.getLastAppliedIndex()); @@ -305,7 +305,8 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest } } - protected void verifyPersistedJournal(String persistenceId, List expJournal) { + protected void verifyPersistedJournal(final String persistenceId, + final List expJournal) { List journal = InMemoryJournal.get(persistenceId, ReplicatedLogEntry.class); assertEquals("Journal ReplicatedLogEntry count", expJournal.size(), journal.size()); for (int i = 0; i < expJournal.size(); i++) { @@ -315,11 +316,11 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest } } - protected MockPayload sendPayloadData(ActorRef actor, String data) { + protected MockPayload sendPayloadData(final ActorRef actor, final String data) { return sendPayloadData(actor, data, 0); } - protected MockPayload sendPayloadData(ActorRef actor, String data, int size) { + protected MockPayload sendPayloadData(final ActorRef actor, final String data, final int size) { MockPayload payload; if (size > 0) { payload = new MockPayload(data, size); @@ -331,8 +332,8 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest return payload; } - protected void verifyApplyState(ApplyState applyState, ActorRef expClientActor, - String expId, long expTerm, long expIndex, Payload payload) { + protected void verifyApplyState(final ApplyState applyState, final ActorRef expClientActor, + final String expId, final long expTerm, final long expIndex, final Payload payload) { assertEquals("ApplyState getClientActor", expClientActor, applyState.getClientActor()); final Identifier id = expId == null ? null : new MockIdentifier(expId); @@ -341,31 +342,32 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest verifyReplicatedLogEntry(replicatedLogEntry, expTerm, expIndex, payload); } - protected void verifyReplicatedLogEntry(ReplicatedLogEntry replicatedLogEntry, long expTerm, long expIndex, - Payload payload) { + protected void verifyReplicatedLogEntry(final ReplicatedLogEntry replicatedLogEntry, final long expTerm, + final long expIndex, final Payload payload) { assertEquals("ReplicatedLogEntry getTerm", expTerm, replicatedLogEntry.getTerm()); assertEquals("ReplicatedLogEntry getIndex", expIndex, replicatedLogEntry.getIndex()); assertEquals("ReplicatedLogEntry getData", payload, replicatedLogEntry.getData()); } - protected String testActorPath(String id) { + protected String testActorPath(final String id) { return factory.createTestActorPath(id); } - protected void verifyLeadersTrimmedLog(long lastIndex) { + protected void verifyLeadersTrimmedLog(final long lastIndex) { verifyTrimmedLog("Leader", leaderActor, lastIndex, lastIndex - 1); } - protected void verifyLeadersTrimmedLog(long lastIndex, long replicatedToAllIndex) { + protected void verifyLeadersTrimmedLog(final long lastIndex, final long replicatedToAllIndex) { verifyTrimmedLog("Leader", leaderActor, lastIndex, replicatedToAllIndex); } - protected void verifyFollowersTrimmedLog(int num, TestActorRef actorRef, long lastIndex) { + protected void verifyFollowersTrimmedLog(final int num, final TestActorRef actorRef, + final long lastIndex) { verifyTrimmedLog("Follower " + num, actorRef, lastIndex, lastIndex - 1); } - protected void verifyTrimmedLog(String name, TestActorRef actorRef, long lastIndex, - long replicatedToAllIndex) { + protected void verifyTrimmedLog(final String name, final TestActorRef actorRef, final long lastIndex, + final long replicatedToAllIndex) { TestRaftActor actor = actorRef.underlyingActor(); RaftActorContext context = actor.getRaftActorContext(); long snapshotIndex = lastIndex - 1; @@ -381,7 +383,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest } @SuppressWarnings("checkstyle:IllegalCatch") - static void verifyRaftState(ActorRef raftActor, Consumer verifier) { + static void verifyRaftState(final ActorRef raftActor, final Consumer verifier) { Timeout timeout = new Timeout(500, TimeUnit.MILLISECONDS); AssertionError lastError = null; Stopwatch sw = Stopwatch.createStarted(); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java index 108156d951..28cc9b3f81 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.java @@ -353,7 +353,7 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort, } public static class Builder extends AbstractBuilder { - private Builder() { + Builder() { super(MockRaftActor.class); } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java index 27fc7c0974..1212274ddc 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java @@ -177,15 +177,15 @@ public class AbstractLeaderElectionScenarioTest { } } - static class SendImmediateHeartBeat implements ControlMessage { - public static final SendImmediateHeartBeat INSTANCE = new SendImmediateHeartBeat(); + static final class SendImmediateHeartBeat implements ControlMessage { + static final SendImmediateHeartBeat INSTANCE = new SendImmediateHeartBeat(); private SendImmediateHeartBeat() { } } - static class GetBehaviorState implements ControlMessage { - public static final GetBehaviorState INSTANCE = new GetBehaviorState(); + static final class GetBehaviorState implements ControlMessage { + static final GetBehaviorState INSTANCE = new GetBehaviorState(); private GetBehaviorState() { } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java index 7ad5812f64..5317ec4d34 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java @@ -592,7 +592,7 @@ public class LeaderTest extends AbstractLeaderTest { leader.markFollowerActive(FOLLOWER_ID); ByteString bs = toByteString(leadersSnapshot); - leader.setSnapshot(new SnapshotHolder(Snapshot.create(ByteState.of(bs.toByteArray()), + leader.setSnapshotHolder(new SnapshotHolder(Snapshot.create(ByteState.of(bs.toByteArray()), Collections.emptyList(), commitIndex, snapshotTerm, commitIndex, snapshotTerm, -1, null, null), ByteSource.wrap(bs.toByteArray()))); LeaderInstallSnapshotState fts = new LeaderInstallSnapshotState( @@ -699,7 +699,7 @@ public class LeaderTest extends AbstractLeaderTest { MessageCollectorActor.expectFirstMatching(followerActor, AppendEntries.class); // set the snapshot as absent and check if capture-snapshot is invoked. - leader.setSnapshot(null); + leader.setSnapshotHolder(null); // new entry SimpleReplicatedLogEntry entry = new SimpleReplicatedLogEntry(newEntryIndex, currentTerm, @@ -757,7 +757,7 @@ public class LeaderTest extends AbstractLeaderTest { MessageCollectorActor.expectFirstMatching(followerActor, AppendEntries.class); // set the snapshot as absent and check if capture-snapshot is invoked. - leader.setSnapshot(null); + leader.setSnapshotHolder(null); for (int i = 0; i < 4; i++) { actorContext.getReplicatedLog().append(new SimpleReplicatedLogEntry(i, 1, @@ -953,7 +953,7 @@ public class LeaderTest extends AbstractLeaderTest { actorContext.getTermInformation().update(currentTerm, leaderActor.path().toString()); ByteString bs = toByteString(leadersSnapshot); - leader.setSnapshot(new SnapshotHolder(Snapshot.create(ByteState.of(bs.toByteArray()), + leader.setSnapshotHolder(new SnapshotHolder(Snapshot.create(ByteState.of(bs.toByteArray()), Collections.emptyList(), commitIndex, snapshotTerm, commitIndex, snapshotTerm, -1, null, null), ByteSource.wrap(bs.toByteArray()))); LeaderInstallSnapshotState fts = new LeaderInstallSnapshotState( diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ByteState.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ByteState.java index 42411a95c4..b32b4f4728 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ByteState.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ByteState.java @@ -16,16 +16,16 @@ import javax.annotation.Nonnull; * * @author Thomas Pantelis */ -public class ByteState implements Snapshot.State { +public final class ByteState implements Snapshot.State { private static final long serialVersionUID = 1L; private final byte[] bytes; - private ByteState(@Nonnull byte[] bytes) { + private ByteState(@Nonnull final byte[] bytes) { this.bytes = Preconditions.checkNotNull(bytes); } - public static ByteState of(@Nonnull byte[] bytes) { + public static ByteState of(@Nonnull final byte[] bytes) { return new ByteState(bytes); } @@ -46,7 +46,7 @@ public class ByteState implements Snapshot.State { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/InMemorySnapshotStore.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/InMemorySnapshotStore.java index 699a5e3daf..4c3ad09d51 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/InMemorySnapshotStore.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/InMemorySnapshotStore.java @@ -41,7 +41,7 @@ public class InMemorySnapshotStore extends SnapshotStore { private static final Map SNAPSHOT_DELETED_LATCHES = new ConcurrentHashMap<>(); private static Map> snapshots = new ConcurrentHashMap<>(); - public static void addSnapshot(String persistentId, Object snapshot) { + public static void addSnapshot(final String persistentId, final Object snapshot) { List snapshotList = snapshots.computeIfAbsent(persistentId, k -> new ArrayList<>()); synchronized (snapshotList) { @@ -51,7 +51,7 @@ public class InMemorySnapshotStore extends SnapshotStore { } @SuppressWarnings("unchecked") - public static List getSnapshots(String persistentId, Class type) { + public static List getSnapshots(final String persistentId, final Class type) { List stored = snapshots.get(persistentId); if (stored == null) { return Collections.emptyList(); @@ -74,15 +74,15 @@ public class InMemorySnapshotStore extends SnapshotStore { snapshots.clear(); } - public static void addSnapshotSavedLatch(String persistenceId) { + public static void addSnapshotSavedLatch(final String persistenceId) { SNAPSHOT_SAVED_LATCHES.put(persistenceId, new CountDownLatch(1)); } - public static void addSnapshotDeletedLatch(String persistenceId) { + public static void addSnapshotDeletedLatch(final String persistenceId) { SNAPSHOT_DELETED_LATCHES.put(persistenceId, new CountDownLatch(1)); } - public static T waitForSavedSnapshot(String persistenceId, Class type) { + public static T waitForSavedSnapshot(final String persistenceId, final Class type) { if (!Uninterruptibles.awaitUninterruptibly(SNAPSHOT_SAVED_LATCHES.get(persistenceId), 5, TimeUnit.SECONDS)) { throw new AssertionError("Snapshot was not saved"); } @@ -90,15 +90,15 @@ public class InMemorySnapshotStore extends SnapshotStore { return getSnapshots(persistenceId, type).get(0); } - public static void waitForDeletedSnapshot(String persistenceId) { + public static void waitForDeletedSnapshot(final String persistenceId) { if (!Uninterruptibles.awaitUninterruptibly(SNAPSHOT_DELETED_LATCHES.get(persistenceId), 5, TimeUnit.SECONDS)) { throw new AssertionError("Snapshot was not deleted"); } } @Override - public Future> doLoadAsync(String persistenceId, - SnapshotSelectionCriteria snapshotSelectionCriteria) { + public Future> doLoadAsync(final String persistenceId, + final SnapshotSelectionCriteria snapshotSelectionCriteria) { List snapshotList = snapshots.get(persistenceId); if (snapshotList == null) { return Futures.successful(Optional.empty()); @@ -117,13 +117,13 @@ public class InMemorySnapshotStore extends SnapshotStore { return Futures.successful(Optional.empty()); } - private static boolean matches(StoredSnapshot snapshot, SnapshotSelectionCriteria criteria) { + private static boolean matches(final StoredSnapshot snapshot, final SnapshotSelectionCriteria criteria) { return snapshot.metadata.sequenceNr() <= criteria.maxSequenceNr() && snapshot.metadata.timestamp() <= criteria.maxTimestamp(); } @Override - public Future doSaveAsync(SnapshotMetadata snapshotMetadata, Object obj) { + public Future doSaveAsync(final SnapshotMetadata snapshotMetadata, final Object obj) { List snapshotList = snapshots.get(snapshotMetadata.persistenceId()); LOG.trace("doSaveAsync: persistentId {}: sequenceNr: {}: timestamp {}: {}", snapshotMetadata.persistenceId(), @@ -146,7 +146,7 @@ public class InMemorySnapshotStore extends SnapshotStore { } @Override - public Future doDeleteAsync(SnapshotMetadata metadata) { + public Future doDeleteAsync(final SnapshotMetadata metadata) { List snapshotList = snapshots.get(metadata.persistenceId()); if (snapshotList != null) { @@ -165,7 +165,7 @@ public class InMemorySnapshotStore extends SnapshotStore { } @Override - public Future doDeleteAsync(String persistenceId, SnapshotSelectionCriteria criteria) { + public Future doDeleteAsync(final String persistenceId, final SnapshotSelectionCriteria criteria) { LOG.trace("doDelete: persistentId {}: maxSequenceNr: {}: maxTimestamp {}", persistenceId, criteria.maxSequenceNr(), criteria.maxTimestamp()); @@ -193,11 +193,11 @@ public class InMemorySnapshotStore extends SnapshotStore { return Futures.successful(null); } - private static class StoredSnapshot { + private static final class StoredSnapshot { private final SnapshotMetadata metadata; private final Object data; - private StoredSnapshot(SnapshotMetadata metadata, Object data) { + StoredSnapshot(final SnapshotMetadata metadata, final Object data) { this.metadata = metadata; this.data = data; } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/Dispatchers.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/Dispatchers.java index 2dc31145ec..aaa9ad6c81 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/Dispatchers.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/common/actor/Dispatchers.java @@ -30,35 +30,35 @@ public class Dispatchers { private final String path; - DispatcherType(String path) { + DispatcherType(final String path) { this.path = path; } - private String path(akka.dispatch.Dispatchers dispatchers) { - if (dispatchers.hasDispatcher(path)) { + String path(final akka.dispatch.Dispatchers knownDispatchers) { + if (knownDispatchers.hasDispatcher(path)) { return path; } return DEFAULT_DISPATCHER_PATH; } - private ExecutionContext dispatcher(akka.dispatch.Dispatchers dispatchers) { - if (dispatchers.hasDispatcher(path)) { - return dispatchers.lookup(path); + ExecutionContext dispatcher(final akka.dispatch.Dispatchers knownDispatchers) { + if (knownDispatchers.hasDispatcher(path)) { + return knownDispatchers.lookup(path); } - return dispatchers.defaultGlobalDispatcher(); + return knownDispatchers.defaultGlobalDispatcher(); } } - public Dispatchers(akka.dispatch.Dispatchers dispatchers) { + public Dispatchers(final akka.dispatch.Dispatchers dispatchers) { Preconditions.checkNotNull(dispatchers, "dispatchers should not be null"); this.dispatchers = dispatchers; } - public ExecutionContext getDispatcher(DispatcherType dispatcherType) { + public ExecutionContext getDispatcher(final DispatcherType dispatcherType) { return dispatcherType.dispatcher(this.dispatchers); } - public String getDispatcherPath(DispatcherType dispatcherType) { + public String getDispatcherPath(final DispatcherType dispatcherType) { return dispatcherType.path(this.dispatchers); } } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageAssembler.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageAssembler.java index 45e3a8e828..87f0e9890e 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageAssembler.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageAssembler.java @@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory; * @author Thomas Pantelis * @see MessageSlicer */ -public class MessageAssembler implements AutoCloseable { +public final class MessageAssembler implements AutoCloseable { private static final Logger LOG = LoggerFactory.getLogger(MessageAssembler.class); private final Cache stateCache; @@ -40,7 +40,7 @@ public class MessageAssembler implements AutoCloseable { private final BiConsumer assembledMessageCallback; private final String logContext; - private MessageAssembler(final Builder builder) { + MessageAssembler(final Builder builder) { this.fileBackedStreamFactory = Preconditions.checkNotNull(builder.fileBackedStreamFactory, "FiledBackedStreamFactory cannot be null"); this.assembledMessageCallback = Preconditions.checkNotNull(builder.assembledMessageCallback, diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSliceReply.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSliceReply.java index dc80c330fd..bfcfdede85 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSliceReply.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSliceReply.java @@ -24,7 +24,7 @@ import org.opendaylight.yangtools.concepts.Identifier; * * @author Thomas Pantelis */ -public class MessageSliceReply implements Serializable { +public final class MessageSliceReply implements Serializable { private static final long serialVersionUID = 1L; private final Identifier identifier; @@ -86,12 +86,12 @@ public class MessageSliceReply implements Serializable { public Proxy() { } - Proxy(MessageSliceReply messageSliceReply) { + Proxy(final MessageSliceReply messageSliceReply) { this.messageSliceReply = messageSliceReply; } @Override - public void writeExternal(ObjectOutput out) throws IOException { + public void writeExternal(final ObjectOutput out) throws IOException { out.writeObject(messageSliceReply.identifier); out.writeInt(messageSliceReply.sliceIndex); out.writeObject(messageSliceReply.failure); @@ -99,7 +99,7 @@ public class MessageSliceReply implements Serializable { } @Override - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { final Identifier identifier = (Identifier) in.readObject(); final int sliceIndex = in.readInt(); final MessageSliceException failure = (MessageSliceException) in.readObject(); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlicer.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlicer.java index fd08a95a34..5f75e495af 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlicer.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/MessageSlicer.java @@ -46,7 +46,7 @@ public class MessageSlicer implements AutoCloseable { private final String logContext; private final long id; - private MessageSlicer(final Builder builder) { + MessageSlicer(final Builder builder) { this.fileBackedStreamFactory = builder.fileBackedStreamFactory; this.messageSliceSize = builder.messageSliceSize; this.maxSlicingTries = builder.maxSlicingTries; diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/SliceOptions.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/SliceOptions.java index 630a554590..6bae647cb7 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/SliceOptions.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/messaging/SliceOptions.java @@ -21,10 +21,10 @@ import org.opendaylight.yangtools.concepts.Identifier; * * @author Thomas Pantelis */ -public class SliceOptions { +public final class SliceOptions { private final Builder builder; - private SliceOptions(Builder builder) { + private SliceOptions(final Builder builder) { this.builder = builder; } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/reporting/MetricsReporter.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/reporting/MetricsReporter.java index cc64c321f5..e815187d59 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/reporting/MetricsReporter.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/reporting/MetricsReporter.java @@ -36,7 +36,7 @@ public class MetricsReporter implements AutoCloseable { private final JmxReporter jmxReporter; private final MetricRegistry metricRegistry = new MetricRegistry(); - private MetricsReporter(final String domainName) { + MetricsReporter(final String domainName) { this.domainName = domainName; jmxReporter = JmxReporter.forRegistry(metricRegistry).inDomain(domainName).build(); jmxReporter.start(); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java index 043aa467c0..7f91c1bc85 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java @@ -77,7 +77,7 @@ public class MeteredBoundedMailboxTest { ReentrantLock lock; - private PingPongActor(final ReentrantLock lock) { + PingPongActor(final ReentrantLock lock) { this.lock = lock; } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java index 770a2ffb3e..22d4d20dc7 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/util/TestModel.java @@ -52,7 +52,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; -public class TestModel { +public final class TestModel { public static final QName TEST_QNAME = QName.create( "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", @@ -102,7 +102,6 @@ public class TestModel { private static final String DATASTORE_AUG_YANG = "/odl-datastore-augmentation.yang"; private static final String DATASTORE_TEST_NOTIFICATION_YANG = "/odl-datastore-test-notification.yang"; - public static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME); public static final YangInstanceIdentifier DESC_PATH = YangInstanceIdentifier .builder(TEST_PATH).node(DESC_QNAME).build(); @@ -156,15 +155,19 @@ public class TestModel { .build()) // .build(); - public static final InputStream getDatastoreTestInputStream() { + private TestModel() { + throw new UnsupportedOperationException(); + } + + public static InputStream getDatastoreTestInputStream() { return getInputStream(DATASTORE_TEST_YANG); } - public static final InputStream getDatastoreAugInputStream() { + public static InputStream getDatastoreAugInputStream() { return getInputStream(DATASTORE_AUG_YANG); } - public static final InputStream getDatastoreTestNotificationInputStream() { + public static InputStream getDatastoreTestNotificationInputStream() { return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG); } diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java index 5ff1f38e83..c4738998f3 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java @@ -74,13 +74,13 @@ public class AbstractMessagingTest { JavaTestKit.shutdownActorSystem(ACTOR_SYSTEM, Boolean.TRUE); } - void setupMockFiledBackedStream(final FileBackedOutputStream mockFiledBackedStream) throws IOException { - doNothing().when(mockFiledBackedStream).write(any(byte[].class), anyInt(), anyInt()); - doNothing().when(mockFiledBackedStream).write(any(byte[].class)); - doNothing().when(mockFiledBackedStream).write(anyInt()); - doNothing().when(mockFiledBackedStream).close(); - doNothing().when(mockFiledBackedStream).cleanup(); - doNothing().when(mockFiledBackedStream).flush(); - doReturn(mockByteSource).when(mockFiledBackedStream).asByteSource(); + void setupMockFiledBackedStream(final FileBackedOutputStream mockOutputStream) throws IOException { + doNothing().when(mockOutputStream).write(any(byte[].class), anyInt(), anyInt()); + doNothing().when(mockOutputStream).write(any(byte[].class)); + doNothing().when(mockOutputStream).write(anyInt()); + doNothing().when(mockOutputStream).close(); + doNothing().when(mockOutputStream).cleanup(); + doNothing().when(mockOutputStream).flush(); + doReturn(mockByteSource).when(mockOutputStream).asByteSource(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractDataStoreClientActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractDataStoreClientActor.java index b7bce6dc33..92071180eb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractDataStoreClientActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractDataStoreClientActor.java @@ -43,6 +43,7 @@ public abstract class AbstractDataStoreClientActor extends AbstractClientActor { return Verify.verifyNotNull(initialBehavior(context, actorContext)); } + @SuppressWarnings("checkstyle:hiddenField") abstract AbstractDataStoreClientBehavior initialBehavior(ClientActorContext context, ActorContext actorContext); @SuppressWarnings("checkstyle:IllegalCatch") diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java index 0ce4df0f13..9b5942c628 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractShardBackendResolver.java @@ -65,9 +65,9 @@ abstract class AbstractShardBackendResolver extends BackendInfoResolver { } @GuardedBy("lock") + @SuppressWarnings("checkstyle:hiddenField") abstract AbstractProxyTransaction doCreateTransactionProxy(AbstractClientConnection connection, TransactionIdentifier txId, boolean snapshotOnly, boolean isDone); + @SuppressWarnings("checkstyle:hiddenField") abstract ProxyHistory createSuccessor(AbstractClientConnection connection); @SuppressFBWarnings(value = "UL_UNRELEASED_LOCK", justification = "Lock is released asynchronously via the cohort") diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java index 2c0be57bc1..33cf8e9c1d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxy.java @@ -31,11 +31,11 @@ import org.slf4j.LoggerFactory; import scala.concurrent.Future; /** - * ListenerRegistrationProxy acts as a proxy for a ListenerRegistration that was done on a remote shard + * ListenerRegistrationProxy acts as a proxy for a ListenerRegistration that was done on a remote shard. + * *

* Registering a DataChangeListener on the Data Store creates a new instance of the ListenerRegistrationProxy * The ListenerRegistrationProxy talks to a remote ListenerRegistration actor. - *

*/ @SuppressWarnings("rawtypes") public class DataChangeListenerRegistrationProxy implements ListenerRegistration { @@ -50,7 +50,8 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration private boolean closed = false; public >> - DataChangeListenerRegistrationProxy(String shardName, ActorContext actorContext, L listener) { + DataChangeListenerRegistrationProxy(final String shardName, final ActorContext actorContext, + final L listener) { this.shardName = Preconditions.checkNotNull(shardName); this.actorContext = Preconditions.checkNotNull(actorContext); this.listener = Preconditions.checkNotNull(listener); @@ -71,7 +72,7 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration return listener; } - private void setListenerRegistrationActor(ActorSelection listenerRegistrationActor) { + private void setListenerRegistrationActor(final ActorSelection listenerRegistrationActor) { if (listenerRegistrationActor == null) { return; } @@ -99,7 +100,7 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration Future findFuture = actorContext.findLocalShardAsync(shardName); findFuture.onComplete(new OnComplete() { @Override - public void onComplete(Throwable failure, ActorRef shard) { + public void onComplete(final Throwable failure, final ActorRef shard) { if (failure instanceof LocalShardNotFoundException) { LOG.debug("No local shard found for {} - DataChangeListener {} at path {} " + "cannot be registered", shardName, listener, path); @@ -113,8 +114,8 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration }, actorContext.getClientDispatcher()); } - private void doRegistration(ActorRef shard, final YangInstanceIdentifier path, - DataChangeScope scope) { + private void doRegistration(final ActorRef shard, final YangInstanceIdentifier path, + final DataChangeScope scope) { Future future = actorContext.executeOperationAsync(shard, new RegisterChangeListener(path, dataChangeListenerActor, scope, @@ -123,7 +124,7 @@ public class DataChangeListenerRegistrationProxy implements ListenerRegistration future.onComplete(new OnComplete() { @Override - public void onComplete(Throwable failure, Object result) { + public void onComplete(final Throwable failure, final Object result) { if (failure != null) { LOG.error("Failed to register DataChangeListener {} at path {}", listener, path.toString(), failure); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java index dee8142bbc..8be23d1994 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreContext.java @@ -35,6 +35,7 @@ import scala.concurrent.duration.FiniteDuration; * * @author Thomas Pantelis */ +// Noo-final for mocking public class DatastoreContext implements ClientActorConfig { public static final String METRICS_DOMAIN = "org.opendaylight.controller.cluster.datastore"; @@ -97,7 +98,7 @@ public class DatastoreContext implements ClientActorConfig { return GLOBAL_DATASTORE_NAMES; } - private DatastoreContext() { + DatastoreContext() { setShardJournalRecoveryLogBatchSize(DEFAULT_JOURNAL_RECOVERY_BATCH_SIZE); setSnapshotBatchCount(DEFAULT_SNAPSHOT_BATCH_COUNT); setHeartbeatInterval(DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS); @@ -348,7 +349,7 @@ public class DatastoreContext implements ClientActorConfig { private int maxShardDataStoreExecutorQueueSize = InMemoryDOMDataStoreConfigProperties.DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE; - private Builder(final DatastoreContext datastoreContext) { + Builder(final DatastoreContext datastoreContext) { this.datastoreContext = datastoreContext; if (datastoreContext.getDataStoreProperties() != null) { @@ -526,23 +527,23 @@ public class DatastoreContext implements ClientActorConfig { return this; } - public Builder maxShardDataChangeExecutorPoolSize(final int maxShardDataChangeExecutorPoolSize) { - this.maxShardDataChangeExecutorPoolSize = maxShardDataChangeExecutorPoolSize; + public Builder maxShardDataChangeExecutorPoolSize(final int newMaxShardDataChangeExecutorPoolSize) { + this.maxShardDataChangeExecutorPoolSize = newMaxShardDataChangeExecutorPoolSize; return this; } - public Builder maxShardDataChangeExecutorQueueSize(final int maxShardDataChangeExecutorQueueSize) { - this.maxShardDataChangeExecutorQueueSize = maxShardDataChangeExecutorQueueSize; + public Builder maxShardDataChangeExecutorQueueSize(final int newMaxShardDataChangeExecutorQueueSize) { + this.maxShardDataChangeExecutorQueueSize = newMaxShardDataChangeExecutorQueueSize; return this; } - public Builder maxShardDataChangeListenerQueueSize(final int maxShardDataChangeListenerQueueSize) { - this.maxShardDataChangeListenerQueueSize = maxShardDataChangeListenerQueueSize; + public Builder maxShardDataChangeListenerQueueSize(final int newMaxShardDataChangeListenerQueueSize) { + this.maxShardDataChangeListenerQueueSize = newMaxShardDataChangeListenerQueueSize; return this; } - public Builder maxShardDataStoreExecutorQueueSize(final int maxShardDataStoreExecutorQueueSize) { - this.maxShardDataStoreExecutorQueueSize = maxShardDataStoreExecutorQueueSize; + public Builder maxShardDataStoreExecutorQueueSize(final int newMaxShardDataStoreExecutorQueueSize) { + this.maxShardDataStoreExecutorQueueSize = newMaxShardDataStoreExecutorQueueSize; return this; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java index e29de0f13f..db9acaebcd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DatastoreSnapshotRestore.java @@ -27,7 +27,7 @@ import org.slf4j.LoggerFactory; * * @author Thomas Pantelis */ -public class DatastoreSnapshotRestore { +public final class DatastoreSnapshotRestore { private static final Logger LOG = LoggerFactory.getLogger(DatastoreSnapshotRestore.class); private static AtomicReference instance = new AtomicReference<>(); @@ -35,12 +35,12 @@ public class DatastoreSnapshotRestore { private final String restoreDirectoryPath; private final Map datastoreSnapshots = new ConcurrentHashMap<>(); - public static DatastoreSnapshotRestore instance(String restoreDirectoryPath) { + public static DatastoreSnapshotRestore instance(final String restoreDirectoryPath) { instance.compareAndSet(null, new DatastoreSnapshotRestore(restoreDirectoryPath)); return instance.get(); } - private DatastoreSnapshotRestore(String restoreDirectoryPath) { + private DatastoreSnapshotRestore(final String restoreDirectoryPath) { this.restoreDirectoryPath = Preconditions.checkNotNull(restoreDirectoryPath); } @@ -84,14 +84,14 @@ public class DatastoreSnapshotRestore { } } - private static DatastoreSnapshotList deserialize(InputStream inputStream) + private static DatastoreSnapshotList deserialize(final InputStream inputStream) throws IOException, ClassNotFoundException { try (ObjectInputStream ois = new ObjectInputStream(inputStream)) { return (DatastoreSnapshotList) ois.readObject(); } } - public DatastoreSnapshot getAndRemove(String datastoreType) { + public DatastoreSnapshot getAndRemove(final String datastoreType) { initialize(); return datastoreSnapshots.remove(datastoreType); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java index a2a2bfca08..53d2730f86 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DebugThreePhaseCommitCohort.java @@ -84,7 +84,7 @@ class DebugThreePhaseCommitCohort extends AbstractThreePhaseCommitCohort } @VisibleForTesting - void setLogger(final Logger log) { - this.log = log; + void setLogger(final Logger logger) { + this.log = logger; } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java index 2f82ac5d64..0846590c1e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreFactory.java @@ -17,7 +17,7 @@ import org.opendaylight.mdsal.dom.api.DOMSchemaService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DistributedDataStoreFactory { +public final class DistributedDataStoreFactory { private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreFactory.class); private static final String DEFAULT_MODULE_SHARDS_PATH = "./configuration/initial/module-shards.conf"; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContextSupport.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContextSupport.java index 22ba497801..c1162c2d93 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContextSupport.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/RemoteTransactionContextSupport.java @@ -97,12 +97,12 @@ final class RemoteTransactionContextSupport { /** * Sets the target primary shard and initiates a CreateTransaction try. */ - void setPrimaryShard(PrimaryShardInfo primaryShardInfo) { - this.primaryShardInfo = primaryShardInfo; + void setPrimaryShard(final PrimaryShardInfo newPrimaryShardInfo) { + this.primaryShardInfo = newPrimaryShardInfo; if (getTransactionType() == TransactionType.WRITE_ONLY && getActorContext().getDatastoreContext().isWriteOnlyTransactionOptimizationsEnabled()) { - ActorSelection primaryShard = primaryShardInfo.getPrimaryShardActor(); + ActorSelection primaryShard = newPrimaryShardInfo.getPrimaryShardActor(); LOG.debug("Tx {} Primary shard {} found - creating WRITE_ONLY transaction context", getIdentifier(), primaryShard); @@ -110,7 +110,7 @@ final class RemoteTransactionContextSupport { // For write-only Tx's we prepare the transaction modifications directly on the shard actor // to avoid the overhead of creating a separate transaction actor. transactionContextWrapper.executePriorTransactionOperations(createValidTransactionContext( - primaryShard, String.valueOf(primaryShard.path()), primaryShardInfo.getPrimaryShardVersion())); + primaryShard, String.valueOf(primaryShard.path()), newPrimaryShardInfo.getPrimaryShardVersion())); } else { tryCreateTransaction(); } @@ -131,7 +131,7 @@ final class RemoteTransactionContextSupport { createTxFuture.onComplete(new OnComplete() { @Override - public void onComplete(Throwable failure, Object response) { + public void onComplete(final Throwable failure, final Object response) { onCreateTransactionComplete(failure, response); } }, getActorContext().getClientDispatcher()); @@ -161,7 +161,7 @@ final class RemoteTransactionContextSupport { } } - private void onCreateTransactionComplete(Throwable failure, Object response) { + private void onCreateTransactionComplete(final Throwable failure, final Object response) { // An AskTimeoutException will occur if the local shard forwards to an unavailable remote leader or // the cached remote leader actor is no longer available. boolean retryCreateTransaction = primaryShardInfo != null @@ -194,7 +194,7 @@ final class RemoteTransactionContextSupport { createTransactionContext(failure, response); } - private void createTransactionContext(Throwable failure, Object response) { + private void createTransactionContext(final Throwable failure, final Object response) { // Create the TransactionContext from the response or failure. Store the new // TransactionContext locally until we've completed invoking the // TransactionOperations. This avoids thread timing issues which could cause @@ -231,15 +231,15 @@ final class RemoteTransactionContextSupport { transactionContextWrapper.executePriorTransactionOperations(localTransactionContext); } - private TransactionContext createValidTransactionContext(CreateTransactionReply reply) { + private TransactionContext createValidTransactionContext(final CreateTransactionReply reply) { LOG.debug("Tx {} Received {}", getIdentifier(), reply); return createValidTransactionContext(getActorContext().actorSelection(reply.getTransactionPath()), reply.getTransactionPath(), primaryShardInfo.getPrimaryShardVersion()); } - private TransactionContext createValidTransactionContext(ActorSelection transactionActor, String transactionPath, - short remoteTransactionVersion) { + private TransactionContext createValidTransactionContext(final ActorSelection transactionActor, + final String transactionPath, final short remoteTransactionVersion) { final TransactionContext ret = new RemoteTransactionContext(transactionContextWrapper.getIdentifier(), transactionActor, getActorContext(), remoteTransactionVersion, transactionContextWrapper.getLimiter()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java index 402bf4822b..3719f749df 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/Shard.java @@ -1059,9 +1059,9 @@ public class Shard extends RaftActor { return self(); } - public T schemaContextProvider(final SchemaContextProvider schemaContextProvider) { + public T schemaContextProvider(final SchemaContextProvider newSchemaContextProvider) { checkSealed(); - this.schemaContextProvider = Preconditions.checkNotNull(schemaContextProvider); + this.schemaContextProvider = Preconditions.checkNotNull(newSchemaContextProvider); return self(); } @@ -1128,7 +1128,7 @@ public class Shard extends RaftActor { } public static class Builder extends AbstractBuilder { - private Builder() { + Builder() { super(Shard.class); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangePublisherActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangePublisherActor.java index ef40480e4d..b7d77f88a0 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangePublisherActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataChangePublisherActor.java @@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; * * @author Thomas Pantelis */ -public class ShardDataChangePublisherActor +public final class ShardDataChangePublisherActor extends ShardDataTreeNotificationPublisherActor { private ShardDataChangePublisherActor(final String name, final String logContext) { @@ -31,7 +31,7 @@ public class ShardDataChangePublisherActor } @Override - protected void handleReceive(Object message) { + protected void handleReceive(final Object message) { if (message instanceof RegisterListener) { RegisterListener reg = (RegisterListener)message; if (reg.initialState.isPresent()) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangePublisherActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangePublisherActor.java index 61a3fa13be..72d0ee8a88 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangePublisherActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardDataTreeChangePublisherActor.java @@ -21,7 +21,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; * * @author Thomas Pantelis */ -public class ShardDataTreeChangePublisherActor +public final class ShardDataTreeChangePublisherActor extends ShardDataTreeNotificationPublisherActor { private ShardDataTreeChangePublisherActor(final String name, final String logContext) { @@ -29,7 +29,7 @@ public class ShardDataTreeChangePublisherActor } @Override - protected void handleReceive(Object message) { + protected void handleReceive(final Object message) { if (message instanceof RegisterListener) { RegisterListener reg = (RegisterListener)message; LOG.debug("{}: Received {}", logContext(), reg); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java index 455c874229..d8c49a9e74 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/ShardSnapshotCohort.java @@ -33,7 +33,7 @@ import org.slf4j.Logger; * * @author Thomas Pantelis */ -class ShardSnapshotCohort implements RaftActorSnapshotCohort { +final class ShardSnapshotCohort implements RaftActorSnapshotCohort { private static final FrontendType SNAPSHOT_APPLY = FrontendType.forName("snapshot-apply"); private final ActorRef snapshotActor; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ModuleConfig.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ModuleConfig.java index 353c80ce45..5b4e2ffe70 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ModuleConfig.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ModuleConfig.java @@ -22,14 +22,14 @@ import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategy * * @author Thomas Pantelis */ -public class ModuleConfig { +public final class ModuleConfig { private final String name; private final String namespace; private final ShardStrategy shardStrategy; private final Map shardConfigs; - private ModuleConfig(String name, String namespace, ShardStrategy shardStrategy, - Map shardConfigs) { + ModuleConfig(final String name, final String namespace, final ShardStrategy shardStrategy, + final Map shardConfigs) { this.name = name; this.namespace = namespace; this.shardStrategy = shardStrategy; @@ -52,7 +52,7 @@ public class ModuleConfig { } @Nullable - public ShardConfig getShardConfig(String forName) { + public ShardConfig getShardConfig(final String forName) { return shardConfigs.get(forName); } @@ -66,25 +66,25 @@ public class ModuleConfig { return shardConfigs.keySet(); } - public static Builder builder(String name) { + public static Builder builder(final String name) { return new Builder(name); } - public static Builder builder(ModuleConfig moduleConfig) { + public static Builder builder(final ModuleConfig moduleConfig) { return new Builder(moduleConfig); } - public static class Builder { + public static final class Builder { private String name; private String nameSpace; private ShardStrategy shardStrategy; private final Map shardConfigs = new HashMap<>(); - private Builder(String name) { + Builder(final String name) { this.name = name; } - private Builder(ModuleConfig moduleConfig) { + private Builder(final ModuleConfig moduleConfig) { this.name = moduleConfig.getName(); this.nameSpace = moduleConfig.getNamespace(); this.shardStrategy = moduleConfig.getShardStrategy(); @@ -93,22 +93,22 @@ public class ModuleConfig { } } - public Builder name(String newName) { + public Builder name(final String newName) { this.name = newName; return this; } - public Builder nameSpace(String newNameSpace) { + public Builder nameSpace(final String newNameSpace) { this.nameSpace = newNameSpace; return this; } - public Builder shardStrategy(ShardStrategy newShardStrategy) { + public Builder shardStrategy(final ShardStrategy newShardStrategy) { this.shardStrategy = newShardStrategy; return this; } - public Builder shardConfig(String shardName, Collection replicas) { + public Builder shardConfig(final String shardName, final Collection replicas) { shardConfigs.put(shardName, new ShardConfig(shardName, replicas)); return this; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java index beee118a51..944d14a3d9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java @@ -74,7 +74,7 @@ public class DistributedEntityOwnershipService implements DOMEntityOwnershipServ private volatile ActorRef localEntityOwnershipShard; private volatile DataTree localEntityOwnershipShardDataTree; - private DistributedEntityOwnershipService(final ActorContext context) { + DistributedEntityOwnershipService(final ActorContext context) { this.context = Preconditions.checkNotNull(context); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerActor.java index fbffd5b11a..42779b06ed 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerActor.java @@ -20,15 +20,15 @@ import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListener; * * @author Thomas Pantelis */ -class EntityOwnershipListenerActor extends AbstractUntypedActor { +final class EntityOwnershipListenerActor extends AbstractUntypedActor { private final DOMEntityOwnershipListener listener; - private EntityOwnershipListenerActor(DOMEntityOwnershipListener listener) { + private EntityOwnershipListenerActor(final DOMEntityOwnershipListener listener) { this.listener = listener; } @Override - protected void handleReceive(Object message) { + protected void handleReceive(final Object message) { if (message instanceof DOMEntityOwnershipChange) { onEntityOwnershipChanged((DOMEntityOwnershipChange)message); } else { @@ -37,7 +37,7 @@ class EntityOwnershipListenerActor extends AbstractUntypedActor { } @SuppressWarnings("checkstyle:IllegalCatch") - private void onEntityOwnershipChanged(DOMEntityOwnershipChange change) { + private void onEntityOwnershipChanged(final DOMEntityOwnershipChange change) { LOG.debug("Notifying EntityOwnershipListener {}: {}", listener, change); try { @@ -47,7 +47,7 @@ class EntityOwnershipListenerActor extends AbstractUntypedActor { } } - static Props props(DOMEntityOwnershipListener listener) { + static Props props(final DOMEntityOwnershipListener listener) { return Props.create(new EntityOwnershipListenerCreator(listener)); } @@ -58,7 +58,7 @@ class EntityOwnershipListenerActor extends AbstractUntypedActor { + "create remote instances of this actor and thus don't need it to be Serializable.") private final DOMEntityOwnershipListener listener; - EntityOwnershipListenerCreator(DOMEntityOwnershipListener listener) { + EntityOwnershipListenerCreator(final DOMEntityOwnershipListener listener) { this.listener = Preconditions.checkNotNull(listener); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupport.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupport.java index 84a58d9594..ee786e7fc0 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupport.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupport.java @@ -49,11 +49,12 @@ class EntityOwnershipListenerSupport extends EntityOwnershipChangePublisher { private volatile boolean inJeopardy = false; - EntityOwnershipListenerSupport(ActorContext actorContext, String logId) { + EntityOwnershipListenerSupport(final ActorContext actorContext, final String logId) { this.actorContext = actorContext; this.logId = logId; } + @Override String getLogId() { return logId; } @@ -64,13 +65,14 @@ class EntityOwnershipListenerSupport extends EntityOwnershipChangePublisher { * @param inJeopardy new value of the in-jeopardy flag * @return Previous value of the flag. */ + @SuppressWarnings("checkstyle:hiddenField") boolean setInJeopardy(final boolean inJeopardy) { final boolean wasInJeopardy = this.inJeopardy; this.inJeopardy = inJeopardy; return wasInJeopardy; } - void addEntityOwnershipListener(String entityType, DOMEntityOwnershipListener listener) { + void addEntityOwnershipListener(final String entityType, final DOMEntityOwnershipListener listener) { LOG.debug("{}: Adding EntityOwnershipListener {} for entity type {}", logId, listener, entityType); listenerLock.writeLock().lock(); @@ -88,7 +90,7 @@ class EntityOwnershipListenerSupport extends EntityOwnershipChangePublisher { } } - void removeEntityOwnershipListener(String entityType, DOMEntityOwnershipListener listener) { + void removeEntityOwnershipListener(final String entityType, final DOMEntityOwnershipListener listener) { LOG.debug("{}: Removing EntityOwnershipListener {} for entity type {}", logId, listener, entityType); listenerLock.writeLock().lock(); @@ -114,7 +116,8 @@ class EntityOwnershipListenerSupport extends EntityOwnershipChangePublisher { } @Override - void notifyEntityOwnershipListeners(DOMEntity entity, boolean wasOwner, boolean isOwner, boolean hasOwner) { + void notifyEntityOwnershipListeners(final DOMEntity entity, final boolean wasOwner, final boolean isOwner, + final boolean hasOwner) { listenerLock.readLock().lock(); try { Collection listeners = entityTypeListenerMap.get(entity.getType()); @@ -127,8 +130,8 @@ class EntityOwnershipListenerSupport extends EntityOwnershipChangePublisher { } } - void notifyEntityOwnershipListener(DOMEntity entity, boolean wasOwner, boolean isOwner, boolean hasOwner, - DOMEntityOwnershipListener listener) { + void notifyEntityOwnershipListener(final DOMEntity entity, final boolean wasOwner, final boolean isOwner, + final boolean hasOwner, final DOMEntityOwnershipListener listener) { listenerLock.readLock().lock(); try { notifyListeners(entity, wasOwner, isOwner, hasOwner, ImmutableList.of(listenerActorMap.get(listener))); @@ -138,8 +141,8 @@ class EntityOwnershipListenerSupport extends EntityOwnershipChangePublisher { } @GuardedBy("listenerLock") - private void notifyListeners(DOMEntity entity, boolean wasOwner, boolean isOwner, boolean hasOwner, - Collection listenerEntries) { + private void notifyListeners(final DOMEntity entity, final boolean wasOwner, final boolean isOwner, + final boolean hasOwner, final Collection listenerEntries) { DOMEntityOwnershipChange changed = new DOMEntityOwnershipChange(entity, EntityOwnershipChangeState.from(wasOwner, isOwner, hasOwner), inJeopardy); for (ListenerActorRefEntry entry: listenerEntries) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/selectionstrategy/EntityOwnerSelectionStrategyConfig.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/selectionstrategy/EntityOwnerSelectionStrategyConfig.java index 1999296123..a5ffc49a0e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/selectionstrategy/EntityOwnerSelectionStrategyConfig.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/selectionstrategy/EntityOwnerSelectionStrategyConfig.java @@ -30,7 +30,8 @@ public final class EntityOwnerSelectionStrategyConfig { return entityTypeToStrategyInfo.get(entityType) != null; } - public EntityOwnerSelectionStrategy createStrategy(String entityType, Map initialStatistics) { + public EntityOwnerSelectionStrategy createStrategy(final String entityType, + final Map initialStatistics) { final EntityOwnerSelectionStrategy strategy; final EntityOwnerSelectionStrategy existingStrategy = entityTypeToOwnerSelectionStrategy.get(entityType); if (existingStrategy != null) { @@ -70,7 +71,7 @@ public final class EntityOwnerSelectionStrategyConfig { this.delay = delay; } - public EntityOwnerSelectionStrategy createStrategy(Map initialStatistics) { + public EntityOwnerSelectionStrategy createStrategy(final Map initialStatistics) { try { return strategyClass.getDeclaredConstructor(long.class, Map.class) .newInstance(delay, initialStatistics); @@ -86,10 +87,10 @@ public final class EntityOwnerSelectionStrategyConfig { return new Builder(new EntityOwnerSelectionStrategyConfig()); } - public static class Builder { + public static final class Builder { private final EntityOwnerSelectionStrategyConfig config; - private Builder(final EntityOwnerSelectionStrategyConfig config) { + Builder(final EntityOwnerSelectionStrategyConfig config) { this.config = config; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java index e8824fbe11..956fa36d10 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/identifiers/ShardIdentifier.java @@ -23,7 +23,7 @@ public class ShardIdentifier { private final String type; private final String fullName; - private ShardIdentifier(String shardName, MemberName memberName, String type) { + ShardIdentifier(final String shardName, final MemberName memberName, final String type) { this.shardName = Preconditions.checkNotNull(shardName, "shardName should not be null"); this.memberName = Preconditions.checkNotNull(memberName, "memberName should not be null"); this.type = Preconditions.checkNotNull(type, "type should not be null"); @@ -43,7 +43,7 @@ public class ShardIdentifier { } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) { return true; } @@ -101,22 +101,22 @@ public class ShardIdentifier { return new ShardIdentifier(shardName, memberName, type); } - public Builder shardName(String newShardName) { + public Builder shardName(final String newShardName) { this.shardName = newShardName; return this; } - public Builder memberName(MemberName newMemberName) { + public Builder memberName(final MemberName newMemberName) { this.memberName = newMemberName; return this; } - public Builder type(String newType) { + public Builder type(final String newType) { this.type = newType; return this; } - public Builder fromShardIdString(String shardId) { + public Builder fromShardIdString(final String shardId) { Matcher matcher = PATTERN.matcher(shardId); if (matcher.matches()) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/OnDemandShardStateCache.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/OnDemandShardStateCache.java index 230da28e9a..ba00d0b7a5 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/OnDemandShardStateCache.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/OnDemandShardStateCache.java @@ -12,12 +12,8 @@ import akka.pattern.Patterns; import akka.util.Timeout; import com.google.common.base.Preconditions; import com.google.common.base.Stopwatch; -import com.google.common.base.Throwables; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.google.common.util.concurrent.ExecutionError; -import com.google.common.util.concurrent.UncheckedExecutionException; -import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import org.opendaylight.controller.cluster.datastore.messages.OnDemandShardState; import org.opendaylight.controller.cluster.raft.client.messages.GetOnDemandRaftState; @@ -36,7 +32,7 @@ class OnDemandShardStateCache { private final String shardName; private volatile String stateRetrievalTime; - OnDemandShardStateCache(String shardName, ActorRef shardActor) { + OnDemandShardStateCache(final String shardName, final ActorRef shardActor) { this.shardName = Preconditions.checkNotNull(shardName); this.shardActor = shardActor; } @@ -46,16 +42,7 @@ class OnDemandShardStateCache { return OnDemandShardState.newBuilder().build(); } - try { - return ONDEMAND_SHARD_STATE_CACHE.get(shardName, this::retrieveState); - } catch (ExecutionException | UncheckedExecutionException | ExecutionError e) { - if (e.getCause() != null) { - Throwables.propagateIfPossible(e.getCause(), Exception.class); - throw new RuntimeException("unexpected", e.getCause()); - } - - throw e; - } + return ONDEMAND_SHARD_STATE_CACHE.get(shardName, this::retrieveState); } String getStatRetrievaelTime() { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java index 8b46987bb3..bdf125e7d4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/jmx/mbeans/shard/ShardMBeanFactory.java @@ -15,7 +15,7 @@ import org.opendaylight.controller.cluster.datastore.Shard; * * @author Basheeruddin syedbahm@cisco.com */ -public class ShardMBeanFactory { +public final class ShardMBeanFactory { private ShardMBeanFactory() { } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java index 4f90c32635..c70f37ba34 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChangedReply.java @@ -5,10 +5,9 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.datastore.messages; -public class DataChangedReply { +public final class DataChangedReply { public static final DataChangedReply INSTANCE = new DataChangedReply(); private DataChangedReply() { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/GetShardDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/GetShardDataTree.java index 0d63b6bc6d..654bd73c08 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/GetShardDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/GetShardDataTree.java @@ -12,7 +12,7 @@ package org.opendaylight.controller.cluster.datastore.messages; * * @author Thomas Pantelis */ -public class GetShardDataTree { +public final class GetShardDataTree { public static final GetShardDataTree INSTANCE = new GetShardDataTree(); private GetShardDataTree() { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/SuccessReply.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/SuccessReply.java index fde42f8648..4f74bda43e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/SuccessReply.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/SuccessReply.java @@ -14,7 +14,7 @@ import java.io.Serializable; * * @author Thomas Pantelis */ -public class SuccessReply implements Serializable { +public final class SuccessReply implements Serializable { private static final long serialVersionUID = 1L; public static final SuccessReply INSTANCE = new SuccessReply(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java index ced960db5c..b59132fe87 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/CompositeModification.java @@ -5,17 +5,16 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.cluster.datastore.modification; import java.util.List; /** - * CompositeModification contains a list of modifications that need to be applied to the DOMStore + * CompositeModification contains a list of modifications that need to be applied to the DOMStore. + * *

* A CompositeModification gets stored in the transaction log for a Shard. During recovery when the transaction log * is being replayed a DOMStoreWriteTransaction could be created and a CompositeModification could be applied to it. - *

*/ public interface CompositeModification extends Modification { /** diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java index 4692236532..b0ad960cb8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java @@ -63,6 +63,7 @@ public abstract class AbstractIdentifiablePayload protected abstract T readIdentifier(@Nonnull DataInput in) throws IOException; @Nonnull + @SuppressWarnings("checkstyle:hiddenField") protected abstract Identifiable createObject(@Nonnull T identifier, @Nonnull byte[] serialized); } @@ -90,5 +91,6 @@ public abstract class AbstractIdentifiablePayload } @Nonnull + @SuppressWarnings("checkstyle:hiddenField") protected abstract AbstractProxy externalizableProxy(@Nonnull byte[] serialized); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/AbstractShardManagerCreator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/AbstractShardManagerCreator.java index 4dd409e85e..eb6ebb3d62 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/AbstractShardManagerCreator.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/AbstractShardManagerCreator.java @@ -74,9 +74,9 @@ public abstract class AbstractShardManagerCreator builder; - private boolean isActiveMember = true; + private boolean activeMember = true; ShardInformation(final String shardName, final ShardIdentifier shardId, final Map initialPeerAddresses, final DatastoreContext datastoreContext, @@ -101,8 +101,8 @@ final class ShardInformation { return shardId; } - void setLocalDataTree(final Optional localShardDataTree) { - this.localShardDataTree = localShardDataTree; + void setLocalDataTree(final Optional dataTree) { + this.localShardDataTree = dataTree; } Optional getLocalShardDataTree() { @@ -113,8 +113,8 @@ final class ShardInformation { return datastoreContext; } - void setDatastoreContext(final DatastoreContext datastoreContext, final ActorRef sender) { - this.datastoreContext = datastoreContext; + void setDatastoreContext(final DatastoreContext newDatastoreContext, final ActorRef sender) { + this.datastoreContext = newDatastoreContext; if (actor != null) { LOG.debug("Sending new DatastoreContext to {}", shardId); actor.tell(this.datastoreContext, sender); @@ -233,10 +233,10 @@ final class ShardInformation { return false; } - boolean setLeaderId(final String leaderId) { - final boolean changed = !Objects.equals(this.leaderId, leaderId); - this.leaderId = leaderId; - if (leaderId != null) { + boolean setLeaderId(final String newLeaderId) { + final boolean changed = !Objects.equals(this.leaderId, newLeaderId); + this.leaderId = newLeaderId; + if (newLeaderId != null) { this.leaderAvailable = true; } notifyOnShardInitializedCallbacks(); @@ -265,11 +265,11 @@ final class ShardInformation { } boolean isActiveMember() { - return isActiveMember; + return activeMember; } void setActiveMember(final boolean isActiveMember) { - this.isActiveMember = isActiveMember; + this.activeMember = isActiveMember; } SchemaContext getSchemaContext() { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java index c474cf89fc..c767eb208f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActor.java @@ -34,14 +34,14 @@ import scala.concurrent.duration.Duration; * * @author Thomas Pantelis */ -class ShardManagerGetSnapshotReplyActor extends UntypedActor { +final class ShardManagerGetSnapshotReplyActor extends UntypedActor { private static final Logger LOG = LoggerFactory.getLogger(ShardManagerGetSnapshotReplyActor.class); private final Set remainingShardNames; private final Params params; private final List shardSnapshots = new ArrayList<>(); - private ShardManagerGetSnapshotReplyActor(Params params) { + private ShardManagerGetSnapshotReplyActor(final Params params) { this.params = params; remainingShardNames = new HashSet<>(params.shardNames); @@ -51,7 +51,7 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor { } @Override - public void onReceive(Object message) { + public void onReceive(final Object message) { if (message instanceof GetSnapshotReply) { onGetSnapshotReply((GetSnapshotReply)message); } else if (message instanceof Failure) { @@ -70,7 +70,7 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor { } } - private void onGetSnapshotReply(GetSnapshotReply getSnapshotReply) { + private void onGetSnapshotReply(final GetSnapshotReply getSnapshotReply) { LOG.debug("{}: Received {}", params.id, getSnapshotReply); ShardIdentifier shardId = ShardIdentifier.fromShardIdString(getSnapshotReply.getId()); @@ -87,8 +87,9 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor { } } - public static Props props(Collection shardNames, String datastoreType, - ShardManagerSnapshot shardManagerSnapshot, ActorRef replyToActor, String id, Duration receiveTimeout) { + public static Props props(final Collection shardNames, final String datastoreType, + final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, + final Duration receiveTimeout) { return Props.create(ShardManagerGetSnapshotReplyActor.class, new Params(shardNames, datastoreType, shardManagerSnapshot, replyToActor, id, receiveTimeout)); } @@ -101,8 +102,9 @@ class ShardManagerGetSnapshotReplyActor extends UntypedActor { final String id; final Duration receiveTimeout; - Params(Collection shardNames, String datastoreType, ShardManagerSnapshot shardManagerSnapshot, - ActorRef replyToActor, String id, Duration receiveTimeout) { + Params(final Collection shardNames, final String datastoreType, + final ShardManagerSnapshot shardManagerSnapshot, final ActorRef replyToActor, final String id, + final Duration receiveTimeout) { this.shardNames = shardNames; this.datastoreType = datastoreType; this.shardManagerSnapshot = shardManagerSnapshot; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ClusterUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ClusterUtils.java index a877430034..dea8320d0a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ClusterUtils.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/ClusterUtils.java @@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory; /** * Utils for encoding prefix shard name. */ -public class ClusterUtils { +public final class ClusterUtils { private static final Logger LOG = LoggerFactory.getLogger(ClusterUtils.class); // id for the shard used to store prefix configuration diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java index cdbad0b29d..09b497fe6a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/utils/NormalizedNodeAggregator.java @@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType; import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -public class NormalizedNodeAggregator { +public final class NormalizedNodeAggregator { private final YangInstanceIdentifier rootIdentifier; private final List>> nodes; private final DataTree dataTree; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java index 57e75136c7..f91dc3b260 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardChangePublisher.java @@ -178,7 +178,7 @@ public class DistributedShardChangePublisher return listenerPathArgs; } - private static class ProxyRegistration implements ListenerRegistration { + private static final class ProxyRegistration implements ListenerRegistration { private final ListenerRegistration proxy; private final DOMDataTreeChangeListener listener; @@ -349,6 +349,7 @@ public class DistributedShardChangePublisher @Nullable @Override + @SuppressWarnings("checkstyle:hiddenField") public DataTreeCandidateNode getModifiedChild(final PathArgument identifier) { return null; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java index 53893e2251..1b2d993883 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTree.java @@ -655,6 +655,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat @Nonnull @Override + @SuppressWarnings("checkstyle:hiddenField") public DOMDataTreeProducer createProducer(@Nonnull final Collection subtrees) { // TODO we probably don't need to distribute this on the remote nodes since once we have this producer // open we surely have the rights to all the subtrees. diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/LookupTask.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/LookupTask.java index ca33e31a87..232983e4e8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/LookupTask.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/LookupTask.java @@ -23,7 +23,7 @@ import javax.annotation.concurrent.NotThreadSafe; abstract class LookupTask implements Runnable { private final int maxRetries; private final ActorRef replyTo; - private int retries = 0; + private int retried = 0; LookupTask(final ActorRef replyTo, final int maxRetries) { this.replyTo = replyTo; @@ -33,9 +33,9 @@ abstract class LookupTask implements Runnable { abstract void reschedule(int retries); void tryReschedule(@Nullable final Throwable throwable) { - if (retries <= maxRetries) { - retries++; - reschedule(retries); + if (retried <= maxRetries) { + retried++; + reschedule(retried); } else { fail(throwable); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActor.java index 38b69e720a..3307089a45 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActor.java @@ -25,7 +25,7 @@ import org.opendaylight.controller.cluster.notifications.RoleChangeNotification; * {@link LeaderLocationListener#onLeaderLocationChanged(LeaderLocation)} * events. */ -public class RoleChangeListenerActor extends AbstractUntypedActor { +public final class RoleChangeListenerActor extends AbstractUntypedActor { private final LeaderLocationListener leaderLocationListener; private final ActorRef roleChangeNotifier; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java index 3efbbabeb8..d0df84893d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardedDataTreeActor.java @@ -776,8 +776,8 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { return this; } - public ShardedDataTreeActorCreator setClusterWrapper(final ClusterWrapper cluster) { - this.cluster = cluster; + public ShardedDataTreeActorCreator setClusterWrapper(final ClusterWrapper clusterWrapper) { + this.cluster = clusterWrapper; return this; } @@ -805,8 +805,8 @@ public class ShardedDataTreeActor extends AbstractUntypedPersistentActor { return this; } - public ShardedDataTreeActorCreator setLookupTaskMaxRetries(final int maxRetries) { - this.maxRetries = maxRetries; + public ShardedDataTreeActorCreator setLookupTaskMaxRetries(final int newMaxRetries) { + this.maxRetries = newMaxRetries; return this; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/messages/InitConfigListener.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/messages/InitConfigListener.java index bec9765552..fbdf3f8a4d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/messages/InitConfigListener.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/messages/InitConfigListener.java @@ -12,7 +12,7 @@ package org.opendaylight.controller.cluster.sharding.messages; * Message sent to the local ShardManager, once the shard configuration shard is ready and the ShardManager should * start its listener. */ -public class InitConfigListener { +public final class InitConfigListener { public static final InitConfigListener INSTANCE = new InitConfigListener(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/AkkaConfigFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/AkkaConfigFactory.java index 1357e555bb..0eac56f61c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/AkkaConfigFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/AkkaConfigFactory.java @@ -11,10 +11,14 @@ import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import org.opendaylight.controller.cluster.common.actor.AkkaConfigurationReader; -public class AkkaConfigFactory { +public final class AkkaConfigFactory { private static final String CONFIGURATION_NAME = "odl-cluster-data"; + private AkkaConfigFactory() { + + } + public static Config createAkkaConfig(final AkkaConfigurationReader reader) { return ConfigFactory.load(reader.read()).getConfig(CONFIGURATION_NAME); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/osgi/BundleClassLoaderFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/osgi/BundleClassLoaderFactory.java index d47b47bb60..f01e85d531 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/osgi/BundleClassLoaderFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/osgi/BundleClassLoaderFactory.java @@ -12,7 +12,11 @@ import java.security.AccessController; import java.security.PrivilegedAction; import org.osgi.framework.BundleContext; -public class BundleClassLoaderFactory { +public final class BundleClassLoaderFactory { + + private BundleClassLoaderFactory() { + + } public static ClassLoader createClassLoader(final BundleContext bundleContext) { return AccessController diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/osgi/QuarantinedMonitorActorPropsFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/osgi/QuarantinedMonitorActorPropsFactory.java index 3917c5ee5a..50a7647754 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/osgi/QuarantinedMonitorActorPropsFactory.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/actor_system_provider/impl/factory/osgi/QuarantinedMonitorActorPropsFactory.java @@ -13,9 +13,13 @@ import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QuarantinedMonitorActorPropsFactory { +public final class QuarantinedMonitorActorPropsFactory { private static final Logger LOG = LoggerFactory.getLogger(QuarantinedMonitorActorPropsFactory.class); + private QuarantinedMonitorActorPropsFactory() { + + } + public static Props createProps(final BundleContext bundleContext) { return QuarantinedMonitorActor.props(() -> { // restart the entire karaf container diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java index 9cbf3b5a31..9044728ef6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java @@ -490,6 +490,7 @@ public class ConcurrentDOMDataBrokerTest { LogicalDatastoreType.OPERATIONAL, operationalDomStore, LogicalDatastoreType.CONFIGURATION, configDomStore), futureExecutor) { @Override + @SuppressWarnings("checkstyle:hiddenField") public CheckedFuture submit(DOMDataWriteTransaction transaction, Collection cohorts) { commitCohorts.addAll(cohorts); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java index ade447eed8..5e30b0464b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java @@ -94,6 +94,7 @@ public abstract class AbstractClientHandleTest(transaction, connection, backendProbe); } + @SuppressWarnings("checkstyle:hiddenField") protected abstract T createTransaction(ProxyHistory parent, TransactionIdentifier id, DataTreeSnapshot snapshot); @After @@ -226,6 +227,7 @@ public abstract class AbstractProxyTransactionTest> void testRequestResponse(final Consumer> consumer, final Class expectedRequest, final BiFunction> replySupplier) throws Exception { @@ -291,6 +293,7 @@ public abstract class AbstractProxyTransactionTest createLocalProxy() { final TestProbe backendProbe = new TestProbe(system, "backend2"); final TestProbe clientContextProbe = new TestProbe(system, "clientContext2"); @@ -309,6 +312,7 @@ public abstract class AbstractProxyTransactionTest(tx, connection, backendProbe); } + @SuppressWarnings("checkstyle:hiddenField") protected TransactionTester createRemoteProxyTransactionTester() { final TestProbe clientContextProbe = new TestProbe(system, "remoteClientContext"); final TestProbe backendProbe = new TestProbe(system, "remoteBackend"); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientLocalHistoryTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientLocalHistoryTest.java index 8aadd86ddb..158b408c87 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientLocalHistoryTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/ClientLocalHistoryTest.java @@ -105,15 +105,15 @@ public class ClientLocalHistoryTest extends AbstractClientHistoryTest transaction.replayModifyTransactionRequest(request, createCallbackMock(), Ticker.systemTicker().read()), VerifyException.class); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java index 977ada54e6..092d262ae8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java @@ -17,7 +17,11 @@ import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifie import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -class TestUtils { +final class TestUtils { + @FunctionalInterface + public interface RunnableWithException { + void run() throws Exception; + } static final MemberName MEMBER_NAME = MemberName.forName("member-1"); static final FrontendType FRONTEND_TYPE = FrontendType.forName("type-1"); @@ -26,13 +30,12 @@ class TestUtils { static final LocalHistoryIdentifier HISTORY_ID = new LocalHistoryIdentifier(CLIENT_ID, 0L); static final TransactionIdentifier TRANSACTION_ID = new TransactionIdentifier(HISTORY_ID, 0L); - @FunctionalInterface - public interface RunnableWithException { - void run() throws Exception; - } - private static final long TIMEOUT = 3; + private TestUtils() { + + } + /** * Asserts, that future result when it completes is equal to given object. * Future must complete in {@link TestUtils#TIMEOUT} seconds. diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TransactionTester.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TransactionTester.java index c0ce539144..e52012b459 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TransactionTester.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TransactionTester.java @@ -84,7 +84,7 @@ class TransactionTester { private static class MockFailure extends RequestFailure { private static final long serialVersionUID = 1L; - private MockFailure(@Nonnull final TransactionIdentifier target, final long sequence, + MockFailure(@Nonnull final TransactionIdentifier target, final long sequence, @Nonnull final RequestException cause) { super(target, sequence, cause); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java index 322e15b3ca..894e7df91c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java @@ -386,6 +386,7 @@ public abstract class AbstractTransactionProxyTest extends AbstractTest { shardName); } + @SuppressWarnings("checkstyle:avoidHidingCauseException") protected void propagateReadFailedExceptionCause(final CheckedFuture future) throws Exception { try { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextContextPropertiesUpdaterTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextContextPropertiesUpdaterTest.java index 88d1b8061f..4659b16035 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextContextPropertiesUpdaterTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextContextPropertiesUpdaterTest.java @@ -94,6 +94,7 @@ public class DatastoreContextContextPropertiesUpdaterTest { private DatastoreContextFactory contextFactory; @Override + @SuppressWarnings("checkstyle:hiddenField") public void onDatastoreContextUpdated(final DatastoreContextFactory contextFactory) { this.contextFactory = contextFactory; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MockIdentifiers.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MockIdentifiers.java index ae07ffdeda..6b7509e7fa 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MockIdentifiers.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/MockIdentifiers.java @@ -15,6 +15,10 @@ import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; public final class MockIdentifiers { + private MockIdentifiers() { + + } + public static ClientIdentifier clientIdentifier(final Class clazz, final String memberName) { return ClientIdentifier.create(FrontendIdentifier.create(MemberName.forName(memberName), FrontendType.forName(clazz.getSimpleName())), 0); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java index dadd3a99f7..ba7295bcea 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortProxyTest.java @@ -260,8 +260,8 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest { verifyCohortActors(); } + @SuppressWarnings("checkstyle:avoidHidingCauseException") private void propagateExecutionExceptionCause(final ListenableFuture future) throws Exception { - try { future.get(5, TimeUnit.SECONDS); fail("Expected ExecutionException"); @@ -315,7 +315,7 @@ public class ThreePhaseCommitCohortProxyTest extends AbstractActorTest { private final AtomicInteger abortCount = new AtomicInteger(); private volatile AssertionError assertionError; - private CohortActor(final Builder builder) { + CohortActor(final Builder builder) { this.builder = builder; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java index a3cf9aaf65..ee0f91ee27 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java @@ -2092,7 +2092,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { private CountDownLatch memberReachableReceived = new CountDownLatch(1); private volatile MessageInterceptor messageInterceptor; - private TestShardManager(final Builder builder) { + TestShardManager(final Builder builder) { super(builder); shardActor = builder.shardActor; shardActors = builder.shardActors; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java index 960e0328d6..0dc8192690 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java @@ -73,7 +73,7 @@ public class ActorContextTest extends AbstractActorTest { private static class TestMessage { } - private static class MockShardManager extends UntypedActor { + private static final class MockShardManager extends UntypedActor { private final boolean found; private final ActorRef actorRef; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ForwardingActor.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ForwardingActor.java index fb7431f974..92c6349ba6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ForwardingActor.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ForwardingActor.java @@ -11,15 +11,15 @@ package org.opendaylight.controller.cluster.datastore.utils; import akka.actor.ActorRef; import akka.actor.UntypedActor; -public class ForwardingActor extends UntypedActor { +public final class ForwardingActor extends UntypedActor { private final ActorRef target; - private ForwardingActor(ActorRef target) { + private ForwardingActor(final ActorRef target) { this.target = target; } @Override - public void onReceive(Object obj) throws Exception { + public void onReceive(final Object obj) throws Exception { target.forward(obj, context()); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java index 7a8d065b14..2d345e5ea8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/PruningDataTreeModificationTest.java @@ -72,6 +72,7 @@ public class PruningDataTreeModificationTest { private PruningDataTreeModification pruningDataTreeModification; @Before + @SuppressWarnings("checkstyle:avoidHidingCauseException") public void setUp() { MockitoAnnotations.initMocks(this); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java index b710958084..6a346202fb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java @@ -149,10 +149,10 @@ public class DistributedShardFrontendTest { final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(Collections.singletonList(ROOT)); final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(false); - final DOMDataTreeWriteCursor cursor = tx.createCursor(ROOT); + final DOMDataTreeWriteCursor txCursor = tx.createCursor(ROOT); - assertNotNull(cursor); - cursor.write(TestModel.TEST_PATH.getLastPathArgument(), createCrossShardContainer()); + assertNotNull(txCursor); + txCursor.write(TestModel.TEST_PATH.getLastPathArgument(), createCrossShardContainer()); //check the lower shard got the correct modification verify(outerListCursor, times(2)).write(pathArgumentCaptor.capture(), nodeCaptor.capture()); @@ -171,13 +171,12 @@ public class DistributedShardFrontendTest { final MapNode actualInnerListNode = (MapNode) nodeCaptor.getAllValues().get(1); assertEquals(createInnerMapNode(1), actualInnerListNode); - cursor.close(); + txCursor.close(); tx.submit().checkedGet(); verify(commitCohort, times(2)).canCommit(); verify(commitCohort, times(2)).preCommit(); verify(commitCohort, times(2)).commit(); - } private static MapNode createInnerMapNode(final int id) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java index bd6594007d..f633804e66 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CarsModel.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.cluster.datastore.model; import java.math.BigInteger; @@ -20,7 +19,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNo import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; -public class CarsModel { +public final class CarsModel { public static final QName BASE_QNAME = QName.create( "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:cars", "2014-03-13", "cars"); @@ -32,6 +31,10 @@ public class CarsModel { public static final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME); public static final YangInstanceIdentifier CAR_LIST_PATH = BASE_PATH.node(CAR_QNAME); + private CarsModel() { + + } + public static NormalizedNode create() { // Create a list builder @@ -68,12 +71,12 @@ public class CarsModel { return newCarsNode(newCarsMapNode()); } - public static ContainerNode newCarsNode(MapNode carsList) { + public static ContainerNode newCarsNode(final MapNode carsList) { return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier( BASE_QNAME)).withChild(carsList).build(); } - public static MapNode newCarsMapNode(MapEntryNode... carEntries) { + public static MapNode newCarsMapNode(final MapEntryNode... carEntries) { CollectionNodeBuilder builder = ImmutableMapNodeBuilder.create() .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CAR_QNAME)); for (MapEntryNode e : carEntries) { @@ -93,13 +96,13 @@ public class CarsModel { return ImmutableNodes.mapNodeBuilder(CAR_QNAME).build(); } - public static MapEntryNode newCarEntry(String name, BigInteger price) { + public static MapEntryNode newCarEntry(final String name, final BigInteger price) { return ImmutableNodes.mapEntryBuilder(CAR_QNAME, CAR_NAME_QNAME, name) .withChild(ImmutableNodes.leafNode(CAR_NAME_QNAME, name)) .withChild(ImmutableNodes.leafNode(CAR_PRICE_QNAME, price)).build(); } - public static YangInstanceIdentifier newCarPath(String name) { + public static YangInstanceIdentifier newCarPath(final String name) { return YangInstanceIdentifier.builder(CAR_LIST_PATH).nodeWithKey(CAR_QNAME, CAR_NAME_QNAME, name).build(); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java index 2b72099798..3047082b4c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/CompositeModel.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.cluster.datastore.model; import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.mapEntry; @@ -38,7 +37,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; -public class CompositeModel { +public final class CompositeModel { public static final QName TEST_QNAME = QName .create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test"); @@ -102,22 +101,26 @@ public class CompositeModel { private static final String FIRST_GRAND_CHILD_NAME = "first grand child"; private static final String SECOND_GRAND_CHILD_NAME = "second grand child"; - private static final MapEntryNode BAR_NODE = mapEntryBuilder(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) // - .withChild(mapNodeBuilder(INNER_LIST_QNAME) // - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) // - .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) // - .build()) // + private static final MapEntryNode BAR_NODE = mapEntryBuilder(OUTER_LIST_QNAME, ID_QNAME, TWO_ID) + .withChild(mapNodeBuilder(INNER_LIST_QNAME) + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_ONE_NAME)) + .withChild(mapEntry(INNER_LIST_QNAME, NAME_QNAME, TWO_TWO_NAME)) + .build()) .build(); - public static final InputStream getDatastoreTestInputStream() { + private CompositeModel() { + + } + + public static InputStream getDatastoreTestInputStream() { return getInputStream(DATASTORE_TEST_YANG); } - public static final InputStream getDatastoreAugInputStream() { + public static InputStream getDatastoreAugInputStream() { return getInputStream(DATASTORE_AUG_YANG); } - public static final InputStream getDatastoreTestNotificationInputStream() { + public static InputStream getDatastoreTestNotificationInputStream() { return getInputStream(DATASTORE_TEST_NOTIFICATION_YANG); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java index 566ca34034..33ee0a38af 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/PeopleModel.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.md.cluster.datastore.model; import org.opendaylight.yangtools.yang.common.QName; @@ -18,7 +17,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNo import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; -public class PeopleModel { +public final class PeopleModel { public static final QName BASE_QNAME = QName.create( "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:people", "2014-03-13", "people"); @@ -30,6 +29,10 @@ public class PeopleModel { public static final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME); public static final YangInstanceIdentifier PERSON_LIST_PATH = BASE_PATH.node(PERSON_QNAME); + private PeopleModel() { + + } + public static NormalizedNode create() { // Create a list builder @@ -73,12 +76,12 @@ public class PeopleModel { return ImmutableNodes.mapNodeBuilder(PERSON_QNAME).build(); } - public static MapEntryNode newPersonEntry(String name) { + public static MapEntryNode newPersonEntry(final String name) { return ImmutableNodes.mapEntryBuilder(PERSON_QNAME, PERSON_NAME_QNAME, name) .withChild(ImmutableNodes.leafNode(PERSON_NAME_QNAME, name)).build(); } - public static YangInstanceIdentifier newPersonPath(String name) { + public static YangInstanceIdentifier newPersonPath(final String name) { return YangInstanceIdentifier.builder(PERSON_LIST_PATH) .nodeWithKey(PERSON_QNAME, PERSON_NAME_QNAME, name).build(); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java index ceee437ac3..f2d23e0059 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/SchemaContextHelper.java @@ -19,12 +19,16 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; -public class SchemaContextHelper { +public final class SchemaContextHelper { public static final String ODL_DATASTORE_TEST_YANG = "/odl-datastore-test.yang"; public static final String PEOPLE_YANG = "/people.yang"; public static final String CARS_YANG = "/cars.yang"; + private SchemaContextHelper() { + + } + public static InputStream getInputStream(final String yangFileName) { return SchemaContextHelper.class.getResourceAsStream(yangFileName); } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java index cd8a75454c..c75bd04bf4 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/md/cluster/datastore/model/TestModel.java @@ -26,7 +26,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; -public class TestModel { +public final class TestModel { public static final QName TEST_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test"); @@ -37,7 +37,6 @@ public class TestModel { public static final QName JUNK_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:junk", "2014-03-13", "junk"); - public static final QName OUTER_LIST_QNAME = QName.create(TEST_QNAME, "outer-list"); public static final QName OUTER_CONTAINER_QNAME = QName.create(TEST_QNAME, "outer-container"); public static final QName INNER_LIST_QNAME = QName.create(TEST_QNAME, "inner-list"); @@ -59,6 +58,10 @@ public class TestModel { public static final QName TWO_QNAME = QName.create(TEST_QNAME,"two"); public static final QName THREE_QNAME = QName.create(TEST_QNAME,"three"); + private TestModel() { + + } + public static SchemaContext createTestContext() { final List sources; diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java index 9bb4928a63..e3cf76dc80 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/AbstractDOMRpcRoutingTableEntry.java @@ -27,13 +27,13 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.SchemaPath; abstract class AbstractDOMRpcRoutingTableEntry { - private final Map> impls; + private final Map> implementations; private final SchemaPath schemaPath; AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath, - final Map> impls) { + final Map> implementations) { this.schemaPath = Preconditions.checkNotNull(schemaPath); - this.impls = Preconditions.checkNotNull(impls); + this.implementations = Preconditions.checkNotNull(implementations); } final SchemaPath getSchemaPath() { @@ -41,19 +41,20 @@ abstract class AbstractDOMRpcRoutingTableEntry { } final List getImplementations(final YangInstanceIdentifier context) { - return impls.get(context); + return implementations.get(context); } final Map> getImplementations() { - return impls; + return implementations; } final boolean containsContext(final YangInstanceIdentifier contextReference) { - return impls.containsKey(contextReference); + return implementations.containsKey(contextReference); } final Set registeredIdentifiers(final DOMRpcAvailabilityListener listener) { - return Maps.filterValues(impls, list -> list.stream().anyMatch(listener::acceptsImplementation)).keySet(); + return Maps.filterValues(implementations, list -> list.stream().anyMatch(listener::acceptsImplementation)) + .keySet(); } /** @@ -65,7 +66,7 @@ abstract class AbstractDOMRpcRoutingTableEntry { final AbstractDOMRpcRoutingTableEntry add(final DOMRpcImplementation implementation, final List newRpcs) { final Builder> vb = ImmutableMap.builder(); - for (final Entry> ve : impls.entrySet()) { + for (final Entry> ve : implementations.entrySet()) { if (newRpcs.remove(ve.getKey())) { final List i = new ArrayList<>(ve.getValue().size() + 1); i.addAll(ve.getValue()); @@ -91,7 +92,7 @@ abstract class AbstractDOMRpcRoutingTableEntry { final AbstractDOMRpcRoutingTableEntry remove(final DOMRpcImplementation implementation, final List removed) { final Builder> vb = ImmutableMap.builder(); - for (final Entry> ve : impls.entrySet()) { + for (final Entry> ve : implementations.entrySet()) { if (removed.remove(ve.getKey())) { final List i = new ArrayList<>(ve.getValue()); i.remove(implementation); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java index 9bf0e2adb6..a1d5faee7c 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMNotificationRouterEvent.java @@ -34,6 +34,7 @@ final class DOMNotificationRouterEvent { // Hidden on purpose, initialized in initialize() } + @SuppressWarnings("checkstyle:hiddenField") ListenableFuture initialize(final DOMNotification notification, final Collection> subscribers) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java index 692ad99b3c..2e1348718e 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRoutingTable.java @@ -58,13 +58,13 @@ final class DOMRpcRoutingTable { return ret; } - DOMRpcRoutingTable add(final DOMRpcImplementation implementation, final Set rpcs) { - if (rpcs.isEmpty()) { + DOMRpcRoutingTable add(final DOMRpcImplementation implementation, final Set rpcsToAdd) { + if (rpcsToAdd.isEmpty()) { return this; } // First decompose the identifiers to a multimap - final ListMultimap toAdd = decomposeIdentifiers(rpcs); + final ListMultimap toAdd = decomposeIdentifiers(rpcsToAdd); // Now iterate over existing entries, modifying them as appropriate... final Builder mb = ImmutableMap.builder(); @@ -92,13 +92,13 @@ final class DOMRpcRoutingTable { return new DOMRpcRoutingTable(mb.build(), schemaContext); } - DOMRpcRoutingTable remove(final DOMRpcImplementation implementation, final Set rpcs) { - if (rpcs.isEmpty()) { + DOMRpcRoutingTable remove(final DOMRpcImplementation implementation, final Set rpcIds) { + if (rpcIds.isEmpty()) { return this; } // First decompose the identifiers to a multimap - final ListMultimap toRemove = decomposeIdentifiers(rpcs); + final ListMultimap toRemove = decomposeIdentifiers(rpcIds); // Now iterate over existing entries, modifying them as appropriate... final Builder b = ImmutableMap.builder(); diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/clustering/impl/LegacyEntityOwnershipServiceAdapter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/clustering/impl/LegacyEntityOwnershipServiceAdapter.java index cb56f10bf9..5d91a742a3 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/clustering/impl/LegacyEntityOwnershipServiceAdapter.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/clustering/impl/LegacyEntityOwnershipServiceAdapter.java @@ -35,13 +35,14 @@ import org.opendaylight.yangtools.concepts.AbstractObjectRegistration; public class LegacyEntityOwnershipServiceAdapter implements EntityOwnershipService, AutoCloseable { private final DOMEntityOwnershipService domService; - public LegacyEntityOwnershipServiceAdapter(@Nonnull DOMEntityOwnershipService domService) { + public LegacyEntityOwnershipServiceAdapter(@Nonnull final DOMEntityOwnershipService domService) { this.domService = Preconditions.checkNotNull(domService); } @Override + @SuppressWarnings("checkstyle:avoidHidingCauseException") public EntityOwnershipCandidateRegistration registerCandidate( - Entity entity) throws CandidateAlreadyRegisteredException { + final Entity entity) throws CandidateAlreadyRegisteredException { try { return new EntityOwnershipCandidateRegistrationAdapter(domService.registerCandidate(toDOMEntity(entity)), entity); @@ -51,18 +52,19 @@ public class LegacyEntityOwnershipServiceAdapter implements EntityOwnershipServi } @Override - public EntityOwnershipListenerRegistration registerListener(String entityType, EntityOwnershipListener listener) { + public EntityOwnershipListenerRegistration registerListener(final String entityType, + final EntityOwnershipListener listener) { return new EntityOwnershipListenerRegistrationAdapter(entityType, listener, domService .registerListener(entityType, new DOMEntityOwnershipListenerAdapter(listener))); } @Override - public Optional getOwnershipState(Entity forEntity) { + public Optional getOwnershipState(final Entity forEntity) { return toEntityOwnershipState(domService.getOwnershipState(toDOMEntity(forEntity))); } @Override - public boolean isCandidateRegistered(Entity entity) { + public boolean isCandidateRegistered(final Entity entity) { return domService.isCandidateRegistered(toDOMEntity(entity)); } @@ -70,12 +72,12 @@ public class LegacyEntityOwnershipServiceAdapter implements EntityOwnershipServi public void close() { } - private DOMEntity toDOMEntity(Entity from) { + private static DOMEntity toDOMEntity(final Entity from) { return new DOMEntity(from.getType(), from.getId()); } - private Optional toEntityOwnershipState( - Optional from) { + private static Optional toEntityOwnershipState( + final Optional from) { if (!from.isPresent()) { return Optional.absent(); } @@ -90,8 +92,8 @@ public class LegacyEntityOwnershipServiceAdapter implements EntityOwnershipServi implements EntityOwnershipCandidateRegistration { private final DOMEntityOwnershipCandidateRegistration domRegistration; - EntityOwnershipCandidateRegistrationAdapter(DOMEntityOwnershipCandidateRegistration domRegistration, - Entity entity) { + EntityOwnershipCandidateRegistrationAdapter(final DOMEntityOwnershipCandidateRegistration domRegistration, + final Entity entity) { super(entity); this.domRegistration = Preconditions.checkNotNull(domRegistration); } @@ -107,8 +109,8 @@ public class LegacyEntityOwnershipServiceAdapter implements EntityOwnershipServi private final String entityType; private final DOMEntityOwnershipListenerRegistration domRegistration; - EntityOwnershipListenerRegistrationAdapter(String entityType, EntityOwnershipListener listener, - DOMEntityOwnershipListenerRegistration domRegistration) { + EntityOwnershipListenerRegistrationAdapter(final String entityType, final EntityOwnershipListener listener, + final DOMEntityOwnershipListenerRegistration domRegistration) { super(listener); this.entityType = Preconditions.checkNotNull(entityType); this.domRegistration = Preconditions.checkNotNull(domRegistration); @@ -128,12 +130,12 @@ public class LegacyEntityOwnershipServiceAdapter implements EntityOwnershipServi private static class DOMEntityOwnershipListenerAdapter implements DOMEntityOwnershipListener { private final EntityOwnershipListener delegateListener; - DOMEntityOwnershipListenerAdapter(EntityOwnershipListener delegateListener) { + DOMEntityOwnershipListenerAdapter(final EntityOwnershipListener delegateListener) { this.delegateListener = Preconditions.checkNotNull(delegateListener); } @Override - public void ownershipChanged(DOMEntityOwnershipChange ownershipChange) { + public void ownershipChanged(final DOMEntityOwnershipChange ownershipChange) { Entity entity = new Entity(ownershipChange.getEntity().getType(), ownershipChange.getEntity().getIdentifier()); delegateListener.ownershipChanged(new EntityOwnershipChange(entity, ownershipChange.getState().wasOwner(), diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java index e82db12b4d..e2baf3ecbf 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMBrokerTest.java @@ -203,7 +203,7 @@ public class DOMBrokerTest { throw caughtEx.get(); } - NormalizedNode actualNode = dcListener.change.getCreatedData().get(TestModel.TEST_PATH); + NormalizedNode actualNode = dcListener.capturedChange.getCreatedData().get(TestModel.TEST_PATH); assertEquals("Created node", testNode, actualNode); } @@ -326,12 +326,12 @@ public class DOMBrokerTest { static class TestDOMDataChangeListener implements DOMDataChangeListener { - volatile AsyncDataChangeEvent> change; + volatile AsyncDataChangeEvent> capturedChange; private final CountDownLatch latch = new CountDownLatch(1); @Override public void onDataChanged(final AsyncDataChangeEvent> change) { - this.change = change; + this.capturedChange = change; latch.countDown(); } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteDOMRpcFuture.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteDOMRpcFuture.java index 74e98e447a..5a8591330c 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteDOMRpcFuture.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteDOMRpcFuture.java @@ -25,7 +25,8 @@ import org.slf4j.LoggerFactory; import scala.concurrent.ExecutionContext; import scala.concurrent.Future; -class RemoteDOMRpcFuture extends AbstractFuture implements CheckedFuture { +final class RemoteDOMRpcFuture extends AbstractFuture + implements CheckedFuture { private static final Logger LOG = LoggerFactory.getLogger(RemoteDOMRpcFuture.class); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java index 226faf22dc..cc77e4cb6c 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java @@ -12,7 +12,11 @@ import akka.actor.ActorSystem; import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; -public class RemoteRpcProviderFactory { +public final class RemoteRpcProviderFactory { + private RemoteRpcProviderFactory() { + + } + public static RemoteRpcProvider createInstance(final DOMRpcProviderService rpcProviderService, final DOMRpcService rpcService, final ActorSystem actorSystem, final RemoteRpcProviderConfig config) { diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java index 6f0e3b8f79..a863166eb4 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java @@ -34,9 +34,8 @@ public class RpcManager extends AbstractUntypedActor { private ActorRef rpcRegistry; private ActorRef rpcRegistrar; - private RpcManager(final DOMRpcProviderService rpcProvisionRegistry, - final DOMRpcService rpcServices, - final RemoteRpcProviderConfig config) { + RpcManager(final DOMRpcProviderService rpcProvisionRegistry, final DOMRpcService rpcServices, + final RemoteRpcProviderConfig config) { this.rpcProvisionRegistry = Preconditions.checkNotNull(rpcProvisionRegistry); this.rpcServices = Preconditions.checkNotNull(rpcServices); this.config = Preconditions.checkNotNull(config); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java index 7d647cff8c..be76674a3d 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/ExecuteRpc.java @@ -22,7 +22,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -public class ExecuteRpc implements Serializable { +public final class ExecuteRpc implements Serializable { private static final long serialVersionUID = 1128904894827335676L; @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class " diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/LocalBucket.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/LocalBucket.java index e5a2a54883..5e9d907aad 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/LocalBucket.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/registry/gossip/LocalBucket.java @@ -48,8 +48,8 @@ final class LocalBucket> { return new BucketImpl<>(version, data); } - boolean setData(final T data) { - this.data = Preconditions.checkNotNull(data); + boolean setData(final T newData) { + this.data = Preconditions.checkNotNull(newData); if (!bumpVersion) { return false; } -- 2.36.6