You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/11/21 03:12:14 UTC
[commons-jcs] branch master updated: Use final.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
The following commit(s) were added to refs/heads/master by this push:
new a4d70b5 Use final.
a4d70b5 is described below
commit a4d70b5f845aa0a98ac91317ab0c26fb9d38bdf0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 20 22:12:06 2020 -0500
Use final.
---
.../src/main/java/org/apache/commons/jcs3/JCS.java | 30 +-
.../commons/jcs3/access/AbstractCacheAccess.java | 14 +-
.../apache/commons/jcs3/access/CacheAccess.java | 38 +--
.../commons/jcs3/access/GroupCacheAccess.java | 32 +-
.../jcs3/access/exception/CacheException.java | 6 +-
.../access/exception/ConfigurationException.java | 2 +-
.../access/exception/InvalidArgumentException.java | 2 +-
.../access/exception/InvalidGroupException.java | 2 +-
.../access/exception/InvalidHandleException.java | 2 +-
.../access/exception/ObjectExistsException.java | 2 +-
.../access/exception/ObjectNotFoundException.java | 2 +-
.../commons/jcs3/admin/CacheElementInfo.java | 6 +-
.../apache/commons/jcs3/admin/CacheRegionInfo.java | 8 +-
.../jcs3/admin/CountingOnlyOutputStream.java | 6 +-
.../apache/commons/jcs3/admin/JCSAdminBean.java | 76 ++---
.../jcs3/auxiliary/AbstractAuxiliaryCache.java | 24 +-
.../AbstractAuxiliaryCacheAttributes.java | 10 +-
.../AbstractAuxiliaryCacheEventLogging.java | 34 +--
.../auxiliary/AbstractAuxiliaryCacheFactory.java | 2 +-
.../auxiliary/AbstractAuxiliaryCacheMonitor.java | 8 +-
.../jcs3/auxiliary/AuxiliaryCacheConfigurator.java | 14 +-
.../jcs3/auxiliary/disk/AbstractDiskCache.java | 58 ++--
.../disk/AbstractDiskCacheAttributes.java | 16 +-
.../jcs3/auxiliary/disk/PurgatoryElement.java | 8 +-
.../jcs3/auxiliary/disk/block/BlockDisk.java | 70 ++---
.../jcs3/auxiliary/disk/block/BlockDiskCache.java | 70 ++---
.../disk/block/BlockDiskCacheAttributes.java | 8 +-
.../disk/block/BlockDiskCacheFactory.java | 8 +-
.../disk/block/BlockDiskElementDescriptor.java | 10 +-
.../auxiliary/disk/block/BlockDiskKeyStore.java | 59 ++--
.../jcs3/auxiliary/disk/indexed/IndexedDisk.java | 34 +--
.../auxiliary/disk/indexed/IndexedDiskCache.java | 166 +++++------
.../disk/indexed/IndexedDiskCacheAttributes.java | 10 +-
.../disk/indexed/IndexedDiskCacheFactory.java | 8 +-
.../auxiliary/disk/indexed/IndexedDiskDumper.java | 6 +-
.../disk/indexed/IndexedDiskElementDescriptor.java | 10 +-
.../jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java | 108 +++----
.../disk/jdbc/JDBCDiskCacheAttributes.java | 28 +-
.../auxiliary/disk/jdbc/JDBCDiskCacheFactory.java | 42 +--
.../jcs3/auxiliary/disk/jdbc/ShrinkerThread.java | 16 +-
.../jcs3/auxiliary/disk/jdbc/TableState.java | 8 +-
.../disk/jdbc/dsfactory/JndiDataSourceFactory.java | 16 +-
.../dsfactory/SharedPoolDataSourceFactory.java | 12 +-
.../disk/jdbc/hsql/HSQLDiskCacheFactory.java | 20 +-
.../auxiliary/disk/jdbc/mysql/MySQLDiskCache.java | 12 +-
.../disk/jdbc/mysql/MySQLDiskCacheAttributes.java | 6 +-
.../disk/jdbc/mysql/MySQLDiskCacheFactory.java | 32 +-
.../disk/jdbc/mysql/MySQLTableOptimizer.java | 30 +-
.../disk/jdbc/mysql/util/ScheduleParser.java | 18 +-
.../jcs3/auxiliary/lateral/LateralCache.java | 40 +--
.../auxiliary/lateral/LateralCacheAttributes.java | 22 +-
.../auxiliary/lateral/LateralCacheMonitor.java | 15 +-
.../jcs3/auxiliary/lateral/LateralCacheNoWait.java | 50 ++--
.../lateral/LateralCacheNoWaitFacade.java | 48 +--
.../lateral/LateralElementDescriptor.java | 4 +-
.../lateral/socket/tcp/LateralTCPCacheFactory.java | 75 ++---
.../socket/tcp/LateralTCPDiscoveryListener.java | 49 +--
.../lateral/socket/tcp/LateralTCPListener.java | 67 +++--
.../lateral/socket/tcp/LateralTCPSender.java | 28 +-
.../lateral/socket/tcp/LateralTCPService.java | 83 +++---
.../socket/tcp/TCPLateralCacheAttributes.java | 26 +-
.../remote/AbstractRemoteAuxiliaryCache.java | 73 ++---
.../remote/AbstractRemoteCacheListener.java | 18 +-
.../remote/AbstractRemoteCacheNoWaitFacade.java | 64 ++--
.../remote/CommonRemoteCacheAttributes.java | 24 +-
.../commons/jcs3/auxiliary/remote/RemoteCache.java | 20 +-
.../auxiliary/remote/RemoteCacheAttributes.java | 18 +-
.../jcs3/auxiliary/remote/RemoteCacheFactory.java | 54 ++--
.../remote/RemoteCacheFailoverRunner.java | 46 +--
.../jcs3/auxiliary/remote/RemoteCacheListener.java | 8 +-
.../jcs3/auxiliary/remote/RemoteCacheManager.java | 44 +--
.../jcs3/auxiliary/remote/RemoteCacheMonitor.java | 4 +-
.../jcs3/auxiliary/remote/RemoteCacheNoWait.java | 56 ++--
.../auxiliary/remote/RemoteCacheNoWaitFacade.java | 14 +-
.../jcs3/auxiliary/remote/RemoteLocation.java | 12 +-
.../commons/jcs3/auxiliary/remote/RemoteUtils.java | 24 +-
.../remote/http/client/AbstractHttpClient.java | 14 +-
.../remote/http/client/RemoteHttpCache.java | 8 +-
.../http/client/RemoteHttpCacheAttributes.java | 20 +-
.../remote/http/client/RemoteHttpCacheClient.java | 84 +++---
.../http/client/RemoteHttpCacheDispatcher.java | 26 +-
.../remote/http/client/RemoteHttpCacheFactory.java | 18 +-
.../remote/http/client/RemoteHttpCacheMonitor.java | 12 +-
.../http/client/RemoteHttpClientListener.java | 2 +-
.../http/server/AbstractRemoteCacheService.java | 70 ++---
.../server/RemoteHttpCacheServerAttributes.java | 6 +-
.../remote/http/server/RemoteHttpCacheService.java | 48 +--
.../remote/http/server/RemoteHttpCacheServlet.java | 69 ++---
.../remote/server/RegistryKeepAliveRunner.java | 26 +-
.../auxiliary/remote/server/RemoteCacheServer.java | 244 +++++++--------
.../remote/server/RemoteCacheServerAttributes.java | 14 +-
.../remote/server/RemoteCacheServerFactory.java | 80 ++---
.../remote/server/RemoteCacheStartupServlet.java | 36 +--
.../TimeoutConfigurableRMISocketFactory.java | 10 +-
.../remote/util/RemoteCacheRequestFactory.java | 40 +--
.../auxiliary/remote/value/RemoteCacheRequest.java | 16 +-
.../remote/value/RemoteCacheResponse.java | 8 +-
.../jcs3/engine/AbstractCacheEventQueue.java | 20 +-
.../apache/commons/jcs3/engine/CacheAdaptor.java | 14 +-
.../apache/commons/jcs3/engine/CacheElement.java | 10 +-
.../jcs3/engine/CacheElementSerialized.java | 6 +-
.../commons/jcs3/engine/CacheEventQueue.java | 10 +-
.../jcs3/engine/CacheEventQueueFactory.java | 10 +-
.../org/apache/commons/jcs3/engine/CacheGroup.java | 2 +-
.../apache/commons/jcs3/engine/CacheListeners.java | 4 +-
.../commons/jcs3/engine/CacheWatchRepairable.java | 26 +-
.../jcs3/engine/CompositeCacheAttributes.java | 32 +-
.../commons/jcs3/engine/ElementAttributes.java | 32 +-
.../commons/jcs3/engine/PooledCacheEventQueue.java | 14 +-
.../commons/jcs3/engine/ZombieCacheService.java | 18 +-
.../jcs3/engine/ZombieCacheServiceNonLocal.java | 38 +--
.../commons/jcs3/engine/ZombieCacheWatch.java | 8 +-
.../jcs3/engine/control/CompositeCache.java | 217 +++++++-------
.../engine/control/CompositeCacheConfigurator.java | 87 +++---
.../jcs3/engine/control/CompositeCacheManager.java | 102 +++----
.../jcs3/engine/control/event/ElementEvent.java | 2 +-
.../engine/control/event/ElementEventQueue.java | 8 +-
.../jcs3/engine/control/group/GroupAttrName.java | 6 +-
.../commons/jcs3/engine/control/group/GroupId.java | 6 +-
.../commons/jcs3/engine/logging/CacheEvent.java | 12 +-
.../logging/CacheEventLoggerDebugLogger.java | 14 +-
.../jcs3/engine/match/KeyMatcherPatternImpl.java | 4 +-
.../AbstractDoubleLinkedListMemoryCache.java | 46 +--
.../jcs3/engine/memory/AbstractMemoryCache.java | 40 +--
.../jcs3/engine/memory/fifo/FIFOMemoryCache.java | 4 +-
.../jcs3/engine/memory/lru/LHMLRUMemoryCache.java | 16 +-
.../jcs3/engine/memory/lru/LRUMemoryCache.java | 4 +-
.../jcs3/engine/memory/mru/MRUMemoryCache.java | 4 +-
.../engine/memory/shrinking/ShrinkerThread.java | 18 +-
.../memory/soft/SoftReferenceMemoryCache.java | 34 +--
.../memory/util/MemoryElementDescriptor.java | 2 +-
.../util/SoftReferenceElementDescriptor.java | 2 +-
.../commons/jcs3/engine/stats/CacheStats.java | 10 +-
.../commons/jcs3/engine/stats/StatElement.java | 8 +-
.../apache/commons/jcs3/engine/stats/Stats.java | 8 +-
.../jcs3/io/ObjectInputStreamClassLoaderAware.java | 4 +-
.../org/apache/commons/jcs3/log/JulLogAdapter.java | 76 ++---
.../org/apache/commons/jcs3/log/JulLogFactory.java | 4 +-
.../org/apache/commons/jcs3/log/Log4j2Factory.java | 4 +-
.../apache/commons/jcs3/log/Log4j2LogAdapter.java | 64 ++--
.../org/apache/commons/jcs3/log/LogManager.java | 6 +-
.../jcs3/utils/access/AbstractJCSWorkerHelper.java | 2 +-
.../commons/jcs3/utils/access/JCSWorker.java | 12 +-
.../commons/jcs3/utils/config/OptionConverter.java | 55 ++--
.../commons/jcs3/utils/config/PropertySetter.java | 40 +--
.../jcs3/utils/config/PropertySetterException.java | 4 +-
.../jcs3/utils/discovery/DiscoveredService.java | 14 +-
.../jcs3/utils/discovery/UDPCleanupRunner.java | 10 +-
.../utils/discovery/UDPDiscoveryAttributes.java | 24 +-
.../jcs3/utils/discovery/UDPDiscoveryManager.java | 12 +-
.../jcs3/utils/discovery/UDPDiscoveryMessage.java | 14 +-
.../jcs3/utils/discovery/UDPDiscoveryReceiver.java | 32 +-
.../jcs3/utils/discovery/UDPDiscoverySender.java | 22 +-
.../utils/discovery/UDPDiscoverySenderThread.java | 10 +-
.../jcs3/utils/discovery/UDPDiscoveryService.java | 36 +--
.../commons/jcs3/utils/net/HostNameUtil.java | 26 +-
.../utils/serialization/CompressingSerializer.java | 10 +-
.../serialization/SerializationConversionUtil.java | 18 +-
.../utils/serialization/StandardSerializer.java | 7 +-
.../utils/servlet/JCSServletContextListener.java | 4 +-
.../commons/jcs3/utils/struct/AbstractLRUMap.java | 34 +--
.../jcs3/utils/struct/DoubleLinkedList.java | 14 +-
.../jcs3/utils/struct/DoubleLinkedListNode.java | 2 +-
.../jcs3/utils/struct/LRUElementDescriptor.java | 4 +-
.../apache/commons/jcs3/utils/struct/LRUMap.java | 2 +-
.../jcs3/utils/threadpool/DaemonThreadFactory.java | 10 +-
.../jcs3/utils/threadpool/PoolConfiguration.java | 24 +-
.../jcs3/utils/threadpool/ThreadPoolManager.java | 40 +--
.../commons/jcs3/utils/timing/ElapsedTimer.java | 4 +-
.../commons/jcs3/utils/zip/CompressionUtil.java | 28 +-
.../commons/jcs3/ConcurrentRemovalLoadTest.java | 2 +-
.../jcs3/JCSCacheElementRetrievalUnitTest.java | 8 +-
.../jcs3/JCSConcurrentCacheAccessUnitTest.java | 10 +-
.../apache/commons/jcs3/JCSLightLoadUnitTest.java | 4 +-
.../jcs3/JCSRemovalSimpleConcurrentTest.java | 34 +--
.../org/apache/commons/jcs3/JCSThrashTest.java | 18 +-
.../java/org/apache/commons/jcs3/JCSUnitTest.java | 12 +-
.../jcs3/JCSvsHashtablePerformanceTest.java | 18 +-
.../org/apache/commons/jcs3/RemovalTestUtil.java | 20 +-
.../commons/jcs3/TestLogConfigurationUtil.java | 10 +-
.../apache/commons/jcs3/TestTCPLateralCache.java | 10 +-
.../apache/commons/jcs3/ZeroSizeCacheUnitTest.java | 6 +-
.../commons/jcs3/access/CacheAccessUnitTest.java | 148 ++++-----
.../jcs3/access/GroupCacheAccessUnitTest.java | 66 ++--
.../jcs3/access/SystemPropertyUnitTest.java | 8 +-
.../commons/jcs3/access/TestCacheAccess.java | 214 ++++++-------
.../commons/jcs3/admin/AdminBeanUnitTest.java | 46 +--
.../commons/jcs3/admin/CountingStreamUnitTest.java | 12 +-
.../org/apache/commons/jcs3/admin/TestJMX.java | 4 +-
.../AuxiliaryCacheConfiguratorUnitTest.java | 32 +-
.../commons/jcs3/auxiliary/MockAuxiliaryCache.java | 10 +-
.../jcs3/auxiliary/MockAuxiliaryCacheFactory.java | 8 +-
.../jcs3/auxiliary/MockCacheEventLogger.java | 10 +-
.../auxiliary/disk/AbstractDiskCacheUnitTest.java | 72 ++---
.../jcs3/auxiliary/disk/DiskTestObject.java | 6 +-
.../auxiliary/disk/PurgatoryElementUnitTest.java | 42 +--
.../block/BlockDiskCacheConcurrentUnitTest.java | 32 +-
.../disk/block/BlockDiskCacheCountUnitTest.java | 44 +--
.../disk/block/BlockDiskCacheKeyStoreUnitTest.java | 35 +--
.../BlockDiskCacheRandomConcurrentTestUtil.java | 14 +-
...BlockDiskCacheSameRegionConcurrentUnitTest.java | 22 +-
.../disk/block/BlockDiskCacheSizeUnitTest.java | 44 +--
.../disk/block/BlockDiskCacheSteadyLoadTest.java | 28 +-
.../disk/block/BlockDiskCacheUnitTestAbstract.java | 166 +++++------
.../auxiliary/disk/block/BlockDiskUnitTest.java | 76 ++---
.../block/HugeQuantityBlockDiskCacheLoadTest.java | 16 +-
.../auxiliary/disk/indexed/DiskTestObjectUtil.java | 36 +--
.../indexed/HugeQuantityIndDiskCacheLoadTest.java | 8 +-
.../disk/indexed/IndexDiskCacheCountUnitTest.java | 20 +-
.../disk/indexed/IndexDiskCacheSizeUnitTest.java | 22 +-
.../indexed/IndexDiskCacheUnitTestAbstract.java | 332 ++++++++++-----------
...dexedDiskCacheConcurrentNoDeadLockUnitTest.java | 12 +-
.../IndexedDiskCacheConcurrentUnitTest.java | 32 +-
.../IndexedDiskCacheDefragPerformanceTest.java | 22 +-
.../indexed/IndexedDiskCacheKeyStoreUnitTest.java | 38 +--
.../indexed/IndexedDiskCacheNoMemoryUnitTest.java | 20 +-
.../IndexedDiskCacheOptimizationUnitTest.java | 16 +-
.../IndexedDiskCacheRandomConcurrentTestUtil.java | 14 +-
...dexedDiskCacheSameRegionConcurrentUnitTest.java | 22 +-
.../indexed/IndexedDiskCacheSteadyLoadTest.java | 30 +-
.../auxiliary/disk/indexed/LRUMapSizeVsCount.java | 24 +-
.../auxiliary/disk/jdbc/HsqlSetupTableUtil.java | 4 +-
.../disk/jdbc/JDBCDataSourceFactoryUnitTest.java | 64 ++--
.../disk/jdbc/JDBCDiskCacheRemovalUnitTest.java | 30 +-
.../disk/jdbc/JDBCDiskCacheSharedPoolUnitTest.java | 28 +-
.../disk/jdbc/JDBCDiskCacheShrinkUnitTest.java | 38 +--
.../auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java | 60 ++--
.../jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java | 16 +-
.../disk/jdbc/hsql/HSQLDiskCacheUnitTest.java | 30 +-
.../mysql/MySQLDiskCacheHsqlBackedUnitTest.java | 32 +-
.../disk/jdbc/mysql/MySQLDiskCacheUnitTest.java | 12 +-
.../mysql/util/ScheduleParserUtilUnitTest.java | 20 +-
.../lateral/LateralCacheNoWaitFacadeUnitTest.java | 38 +--
.../tcp/LateralTCPConcurrentRandomTestUtil.java | 42 +--
.../tcp/LateralTCPDiscoveryListenerUnitTest.java | 96 +++---
.../LateralTCPFilterRemoveHashCodeUnitTest.java | 38 +--
.../tcp/LateralTCPIssueRemoveOnPutUnitTest.java | 58 ++--
.../tcp/LateralTCPNoDeadLockConcurrentTest.java | 12 +-
.../lateral/socket/tcp/TestTCPLateralUnitTest.java | 110 +++----
.../auxiliary/remote/MockRemoteCacheClient.java | 12 +-
.../auxiliary/remote/MockRemoteCacheListener.java | 10 +-
.../auxiliary/remote/MockRemoteCacheService.java | 28 +-
.../auxiliary/remote/RemoteCacheClientTester.java | 32 +-
.../remote/RemoteCacheListenerUnitTest.java | 44 +--
.../remote/RemoteCacheNoWaitFacadeUnitTest.java | 10 +-
.../remote/RemoteCacheNoWaitUnitTest.java | 52 ++--
.../jcs3/auxiliary/remote/RemoteCacheUnitTest.java | 58 ++--
.../jcs3/auxiliary/remote/RemoteUtilsUnitTest.java | 2 +-
.../jcs3/auxiliary/remote/TestRemoteCache.java | 22 +-
.../remote/ZombieRemoteCacheServiceUnitTest.java | 30 +-
.../http/client/MockRemoteCacheDispatcher.java | 2 +-
.../http/client/RemoteHttpCacheClientUnitTest.java | 100 +++----
.../client/RemoteHttpCacheFactoryUnitTest.java | 26 +-
.../http/client/RemoteHttpCacheManualTester.java | 4 +-
.../server/RemoteHttpCacheServiceUnitTest.java | 56 ++--
.../server/RemoteHttpCacheServletUnitTest.java | 64 ++--
.../BasicRemoteCacheClientServerUnitTest.java | 94 +++---
.../remote/server/MockRMISocketFactory.java | 8 +-
.../server/RegistryKeepAliveRunnerUnitTest.java | 10 +-
.../RemoteCacheServerAttributesUnitTest.java | 6 +-
.../server/RemoteCacheServerFactoryUnitTest.java | 66 ++--
.../server/RemoteCacheServerStartupUtil.java | 14 +-
.../remote/server/RemoteCacheServerUnitTest.java | 82 ++---
...imeoutConfigurableRMISocketFactoryUnitTest.java | 10 +-
.../util/RemoteCacheRequestFactoryUnitTest.java | 48 +--
.../engine/CacheEventQueueFactoryUnitTest.java | 20 +-
.../jcs3/engine/ElementAttributesUtils.java | 2 +-
.../jcs3/engine/EventQueueConcurrentLoadTest.java | 30 +-
.../jcs3/engine/MockCacheServiceNonLocal.java | 28 +-
.../jcs3/engine/SystemPropertyUsageUnitTest.java | 6 +-
.../engine/ZombieCacheServiceNonLocalUnitTest.java | 30 +-
.../engine/control/CacheManagerStatsUnitTest.java | 10 +-
.../CompositeCacheConfiguratorUnitTest.java | 32 +-
.../control/CompositeCacheDiskUsageUnitTest.java | 86 +++---
.../engine/control/CompositeCacheManagerTest.java | 6 +-
.../engine/control/CompositeCacheUnitTest.java | 99 +++---
.../engine/control/MockCompositeCacheManager.java | 14 +-
.../jcs3/engine/control/MockElementSerializer.java | 6 +-
.../control/event/ElementEventHandlerMockImpl.java | 14 +-
.../control/event/SimpleEventHandlingUnitTest.java | 52 ++--
.../CacheEventLoggerDebugLoggerUnitTest.java | 48 +--
.../jcs3/engine/logging/MockCacheEventLogger.java | 12 +-
.../match/KeyMatcherPatternImpllUnitTest.java | 36 +--
.../jcs3/engine/memory/MockMemoryCache.java | 28 +-
.../memory/fifo/FIFOMemoryCacheUnitTest.java | 22 +-
.../lru/LHMLRUMemoryCacheConcurrentUnitTest.java | 26 +-
.../memory/lru/LHMLRUMemoryCacheUnitTest.java | 78 ++---
.../lru/LRUMemoryCacheConcurrentUnitTest.java | 26 +-
.../engine/memory/mru/LRUvsMRUPerformanceTest.java | 18 +-
.../engine/memory/mru/MRUMemoryCacheUnitTest.java | 78 ++---
.../memory/shrinking/ShrinkerThreadUnitTest.java | 114 +++----
.../soft/SoftReferenceMemoryCacheUnitTest.java | 58 ++--
.../jcs3/utils/access/JCSWorkerUnitTest.java | 10 +-
.../jcs3/utils/config/PropertySetterUnitTest.java | 14 +-
.../utils/discovery/MockDiscoveryListener.java | 4 +-
.../discovery/UDPDiscoverySenderUnitTest.java | 16 +-
.../discovery/UDPDiscoveryServiceUnitTest.java | 60 ++--
.../jcs3/utils/discovery/UDPDiscoveryUnitTest.java | 18 +-
.../jcs3/utils/net/HostNameUtilUnitTest.java | 2 +-
.../commons/jcs3/utils/props/PropertyLoader.java | 6 +-
.../CompressingSerializerUnitTest.java | 26 +-
.../SerializationConversionUtilUnitTest.java | 60 ++--
.../serialization/StandardSerializerUnitTest.java | 24 +-
.../utils/struct/DoubleLinkedListDumpUnitTest.java | 14 +-
.../utils/struct/DoubleLinkedListUnitTest.java | 56 ++--
.../struct/JCSvsCommonsLRUMapPerformanceTest.java | 16 +-
.../utils/struct/LRUMapConcurrentUnitTest.java | 30 +-
.../jcs3/utils/struct/LRUMapPerformanceTest.java | 14 +-
.../commons/jcs3/utils/struct/LRUMapUnitTest.java | 32 +-
.../threadpool/ThreadPoolManagerUnitTest.java | 20 +-
.../commons/jcs3/utils/timing/SleepUtil.java | 6 +-
.../jcs3/utils/zip/CompressionUtilUnitTest.java | 20 +-
312 files changed, 4829 insertions(+), 4787 deletions(-)
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/JCS.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/JCS.java
index fd53588..9b65da1 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/JCS.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/JCS.java
@@ -55,7 +55,7 @@ public abstract class JCS
* <p>
* @param configFilename
*/
- public static void setConfigFilename( String configFilename )
+ public static void setConfigFilename( final String configFilename )
{
JCS.configFilename = configFilename;
}
@@ -66,7 +66,7 @@ public abstract class JCS
*
* @param configProps
*/
- public static void setConfigProperties( Properties configProps )
+ public static void setConfigProperties( final Properties configProps )
{
JCS.configProps = configProps;
}
@@ -78,7 +78,7 @@ public abstract class JCS
*
* @param logSystem the logSystem to set
*/
- public static void setLogSystem(String logSystem)
+ public static void setLogSystem(final String logSystem)
{
LogManager.setLogSystem(logSystem);
}
@@ -138,10 +138,10 @@ public abstract class JCS
* @return A CacheAccess which provides access to a given region.
* @throws CacheException
*/
- public static <K, V> CacheAccess<K, V> getInstance( String region )
+ public static <K, V> CacheAccess<K, V> getInstance( final String region )
throws CacheException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( region );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( region );
return new CacheAccess<>( cache );
}
@@ -153,10 +153,10 @@ public abstract class JCS
* @return A CacheAccess which provides access to a given region.
* @throws CacheException
*/
- public static <K, V> CacheAccess<K, V> getInstance( String region, ICompositeCacheAttributes icca )
+ public static <K, V> CacheAccess<K, V> getInstance( final String region, final ICompositeCacheAttributes icca )
throws CacheException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( region, icca );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( region, icca );
return new CacheAccess<>( cache );
}
@@ -169,10 +169,10 @@ public abstract class JCS
* @return A CacheAccess which provides access to a given region.
* @throws CacheException
*/
- public static <K, V> CacheAccess<K, V> getInstance( String region, ICompositeCacheAttributes icca, IElementAttributes eattr )
+ public static <K, V> CacheAccess<K, V> getInstance( final String region, final ICompositeCacheAttributes icca, final IElementAttributes eattr )
throws CacheException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( region, icca, eattr );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( region, icca, eattr );
return new CacheAccess<>( cache );
}
@@ -183,10 +183,10 @@ public abstract class JCS
* @return A GroupCacheAccess which provides access to a given region.
* @throws CacheException
*/
- public static <K, V> GroupCacheAccess<K, V> getGroupCacheInstance( String region )
+ public static <K, V> GroupCacheAccess<K, V> getGroupCacheInstance( final String region )
throws CacheException
{
- CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region );
+ final CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region );
return new GroupCacheAccess<>( cache );
}
@@ -198,10 +198,10 @@ public abstract class JCS
* @return A GroupCacheAccess which provides access to a given region.
* @throws CacheException
*/
- public static <K, V> GroupCacheAccess<K, V> getGroupCacheInstance( String region, ICompositeCacheAttributes icca )
+ public static <K, V> GroupCacheAccess<K, V> getGroupCacheInstance( final String region, final ICompositeCacheAttributes icca )
throws CacheException
{
- CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region, icca );
+ final CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region, icca );
return new GroupCacheAccess<>( cache );
}
@@ -214,10 +214,10 @@ public abstract class JCS
* @return A GroupCacheAccess which provides access to a given region.
* @throws CacheException
*/
- public static <K, V> GroupCacheAccess<K, V> getGroupCacheInstance( String region, ICompositeCacheAttributes icca, IElementAttributes eattr )
+ public static <K, V> GroupCacheAccess<K, V> getGroupCacheInstance( final String region, final ICompositeCacheAttributes icca, final IElementAttributes eattr )
throws CacheException
{
- CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region, icca, eattr );
+ final CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region, icca, eattr );
return new GroupCacheAccess<>( cache );
}
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/AbstractCacheAccess.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/AbstractCacheAccess.java
index 2c28555..374620d 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/AbstractCacheAccess.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/AbstractCacheAccess.java
@@ -54,7 +54,7 @@ public abstract class AbstractCacheAccess<K, V>
* <p>
* @param cacheControl The cache which the created instance accesses
*/
- protected AbstractCacheAccess( CompositeCache<K, V> cacheControl )
+ protected AbstractCacheAccess( final CompositeCache<K, V> cacheControl )
{
this.cacheControl = cacheControl;
}
@@ -72,7 +72,7 @@ public abstract class AbstractCacheAccess<K, V>
{
this.getCacheControl().removeAll();
}
- catch ( IOException e )
+ catch ( final IOException e )
{
throw new CacheException( e );
}
@@ -89,7 +89,7 @@ public abstract class AbstractCacheAccess<K, V>
* @throws CacheException if something goes wrong.
*/
@Override
- public void setDefaultElementAttributes( IElementAttributes attr )
+ public void setDefaultElementAttributes( final IElementAttributes attr )
throws CacheException
{
this.getCacheControl().setElementAttributes( attr );
@@ -164,7 +164,7 @@ public abstract class AbstractCacheAccess<K, V>
* @param cattr The new ICompositeCacheAttribute value
*/
@Override
- public void setCacheAttributes( ICompositeCacheAttributes cattr )
+ public void setCacheAttributes( final ICompositeCacheAttributes cattr )
{
this.getCacheControl().setCacheAttributes( cattr );
}
@@ -180,7 +180,7 @@ public abstract class AbstractCacheAccess<K, V>
* @throws CacheException
*/
@Override
- public int freeMemoryElements( int numberToFree )
+ public int freeMemoryElements( final int numberToFree )
throws CacheException
{
int numFreed = -1;
@@ -188,9 +188,9 @@ public abstract class AbstractCacheAccess<K, V>
{
numFreed = this.getCacheControl().getMemoryCache().freeElements( numberToFree );
}
- catch ( IOException ioe )
+ catch ( final IOException ioe )
{
- String message = "Failure freeing memory elements.";
+ final String message = "Failure freeing memory elements.";
throw new CacheException( message, ioe );
}
return numFreed;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/CacheAccess.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/CacheAccess.java
index 0964216..4d3efe8 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/CacheAccess.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/CacheAccess.java
@@ -57,7 +57,7 @@ public class CacheAccess<K, V>
* <p>
* @param cacheControl The cache which the created instance accesses
*/
- public CacheAccess( CompositeCache<K, V> cacheControl )
+ public CacheAccess( final CompositeCache<K, V> cacheControl )
{
super(cacheControl);
}
@@ -69,9 +69,9 @@ public class CacheAccess<K, V>
* @return The object if found or null
*/
@Override
- public V get( K name )
+ public V get( final K name )
{
- ICacheElement<K, V> element = this.getCacheControl().get( name );
+ final ICacheElement<K, V> element = this.getCacheControl().get( name );
return ( element != null ) ? element.getVal() : null;
}
@@ -86,7 +86,7 @@ public class CacheAccess<K, V>
* @return Object.
*/
@Override
- public V get(K name, Supplier<V> supplier)
+ public V get(final K name, final Supplier<V> supplier)
{
V value = get(name);
@@ -106,11 +106,11 @@ public class CacheAccess<K, V>
* @return A map of key to values. These are stripped from the wrapper.
*/
@Override
- public Map<K, V> getMatching( String pattern )
+ public Map<K, V> getMatching( final String pattern )
{
Map<K, V> unwrappedResults;
- Map<K, ICacheElement<K, V>> wrappedResults = this.getCacheControl().getMatching( pattern );
+ final Map<K, ICacheElement<K, V>> wrappedResults = this.getCacheControl().getMatching( pattern );
if ( wrappedResults == null )
{
@@ -145,7 +145,7 @@ public class CacheAccess<K, V>
* @return The ICacheElement<K, V> if the object is found or null
*/
@Override
- public ICacheElement<K, V> getCacheElement( K name )
+ public ICacheElement<K, V> getCacheElement( final K name )
{
return this.getCacheControl().get( name );
}
@@ -168,7 +168,7 @@ public class CacheAccess<K, V>
* @return a map of K key to ICacheElement<K, V> element, or empty map if none of the keys are present
*/
@Override
- public Map<K, ICacheElement<K, V>> getCacheElements( Set<K> names )
+ public Map<K, ICacheElement<K, V>> getCacheElements( final Set<K> names )
{
return this.getCacheControl().getMultiple( names );
}
@@ -191,7 +191,7 @@ public class CacheAccess<K, V>
* @return a map of K key to ICacheElement<K, V> element, or empty map if no keys match the pattern
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatchingCacheElements( String pattern )
+ public Map<K, ICacheElement<K, V>> getMatchingCacheElements( final String pattern )
{
return this.getCacheControl().getMatching( pattern );
}
@@ -207,7 +207,7 @@ public class CacheAccess<K, V>
* cache.
*/
@Override
- public void putSafe( K key, V value )
+ public void putSafe( final K key, final V value )
{
if ( this.getCacheControl().get( key ) != null )
{
@@ -225,7 +225,7 @@ public class CacheAccess<K, V>
* @param obj Object to store
*/
@Override
- public void put( K name, V obj )
+ public void put( final K name, final V obj )
{
// Call put with a copy of the contained caches default attributes.
// the attributes are copied by the cacheControl
@@ -240,7 +240,7 @@ public class CacheAccess<K, V>
* @see org.apache.commons.jcs3.access.behavior.ICacheAccess#put(Object, Object, IElementAttributes)
*/
@Override
- public void put( K key, V val, IElementAttributes attr )
+ public void put( final K key, final V val, final IElementAttributes attr )
{
if ( key == null )
{
@@ -256,14 +256,14 @@ public class CacheAccess<K, V>
// should be wrapped by cache access.
try
{
- CacheElement<K, V> ce = new CacheElement<>( this.getCacheControl().getCacheName(), key,
+ final CacheElement<K, V> ce = new CacheElement<>( this.getCacheControl().getCacheName(), key,
val );
ce.setElementAttributes( attr );
this.getCacheControl().update( ce );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
throw new CacheException( e );
}
@@ -275,7 +275,7 @@ public class CacheAccess<K, V>
* @param name the name of the item to remove.
*/
@Override
- public void remove( K name )
+ public void remove( final K name )
{
this.getCacheControl().remove( name );
}
@@ -289,9 +289,9 @@ public class CacheAccess<K, V>
* @throws InvalidHandleException if the item does not exist.
*/
@Override
- public void resetElementAttributes( K name, IElementAttributes attr )
+ public void resetElementAttributes( final K name, final IElementAttributes attr )
{
- ICacheElement<K, V> element = this.getCacheControl().get( name );
+ final ICacheElement<K, V> element = this.getCacheControl().get( name );
if ( element == null )
{
@@ -315,7 +315,7 @@ public class CacheAccess<K, V>
* @return Attributes for the object, null if object not in cache
*/
@Override
- public IElementAttributes getElementAttributes( K name ) throws CacheException
+ public IElementAttributes getElementAttributes( final K name ) throws CacheException
{
IElementAttributes attr = null;
@@ -323,7 +323,7 @@ public class CacheAccess<K, V>
{
attr = this.getCacheControl().getElementAttributes( name );
}
- catch ( IOException ioe )
+ catch ( final IOException ioe )
{
throw new CacheException("Failure getting element attributes", ioe);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/GroupCacheAccess.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/GroupCacheAccess.java
index cad9082..7d42573 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/GroupCacheAccess.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/GroupCacheAccess.java
@@ -45,7 +45,7 @@ public class GroupCacheAccess<K, V>
* <p>
* @param cacheControl
*/
- public GroupCacheAccess( CompositeCache<GroupAttrName<K>, V> cacheControl )
+ public GroupCacheAccess( final CompositeCache<GroupAttrName<K>, V> cacheControl )
{
super(cacheControl);
}
@@ -60,9 +60,9 @@ public class GroupCacheAccess<K, V>
* @return The cached value, null if not found.
*/
@Override
- public V getFromGroup( K name, String group )
+ public V getFromGroup( final K name, final String group )
{
- ICacheElement<GroupAttrName<K>, V> element = this.getCacheControl().get( getGroupAttrName( group, name ) );
+ final ICacheElement<GroupAttrName<K>, V> element = this.getCacheControl().get( getGroupAttrName( group, name ) );
return ( element != null ) ? element.getVal() : null;
}
@@ -73,9 +73,9 @@ public class GroupCacheAccess<K, V>
* @param name
* @return GroupAttrName
*/
- private GroupAttrName<K> getGroupAttrName( String group, K name )
+ private GroupAttrName<K> getGroupAttrName( final String group, final K name )
{
- GroupId gid = new GroupId( this.getCacheControl().getCacheName(), group );
+ final GroupId gid = new GroupId( this.getCacheControl().getCacheName(), group );
return new GroupAttrName<>( gid, name );
}
@@ -93,7 +93,7 @@ public class GroupCacheAccess<K, V>
* @throws CacheException
*/
@Override
- public void putInGroup( K name, String groupName, V value )
+ public void putInGroup( final K name, final String groupName, final V value )
throws CacheException
{
putInGroup( name, groupName, value, null );
@@ -115,7 +115,7 @@ public class GroupCacheAccess<K, V>
* @throws CacheException
*/
@Override
- public void putInGroup( K name, String groupName, V value, IElementAttributes attr )
+ public void putInGroup( final K name, final String groupName, final V value, final IElementAttributes attr )
throws CacheException
{
if ( name == null )
@@ -132,16 +132,16 @@ public class GroupCacheAccess<K, V>
// should be wrapped by cache access.
try
{
- GroupAttrName<K> key = getGroupAttrName( groupName, name );
- CacheElement<GroupAttrName<K>, V> ce =
+ final GroupAttrName<K> key = getGroupAttrName( groupName, name );
+ final CacheElement<GroupAttrName<K>, V> ce =
new CacheElement<>( this.getCacheControl().getCacheName(), key, value );
- IElementAttributes attributes = (attr == null) ? this.getCacheControl().getElementAttributes() : attr;
+ final IElementAttributes attributes = (attr == null) ? this.getCacheControl().getElementAttributes() : attr;
ce.setElementAttributes( attributes );
this.getCacheControl().update( ce );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
throw new CacheException( e );
}
@@ -155,9 +155,9 @@ public class GroupCacheAccess<K, V>
* @param group
*/
@Override
- public void removeFromGroup( K name, String group )
+ public void removeFromGroup( final K name, final String group )
{
- GroupAttrName<K> key = getGroupAttrName( group, name );
+ final GroupAttrName<K> key = getGroupAttrName( group, name );
this.getCacheControl().remove( key );
}
@@ -168,9 +168,9 @@ public class GroupCacheAccess<K, V>
* @return A Set of keys.
*/
@Override
- public Set<K> getGroupKeys( String group )
+ public Set<K> getGroupKeys( final String group )
{
- GroupId groupId = new GroupId( this.getCacheControl().getCacheName(), group );
+ final GroupId groupId = new GroupId( this.getCacheControl().getCacheName(), group );
return this.getCacheControl().getKeySet()
.stream()
@@ -199,7 +199,7 @@ public class GroupCacheAccess<K, V>
* The name of the group to invalidate
*/
@Override
- public void invalidateGroup( String group )
+ public void invalidateGroup( final String group )
{
this.getCacheControl().remove(getGroupAttrName(group, null));
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/CacheException.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/CacheException.java
index ba20f88..9825b4b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/CacheException.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/CacheException.java
@@ -39,7 +39,7 @@ public class CacheException
* Constructor for the CacheException object
* @param nested a nested exception
*/
- public CacheException( Throwable nested )
+ public CacheException( final Throwable nested )
{
super(nested);
}
@@ -48,7 +48,7 @@ public class CacheException
* Constructor for the CacheException object
* @param message the exception message
*/
- public CacheException( String message )
+ public CacheException( final String message )
{
super(message);
}
@@ -58,7 +58,7 @@ public class CacheException
* @param message the exception message
* @param nested a nested exception
*/
- public CacheException(String message, Throwable nested)
+ public CacheException(final String message, final Throwable nested)
{
super(message, nested);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ConfigurationException.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ConfigurationException.java
index bb977a4..da3c890 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ConfigurationException.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ConfigurationException.java
@@ -36,7 +36,7 @@ public class ConfigurationException
* <p>
* @param message
*/
- public ConfigurationException( String message )
+ public ConfigurationException( final String message )
{
super( message );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidArgumentException.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidArgumentException.java
index 02cab12..26baa96 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidArgumentException.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidArgumentException.java
@@ -39,7 +39,7 @@ public class InvalidArgumentException
* <p>
* @param message
*/
- public InvalidArgumentException( String message )
+ public InvalidArgumentException( final String message )
{
super( message );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidGroupException.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidGroupException.java
index 440dcaa..cc59fd4 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidGroupException.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidGroupException.java
@@ -38,7 +38,7 @@ public class InvalidGroupException
* <p>
* @param message
*/
- public InvalidGroupException( String message )
+ public InvalidGroupException( final String message )
{
super( message );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidHandleException.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidHandleException.java
index 45f84fb..ad49507 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidHandleException.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/InvalidHandleException.java
@@ -40,7 +40,7 @@ public class InvalidHandleException
* <p>
* @param message
*/
- public InvalidHandleException( String message )
+ public InvalidHandleException( final String message )
{
super( message );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ObjectExistsException.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ObjectExistsException.java
index b005ec7..df7db12 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ObjectExistsException.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ObjectExistsException.java
@@ -44,7 +44,7 @@ public class ObjectExistsException
* Constructor for the ObjectExistsException object
* @param message
*/
- public ObjectExistsException( String message )
+ public ObjectExistsException( final String message )
{
super( message );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ObjectNotFoundException.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ObjectNotFoundException.java
index bdee272..f0d9a99 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ObjectNotFoundException.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/access/exception/ObjectNotFoundException.java
@@ -42,7 +42,7 @@ public class ObjectNotFoundException
* Constructor for the ObjectNotFoundException object
* @param message
*/
- public ObjectNotFoundException( String message )
+ public ObjectNotFoundException( final String message )
{
super( message );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CacheElementInfo.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CacheElementInfo.java
index fbfa7b0..a1266e5 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CacheElementInfo.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CacheElementInfo.java
@@ -52,8 +52,8 @@ public class CacheElementInfo
* @param expiresInSeconds when it will expire
*/
@ConstructorProperties({"key", "eternal", "createTime", "maxLifeSeconds", "expiresInSeconds"})
- public CacheElementInfo(String key, boolean eternal, String createTime,
- long maxLifeSeconds, long expiresInSeconds)
+ public CacheElementInfo(final String key, final boolean eternal, final String createTime,
+ final long maxLifeSeconds, final long expiresInSeconds)
{
this.key = key;
this.eternal = eternal;
@@ -110,7 +110,7 @@ public class CacheElementInfo
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\nCacheElementInfo " );
buf.append( "\n Key [" ).append( getKey() ).append( "]" );
buf.append( "\n Eternal [" ).append( isEternal() ).append( "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CacheRegionInfo.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CacheRegionInfo.java
index c2b4aa5..7956aee 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CacheRegionInfo.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CacheRegionInfo.java
@@ -70,9 +70,9 @@ public class CacheRegionInfo
*/
@ConstructorProperties({"cacheName", "cacheSize", "cacheStatus", "cacheStatistics",
"hitCountRam", "hitCountAux", "missCountNotFound", "missCountExpired", "byteCount"})
- public CacheRegionInfo(String cacheName, int cacheSize, String cacheStatus,
- String cacheStatistics, long hitCountRam, long hitCountAux,
- long missCountNotFound, long missCountExpired, long byteCount)
+ public CacheRegionInfo(final String cacheName, final int cacheSize, final String cacheStatus,
+ final String cacheStatistics, final long hitCountRam, final long hitCountAux,
+ final long missCountNotFound, final long missCountExpired, final long byteCount)
{
this.cacheName = cacheName;
this.cacheSize = cacheSize;
@@ -165,7 +165,7 @@ public class CacheRegionInfo
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\nCacheRegionInfo " );
if ( cacheName != null )
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CountingOnlyOutputStream.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CountingOnlyOutputStream.java
index 3ee9736..a08bdc7 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CountingOnlyOutputStream.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/CountingOnlyOutputStream.java
@@ -38,7 +38,7 @@ public class CountingOnlyOutputStream
* @throws IOException
*/
@Override
- public void write( byte[] b )
+ public void write( final byte[] b )
throws IOException
{
this.count += b.length;
@@ -53,7 +53,7 @@ public class CountingOnlyOutputStream
* @throws IOException
*/
@Override
- public void write( byte[] b, int off, int len )
+ public void write( final byte[] b, final int off, final int len )
throws IOException
{
this.count += len;
@@ -66,7 +66,7 @@ public class CountingOnlyOutputStream
* @throws IOException
*/
@Override
- public void write( int b )
+ public void write( final int b )
throws IOException
{
this.count++;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
index 6d54ffb..4b52893 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/admin/JCSAdminBean.java
@@ -62,7 +62,7 @@ public class JCSAdminBean implements JCSJMXBean
{
this.cacheHub = CompositeCacheManager.getInstance();
}
- catch (CacheException e)
+ catch (final CacheException e)
{
throw new RuntimeException("Could not retrieve cache manager instance", e);
}
@@ -73,7 +73,7 @@ public class JCSAdminBean implements JCSJMXBean
*
* @param cacheHub the cache manager instance
*/
- public JCSAdminBean(CompositeCacheManager cacheHub)
+ public JCSAdminBean(final CompositeCacheManager cacheHub)
{
this.cacheHub = cacheHub;
}
@@ -86,29 +86,29 @@ public class JCSAdminBean implements JCSJMXBean
* @throws IOException
*/
@Override
- public List<CacheElementInfo> buildElementInfo( String cacheName )
+ public List<CacheElementInfo> buildElementInfo( final String cacheName )
throws IOException
{
- CompositeCache<Object, Object> cache = cacheHub.getCache( cacheName );
+ final CompositeCache<Object, Object> cache = cacheHub.getCache( cacheName );
// Convert all keys to string, store in a sorted map
- TreeMap<String, ?> keys = new TreeMap<>(cache.getMemoryCache().getKeySet()
+ final TreeMap<String, ?> keys = new TreeMap<>(cache.getMemoryCache().getKeySet()
.stream()
.collect(Collectors.toMap(Object::toString, k -> k)));
- LinkedList<CacheElementInfo> records = new LinkedList<>();
+ final LinkedList<CacheElementInfo> records = new LinkedList<>();
- DateFormat format = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT );
+ final DateFormat format = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT );
- long now = System.currentTimeMillis();
+ final long now = System.currentTimeMillis();
- for (Map.Entry<String, ?> key : keys.entrySet())
+ for (final Map.Entry<String, ?> key : keys.entrySet())
{
- ICacheElement<?, ?> element = cache.getMemoryCache().getQuiet( key.getValue() );
+ final ICacheElement<?, ?> element = cache.getMemoryCache().getQuiet( key.getValue() );
- IElementAttributes attributes = element.getElementAttributes();
+ final IElementAttributes attributes = element.getElementAttributes();
- CacheElementInfo elementInfo = new CacheElementInfo(
+ final CacheElementInfo elementInfo = new CacheElementInfo(
key.getKey(),
attributes.getIsEternal(),
format.format(new Date(attributes.getCreateTime())),
@@ -131,15 +131,15 @@ public class JCSAdminBean implements JCSJMXBean
@Override
public List<CacheRegionInfo> buildCacheInfo()
{
- TreeSet<String> cacheNames = new TreeSet<>(cacheHub.getCacheNames());
+ final TreeSet<String> cacheNames = new TreeSet<>(cacheHub.getCacheNames());
- LinkedList<CacheRegionInfo> cacheInfo = new LinkedList<>();
+ final LinkedList<CacheRegionInfo> cacheInfo = new LinkedList<>();
- for (String cacheName : cacheNames)
+ for (final String cacheName : cacheNames)
{
- CompositeCache<?, ?> cache = cacheHub.getCache( cacheName );
+ final CompositeCache<?, ?> cache = cacheHub.getCache( cacheName );
- CacheRegionInfo regionInfo = new CacheRegionInfo(
+ final CacheRegionInfo regionInfo = new CacheRegionInfo(
cache.getCacheName(),
cache.getSize(),
cache.getStatus().toString(),
@@ -165,7 +165,7 @@ public class JCSAdminBean implements JCSJMXBean
* @return int The size of the region in bytes.
*/
@Override
- public long getByteCount(String cacheName)
+ public long getByteCount(final String cacheName)
{
return getByteCount(cacheHub.getCache(cacheName));
}
@@ -177,7 +177,7 @@ public class JCSAdminBean implements JCSJMXBean
*
* @return int The size of the region in bytes.
*/
- public <K, V> long getByteCount(CompositeCache<K, V> cache)
+ public <K, V> long getByteCount(final CompositeCache<K, V> cache)
{
if (cache == null)
{
@@ -185,16 +185,16 @@ public class JCSAdminBean implements JCSJMXBean
}
long size = 0;
- IMemoryCache<K, V> memCache = cache.getMemoryCache();
+ final IMemoryCache<K, V> memCache = cache.getMemoryCache();
- for (K key : memCache.getKeySet())
+ for (final K key : memCache.getKeySet())
{
ICacheElement<K, V> ice = null;
try
{
ice = memCache.get(key);
}
- catch (IOException e)
+ catch (final IOException e)
{
throw new RuntimeException("IOException while trying to get a cached element", e);
}
@@ -210,15 +210,15 @@ public class JCSAdminBean implements JCSJMXBean
}
else
{
- Object element = ice.getVal();
+ final Object element = ice.getVal();
//CountingOnlyOutputStream: Keeps track of the number of bytes written to it, but doesn't write them anywhere.
- CountingOnlyOutputStream counter = new CountingOnlyOutputStream();
+ final CountingOnlyOutputStream counter = new CountingOnlyOutputStream();
try (ObjectOutputStream out = new ObjectOutputStream(counter);)
{
out.writeObject(element);
}
- catch (IOException e)
+ catch (final IOException e)
{
throw new RuntimeException("IOException while trying to measure the size of the cached element", e);
}
@@ -228,7 +228,7 @@ public class JCSAdminBean implements JCSJMXBean
{
counter.close();
}
- catch (IOException e)
+ catch (final IOException e)
{
// ignore
}
@@ -252,13 +252,13 @@ public class JCSAdminBean implements JCSJMXBean
@Override
public void clearAllRegions() throws IOException
{
- RemoteCacheServer<?, ?> remoteCacheServer = RemoteCacheServerFactory.getRemoteCacheServer();
+ final RemoteCacheServer<?, ?> remoteCacheServer = RemoteCacheServerFactory.getRemoteCacheServer();
if (remoteCacheServer == null)
{
// Not running in a remote cache server.
// Remove objects from the cache directly, as no need to broadcast removes to client machines...
- for (String name : cacheHub.getCacheNames())
+ for (final String name : cacheHub.getCacheNames())
{
cacheHub.getCache(name).removeAll();
}
@@ -268,7 +268,7 @@ public class JCSAdminBean implements JCSJMXBean
// Running in a remote cache server.
// Remove objects via the RemoteCacheServer API, so that removes will be broadcast to client machines...
// Call remoteCacheServer.removeAll(String) for each cacheName...
- for (String name : cacheHub.getCacheNames())
+ for (final String name : cacheHub.getCacheNames())
{
remoteCacheServer.removeAll(name);
}
@@ -283,7 +283,7 @@ public class JCSAdminBean implements JCSJMXBean
* cache API.
*/
@Override
- public void clearRegion(String cacheName) throws IOException
+ public void clearRegion(final String cacheName) throws IOException
{
if (cacheName == null)
{
@@ -302,10 +302,10 @@ public class JCSAdminBean implements JCSJMXBean
try
{
// Call remoteCacheServer.removeAll(String)...
- RemoteCacheServer<?, ?> remoteCacheServer = RemoteCacheServerFactory.getRemoteCacheServer();
+ final RemoteCacheServer<?, ?> remoteCacheServer = RemoteCacheServerFactory.getRemoteCacheServer();
remoteCacheServer.removeAll(cacheName);
}
- catch (IOException e)
+ catch (final IOException e)
{
throw new IllegalStateException("Failed to remove all elements from cache region [" + cacheName + "]: " + e, e);
}
@@ -325,7 +325,7 @@ public class JCSAdminBean implements JCSJMXBean
* @throws IOException
*/
@Override
- public void removeItem(String cacheName, String key) throws IOException
+ public void removeItem(final String cacheName, final String key) throws IOException
{
if (cacheName == null)
{
@@ -348,14 +348,14 @@ public class JCSAdminBean implements JCSJMXBean
try
{
Object keyToRemove = null;
- CompositeCache<?, ?> cache = CompositeCacheManager.getInstance().getCache(cacheName);
+ final CompositeCache<?, ?> cache = CompositeCacheManager.getInstance().getCache(cacheName);
// A String key was supplied, but to remove elements via the RemoteCacheServer API, we need the
// actual key object as stored in the cache (i.e. a Serializable object). To find the key in this form,
// we iterate through all keys stored in the memory cache until we find one whose toString matches
// the string supplied...
- Set<?> allKeysInCache = cache.getMemoryCache().getKeySet();
- for (Object keyInCache : allKeysInCache)
+ final Set<?> allKeysInCache = cache.getMemoryCache().getKeySet();
+ for (final Object keyInCache : allKeysInCache)
{
if (keyInCache.toString().equals(key))
{
@@ -377,10 +377,10 @@ public class JCSAdminBean implements JCSJMXBean
// At this point, we have retrieved the matching K key.
// Call remoteCacheServer.remove(String, Serializable)...
- RemoteCacheServer<Serializable, Serializable> remoteCacheServer = RemoteCacheServerFactory.getRemoteCacheServer();
+ final RemoteCacheServer<Serializable, Serializable> remoteCacheServer = RemoteCacheServerFactory.getRemoteCacheServer();
remoteCacheServer.remove(cacheName, key);
}
- catch (Exception e)
+ catch (final Exception e)
{
throw new IllegalStateException("Failed to remove element with key [" + key + ", " + key.getClass() + "] from cache region [" + cacheName + "]: " + e, e);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java
index bfb231b..d9df597 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCache.java
@@ -54,7 +54,7 @@ public abstract class AbstractAuxiliaryCache<K, V>
* @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no
* data in cache for any of these keys
*/
- protected Map<K, ICacheElement<K, V>> processGetMultiple(Set<K> keys) throws IOException
+ protected Map<K, ICacheElement<K, V>> processGetMultiple(final Set<K> keys) throws IOException
{
if (keys != null)
{
@@ -64,7 +64,7 @@ public abstract class AbstractAuxiliaryCache<K, V>
{
return get(key);
}
- catch (IOException e)
+ catch (final IOException e)
{
return null;
}
@@ -95,13 +95,13 @@ public abstract class AbstractAuxiliaryCache<K, V>
* @param eventName
* @return ICacheEvent
*/
- protected ICacheEvent<K> createICacheEvent( ICacheElement<K, V> item, String eventName )
+ protected ICacheEvent<K> createICacheEvent( final ICacheElement<K, V> item, final String eventName )
{
if ( cacheEventLogger == null )
{
return new CacheEvent<>();
}
- String diskLocation = getEventLoggingExtraInfo();
+ final String diskLocation = getEventLoggingExtraInfo();
String regionName = null;
K key = null;
if ( item != null )
@@ -121,13 +121,13 @@ public abstract class AbstractAuxiliaryCache<K, V>
* @param eventName
* @return ICacheEvent
*/
- protected <T> ICacheEvent<T> createICacheEvent( String regionName, T key, String eventName )
+ protected <T> ICacheEvent<T> createICacheEvent( final String regionName, final T key, final String eventName )
{
if ( cacheEventLogger == null )
{
return new CacheEvent<>();
}
- String diskLocation = getEventLoggingExtraInfo();
+ final String diskLocation = getEventLoggingExtraInfo();
return cacheEventLogger.createICacheEvent( getAuxiliaryCacheAttributes().getName(), regionName, eventName,
diskLocation, key );
@@ -138,7 +138,7 @@ public abstract class AbstractAuxiliaryCache<K, V>
* <p>
* @param cacheEvent
*/
- protected <T> void logICacheEvent( ICacheEvent<T> cacheEvent )
+ protected <T> void logICacheEvent( final ICacheEvent<T> cacheEvent )
{
if ( cacheEventLogger != null )
{
@@ -153,7 +153,7 @@ public abstract class AbstractAuxiliaryCache<K, V>
* @param eventName
* @param optionalDetails
*/
- protected void logApplicationEvent( String source, String eventName, String optionalDetails )
+ protected void logApplicationEvent( final String source, final String eventName, final String optionalDetails )
{
if ( cacheEventLogger != null )
{
@@ -168,7 +168,7 @@ public abstract class AbstractAuxiliaryCache<K, V>
* @param eventName
* @param errorMessage
*/
- protected void logError( String source, String eventName, String errorMessage )
+ protected void logError( final String source, final String eventName, final String errorMessage )
{
if ( cacheEventLogger != null )
{
@@ -189,7 +189,7 @@ public abstract class AbstractAuxiliaryCache<K, V>
* @param cacheEventLogger
*/
@Override
- public void setCacheEventLogger( ICacheEventLogger cacheEventLogger )
+ public void setCacheEventLogger( final ICacheEventLogger cacheEventLogger )
{
this.cacheEventLogger = cacheEventLogger;
}
@@ -213,7 +213,7 @@ public abstract class AbstractAuxiliaryCache<K, V>
* @param elementSerializer
*/
@Override
- public void setElementSerializer( IElementSerializer elementSerializer )
+ public void setElementSerializer( final IElementSerializer elementSerializer )
{
if ( elementSerializer != null )
{
@@ -237,7 +237,7 @@ public abstract class AbstractAuxiliaryCache<K, V>
* @param keyMatcher
*/
@Override
- public void setKeyMatcher( IKeyMatcher<K> keyMatcher )
+ public void setKeyMatcher( final IKeyMatcher<K> keyMatcher )
{
if ( keyMatcher != null )
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java
index 8792615..757409a 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheAttributes.java
@@ -46,7 +46,7 @@ public abstract class AbstractAuxiliaryCacheAttributes
* @param name
*/
@Override
- public void setCacheName( String name )
+ public void setCacheName( final String name )
{
this.cacheName = name;
}
@@ -68,7 +68,7 @@ public abstract class AbstractAuxiliaryCacheAttributes
* @see org.apache.commons.jcs3.auxiliary.AuxiliaryCacheAttributes#setName(java.lang.String)
*/
@Override
- public void setName( String s )
+ public void setName( final String s )
{
this.name = s;
}
@@ -90,7 +90,7 @@ public abstract class AbstractAuxiliaryCacheAttributes
* @param queueType SINGLE or POOLED
*/
@Override
- public void setEventQueueType( ICacheEventQueue.QueueType queueType )
+ public void setEventQueueType( final ICacheEventQueue.QueueType queueType )
{
this.eventQueueType = queueType;
}
@@ -111,7 +111,7 @@ public abstract class AbstractAuxiliaryCacheAttributes
* @param s SINGLE or POOLED
*/
@Override
- public void setEventQueuePoolName( String s )
+ public void setEventQueuePoolName( final String s )
{
eventQueuePoolName = s;
}
@@ -138,7 +138,7 @@ public abstract class AbstractAuxiliaryCacheAttributes
{
return (AbstractAuxiliaryCacheAttributes)super.clone();
}
- catch (CloneNotSupportedException e)
+ catch (final CloneNotSupportedException e)
{
throw new RuntimeException("Clone not supported. This should never happen.", e);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheEventLogging.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheEventLogging.java
index 8b78f3b..d7db07c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheEventLogging.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheEventLogging.java
@@ -44,7 +44,7 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> cacheElement )
+ public void update( final ICacheElement<K, V> cacheElement )
throws IOException
{
updateWithEventLogging( cacheElement );
@@ -56,10 +56,10 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* @param cacheElement
* @throws IOException
*/
- protected final void updateWithEventLogging( ICacheElement<K, V> cacheElement )
+ protected final void updateWithEventLogging( final ICacheElement<K, V> cacheElement )
throws IOException
{
- ICacheEvent<K> cacheEvent = createICacheEvent( cacheElement, ICacheEventLogger.UPDATE_EVENT );
+ final ICacheEvent<K> cacheEvent = createICacheEvent( cacheElement, ICacheEventLogger.UPDATE_EVENT );
try
{
processUpdate( cacheElement );
@@ -87,7 +87,7 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> get( K key )
+ public ICacheElement<K, V> get( final K key )
throws IOException
{
return getWithEventLogging( key );
@@ -100,10 +100,10 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* @return ICacheElement, a wrapper around the key, value, and attributes
* @throws IOException
*/
- protected final ICacheElement<K, V> getWithEventLogging( K key )
+ protected final ICacheElement<K, V> getWithEventLogging( final K key )
throws IOException
{
- ICacheEvent<K> cacheEvent = createICacheEvent( getCacheName(), key, ICacheEventLogger.GET_EVENT );
+ final ICacheEvent<K> cacheEvent = createICacheEvent( getCacheName(), key, ICacheEventLogger.GET_EVENT );
try
{
return processGet( key );
@@ -133,7 +133,7 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
+ public Map<K, ICacheElement<K, V>> getMultiple(final Set<K> keys)
throws IOException
{
return getMultipleWithEventLogging( keys );
@@ -147,10 +147,10 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* data in cache for any of these keys
* @throws IOException
*/
- protected final Map<K, ICacheElement<K, V>> getMultipleWithEventLogging(Set<K> keys )
+ protected final Map<K, ICacheElement<K, V>> getMultipleWithEventLogging(final Set<K> keys )
throws IOException
{
- ICacheEvent<Serializable> cacheEvent = createICacheEvent( getCacheName(), (Serializable) keys,
+ final ICacheEvent<Serializable> cacheEvent = createICacheEvent( getCacheName(), (Serializable) keys,
ICacheEventLogger.GETMULTIPLE_EVENT );
try
{
@@ -177,7 +177,7 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( final String pattern )
throws IOException
{
return getMatchingWithEventLogging( pattern );
@@ -191,10 +191,10 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* data matching the pattern.
* @throws IOException
*/
- protected final Map<K, ICacheElement<K, V>> getMatchingWithEventLogging( String pattern )
+ protected final Map<K, ICacheElement<K, V>> getMatchingWithEventLogging( final String pattern )
throws IOException
{
- ICacheEvent<String> cacheEvent = createICacheEvent( getCacheName(), pattern, ICacheEventLogger.GETMATCHING_EVENT );
+ final ICacheEvent<String> cacheEvent = createICacheEvent( getCacheName(), pattern, ICacheEventLogger.GETMATCHING_EVENT );
try
{
return processGetMatching( pattern );
@@ -224,7 +224,7 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* @throws IOException
*/
@Override
- public boolean remove( K key )
+ public boolean remove( final K key )
throws IOException
{
return removeWithEventLogging( key );
@@ -237,10 +237,10 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
* @return boolean, whether or not the item was removed
* @throws IOException
*/
- protected final boolean removeWithEventLogging( K key )
+ protected final boolean removeWithEventLogging( final K key )
throws IOException
{
- ICacheEvent<K> cacheEvent = createICacheEvent( getCacheName(), key, ICacheEventLogger.REMOVE_EVENT );
+ final ICacheEvent<K> cacheEvent = createICacheEvent( getCacheName(), key, ICacheEventLogger.REMOVE_EVENT );
try
{
return processRemove( key );
@@ -281,7 +281,7 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
protected final void removeAllWithEventLogging()
throws IOException
{
- ICacheEvent<String> cacheEvent = createICacheEvent( getCacheName(), "all", ICacheEventLogger.REMOVEALL_EVENT );
+ final ICacheEvent<String> cacheEvent = createICacheEvent( getCacheName(), "all", ICacheEventLogger.REMOVEALL_EVENT );
try
{
processRemoveAll();
@@ -321,7 +321,7 @@ public abstract class AbstractAuxiliaryCacheEventLogging<K, V>
protected final void disposeWithEventLogging()
throws IOException
{
- ICacheEvent<String> cacheEvent = createICacheEvent( getCacheName(), "none", ICacheEventLogger.DISPOSE_EVENT );
+ final ICacheEvent<String> cacheEvent = createICacheEvent( getCacheName(), "none", ICacheEventLogger.DISPOSE_EVENT );
try
{
processDispose();
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheFactory.java
index bca907f..606ccc3 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheFactory.java
@@ -45,7 +45,7 @@ public abstract class AbstractAuxiliaryCacheFactory
* @param name The new name value
*/
@Override
- public void setName( String name )
+ public void setName( final String name )
{
this.name = name;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheMonitor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheMonitor.java
index 2595ddd..bc62464 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheMonitor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AbstractAuxiliaryCacheMonitor.java
@@ -63,7 +63,7 @@ public abstract class AbstractAuxiliaryCacheMonitor extends Thread
*
* @param name the thread name
*/
- public AbstractAuxiliaryCacheMonitor(String name)
+ public AbstractAuxiliaryCacheMonitor(final String name)
{
super(name);
}
@@ -73,7 +73,7 @@ public abstract class AbstractAuxiliaryCacheMonitor extends Thread
* <p>
* @param idlePeriod The new idlePeriod value
*/
- public static void setIdlePeriod( long idlePeriod )
+ public static void setIdlePeriod( final long idlePeriod )
{
if ( idlePeriod > AbstractAuxiliaryCacheMonitor.idlePeriod )
{
@@ -153,7 +153,7 @@ public abstract class AbstractAuxiliaryCacheMonitor extends Thread
trigger.await();
// wake up only if there is an error.
}
- catch ( InterruptedException ignore )
+ catch ( final InterruptedException ignore )
{
//no op, this is expected
}
@@ -187,7 +187,7 @@ public abstract class AbstractAuxiliaryCacheMonitor extends Thread
Thread.sleep( idlePeriod );
}
- catch ( InterruptedException ex )
+ catch ( final InterruptedException ex )
{
// ignore;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AuxiliaryCacheConfigurator.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AuxiliaryCacheConfigurator.java
index 575f1c4..90f0610 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AuxiliaryCacheConfigurator.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/AuxiliaryCacheConfigurator.java
@@ -62,15 +62,15 @@ public class AuxiliaryCacheConfigurator
* @param auxPrefix - ex. AUXILIARY_PREFIX + auxName
* @return cacheEventLogger
*/
- public static ICacheEventLogger parseCacheEventLogger( Properties props, String auxPrefix )
+ public static ICacheEventLogger parseCacheEventLogger( final Properties props, final String auxPrefix )
{
// auxFactory was not previously initialized.
- String eventLoggerClassName = auxPrefix + CACHE_EVENT_LOGGER_PREFIX;
- ICacheEventLogger cacheEventLogger = OptionConverter.instantiateByKey( props, eventLoggerClassName, null );
+ final String eventLoggerClassName = auxPrefix + CACHE_EVENT_LOGGER_PREFIX;
+ final ICacheEventLogger cacheEventLogger = OptionConverter.instantiateByKey( props, eventLoggerClassName, null );
if ( cacheEventLogger != null )
{
- String cacheEventLoggerAttributePrefix = auxPrefix + CACHE_EVENT_LOGGER_PREFIX + ATTRIBUTE_PREFIX;
+ final String cacheEventLoggerAttributePrefix = auxPrefix + CACHE_EVENT_LOGGER_PREFIX + ATTRIBUTE_PREFIX;
PropertySetter.setProperties( cacheEventLogger, props, cacheEventLoggerAttributePrefix + "." );
log.info( "Using custom cache event logger [{0}] for auxiliary [{1}]",
cacheEventLogger, auxPrefix );
@@ -89,15 +89,15 @@ public class AuxiliaryCacheConfigurator
* @param auxPrefix - ex. AUXILIARY_PREFIX + auxName
* @return cacheEventLogger
*/
- public static IElementSerializer parseElementSerializer( Properties props, String auxPrefix )
+ public static IElementSerializer parseElementSerializer( final Properties props, final String auxPrefix )
{
// TODO take in the entire prop key
// auxFactory was not previously initialized.
- String elementSerializerClassName = auxPrefix + SERIALIZER_PREFIX;
+ final String elementSerializerClassName = auxPrefix + SERIALIZER_PREFIX;
IElementSerializer elementSerializer = OptionConverter.instantiateByKey( props, elementSerializerClassName, null );
if ( elementSerializer != null )
{
- String attributePrefix = auxPrefix + SERIALIZER_PREFIX + ATTRIBUTE_PREFIX;
+ final String attributePrefix = auxPrefix + SERIALIZER_PREFIX + ATTRIBUTE_PREFIX;
PropertySetter.setProperties( elementSerializer, props, attributePrefix + "." );
log.info( "Using custom element serializer [{0}] for auxiliary [{1}]",
elementSerializer, auxPrefix );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCache.java
index 138c2a7..b3aca70 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCache.java
@@ -108,13 +108,13 @@ public abstract class AbstractDiskCache<K, V>
*
* @param attr
*/
- protected AbstractDiskCache( IDiskCacheAttributes attr )
+ protected AbstractDiskCache( final IDiskCacheAttributes attr )
{
this.diskCacheAttributes = attr;
this.cacheName = attr.getCacheName();
// create queue
- CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
+ final CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
this.cacheEventQueue = fact.createCacheEventQueue( new MyCacheListener(), CacheInfo.listenerId, cacheName,
diskCacheAttributes.getEventQueuePoolName(),
diskCacheAttributes.getEventQueueType() );
@@ -134,7 +134,7 @@ public abstract class AbstractDiskCache<K, V>
/**
* @param alive set the alive status
*/
- public void setAlive(boolean alive)
+ public void setAlive(final boolean alive)
{
this.alive = alive;
}
@@ -187,7 +187,7 @@ public abstract class AbstractDiskCache<K, V>
* @see org.apache.commons.jcs3.engine.behavior.ICache#update
*/
@Override
- public final void update( ICacheElement<K, V> cacheElement )
+ public final void update( final ICacheElement<K, V> cacheElement )
throws IOException
{
log.debug( "Putting element in purgatory, cacheName: {0}, key: {1}",
@@ -196,7 +196,7 @@ public abstract class AbstractDiskCache<K, V>
try
{
// Wrap the CacheElement in a PurgatoryElement
- PurgatoryElement<K, V> pe = new PurgatoryElement<>( cacheElement );
+ final PurgatoryElement<K, V> pe = new PurgatoryElement<>( cacheElement );
// Indicates the the element is eligible to be spooled to disk,
// this will remain true unless the item is pulled back into
@@ -212,7 +212,7 @@ public abstract class AbstractDiskCache<K, V>
// Queue element for serialization
cacheEventQueue.addPutEvent( pe );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( "Problem adding put event to queue.", ex );
@@ -229,7 +229,7 @@ public abstract class AbstractDiskCache<K, V>
* @see AuxiliaryCache#get
*/
@Override
- public final ICacheElement<K, V> get( K key )
+ public final ICacheElement<K, V> get( final K key )
{
// If not alive, always return null.
@@ -280,7 +280,7 @@ public abstract class AbstractDiskCache<K, V>
{
return doGet( key );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( e );
@@ -305,7 +305,7 @@ public abstract class AbstractDiskCache<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( final String pattern )
throws IOException
{
// Get the keys from purgatory
@@ -317,13 +317,13 @@ public abstract class AbstractDiskCache<K, V>
keyArray = new HashSet<>(purgatory.keySet());
}
- Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
+ final Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
// call getMultiple with the set
- Map<K, ICacheElement<K, V>> result = processGetMultiple( matchingKeys );
+ final Map<K, ICacheElement<K, V>> result = processGetMultiple( matchingKeys );
// Get the keys from disk
- Map<K, ICacheElement<K, V>> diskMatches = doGetMatching( pattern );
+ final Map<K, ICacheElement<K, V>> diskMatches = doGetMatching( pattern );
result.putAll( diskMatches );
@@ -347,7 +347,7 @@ public abstract class AbstractDiskCache<K, V>
* @see org.apache.commons.jcs3.engine.behavior.ICache#remove
*/
@Override
- public final boolean remove( K key )
+ public final boolean remove( final K key )
throws IOException
{
PurgatoryElement<K, V> pe = null;
@@ -425,11 +425,11 @@ public abstract class AbstractDiskCache<K, V>
public final void dispose()
throws IOException
{
- Thread t = new Thread(() ->
+ final Thread t = new Thread(() ->
{
boolean keepGoing = true;
// long total = 0;
- long interval = 100;
+ final long interval = 100;
while ( keepGoing )
{
keepGoing = !cacheEventQueue.isEmpty();
@@ -439,7 +439,7 @@ public abstract class AbstractDiskCache<K, V>
// total += interval;
// log.info( "total = " + total );
}
- catch ( InterruptedException e )
+ catch ( final InterruptedException e )
{
break;
}
@@ -453,7 +453,7 @@ public abstract class AbstractDiskCache<K, V>
{
t.join( this.diskCacheAttributes.getShutdownSpoolTimeLimit() * 1000L );
}
- catch ( InterruptedException ex )
+ catch ( final InterruptedException ex )
{
log.error( "The Shutdown Spool Process was interrupted.", ex );
}
@@ -498,16 +498,16 @@ public abstract class AbstractDiskCache<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "Abstract Disk Cache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
elems.add(new StatElement<>( "Purgatory Hits", Integer.valueOf(purgHits) ) );
elems.add(new StatElement<>( "Purgatory Size", Integer.valueOf(purgatory.size()) ) );
// get the stats from the event queue too
- IStats eqStats = this.cacheEventQueue.getStatistics();
+ final IStats eqStats = this.cacheEventQueue.getStatistics();
elems.addAll(eqStats.getStatElements());
stats.setStatElements( elems );
@@ -573,7 +573,7 @@ public abstract class AbstractDiskCache<K, V>
* @see ICacheListener#setListenerId
*/
@Override
- public void setListenerId( long id )
+ public void setListenerId( final long id )
throws IOException
{
this.listenerId = id;
@@ -597,7 +597,7 @@ public abstract class AbstractDiskCache<K, V>
// if it is still spoolable, and remove it from purgatory.
if ( element instanceof PurgatoryElement )
{
- PurgatoryElement<K, V> pe = (PurgatoryElement<K, V>) element;
+ final PurgatoryElement<K, V> pe = (PurgatoryElement<K, V>) element;
synchronized ( pe.getCacheElement() )
{
@@ -671,7 +671,7 @@ public abstract class AbstractDiskCache<K, V>
* @see ICacheListener#handleRemove
*/
@Override
- public void handleRemove( String cacheName, K key )
+ public void handleRemove( final String cacheName, final K key )
throws IOException
{
if ( alive )
@@ -689,7 +689,7 @@ public abstract class AbstractDiskCache<K, V>
* @see ICacheListener#handleRemoveAll
*/
@Override
- public void handleRemoveAll( String cacheName )
+ public void handleRemoveAll( final String cacheName )
throws IOException
{
if ( alive )
@@ -704,7 +704,7 @@ public abstract class AbstractDiskCache<K, V>
* @see ICacheListener#handleDispose
*/
@Override
- public void handleDispose( String cacheName )
+ public void handleDispose( final String cacheName )
throws IOException
{
if ( alive )
@@ -733,7 +733,7 @@ public abstract class AbstractDiskCache<K, V>
* @return An object matching key, or null.
* @throws IOException
*/
- protected final ICacheElement<K, V> doGet( K key )
+ protected final ICacheElement<K, V> doGet( final K key )
throws IOException
{
return super.getWithEventLogging( key );
@@ -750,7 +750,7 @@ public abstract class AbstractDiskCache<K, V>
* @return A map of matches..
* @throws IOException
*/
- protected final Map<K, ICacheElement<K, V>> doGetMatching( String pattern )
+ protected final Map<K, ICacheElement<K, V>> doGetMatching( final String pattern )
throws IOException
{
return super.getMatchingWithEventLogging( pattern );
@@ -766,7 +766,7 @@ public abstract class AbstractDiskCache<K, V>
* @param cacheElement
* @throws IOException
*/
- protected final void doUpdate( ICacheElement<K, V> cacheElement )
+ protected final void doUpdate( final ICacheElement<K, V> cacheElement )
throws IOException
{
super.updateWithEventLogging( cacheElement );
@@ -783,7 +783,7 @@ public abstract class AbstractDiskCache<K, V>
* @return whether or no the item was present when removed
* @throws IOException
*/
- protected final boolean doRemove( K key )
+ protected final boolean doRemove( final K key )
throws IOException
{
return super.removeWithEventLogging( key );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCacheAttributes.java
index 266c922..4aa4c6c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/AbstractDiskCacheAttributes.java
@@ -66,7 +66,7 @@ public abstract class AbstractDiskCacheAttributes extends AbstractAuxiliaryCache
* The new diskPath value
*/
@Override
- public void setDiskPath(String path)
+ public void setDiskPath(final String path)
{
setDiskPath(new File(path));
}
@@ -78,7 +78,7 @@ public abstract class AbstractDiskCacheAttributes extends AbstractAuxiliaryCache
* @param diskPath
* The new diskPath value
*/
- public void setDiskPath(File diskPath)
+ public void setDiskPath(final File diskPath)
{
this.diskPath = diskPath;
boolean result = this.diskPath.isDirectory();
@@ -125,7 +125,7 @@ public abstract class AbstractDiskCacheAttributes extends AbstractAuxiliaryCache
* The new maxPurgatorySize value
*/
@Override
- public void setMaxPurgatorySize(int maxPurgatorySize)
+ public void setMaxPurgatorySize(final int maxPurgatorySize)
{
this.maxPurgatorySize = maxPurgatorySize;
}
@@ -156,7 +156,7 @@ public abstract class AbstractDiskCacheAttributes extends AbstractAuxiliaryCache
* the time in seconds
*/
@Override
- public void setShutdownSpoolTimeLimit(int shutdownSpoolTimeLimit)
+ public void setShutdownSpoolTimeLimit(final int shutdownSpoolTimeLimit)
{
this.shutdownSpoolTimeLimit = shutdownSpoolTimeLimit;
}
@@ -166,7 +166,7 @@ public abstract class AbstractDiskCacheAttributes extends AbstractAuxiliaryCache
* The allowRemoveAll to set.
*/
@Override
- public void setAllowRemoveAll(boolean allowRemoveAll)
+ public void setAllowRemoveAll(final boolean allowRemoveAll)
{
this.allowRemoveAll = allowRemoveAll;
}
@@ -189,7 +189,7 @@ public abstract class AbstractDiskCacheAttributes extends AbstractAuxiliaryCache
@Override
public String toString()
{
- StringBuilder str = new StringBuilder();
+ final StringBuilder str = new StringBuilder();
str.append("AbstractDiskCacheAttributes ");
str.append("\n diskPath = " + getDiskPath());
str.append("\n maxPurgatorySize = " + getMaxPurgatorySize());
@@ -199,13 +199,13 @@ public abstract class AbstractDiskCacheAttributes extends AbstractAuxiliaryCache
}
@Override
- public void setDiskLimitType(DiskLimitType diskLimitType)
+ public void setDiskLimitType(final DiskLimitType diskLimitType)
{
this.diskLimitType = diskLimitType;
}
@Override
- public void setDiskLimitTypeName(String diskLimitTypeName)
+ public void setDiskLimitTypeName(final String diskLimitTypeName)
{
if (diskLimitTypeName != null)
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/PurgatoryElement.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/PurgatoryElement.java
index f2babab..f7fa6f5 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/PurgatoryElement.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/PurgatoryElement.java
@@ -46,7 +46,7 @@ public class PurgatoryElement<K, V>
*
* @param cacheElement CacheElement
*/
- public PurgatoryElement( ICacheElement<K, V> cacheElement )
+ public PurgatoryElement( final ICacheElement<K, V> cacheElement )
{
super(cacheElement.getCacheName(),
cacheElement.getKey(), cacheElement.getVal(),
@@ -69,7 +69,7 @@ public class PurgatoryElement<K, V>
*
* @param spoolable The new spoolable value
*/
- public void setSpoolable( boolean spoolable )
+ public void setSpoolable( final boolean spoolable )
{
this.spoolable = spoolable;
}
@@ -131,7 +131,7 @@ public class PurgatoryElement<K, V>
* @see ICacheElement#setElementAttributes
*/
@Override
- public void setElementAttributes( IElementAttributes attr )
+ public void setElementAttributes( final IElementAttributes attr )
{
cacheElement.setElementAttributes( attr );
}
@@ -142,7 +142,7 @@ public class PurgatoryElement<K, V>
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "[PurgatoryElement: " );
buf.append( " isSpoolable = " + isSpoolable() );
buf.append( " CacheElement = " + getCacheElement() );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDisk.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDisk.java
index 517a9bf..7b0555c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDisk.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDisk.java
@@ -85,7 +85,7 @@ public class BlockDisk implements AutoCloseable
* @param elementSerializer
* @throws IOException
*/
- public BlockDisk(File file, IElementSerializer elementSerializer)
+ public BlockDisk(final File file, final IElementSerializer elementSerializer)
throws IOException
{
this(file, DEFAULT_BLOCK_SIZE_BYTES, elementSerializer);
@@ -98,7 +98,7 @@ public class BlockDisk implements AutoCloseable
* @param blockSizeBytes
* @throws IOException
*/
- public BlockDisk(File file, int blockSizeBytes)
+ public BlockDisk(final File file, final int blockSizeBytes)
throws IOException
{
this(file, blockSizeBytes, new StandardSerializer());
@@ -112,7 +112,7 @@ public class BlockDisk implements AutoCloseable
* @param elementSerializer
* @throws IOException
*/
- public BlockDisk(File file, int blockSizeBytes, IElementSerializer elementSerializer)
+ public BlockDisk(final File file, final int blockSizeBytes, final IElementSerializer elementSerializer)
throws IOException
{
this.filepath = file.getAbsolutePath();
@@ -134,11 +134,11 @@ public class BlockDisk implements AutoCloseable
* @param numBlocksNeeded
* @return an array of allocated blocks
*/
- private int[] allocateBlocks(int numBlocksNeeded)
+ private int[] allocateBlocks(final int numBlocksNeeded)
{
assert numBlocksNeeded >= 1;
- int[] blocks = new int[numBlocksNeeded];
+ final int[] blocks = new int[numBlocksNeeded];
// get them from the empty list or take the next one
for (int i = 0; i < numBlocksNeeded; i++)
{
@@ -170,11 +170,11 @@ public class BlockDisk implements AutoCloseable
* @return the blocks we used.
* @throws IOException
*/
- protected <T> int[] write(T object)
+ protected <T> int[] write(final T object)
throws IOException
{
// serialize the object
- byte[] data = elementSerializer.serialize(object);
+ final byte[] data = elementSerializer.serialize(object);
log.debug("write, total pre-chunking data.length = {0}", data.length);
@@ -182,29 +182,29 @@ public class BlockDisk implements AutoCloseable
this.putCount.incrementAndGet();
// figure out how many blocks we need.
- int numBlocksNeeded = calculateTheNumberOfBlocksNeeded(data);
+ final int numBlocksNeeded = calculateTheNumberOfBlocksNeeded(data);
log.debug("numBlocksNeeded = {0}", numBlocksNeeded);
// allocate blocks
- int[] blocks = allocateBlocks(numBlocksNeeded);
+ final int[] blocks = allocateBlocks(numBlocksNeeded);
int offset = 0;
final int maxChunkSize = blockSizeBytes - HEADER_SIZE_BYTES;
- ByteBuffer headerBuffer = ByteBuffer.allocate(HEADER_SIZE_BYTES);
- ByteBuffer dataBuffer = ByteBuffer.wrap(data);
+ final ByteBuffer headerBuffer = ByteBuffer.allocate(HEADER_SIZE_BYTES);
+ final ByteBuffer dataBuffer = ByteBuffer.wrap(data);
for (int i = 0; i < numBlocksNeeded; i++)
{
headerBuffer.clear();
- int length = Math.min(maxChunkSize, data.length - offset);
+ final int length = Math.min(maxChunkSize, data.length - offset);
headerBuffer.putInt(length);
headerBuffer.flip();
dataBuffer.position(offset).limit(offset + length);
- ByteBuffer slice = dataBuffer.slice();
+ final ByteBuffer slice = dataBuffer.slice();
- long position = calculateByteOffsetForBlockAsLong(blocks[i]);
+ final long position = calculateByteOffsetForBlockAsLong(blocks[i]);
// write the header
int written = fc.write(headerBuffer, position);
assert written == HEADER_SIZE_BYTES;
@@ -228,9 +228,9 @@ public class BlockDisk implements AutoCloseable
* @param numBlocksNeeded
* @return byte[][]
*/
- protected byte[][] getBlockChunks(byte[] complete, int numBlocksNeeded)
+ protected byte[][] getBlockChunks(final byte[] complete, final int numBlocksNeeded)
{
- byte[][] chunks = new byte[numBlocksNeeded][];
+ final byte[][] chunks = new byte[numBlocksNeeded][];
if (numBlocksNeeded == 1)
{
@@ -238,15 +238,15 @@ public class BlockDisk implements AutoCloseable
}
else
{
- int maxChunkSize = this.blockSizeBytes - HEADER_SIZE_BYTES;
- int totalBytes = complete.length;
+ final int maxChunkSize = this.blockSizeBytes - HEADER_SIZE_BYTES;
+ final int totalBytes = complete.length;
int totalUsed = 0;
for (short i = 0; i < numBlocksNeeded; i++)
{
// use the max that can be written to a block or whatever is left in the original
// array
- int chunkSize = Math.min(maxChunkSize, totalBytes - totalUsed);
- byte[] chunk = new byte[chunkSize];
+ final int chunkSize = Math.min(maxChunkSize, totalBytes - totalUsed);
+ final byte[] chunk = new byte[chunkSize];
// copy from the used position to the chunk size on the complete array to the chunk
// array.
System.arraycopy(complete, totalUsed, chunk, 0, chunkSize);
@@ -266,7 +266,7 @@ public class BlockDisk implements AutoCloseable
* @throws IOException
* @throws ClassNotFoundException
*/
- protected <T> T read(int[] blockNumbers)
+ protected <T> T read(final int[] blockNumbers)
throws IOException, ClassNotFoundException
{
final ByteBuffer data;
@@ -281,7 +281,7 @@ public class BlockDisk implements AutoCloseable
// get all the blocks into data
for (short i = 0; i < blockNumbers.length; i++)
{
- ByteBuffer chunk = readBlock(blockNumbers[i]);
+ final ByteBuffer chunk = readBlock(blockNumbers[i]);
data.put(chunk);
}
@@ -303,16 +303,16 @@ public class BlockDisk implements AutoCloseable
* @param block
* @throws IOException
*/
- private ByteBuffer readBlock(int block)
+ private ByteBuffer readBlock(final int block)
throws IOException
{
int datalen = 0;
String message = null;
boolean corrupted = false;
- long fileLength = fc.size();
+ final long fileLength = fc.size();
- long position = calculateByteOffsetForBlockAsLong(block);
+ final long position = calculateByteOffsetForBlockAsLong(block);
// if (position > fileLength)
// {
// corrupted = true;
@@ -320,7 +320,7 @@ public class BlockDisk implements AutoCloseable
// }
// else
{
- ByteBuffer datalength = ByteBuffer.allocate(HEADER_SIZE_BYTES);
+ final ByteBuffer datalength = ByteBuffer.allocate(HEADER_SIZE_BYTES);
fc.read(datalength, position);
datalength.flip();
datalen = datalength.getInt();
@@ -337,7 +337,7 @@ public class BlockDisk implements AutoCloseable
throw new IOException("The File Is Corrupt, need to reset");
}
- ByteBuffer data = ByteBuffer.allocate(datalen);
+ final ByteBuffer data = ByteBuffer.allocate(datalen);
fc.read(data, position + HEADER_SIZE_BYTES);
data.flip();
@@ -349,7 +349,7 @@ public class BlockDisk implements AutoCloseable
* <p>
* @param blocksToFree
*/
- protected void freeBlocks(int[] blocksToFree)
+ protected void freeBlocks(final int[] blocksToFree)
{
if (blocksToFree != null)
{
@@ -367,7 +367,7 @@ public class BlockDisk implements AutoCloseable
* @return the byte offset for this block in the file as a long
* @since 2.0
*/
- protected long calculateByteOffsetForBlockAsLong(int block)
+ protected long calculateByteOffsetForBlockAsLong(final int block)
{
return (long) block * blockSizeBytes;
}
@@ -378,11 +378,11 @@ public class BlockDisk implements AutoCloseable
* @param data
* @return the number of blocks needed to store the byte array
*/
- protected int calculateTheNumberOfBlocksNeeded(byte[] data)
+ protected int calculateTheNumberOfBlocksNeeded(final byte[] data)
{
- int dataLength = data.length;
+ final int dataLength = data.length;
- int oneBlock = blockSizeBytes - HEADER_SIZE_BYTES;
+ final int oneBlock = blockSizeBytes - HEADER_SIZE_BYTES;
// takes care of 0 = HEADER_SIZE_BYTES + blockSizeBytes
if (dataLength <= oneBlock)
@@ -460,7 +460,7 @@ public class BlockDisk implements AutoCloseable
*/
protected long getAveragePutSizeBytes()
{
- long count = this.putCount.get();
+ final long count = this.putCount.get();
if (count == 0)
{
@@ -485,7 +485,7 @@ public class BlockDisk implements AutoCloseable
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append("\nBlock Disk ");
buf.append("\n Filepath [" + filepath + "]");
buf.append("\n NumberOfBlocks [" + this.numberOfBlocks.get() + "]");
@@ -498,7 +498,7 @@ public class BlockDisk implements AutoCloseable
{
buf.append("\n Length [" + length() + "]");
}
- catch (IOException e)
+ catch (final IOException e)
{
// swallow
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
index 2a421d3..9f3ab59 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCache.java
@@ -91,7 +91,7 @@ public class BlockDiskCache<K, V>
* <p>
* @param cacheAttributes
*/
- public BlockDiskCache( BlockDiskCacheAttributes cacheAttributes )
+ public BlockDiskCache( final BlockDiskCacheAttributes cacheAttributes )
{
this( cacheAttributes, null );
}
@@ -102,7 +102,7 @@ public class BlockDiskCache<K, V>
* @param cacheAttributes
* @param elementSerializer used if supplied, the super's super will not set a null
*/
- public BlockDiskCache( BlockDiskCacheAttributes cacheAttributes, IElementSerializer elementSerializer )
+ public BlockDiskCache( final BlockDiskCacheAttributes cacheAttributes, final IElementSerializer elementSerializer )
{
super( cacheAttributes );
setElementSerializer( elementSerializer );
@@ -134,7 +134,7 @@ public class BlockDiskCache<K, V>
keyStore = new BlockDiskKeyStore<>( this.blockDiskCacheAttributes, this );
- boolean alright = verifyDisk();
+ final boolean alright = verifyDisk();
if ( keyStore.size() == 0 || !alright )
{
@@ -145,7 +145,7 @@ public class BlockDiskCache<K, V>
setAlive(true);
log.info("{0}: Block Disk Cache is alive.", logCacheName);
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error("{0}: Failure initializing for fileName: {1} and root directory: {2}",
logCacheName, fileName, rootDirectory, e);
@@ -156,7 +156,7 @@ public class BlockDiskCache<K, V>
* @see org.apache.commons.jcs3.engine.behavior.IRequireScheduler#setScheduledExecutorService(java.util.concurrent.ScheduledExecutorService)
*/
@Override
- public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutor)
+ public void setScheduledExecutorService(final ScheduledExecutorService scheduledExecutor)
{
// add this region to the persistence thread.
// TODO we might need to stagger this a bit.
@@ -190,7 +190,7 @@ public class BlockDiskCache<K, V>
.forEach(entry -> {
try
{
- Object data = this.dataFile.read(entry.getValue());
+ final Object data = this.dataFile.read(entry.getValue());
if ( data == null )
{
throw new IOException("Data is null");
@@ -204,7 +204,7 @@ public class BlockDiskCache<K, V>
});
alright = true;
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.warn("{0}: Problem verifying disk.", logCacheName, e);
alright = false;
@@ -225,7 +225,7 @@ public class BlockDiskCache<K, V>
@Override
public Set<K> getKeySet() throws IOException
{
- HashSet<K> keys = new HashSet<>();
+ final HashSet<K> keys = new HashSet<>();
storageLock.readLock().lock();
@@ -249,7 +249,7 @@ public class BlockDiskCache<K, V>
* data in cache matching keys
*/
@Override
- public Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
+ public Map<K, ICacheElement<K, V>> processGetMatching( final String pattern )
{
Set<K> keyArray = null;
storageLock.readLock().lock();
@@ -262,9 +262,9 @@ public class BlockDiskCache<K, V>
storageLock.readLock().unlock();
}
- Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
+ final Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
- Map<K, ICacheElement<K, V>> elements = matchingKeys.stream()
+ final Map<K, ICacheElement<K, V>> elements = matchingKeys.stream()
.collect(Collectors.toMap(
key -> key,
key -> processGet( key ))).entrySet().stream()
@@ -300,7 +300,7 @@ public class BlockDiskCache<K, V>
* @see org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCache#get(Object)
*/
@Override
- protected ICacheElement<K, V> processGet( K key )
+ protected ICacheElement<K, V> processGet( final K key )
{
if ( !isAlive() )
{
@@ -317,7 +317,7 @@ public class BlockDiskCache<K, V>
{
storageLock.readLock().lock();
try {
- int[] ded = this.keyStore.get( key );
+ final int[] ded = this.keyStore.get( key );
if ( ded != null )
{
object = this.dataFile.read( ded );
@@ -327,12 +327,12 @@ public class BlockDiskCache<K, V>
}
}
- catch ( IOException ioe )
+ catch ( final IOException ioe )
{
log.error("{0}: Failure getting from disk--IOException, key = {1}", logCacheName, key, ioe );
reset();
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error("{0}: Failure getting from disk, key = {1}", logCacheName, key, e );
}
@@ -351,7 +351,7 @@ public class BlockDiskCache<K, V>
* @see org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCache#update(ICacheElement)
*/
@Override
- protected void processUpdate( ICacheElement<K, V> element )
+ protected void processUpdate( final ICacheElement<K, V> element )
{
if ( !isAlive() )
{
@@ -374,14 +374,14 @@ public class BlockDiskCache<K, V>
this.dataFile.freeBlocks( old );
}
- int[] blocks = this.dataFile.write( element );
+ final int[] blocks = this.dataFile.write( element );
this.keyStore.put( element.getKey(), blocks );
log.debug("{0}: Put to file [{1}] key [{2}]", () -> logCacheName,
() -> fileName, () -> element.getKey());
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error("{0}: Failure updating element, key: {1} old: {2}",
logCacheName, element.getKey(), Arrays.toString(old), e);
@@ -404,7 +404,7 @@ public class BlockDiskCache<K, V>
* @see org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCache#remove(Object)
*/
@Override
- protected boolean processRemove( K key )
+ protected boolean processRemove( final K key )
{
if ( !isAlive() )
{
@@ -432,7 +432,7 @@ public class BlockDiskCache<K, V>
removed = performSingleKeyRemoval(key);
}
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error("{0}: Problem removing element.", logCacheName, e );
reset = true;
@@ -460,10 +460,10 @@ public class BlockDiskCache<K, V>
* @param key
* @return true if an element was removed
*/
- private boolean performGroupRemoval(GroupId key)
+ private boolean performGroupRemoval(final GroupId key)
{
// remove all keys of the same name group.
- List<K> itemsToRemove = keyStore.keySet()
+ final List<K> itemsToRemove = keyStore.keySet()
.stream()
.filter(k -> k instanceof GroupAttrName && ((GroupAttrName<?>) k).groupId.equals(key))
.collect(Collectors.toList());
@@ -487,10 +487,10 @@ public class BlockDiskCache<K, V>
* @param key
* @return true if there was a match
*/
- private boolean performPartialKeyRemoval(String key)
+ private boolean performPartialKeyRemoval(final String key)
{
// remove all keys of the same name hierarchy.
- List<K> itemsToRemove = keyStore.keySet()
+ final List<K> itemsToRemove = keyStore.keySet()
.stream()
.filter(k -> k instanceof String && k.toString().startsWith(key))
.collect(Collectors.toList());
@@ -505,10 +505,10 @@ public class BlockDiskCache<K, V>
}
- private boolean performSingleKeyRemoval(K key) {
+ private boolean performSingleKeyRemoval(final K key) {
boolean removed;
// remove single item.
- int[] ded = this.keyStore.remove( key );
+ final int[] ded = this.keyStore.remove( key );
removed = ded != null;
if ( removed )
{
@@ -540,14 +540,14 @@ public class BlockDiskCache<K, V>
@Override
public void processDispose()
{
- Thread t = new Thread(this::disposeInternal, "BlockDiskCache-DisposalThread" );
+ final Thread t = new Thread(this::disposeInternal, "BlockDiskCache-DisposalThread" );
t.start();
// wait up to 60 seconds for dispose and then quit if not done.
try
{
t.join( 60 * 1000 );
}
- catch ( InterruptedException ex )
+ catch ( final InterruptedException ex )
{
log.error("{0}: Interrupted while waiting for disposal thread to finish.",
logCacheName, ex );
@@ -586,7 +586,7 @@ public class BlockDiskCache<K, V>
// keyFile.close();
// keyFile = null;
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error("{0}: Failure closing files in dispose, filename: {1}",
logCacheName, fileName, e );
@@ -631,7 +631,7 @@ public class BlockDiskCache<K, V>
dataFile.reset();
}
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error("{0}: Failure resetting state", logCacheName, e );
}
@@ -646,7 +646,7 @@ public class BlockDiskCache<K, V>
* <p>
* @param blocksToFree
*/
- protected void freeBlocks( int[] blocksToFree )
+ protected void freeBlocks( final int[] blocksToFree )
{
this.dataFile.freeBlocks( blocksToFree );
}
@@ -659,10 +659,10 @@ public class BlockDiskCache<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "Block Disk Cache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
elems.add(new StatElement<>( "Is Alive", Boolean.valueOf(isAlive()) ) );
elems.add(new StatElement<>( "Key Map Size", Integer.valueOf(this.keyStore.size()) ) );
@@ -673,7 +673,7 @@ public class BlockDiskCache<K, V>
{
elems.add(new StatElement<>( "Data File Length", Long.valueOf(this.dataFile.length()) ) );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( e );
}
@@ -689,7 +689,7 @@ public class BlockDiskCache<K, V>
}
// get the stats from the super too
- IStats sStats = super.getStatistics();
+ final IStats sStats = super.getStatistics();
elems.addAll(sStats.getStatElements());
stats.setStatElements( elems );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheAttributes.java
index 6df7d40..310db3b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheAttributes.java
@@ -52,7 +52,7 @@ public class BlockDiskCacheAttributes
* <p>
* @param blockSizeBytes The blockSizeBytes to set.
*/
- public void setBlockSizeBytes( int blockSizeBytes )
+ public void setBlockSizeBytes( final int blockSizeBytes )
{
this.blockSizeBytes = blockSizeBytes;
}
@@ -68,7 +68,7 @@ public class BlockDiskCacheAttributes
/**
* @param maxKeySize The maxKeySize to set.
*/
- public void setMaxKeySize( int maxKeySize )
+ public void setMaxKeySize( final int maxKeySize )
{
this.maxKeySize = maxKeySize;
}
@@ -84,7 +84,7 @@ public class BlockDiskCacheAttributes
/**
* @param keyPersistenceIntervalSeconds The keyPersistenceIntervalSeconds to set.
*/
- public void setKeyPersistenceIntervalSeconds( long keyPersistenceIntervalSeconds )
+ public void setKeyPersistenceIntervalSeconds( final long keyPersistenceIntervalSeconds )
{
this.keyPersistenceIntervalSeconds = keyPersistenceIntervalSeconds;
}
@@ -105,7 +105,7 @@ public class BlockDiskCacheAttributes
@Override
public String toString()
{
- StringBuilder str = new StringBuilder();
+ final StringBuilder str = new StringBuilder();
str.append( "\nBlockDiskAttributes " );
str.append( "\n DiskPath [" + this.getDiskPath() + "]" );
str.append( "\n MaxKeySize [" + this.getMaxKeySize() + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheFactory.java
index 8932375..9bf4e0e 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskCacheFactory.java
@@ -48,13 +48,13 @@ public class BlockDiskCacheFactory
* @return BlockDiskCache
*/
@Override
- public <K, V> BlockDiskCache<K, V> createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ public <K, V> BlockDiskCache<K, V> createCache( final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
{
- BlockDiskCacheAttributes idca = (BlockDiskCacheAttributes) iaca;
+ final BlockDiskCacheAttributes idca = (BlockDiskCacheAttributes) iaca;
log.debug("Creating DiskCache for attributes = {0}", idca);
- BlockDiskCache<K, V> cache = new BlockDiskCache<>( idca, elementSerializer );
+ final BlockDiskCache<K, V> cache = new BlockDiskCache<>( idca, elementSerializer );
cache.setCacheEventLogger( cacheEventLogger );
return cache;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskElementDescriptor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskElementDescriptor.java
index 3dedb97..3fad13f 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskElementDescriptor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskElementDescriptor.java
@@ -47,7 +47,7 @@ public class BlockDiskElementDescriptor<K>
/**
* @param key The key to set.
*/
- public void setKey( K key )
+ public void setKey( final K key )
{
this.key = key;
}
@@ -63,7 +63,7 @@ public class BlockDiskElementDescriptor<K>
/**
* @param blocks The blocks to set.
*/
- public void setBlocks( int[] blocks )
+ public void setBlocks( final int[] blocks )
{
this.blocks = blocks;
}
@@ -86,7 +86,7 @@ public class BlockDiskElementDescriptor<K>
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\nBlockDiskElementDescriptor" );
buf.append( "\n key [" + this.getKey() + "]" );
buf.append( "\n blocks [" );
@@ -109,7 +109,7 @@ public class BlockDiskElementDescriptor<K>
*/
@Override
@SuppressWarnings("unchecked") // Need cast to K
- public void readExternal( ObjectInput input )
+ public void readExternal( final ObjectInput input )
throws IOException, ClassNotFoundException
{
this.key = (K) input.readObject();
@@ -123,7 +123,7 @@ public class BlockDiskElementDescriptor<K>
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
*/
@Override
- public void writeExternal( ObjectOutput output )
+ public void writeExternal( final ObjectOutput output )
throws IOException
{
output.writeObject( this.key );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskKeyStore.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskKeyStore.java
index bc1e3e9..42dd314 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskKeyStore.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/block/BlockDiskKeyStore.java
@@ -91,7 +91,7 @@ public class BlockDiskKeyStore<K>
* @param blockDiskCache
* used for freeing
*/
- public BlockDiskKeyStore(BlockDiskCacheAttributes cacheAttributes, BlockDiskCache<K, ?> blockDiskCache)
+ public BlockDiskKeyStore(final BlockDiskCacheAttributes cacheAttributes, final BlockDiskCache<K, ?> blockDiskCache)
{
this.blockDiskCacheAttributes = cacheAttributes;
this.logCacheName = "Region [" + this.blockDiskCacheAttributes.getCacheName() + "] ";
@@ -101,7 +101,7 @@ public class BlockDiskKeyStore<K>
this.diskLimitType = cacheAttributes.getDiskLimitType();
this.blockSize = cacheAttributes.getBlockSizeBytes();
- File rootDirectory = cacheAttributes.getDiskPath();
+ final File rootDirectory = cacheAttributes.getDiskPath();
log.info("{0}: Cache file root directory [{1}]", logCacheName, rootDirectory);
@@ -133,15 +133,15 @@ public class BlockDiskKeyStore<K>
{
try
{
- ElapsedTimer timer = new ElapsedTimer();
- int numKeys = keyHash.size();
+ final ElapsedTimer timer = new ElapsedTimer();
+ final int numKeys = keyHash.size();
log.info("{0}: Saving keys to [{1}], key count [{2}]", () -> logCacheName,
() -> this.keyFile.getAbsolutePath(), () -> numKeys);
synchronized (keyFile)
{
- FileOutputStream fos = new FileOutputStream(keyFile);
- BufferedOutputStream bos = new BufferedOutputStream(fos, 65536);
+ final FileOutputStream fos = new FileOutputStream(keyFile);
+ final BufferedOutputStream bos = new BufferedOutputStream(fos, 65536);
try (ObjectOutputStream oos = new ObjectOutputStream(bos))
{
@@ -151,9 +151,9 @@ public class BlockDiskKeyStore<K>
}
// don't need to synchronize, since the underlying
// collection makes a copy
- for (Map.Entry<K, int[]> entry : keyHash.entrySet())
+ for (final Map.Entry<K, int[]> entry : keyHash.entrySet())
{
- BlockDiskElementDescriptor<K> descriptor = new BlockDiskElementDescriptor<>();
+ final BlockDiskElementDescriptor<K> descriptor = new BlockDiskElementDescriptor<>();
descriptor.setKey(entry.getKey());
descriptor.setBlocks(entry.getValue());
// stream these out in the loop.
@@ -166,7 +166,7 @@ public class BlockDiskKeyStore<K>
() -> logCacheName, () -> timer.getElapsedTimeString(), () -> numKeys,
() -> keyFile.length());
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: Problem storing keys.", logCacheName, e);
}
@@ -234,18 +234,19 @@ public class BlockDiskKeyStore<K>
// create a key map to use.
initKeyMap();
- HashMap<K, int[]> keys = new HashMap<>();
+ final HashMap<K, int[]> keys = new HashMap<>();
synchronized (keyFile)
{
- FileInputStream fis = new FileInputStream(keyFile);
- BufferedInputStream bis = new BufferedInputStream(fis, 65536);
+ final FileInputStream fis = new FileInputStream(keyFile);
+ final BufferedInputStream bis = new BufferedInputStream(fis, 65536);
try (ObjectInputStream ois = new ObjectInputStreamClassLoaderAware(bis, null))
{
while (true)
{
@SuppressWarnings("unchecked")
+ final
// Need to cast from Object
BlockDiskElementDescriptor<K> descriptor = (BlockDiskElementDescriptor<K>) ois.readObject();
if (descriptor != null)
@@ -254,7 +255,7 @@ public class BlockDiskKeyStore<K>
}
}
}
- catch (EOFException eof)
+ catch (final EOFException eof)
{
// nothing
}
@@ -270,7 +271,7 @@ public class BlockDiskKeyStore<K>
() -> maxKeySize);
}
}
- catch (Exception e)
+ catch (final Exception e)
{
log.error("{0}: Problem loading keys for file {1}", logCacheName, fileName, e);
}
@@ -316,7 +317,7 @@ public class BlockDiskKeyStore<K>
* @param key
* @return Object
*/
- public int[] get(K key)
+ public int[] get(final K key)
{
return this.keyHash.get(key);
}
@@ -328,7 +329,7 @@ public class BlockDiskKeyStore<K>
* @param key
* @param value
*/
- public void put(K key, int[] value)
+ public void put(final K key, final int[] value)
{
this.keyHash.put(key, value);
}
@@ -340,7 +341,7 @@ public class BlockDiskKeyStore<K>
* @param key
* @return BlockDiskElementDescriptor if it was present, else null
*/
- public int[] remove(K key)
+ public int[] remove(final K key)
{
return this.keyHash.remove(key);
}
@@ -352,10 +353,10 @@ public class BlockDiskKeyStore<K>
*/
private boolean verify()
{
- Map<Integer, Set<K>> blockAllocationMap = new TreeMap<>();
- for (Entry<K, int[]> e : keyHash.entrySet())
+ final Map<Integer, Set<K>> blockAllocationMap = new TreeMap<>();
+ for (final Entry<K, int[]> e : keyHash.entrySet())
{
- for (int block : e.getValue())
+ for (final int block : e.getValue())
{
Set<K> keys = blockAllocationMap.get(block);
if (keys == null)
@@ -374,7 +375,7 @@ public class BlockDiskKeyStore<K>
boolean ok = true;
if (log.isTraceEnabled())
{
- for (Entry<Integer, Set<K>> e : blockAllocationMap.entrySet())
+ for (final Entry<Integer, Set<K>> e : blockAllocationMap.entrySet())
{
log.trace("Block {0}: {1}", e.getKey(), e.getValue());
if (e.getValue().size() > 1)
@@ -417,26 +418,26 @@ public class BlockDiskKeyStore<K>
* @param maxSize
* maximum cache size in kB
*/
- public LRUMapSizeLimited(int maxSize)
+ public LRUMapSizeLimited(final int maxSize)
{
this.maxSize = maxSize;
this.contentSize = new AtomicInteger(0);
}
// keep the content size in kB, so 2^31 kB is reasonable value
- private void subLengthFromCacheSize(int[] value)
+ private void subLengthFromCacheSize(final int[] value)
{
contentSize.addAndGet(value.length * blockSize / -1024 - 1);
}
// keep the content size in kB, so 2^31 kB is reasonable value
- private void addLengthToCacheSize(int[] value)
+ private void addLengthToCacheSize(final int[] value)
{
contentSize.addAndGet(value.length * blockSize / 1024 + 1);
}
@Override
- public int[] put(K key, int[] value)
+ public int[] put(final K key, final int[] value)
{
int[] oldValue = null;
@@ -460,7 +461,7 @@ public class BlockDiskKeyStore<K>
}
@Override
- public int[] remove(Object key)
+ public int[] remove(final Object key)
{
int[] value = null;
@@ -488,7 +489,7 @@ public class BlockDiskKeyStore<K>
* @param value
*/
@Override
- protected void processRemovedLRU(K key, int[] value)
+ protected void processRemovedLRU(final K key, final int[] value)
{
blockDiskCache.freeBlocks(value);
if (log.isDebugEnabled())
@@ -521,7 +522,7 @@ public class BlockDiskKeyStore<K>
*/
public final static String TAG = "orig-lru-count";
- public LRUMapCountLimited(int maxKeySize)
+ public LRUMapCountLimited(final int maxKeySize)
{
super(maxKeySize);
}
@@ -536,7 +537,7 @@ public class BlockDiskKeyStore<K>
* @param value
*/
@Override
- protected void processRemovedLRU(K key, int[] value)
+ protected void processRemovedLRU(final K key, final int[] value)
{
blockDiskCache.freeBlocks(value);
if (log.isDebugEnabled())
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java
index 47df0fd..38b50d2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDisk.java
@@ -54,7 +54,7 @@ public class IndexedDisk implements AutoCloseable
* @param elementSerializer
* @throws IOException
*/
- public IndexedDisk(File file, IElementSerializer elementSerializer)
+ public IndexedDisk(final File file, final IElementSerializer elementSerializer)
throws IOException
{
this.filepath = file.getAbsolutePath();
@@ -76,12 +76,12 @@ public class IndexedDisk implements AutoCloseable
* @throws IOException
* @throws ClassNotFoundException
*/
- protected <T> T readObject(IndexedDiskElementDescriptor ded)
+ protected <T> T readObject(final IndexedDiskElementDescriptor ded)
throws IOException, ClassNotFoundException
{
String message = null;
boolean corrupted = false;
- long fileLength = fc.size();
+ final long fileLength = fc.size();
if (ded.pos > fileLength)
{
corrupted = true;
@@ -89,10 +89,10 @@ public class IndexedDisk implements AutoCloseable
}
else
{
- ByteBuffer datalength = ByteBuffer.allocate(HEADER_SIZE_BYTES);
+ final ByteBuffer datalength = ByteBuffer.allocate(HEADER_SIZE_BYTES);
fc.read(datalength, ded.pos);
datalength.flip();
- int datalen = datalength.getInt();
+ final int datalen = datalength.getInt();
if (ded.len != datalen)
{
corrupted = true;
@@ -111,7 +111,7 @@ public class IndexedDisk implements AutoCloseable
throw new IOException("The File Is Corrupt, need to reset");
}
- ByteBuffer data = ByteBuffer.allocate(ded.len);
+ final ByteBuffer data = ByteBuffer.allocate(ded.len);
fc.read(data, ded.pos + HEADER_SIZE_BYTES);
data.flip();
@@ -128,10 +128,10 @@ public class IndexedDisk implements AutoCloseable
protected void move(final IndexedDiskElementDescriptor ded, final long newPosition)
throws IOException
{
- ByteBuffer datalength = ByteBuffer.allocate(HEADER_SIZE_BYTES);
+ final ByteBuffer datalength = ByteBuffer.allocate(HEADER_SIZE_BYTES);
fc.read(datalength, ded.pos);
datalength.flip();
- int length = datalength.getInt();
+ final int length = datalength.getInt();
if (length != ded.len)
{
@@ -145,12 +145,12 @@ public class IndexedDisk implements AutoCloseable
// header len + data len
int remaining = HEADER_SIZE_BYTES + length;
- ByteBuffer buffer = ByteBuffer.allocate(16384);
+ final ByteBuffer buffer = ByteBuffer.allocate(16384);
while (remaining > 0)
{
// chunk it
- int chunkSize = Math.min(remaining, buffer.capacity());
+ final int chunkSize = Math.min(remaining, buffer.capacity());
buffer.limit(chunkSize);
fc.read(buffer, readPos);
buffer.flip();
@@ -173,10 +173,10 @@ public class IndexedDisk implements AutoCloseable
* @return true if we wrote successfully
* @throws IOException
*/
- protected boolean write(IndexedDiskElementDescriptor ded, byte[] data)
+ protected boolean write(final IndexedDiskElementDescriptor ded, final byte[] data)
throws IOException
{
- long pos = ded.pos;
+ final long pos = ded.pos;
if (log.isTraceEnabled())
{
log.trace("write> pos={0}", pos);
@@ -188,7 +188,7 @@ public class IndexedDisk implements AutoCloseable
throw new IOException("Mismatched descriptor and data lengths");
}
- ByteBuffer headerBuffer = ByteBuffer.allocate(HEADER_SIZE_BYTES);
+ final ByteBuffer headerBuffer = ByteBuffer.allocate(HEADER_SIZE_BYTES);
headerBuffer.putInt(data.length);
// write the header
headerBuffer.flip();
@@ -196,7 +196,7 @@ public class IndexedDisk implements AutoCloseable
assert written == HEADER_SIZE_BYTES;
//write the data
- ByteBuffer dataBuffer = ByteBuffer.wrap(data);
+ final ByteBuffer dataBuffer = ByteBuffer.wrap(data);
written = fc.write(dataBuffer, pos + HEADER_SIZE_BYTES);
return written == data.length;
@@ -210,10 +210,10 @@ public class IndexedDisk implements AutoCloseable
* @param pos
* @throws IOException
*/
- protected <T> void writeObject(T obj, long pos)
+ protected <T> void writeObject(final T obj, final long pos)
throws IOException
{
- byte[] data = elementSerializer.serialize(obj);
+ final byte[] data = elementSerializer.serialize(obj);
write(new IndexedDiskElementDescriptor(pos, data.length), data);
}
@@ -260,7 +260,7 @@ public class IndexedDisk implements AutoCloseable
* @param length the new length of the file
* @throws IOException
*/
- protected void truncate(long length)
+ protected void truncate(final long length)
throws IOException
{
log.info("Truncating file [{0}] to {1}", filepath, length);
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
index f588ec5..1d185b6 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCache.java
@@ -146,7 +146,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
*
* @param cacheAttributes
*/
- public IndexedDiskCache(IndexedDiskCacheAttributes cacheAttributes)
+ public IndexedDiskCache(final IndexedDiskCacheAttributes cacheAttributes)
{
this(cacheAttributes, null);
}
@@ -159,7 +159,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param elementSerializer
* used if supplied, the super's super will not set a null
*/
- public IndexedDiskCache(IndexedDiskCacheAttributes cattr, IElementSerializer elementSerializer)
+ public IndexedDiskCache(final IndexedDiskCacheAttributes cattr, final IElementSerializer elementSerializer)
{
super(cattr);
@@ -193,7 +193,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
doOptimizeRealTime();
}
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: Failure initializing for fileName: {1} and directory: {2}",
logCacheName, fileName, this.rafDir.getAbsolutePath(), e);
@@ -206,7 +206,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
*
* @param cattr
*/
- private void initializeFileSystem(IndexedDiskCacheAttributes cattr)
+ private void initializeFileSystem(final IndexedDiskCacheAttributes cattr)
{
this.rafDir = cattr.getDiskPath();
log.info("{0}: Cache file root directory: {1}", logCacheName, rafDir);
@@ -221,7 +221,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param cattr
* @throws IOException
*/
- private void initializeKeysAndData(IndexedDiskCacheAttributes cattr) throws IOException
+ private void initializeKeysAndData(final IndexedDiskCacheAttributes cattr) throws IOException
{
this.dataFile = new IndexedDisk(new File(rafDir, fileName + ".data"), getElementSerializer());
this.keyFile = new IndexedDisk(new File(rafDir, fileName + ".key"), getElementSerializer());
@@ -279,7 +279,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
}
else
{
- boolean isOk = checkKeyDataConsistency(false);
+ final boolean isOk = checkKeyDataConsistency(false);
if (!isOk)
{
keyHash.clear();
@@ -312,7 +312,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
// clear a key map to use.
keyHash.clear();
- HashMap<K, IndexedDiskElementDescriptor> keys = keyFile.readObject(
+ final HashMap<K, IndexedDiskElementDescriptor> keys = keyFile.readObject(
new IndexedDiskElementDescriptor(0, (int) keyFile.length() - IndexedDisk.HEADER_SIZE_BYTES));
if (keys != null)
@@ -330,7 +330,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
dump(false);
}
}
- catch (Exception e)
+ catch (final Exception e)
{
log.error("{0}: Problem loading keys for file {1}", logCacheName, fileName, e);
}
@@ -351,9 +351,9 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* data overlap
* @return <code>true</code> if the test passes
*/
- private boolean checkKeyDataConsistency(boolean checkForDedOverlaps)
+ private boolean checkKeyDataConsistency(final boolean checkForDedOverlaps)
{
- ElapsedTimer timer = new ElapsedTimer();
+ final ElapsedTimer timer = new ElapsedTimer();
log.debug("{0}: Performing inital consistency check", logCacheName);
boolean isOk = true;
@@ -362,9 +362,9 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
{
fileLength = dataFile.length();
- for (Map.Entry<K, IndexedDiskElementDescriptor> e : keyHash.entrySet())
+ for (final Map.Entry<K, IndexedDiskElementDescriptor> e : keyHash.entrySet())
{
- IndexedDiskElementDescriptor ded = e.getValue();
+ final IndexedDiskElementDescriptor ded = e.getValue();
isOk = ded.pos + IndexedDisk.HEADER_SIZE_BYTES + ded.len <= fileLength;
@@ -381,7 +381,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
isOk = checkForDedOverlaps(createPositionSortedDescriptorList());
}
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error(e);
isOk = false;
@@ -402,14 +402,14 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param sortedDescriptors
* @return false if there are overlaps.
*/
- protected boolean checkForDedOverlaps(IndexedDiskElementDescriptor[] sortedDescriptors)
+ protected boolean checkForDedOverlaps(final IndexedDiskElementDescriptor[] sortedDescriptors)
{
- ElapsedTimer timer = new ElapsedTimer();
+ final ElapsedTimer timer = new ElapsedTimer();
boolean isOk = true;
long expectedNextPos = 0;
for (int i = 0; i < sortedDescriptors.length; i++)
{
- IndexedDiskElementDescriptor ded = sortedDescriptors[i];
+ final IndexedDiskElementDescriptor ded = sortedDescriptors[i];
if (expectedNextPos > ded.pos)
{
log.error("{0}: Corrupt file: overlapping deds {1}", logCacheName, ded);
@@ -439,7 +439,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
keyFile.reset();
- HashMap<K, IndexedDiskElementDescriptor> keys = new HashMap<>(keyHash);
+ final HashMap<K, IndexedDiskElementDescriptor> keys = new HashMap<>(keyHash);
if (keys.size() > 0)
{
keyFile.writeObject(keys, 0);
@@ -447,7 +447,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
log.info("{0}: Finished saving keys.", logCacheName);
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: Problem storing keys.", logCacheName, e);
}
@@ -462,7 +462,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* The ICacheElement<K, V> to put to disk.
*/
@Override
- protected void processUpdate(ICacheElement<K, V> ce)
+ protected void processUpdate(final ICacheElement<K, V> ce)
{
if (!isAlive())
{
@@ -481,7 +481,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
try
{
- byte[] data = getElementSerializer().serialize(ce);
+ final byte[] data = getElementSerializer().serialize(ce);
// make sure this only locks for one particular cache region
storageLock.writeLock().lock();
@@ -505,7 +505,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
if (doRecycle)
{
- IndexedDiskElementDescriptor rep = recycle.ceiling(ded);
+ final IndexedDiskElementDescriptor rep = recycle.ceiling(ded);
if (rep != null)
{
// remove element from recycle bin
@@ -546,7 +546,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
log.debug("{0}: Put to file: {1}, key: {2}, position: {3}, size: {4}",
logCacheName, fileName, ce.getKey(), ded.pos, ded.len);
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: Failure updating element, key: {1} old: {2}",
logCacheName, ce.getKey(), old, e);
@@ -562,7 +562,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @see AbstractDiskCache#doGet
*/
@Override
- protected ICacheElement<K, V> processGet(K key)
+ protected ICacheElement<K, V> processGet(final K key)
{
if (!isAlive())
{
@@ -591,7 +591,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
hitCount.incrementAndGet();
}
}
- catch (IOException ioe)
+ catch (final IOException ioe)
{
log.error("{0}: Failure getting from disk, key = {1}", logCacheName, key, ioe);
reset();
@@ -608,9 +608,9 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* data in cache matching keys
*/
@Override
- public Map<K, ICacheElement<K, V>> processGetMatching(String pattern)
+ public Map<K, ICacheElement<K, V>> processGetMatching(final String pattern)
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<>();
+ final Map<K, ICacheElement<K, V>> elements = new HashMap<>();
Set<K> keyArray = null;
storageLock.readLock().lock();
try
@@ -622,11 +622,11 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
storageLock.readLock().unlock();
}
- Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray(pattern, keyArray);
+ final Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray(pattern, keyArray);
- for (K key : matchingKeys)
+ for (final K key : matchingKeys)
{
- ICacheElement<K, V> element = processGet(key);
+ final ICacheElement<K, V> element = processGet(key);
if (element != null)
{
elements.put(key, element);
@@ -643,11 +643,11 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @return ICacheElement
* @throws IOException
*/
- private ICacheElement<K, V> readElement(K key) throws IOException
+ private ICacheElement<K, V> readElement(final K key) throws IOException
{
ICacheElement<K, V> object = null;
- IndexedDiskElementDescriptor ded = keyHash.get(key);
+ final IndexedDiskElementDescriptor ded = keyHash.get(key);
if (ded != null)
{
@@ -655,16 +655,16 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
try
{
- ICacheElement<K, V> readObject = dataFile.readObject(ded);
+ final ICacheElement<K, V> readObject = dataFile.readObject(ded);
object = readObject;
// TODO consider checking key equality and throwing if there is a failure
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: IO Exception, Problem reading object from file", logCacheName, e);
throw e;
}
- catch (Exception e)
+ catch (final Exception e)
{
log.error("{0}: Exception, Problem reading object from file", logCacheName, e);
throw new IOException(logCacheName + "Problem reading object from disk.", e);
@@ -683,7 +683,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
@Override
public Set<K> getKeySet() throws IOException
{
- HashSet<K> keys = new HashSet<>();
+ final HashSet<K> keys = new HashSet<>();
storageLock.readLock().lock();
@@ -708,7 +708,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param key
*/
@Override
- protected boolean processRemove(K key)
+ protected boolean processRemove(final K key)
{
if (!isAlive())
{
@@ -721,7 +721,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
return false;
}
- boolean reset = false;
+ final boolean reset = false;
boolean removed = false;
try
{
@@ -770,14 +770,14 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param key
* @return true if there was a match
*/
- private boolean performPartialKeyRemoval(String key)
+ private boolean performPartialKeyRemoval(final String key)
{
boolean removed = false;
// remove all keys of the same name hierarchy.
- List<K> itemsToRemove = new LinkedList<>();
+ final List<K> itemsToRemove = new LinkedList<>();
- for (K k : keyHash.keySet())
+ for (final K k : keyHash.keySet())
{
if (k instanceof String && k.toString().startsWith(key))
{
@@ -786,7 +786,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
}
// remove matches.
- for (K fullKey : itemsToRemove)
+ for (final K fullKey : itemsToRemove)
{
// Don't add to recycle bin here
// https://issues.apache.org/jira/browse/JCS-67
@@ -808,15 +808,15 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param key
* @return true if an element was removed
*/
- private boolean performGroupRemoval(GroupId key)
+ private boolean performGroupRemoval(final GroupId key)
{
boolean removed = false;
// remove all keys of the same name group.
- List<K> itemsToRemove = new LinkedList<>();
+ final List<K> itemsToRemove = new LinkedList<>();
// remove all keys of the same name hierarchy.
- for (K k : keyHash.keySet())
+ for (final K k : keyHash.keySet())
{
if (k instanceof GroupAttrName && ((GroupAttrName<?>) k).groupId.equals(key))
{
@@ -825,7 +825,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
}
// remove matches.
- for (K fullKey : itemsToRemove)
+ for (final K fullKey : itemsToRemove)
{
// Don't add to recycle bin here
// https://issues.apache.org/jira/browse/JCS-67
@@ -846,11 +846,11 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param key
* @return true if an item was removed.
*/
- private boolean performSingleKeyRemoval(K key)
+ private boolean performSingleKeyRemoval(final K key)
{
boolean removed;
// remove single item.
- IndexedDiskElementDescriptor ded = keyHash.remove(key);
+ final IndexedDiskElementDescriptor ded = keyHash.remove(key);
removed = ded != null;
addToRecycleBin(ded);
@@ -865,7 +865,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
@Override
public void processRemoveAll()
{
- ICacheEvent<String> cacheEvent =
+ final ICacheEvent<String> cacheEvent =
createICacheEvent(getCacheName(), "all", ICacheEventLogger.REMOVEALL_EVENT);
try
{
@@ -895,14 +895,14 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
dataFile.close();
}
- File dataFileTemp = new File(rafDir, fileName + ".data");
+ final File dataFileTemp = new File(rafDir, fileName + ".data");
Files.delete(dataFileTemp.toPath());
if (keyFile != null)
{
keyFile.close();
}
- File keyFileTemp = new File(rafDir, fileName + ".key");
+ final File keyFileTemp = new File(rafDir, fileName + ".key");
Files.delete(keyFileTemp.toPath());
dataFile = new IndexedDisk(dataFileTemp, getElementSerializer());
@@ -911,7 +911,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
this.recycle.clear();
this.keyHash.clear();
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: Failure resetting state", logCacheName, e);
}
@@ -962,17 +962,17 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
@Override
public void processDispose()
{
- ICacheEvent<String> cacheEvent = createICacheEvent(getCacheName(), "none", ICacheEventLogger.DISPOSE_EVENT);
+ final ICacheEvent<String> cacheEvent = createICacheEvent(getCacheName(), "none", ICacheEventLogger.DISPOSE_EVENT);
try
{
- Thread t = new Thread(this::disposeInternal, "IndexedDiskCache-DisposalThread");
+ final Thread t = new Thread(this::disposeInternal, "IndexedDiskCache-DisposalThread");
t.start();
// wait up to 60 seconds for dispose and then quit if not done.
try
{
t.join(60 * 1000);
}
- catch (InterruptedException ex)
+ catch (final InterruptedException ex)
{
log.error("{0}: Interrupted while waiting for disposal thread to finish.",
logCacheName, ex);
@@ -999,7 +999,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
// Prevents any interaction with the cache while we're shutting down.
setAlive(false);
- Thread optimizationThread = currentOptimizationThread;
+ final Thread optimizationThread = currentOptimizationThread;
if (isRealTimeOptimizationEnabled && optimizationThread != null)
{
// Join with the current optimization thread.
@@ -1010,7 +1010,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
{
optimizationThread.join();
}
- catch (InterruptedException e)
+ catch (final InterruptedException e)
{
log.error("{0}: Unable to join current optimization thread.",
logCacheName, e);
@@ -1032,7 +1032,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
keyFile.close();
keyFile = null;
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: Failure closing files in dispose, filename: {1}",
logCacheName, fileName, e);
@@ -1052,7 +1052,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
*
* @param ded
*/
- protected void addToRecycleBin(IndexedDiskElementDescriptor ded)
+ protected void addToRecycleBin(final IndexedDiskElementDescriptor ded)
{
// reuse the spot
if (ded != null)
@@ -1138,7 +1138,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
*/
protected void optimizeFile()
{
- ElapsedTimer timer = new ElapsedTimer();
+ final ElapsedTimer timer = new ElapsedTimer();
timesOptimized++;
log.info("{0}: Beginning Optimization #{1}", logCacheName, timesOptimized);
@@ -1180,7 +1180,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
// TRUNCATE THE FILE
dataFile.truncate(expectedNextPos);
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: Error optimizing queued puts.", logCacheName, e);
}
@@ -1216,9 +1216,9 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* the start position in the file
* @return this is the potential new file end
*/
- private long defragFile(IndexedDiskElementDescriptor[] defragList, long startingPos)
+ private long defragFile(final IndexedDiskElementDescriptor[] defragList, final long startingPos)
{
- ElapsedTimer timer = new ElapsedTimer();
+ final ElapsedTimer timer = new ElapsedTimer();
long preFileSize = 0;
long postFileSize = 0;
long expectedNextPos = 0;
@@ -1249,7 +1249,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
// this is the potential new file end
return expectedNextPos;
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("{0}: Error occurred during defragmentation.", logCacheName, e);
}
@@ -1271,7 +1271,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
*/
private IndexedDiskElementDescriptor[] createPositionSortedDescriptorList()
{
- List<IndexedDiskElementDescriptor> defragList = new ArrayList<>(keyHash.values());
+ final List<IndexedDiskElementDescriptor> defragList = new ArrayList<>(keyHash.values());
Collections.sort(defragList, new PositionComparator());
return defragList.toArray(new IndexedDiskElementDescriptor[0]);
@@ -1338,11 +1338,11 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param ded
* @param add
*/
- private void adjustBytesFree(IndexedDiskElementDescriptor ded, boolean add)
+ private void adjustBytesFree(final IndexedDiskElementDescriptor ded, final boolean add)
{
if (ded != null)
{
- int amount = ded.len + IndexedDisk.HEADER_SIZE_BYTES;
+ final int amount = ded.len + IndexedDisk.HEADER_SIZE_BYTES;
if (add)
{
@@ -1398,16 +1398,16 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param dumpValues
* A boolean indicating if values should be dumped.
*/
- public void dump(boolean dumpValues)
+ public void dump(final boolean dumpValues)
{
if (log.isTraceEnabled())
{
log.trace("{0}: [dump] Number of keys: {1}", logCacheName, keyHash.size());
- for (Map.Entry<K, IndexedDiskElementDescriptor> e : keyHash.entrySet())
+ for (final Map.Entry<K, IndexedDiskElementDescriptor> e : keyHash.entrySet())
{
- K key = e.getKey();
- IndexedDiskElementDescriptor ded = e.getValue();
+ final K key = e.getKey();
+ final IndexedDiskElementDescriptor ded = e.getValue();
log.trace("{0}: [dump] Disk element, key: {1}, pos: {2}, len: {3}" +
(dumpValues ? ", val: " + get(key) : ""),
@@ -1434,10 +1434,10 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
@Override
public synchronized IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName("Indexed Disk Cache");
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
elems.add(new StatElement<>("Is Alive", Boolean.valueOf(isAlive())));
elems.add(new StatElement<>("Key Map Size", Integer.valueOf(this.keyHash != null ? this.keyHash.size() : -1)));
@@ -1446,7 +1446,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
elems.add(
new StatElement<>("Data File Length", Long.valueOf(this.dataFile != null ? this.dataFile.length() : -1L)));
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error(e);
}
@@ -1460,7 +1460,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
elems.add(new StatElement<>("Startup Size", Integer.valueOf(this.startupSize)));
// get the stats from the super too
- IStats sStats = super.getStatistics();
+ final IStats sStats = super.getStatistics();
elems.addAll(sStats.getStatElements());
stats.setStatElements(elems);
@@ -1507,7 +1507,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
- public int compare(IndexedDiskElementDescriptor ded1, IndexedDiskElementDescriptor ded2)
+ public int compare(final IndexedDiskElementDescriptor ded1, final IndexedDiskElementDescriptor ded2)
{
if (ded1.pos < ded2.pos)
{
@@ -1550,26 +1550,26 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
/**
* @param maxKeySize
*/
- public LRUMapSizeLimited(int maxKeySize)
+ public LRUMapSizeLimited(final int maxKeySize)
{
this.maxSize = maxKeySize;
this.contentSize = new AtomicInteger(0);
}
// keep the content size in kB, so 2^31 kB is reasonable value
- private void subLengthFromCacheSize(IndexedDiskElementDescriptor value)
+ private void subLengthFromCacheSize(final IndexedDiskElementDescriptor value)
{
contentSize.addAndGet((value.len + IndexedDisk.HEADER_SIZE_BYTES) / -1024 - 1);
}
// keep the content size in kB, so 2^31 kB is reasonable value
- private void addLengthToCacheSize(IndexedDiskElementDescriptor value)
+ private void addLengthToCacheSize(final IndexedDiskElementDescriptor value)
{
contentSize.addAndGet((value.len + IndexedDisk.HEADER_SIZE_BYTES) / 1024 + 1);
}
@Override
- public IndexedDiskElementDescriptor put(K key, IndexedDiskElementDescriptor value)
+ public IndexedDiskElementDescriptor put(final K key, final IndexedDiskElementDescriptor value)
{
IndexedDiskElementDescriptor oldValue = null;
@@ -1594,7 +1594,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
}
@Override
- public IndexedDiskElementDescriptor remove(Object key)
+ public IndexedDiskElementDescriptor remove(final Object key)
{
IndexedDiskElementDescriptor value = null;
@@ -1621,7 +1621,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param value
*/
@Override
- protected void processRemovedLRU(K key, IndexedDiskElementDescriptor value)
+ protected void processRemovedLRU(final K key, final IndexedDiskElementDescriptor value)
{
if (value != null)
{
@@ -1651,7 +1651,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
public class LRUMapCountLimited extends LRUMap<K, IndexedDiskElementDescriptor>
// implements Serializable
{
- public LRUMapCountLimited(int maxKeySize)
+ public LRUMapCountLimited(final int maxKeySize)
{
super(maxKeySize);
}
@@ -1665,7 +1665,7 @@ public class IndexedDiskCache<K, V> extends AbstractDiskCache<K, V>
* @param value
*/
@Override
- protected void processRemovedLRU(K key, IndexedDiskElementDescriptor value)
+ protected void processRemovedLRU(final K key, final IndexedDiskElementDescriptor value)
{
addToRecycleBin(value);
log.debug("{0}: Removing key: [{1}] from key store.", logCacheName, key);
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java
index 4589fea..a60f0d5 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCacheAttributes.java
@@ -73,7 +73,7 @@ public class IndexedDiskCacheAttributes
* <p>
* @param maxKeySize The new maxKeySize value
*/
- public void setMaxKeySize( int maxKeySize )
+ public void setMaxKeySize( final int maxKeySize )
{
this.maxKeySize = maxKeySize;
}
@@ -94,7 +94,7 @@ public class IndexedDiskCacheAttributes
* <p>
* @param cnt The new optimizeAtRemoveCount value
*/
- public void setOptimizeAtRemoveCount( int cnt )
+ public void setOptimizeAtRemoveCount( final int cnt )
{
this.optimizeAtRemoveCount = cnt;
}
@@ -102,7 +102,7 @@ public class IndexedDiskCacheAttributes
/**
* @param optimizeOnShutdown The optimizeOnShutdown to set.
*/
- public void setOptimizeOnShutdown( boolean optimizeOnShutdown )
+ public void setOptimizeOnShutdown( final boolean optimizeOnShutdown )
{
this.optimizeOnShutdown = optimizeOnShutdown;
}
@@ -118,7 +118,7 @@ public class IndexedDiskCacheAttributes
/**
* @param clearDiskOnStartup the clearDiskOnStartup to set
*/
- public void setClearDiskOnStartup( boolean clearDiskOnStartup )
+ public void setClearDiskOnStartup( final boolean clearDiskOnStartup )
{
this.clearDiskOnStartup = clearDiskOnStartup;
}
@@ -139,7 +139,7 @@ public class IndexedDiskCacheAttributes
@Override
public String toString()
{
- StringBuilder str = new StringBuilder();
+ final StringBuilder str = new StringBuilder();
str.append( "IndexedDiskCacheAttributes " );
str.append( "\n diskPath = " + super.getDiskPath() );
str.append( "\n maxPurgatorySize = " + super.getMaxPurgatorySize() );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
index cd5c660..5079d83 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
@@ -48,13 +48,13 @@ public class IndexedDiskCacheFactory
* @return IndexedDiskCache
*/
@Override
- public <K, V> IndexedDiskCache<K, V> createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ public <K, V> IndexedDiskCache<K, V> createCache( final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
{
- IndexedDiskCacheAttributes idca = (IndexedDiskCacheAttributes) iaca;
+ final IndexedDiskCacheAttributes idca = (IndexedDiskCacheAttributes) iaca;
log.debug( "Creating DiskCache for attributes = {0}", idca );
- IndexedDiskCache<K, V> cache = new IndexedDiskCache<>( idca, elementSerializer );
+ final IndexedDiskCache<K, V> cache = new IndexedDiskCache<>( idca, elementSerializer );
cache.setCacheEventLogger( cacheEventLogger );
return cache;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskDumper.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskDumper.java
index ffb25d9..4a2a436 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskDumper.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskDumper.java
@@ -37,7 +37,7 @@ public class IndexedDiskDumper
* @param args
* The command line arguments
*/
- public static void main( String[] args )
+ public static void main( final String[] args )
{
if ( args.length != 1 )
{
@@ -45,12 +45,12 @@ public class IndexedDiskDumper
System.exit( 0 );
}
- IndexedDiskCacheAttributes attr = new IndexedDiskCacheAttributes();
+ final IndexedDiskCacheAttributes attr = new IndexedDiskCacheAttributes();
attr.setCacheName( args[0] );
attr.setDiskPath( args[0] );
- IndexedDiskCache<Serializable, Serializable> dc = new IndexedDiskCache<>( attr );
+ final IndexedDiskCache<Serializable, Serializable> dc = new IndexedDiskCache<>( attr );
dc.dump( true );
System.exit( 0 );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskElementDescriptor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskElementDescriptor.java
index 2158c46..4ab8691 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskElementDescriptor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/indexed/IndexedDiskElementDescriptor.java
@@ -43,7 +43,7 @@ public class IndexedDiskElementDescriptor
* @param pos
* @param len
*/
- public IndexedDiskElementDescriptor( long pos, int len )
+ public IndexedDiskElementDescriptor( final long pos, final int len )
{
this.pos = pos;
this.len = len;
@@ -55,7 +55,7 @@ public class IndexedDiskElementDescriptor
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "[DED: " );
buf.append( " pos = " + pos );
buf.append( " len = " + len );
@@ -76,7 +76,7 @@ public class IndexedDiskElementDescriptor
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
- public boolean equals(Object o)
+ public boolean equals(final Object o)
{
if (o == null)
{
@@ -84,7 +84,7 @@ public class IndexedDiskElementDescriptor
}
else if (o instanceof IndexedDiskElementDescriptor)
{
- IndexedDiskElementDescriptor ided = (IndexedDiskElementDescriptor)o;
+ final IndexedDiskElementDescriptor ided = (IndexedDiskElementDescriptor)o;
return pos == ided.pos && len == ided.len;
}
@@ -98,7 +98,7 @@ public class IndexedDiskElementDescriptor
* @return int
*/
@Override
- public int compareTo( IndexedDiskElementDescriptor o )
+ public int compareTo( final IndexedDiskElementDescriptor o )
{
if ( o == null )
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java
index 8fbb830..59b38c2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCache.java
@@ -116,7 +116,7 @@ public class JDBCDiskCache<K, V>
* @param dsFactory the DataSourceFactory for this cache
* @param tableState an object to track table operations
*/
- public JDBCDiskCache(JDBCDiskCacheAttributes cattr, DataSourceFactory dsFactory, TableState tableState)
+ public JDBCDiskCache(final JDBCDiskCacheAttributes cattr, final DataSourceFactory dsFactory, final TableState tableState)
{
super( cattr );
@@ -140,7 +140,7 @@ public class JDBCDiskCache<K, V>
* @param ce
*/
@Override
- protected void processUpdate( ICacheElement<K, V> ce )
+ protected void processUpdate( final ICacheElement<K, V> ce )
{
updateCount.incrementAndGet();
@@ -156,7 +156,7 @@ public class JDBCDiskCache<K, V>
{
element = getElementSerializer().serialize( ce );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( "Could not serialize element", e );
return;
@@ -164,7 +164,7 @@ public class JDBCDiskCache<K, V>
insertOrUpdate( ce, con, element );
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem getting connection.", e );
}
@@ -188,7 +188,7 @@ public class JDBCDiskCache<K, V>
* @param con
* @param element
*/
- private void insertOrUpdate( ICacheElement<K, V> ce, Connection con, byte[] element )
+ private void insertOrUpdate( final ICacheElement<K, V> ce, final Connection con, final byte[] element )
{
boolean exists = false;
@@ -219,10 +219,10 @@ public class JDBCDiskCache<K, V>
* @param element
* @return true if the insertion fails because the record exists.
*/
- private boolean insertRow( ICacheElement<K, V> ce, Connection con, byte[] element )
+ private boolean insertRow( final ICacheElement<K, V> ce, final Connection con, final byte[] element )
{
boolean exists = false;
- String sqlI = "insert into "
+ final String sqlI = "insert into "
+ getJdbcDiskCacheAttributes().getTableName()
+ " (CACHE_KEY, REGION, ELEMENT, MAX_LIFE_SECONDS, IS_ETERNAL, CREATE_TIME, UPDATE_TIME_SECONDS, SYSTEM_EXPIRE_TIME_SECONDS) "
+ " values (?, ?, ?, ?, ?, ?, ?, ?)";
@@ -241,18 +241,18 @@ public class JDBCDiskCache<K, V>
{
psInsert.setString( 5, "F" );
}
- Timestamp createTime = new Timestamp( ce.getElementAttributes().getCreateTime() );
+ final Timestamp createTime = new Timestamp( ce.getElementAttributes().getCreateTime() );
psInsert.setTimestamp( 6, createTime );
- long now = System.currentTimeMillis() / 1000;
+ final long now = System.currentTimeMillis() / 1000;
psInsert.setLong( 7, now );
- long expireTime = now + ce.getElementAttributes().getMaxLife();
+ final long expireTime = now + ce.getElementAttributes().getMaxLife();
psInsert.setLong( 8, expireTime );
psInsert.execute();
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
if ("23000".equals(e.getSQLState()))
{
@@ -280,9 +280,9 @@ public class JDBCDiskCache<K, V>
* @param con
* @param element
*/
- private void updateRow( ICacheElement<K, V> ce, Connection con, byte[] element )
+ private void updateRow( final ICacheElement<K, V> ce, final Connection con, final byte[] element )
{
- String sqlU = "update " + getJdbcDiskCacheAttributes().getTableName()
+ final String sqlU = "update " + getJdbcDiskCacheAttributes().getTableName()
+ " set ELEMENT = ?, CREATE_TIME = ?, UPDATE_TIME_SECONDS = ?, " + " SYSTEM_EXPIRE_TIME_SECONDS = ? "
+ " where CACHE_KEY = ? and REGION = ?";
@@ -290,13 +290,13 @@ public class JDBCDiskCache<K, V>
{
psUpdate.setBytes( 1, element );
- Timestamp createTime = new Timestamp( ce.getElementAttributes().getCreateTime() );
+ final Timestamp createTime = new Timestamp( ce.getElementAttributes().getCreateTime() );
psUpdate.setTimestamp( 2, createTime );
- long now = System.currentTimeMillis() / 1000;
+ final long now = System.currentTimeMillis() / 1000;
psUpdate.setLong( 3, now );
- long expireTime = now + ce.getElementAttributes().getMaxLife();
+ final long expireTime = now + ce.getElementAttributes().getMaxLife();
psUpdate.setLong( 4, expireTime );
psUpdate.setString( 5, (String) ce.getKey() );
@@ -305,7 +305,7 @@ public class JDBCDiskCache<K, V>
log.debug( "ran update {0}", sqlU );
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Error executing update sql [{0}]", sqlU, e );
}
@@ -318,11 +318,11 @@ public class JDBCDiskCache<K, V>
* @param con a database connection
* @return boolean
*/
- protected boolean doesElementExist( ICacheElement<K, V> ce, Connection con )
+ protected boolean doesElementExist( final ICacheElement<K, V> ce, final Connection con )
{
boolean exists = false;
// don't select the element, since we want this to be fast.
- String sqlS = "select CACHE_KEY from " + getJdbcDiskCacheAttributes().getTableName()
+ final String sqlS = "select CACHE_KEY from " + getJdbcDiskCacheAttributes().getTableName()
+ " where REGION = ? and CACHE_KEY = ?";
try (PreparedStatement psSelect = con.prepareStatement( sqlS ))
@@ -337,7 +337,7 @@ public class JDBCDiskCache<K, V>
log.debug( "[{0}] existing status is {1}", ce.getKey(), exists );
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem looking for item before insert.", e );
}
@@ -353,7 +353,7 @@ public class JDBCDiskCache<K, V>
* @see org.apache.commons.jcs3.auxiliary.disk.AbstractDiskCache#get(Object)
*/
@Override
- protected ICacheElement<K, V> processGet( K key )
+ protected ICacheElement<K, V> processGet( final K key )
{
getCount.incrementAndGet();
@@ -370,7 +370,7 @@ public class JDBCDiskCache<K, V>
try
{
// region, key
- String selectString = "select ELEMENT from " + getJdbcDiskCacheAttributes().getTableName()
+ final String selectString = "select ELEMENT from " + getJdbcDiskCacheAttributes().getTableName()
+ " where REGION = ? and CACHE_KEY = ?";
try (Connection con = getDataSource().getConnection())
@@ -393,7 +393,7 @@ public class JDBCDiskCache<K, V>
// USE THE SERIALIZER
obj = getElementSerializer().deSerialize( data, null );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( "Problem getting item for key [{0}]", key, e );
}
@@ -402,7 +402,7 @@ public class JDBCDiskCache<K, V>
}
}
}
- catch ( SQLException sqle )
+ catch ( final SQLException sqle )
{
log.error( "Caught a SQL exception trying to get the item for key [{0}]",
key, sqle );
@@ -427,7 +427,7 @@ public class JDBCDiskCache<K, V>
* @return key,value map
*/
@Override
- protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
+ protected Map<K, ICacheElement<K, V>> processGetMatching( final String pattern )
{
getMatchingCount.incrementAndGet();
@@ -438,12 +438,12 @@ public class JDBCDiskCache<K, V>
return null;
}
- Map<K, ICacheElement<K, V>> results = new HashMap<>();
+ final Map<K, ICacheElement<K, V>> results = new HashMap<>();
try
{
// region, key
- String selectString = "select CACHE_KEY, ELEMENT from " + getJdbcDiskCacheAttributes().getTableName()
+ final String selectString = "select CACHE_KEY, ELEMENT from " + getJdbcDiskCacheAttributes().getTableName()
+ " where REGION = ? and CACHE_KEY like ?";
try (Connection con = getDataSource().getConnection())
@@ -457,17 +457,17 @@ public class JDBCDiskCache<K, V>
{
while ( rs.next() )
{
- String key = rs.getString( 1 );
- byte[] data = rs.getBytes( 2 );
+ final String key = rs.getString( 1 );
+ final byte[] data = rs.getBytes( 2 );
if ( data != null )
{
try
{
// USE THE SERIALIZER
- ICacheElement<K, V> value = getElementSerializer().deSerialize( data, null );
+ final ICacheElement<K, V> value = getElementSerializer().deSerialize( data, null );
results.put( (K) key, value );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( "Problem getting items for pattern [{0}]", pattern, e );
}
@@ -477,7 +477,7 @@ public class JDBCDiskCache<K, V>
}
}
}
- catch ( SQLException sqle )
+ catch ( final SQLException sqle )
{
log.error( "Caught a SQL exception trying to get items for pattern [{0}]",
pattern, sqle );
@@ -498,7 +498,7 @@ public class JDBCDiskCache<K, V>
* @param pattern
* @return String to use in the like query.
*/
- public String constructLikeParameterFromPattern( String pattern )
+ public String constructLikeParameterFromPattern( final String pattern )
{
String likePattern = pattern.replaceAll( "\\.\\+", "%" );
likePattern = likePattern.replaceAll( "\\.", "_" );
@@ -516,7 +516,7 @@ public class JDBCDiskCache<K, V>
* @return boolean
*/
@Override
- protected boolean processRemove( K key )
+ protected boolean processRemove( final K key )
{
// remove single item.
String sql = "delete from " + getJdbcDiskCacheAttributes().getTableName()
@@ -549,13 +549,13 @@ public class JDBCDiskCache<K, V>
setAlive(true);
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem creating statement. sql [{0}]", sql, e );
setAlive(false);
}
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem updating cache.", e );
reset();
@@ -575,7 +575,7 @@ public class JDBCDiskCache<K, V>
{
try (Connection con = getDataSource().getConnection())
{
- String sql = "delete from " + getJdbcDiskCacheAttributes().getTableName() + " where REGION = ?";
+ final String sql = "delete from " + getJdbcDiskCacheAttributes().getTableName() + " where REGION = ?";
try (PreparedStatement psDelete = con.prepareStatement( sql ))
{
@@ -583,13 +583,13 @@ public class JDBCDiskCache<K, V>
setAlive(true);
psDelete.executeUpdate();
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem creating statement.", e );
setAlive(false);
}
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem removing all.", e );
reset();
@@ -615,16 +615,16 @@ public class JDBCDiskCache<K, V>
{
// The shrinker thread might kick in before the table is created
// So check if the table exists first
- DatabaseMetaData dmd = con.getMetaData();
- ResultSet result = dmd.getTables(null, null,
+ final DatabaseMetaData dmd = con.getMetaData();
+ final ResultSet result = dmd.getTables(null, null,
getJdbcDiskCacheAttributes().getTableName(), null);
if (result.next())
{
getTableState().setState( TableState.DELETE_RUNNING );
- long now = System.currentTimeMillis() / 1000;
+ final long now = System.currentTimeMillis() / 1000;
- String sql = "delete from " + getJdbcDiskCacheAttributes().getTableName()
+ final String sql = "delete from " + getJdbcDiskCacheAttributes().getTableName()
+ " where IS_ETERNAL = ? and REGION = ? and ? > SYSTEM_EXPIRE_TIME_SECONDS";
try (PreparedStatement psDelete = con.prepareStatement( sql ))
@@ -637,7 +637,7 @@ public class JDBCDiskCache<K, V>
deleted = psDelete.executeUpdate();
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem creating statement.", e );
setAlive(false);
@@ -652,7 +652,7 @@ public class JDBCDiskCache<K, V>
getJdbcDiskCacheAttributes().getTableName() );
}
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
logError( getAuxiliaryCacheAttributes().getName(), "deleteExpired",
e.getMessage() + " URL: " + getDiskLocation() );
@@ -679,13 +679,13 @@ public class JDBCDiskCache<K, V>
@Override
public void processDispose()
{
- ICacheEvent<K> cacheEvent = createICacheEvent( getCacheName(), (K)"none", ICacheEventLogger.DISPOSE_EVENT );
+ final ICacheEvent<K> cacheEvent = createICacheEvent( getCacheName(), (K)"none", ICacheEventLogger.DISPOSE_EVENT );
try
{
dsFactory.close();
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem shutting down.", e );
}
@@ -706,7 +706,7 @@ public class JDBCDiskCache<K, V>
int size = 0;
// region, key
- String selectString = "select count(*) from " + getJdbcDiskCacheAttributes().getTableName()
+ final String selectString = "select count(*) from " + getJdbcDiskCacheAttributes().getTableName()
+ " where REGION = ?";
try (Connection con = getDataSource().getConnection())
@@ -724,7 +724,7 @@ public class JDBCDiskCache<K, V>
}
}
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem getting size.", e );
}
@@ -748,7 +748,7 @@ public class JDBCDiskCache<K, V>
* @param elementSerializer The elementSerializer to set.
*/
@Override
- public void setElementSerializer( IElementSerializer elementSerializer )
+ public void setElementSerializer( final IElementSerializer elementSerializer )
{
this.elementSerializer = elementSerializer;
}
@@ -765,7 +765,7 @@ public class JDBCDiskCache<K, V>
/**
* @param jdbcDiskCacheAttributes The jdbcDiskCacheAttributes to set.
*/
- protected void setJdbcDiskCacheAttributes( JDBCDiskCacheAttributes jdbcDiskCacheAttributes )
+ protected void setJdbcDiskCacheAttributes( final JDBCDiskCacheAttributes jdbcDiskCacheAttributes )
{
this.jdbcDiskCacheAttributes = jdbcDiskCacheAttributes;
}
@@ -795,10 +795,10 @@ public class JDBCDiskCache<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = super.getStatistics();
+ final IStats stats = super.getStatistics();
stats.setTypeName( "JDBC/Abstract Disk Cache" );
- List<IStatElement<?>> elems = stats.getStatElements();
+ final List<IStatElement<?>> elems = stats.getStatElements();
elems.add(new StatElement<>( "Update Count", updateCount ) );
elems.add(new StatElement<>( "Get Count", getCount ) );
@@ -828,7 +828,7 @@ public class JDBCDiskCache<K, V>
/**
* @param tableState The tableState to set.
*/
- public void setTableState( TableState tableState )
+ public void setTableState( final TableState tableState )
{
this.tableState = tableState;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java
index ffd50d6..398fcb8 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheAttributes.java
@@ -97,7 +97,7 @@ public class JDBCDiskCacheAttributes
/**
* @param userName The userName to set.
*/
- public void setUserName( String userName )
+ public void setUserName( final String userName )
{
this.userName = userName;
}
@@ -113,7 +113,7 @@ public class JDBCDiskCacheAttributes
/**
* @param password The password to set.
*/
- public void setPassword( String password )
+ public void setPassword( final String password )
{
this.password = password;
}
@@ -129,7 +129,7 @@ public class JDBCDiskCacheAttributes
/**
* @param url The url to set.
*/
- public void setUrl( String url )
+ public void setUrl( final String url )
{
this.url = url;
}
@@ -146,7 +146,7 @@ public class JDBCDiskCacheAttributes
* This is appended to the url.
* @param database The database to set.
*/
- public void setDatabase( String database )
+ public void setDatabase( final String database )
{
this.database = database;
}
@@ -162,7 +162,7 @@ public class JDBCDiskCacheAttributes
/**
* @param driverClassName The driverClassName to set.
*/
- public void setDriverClassName( String driverClassName )
+ public void setDriverClassName( final String driverClassName )
{
this.driverClassName = driverClassName;
}
@@ -186,7 +186,7 @@ public class JDBCDiskCacheAttributes
/**
* @param jndiPath the jndiPath to set
*/
- public void setJndiPath(String jndiPath)
+ public void setJndiPath(final String jndiPath)
{
this.jndiPath = jndiPath;
}
@@ -202,7 +202,7 @@ public class JDBCDiskCacheAttributes
/**
* @param jndiTTL the jndiTTL to set
*/
- public void setJndiTTL(long jndiTTL)
+ public void setJndiTTL(final long jndiTTL)
{
this.jndiTTL = jndiTTL;
}
@@ -210,7 +210,7 @@ public class JDBCDiskCacheAttributes
/**
* @param tableName The tableName to set.
*/
- public void setTableName( String tableName )
+ public void setTableName( final String tableName )
{
this.tableName = tableName;
}
@@ -229,7 +229,7 @@ public class JDBCDiskCacheAttributes
* <p>
* @param testBeforeInsert The testBeforeInsert to set.
*/
- public void setTestBeforeInsert( boolean testBeforeInsert )
+ public void setTestBeforeInsert( final boolean testBeforeInsert )
{
this.testBeforeInsert = testBeforeInsert;
}
@@ -245,7 +245,7 @@ public class JDBCDiskCacheAttributes
/**
* @param maxTotal The maxTotal to set.
*/
- public void setMaxTotal( int maxActive )
+ public void setMaxTotal( final int maxActive )
{
this.maxTotal = maxActive;
}
@@ -261,7 +261,7 @@ public class JDBCDiskCacheAttributes
/**
* @param shrinkerIntervalSecondsArg The shrinkerIntervalSeconds to set.
*/
- public void setShrinkerIntervalSeconds( int shrinkerIntervalSecondsArg )
+ public void setShrinkerIntervalSeconds( final int shrinkerIntervalSecondsArg )
{
this.shrinkerIntervalSeconds = shrinkerIntervalSecondsArg;
}
@@ -277,7 +277,7 @@ public class JDBCDiskCacheAttributes
/**
* @param useDiskShrinker The useDiskShrinker to set.
*/
- public void setUseDiskShrinker( boolean useDiskShrinker )
+ public void setUseDiskShrinker( final boolean useDiskShrinker )
{
this.useDiskShrinker = useDiskShrinker;
}
@@ -293,7 +293,7 @@ public class JDBCDiskCacheAttributes
/**
* @param connectionPoolName the connectionPoolName to set
*/
- public void setConnectionPoolName( String connectionPoolName )
+ public void setConnectionPoolName( final String connectionPoolName )
{
this.connectionPoolName = connectionPoolName;
}
@@ -314,7 +314,7 @@ public class JDBCDiskCacheAttributes
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\nJDBCCacheAttributes" );
buf.append( "\n UserName [" + getUserName() + "]" );
buf.append( "\n Url [" + getUrl() + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
index 1a70699..b3d907f 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
@@ -86,16 +86,16 @@ public class JDBCDiskCacheFactory
* @throws SQLException if the cache instance could not be created
*/
@Override
- public <K, V> JDBCDiskCache<K, V> createCache( AuxiliaryCacheAttributes rawAttr,
- ICompositeCacheManager compositeCacheManager,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ public <K, V> JDBCDiskCache<K, V> createCache( final AuxiliaryCacheAttributes rawAttr,
+ final ICompositeCacheManager compositeCacheManager,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
throws SQLException
{
- JDBCDiskCacheAttributes cattr = (JDBCDiskCacheAttributes) rawAttr;
- TableState tableState = getTableState( cattr.getTableName() );
- DataSourceFactory dsFactory = getDataSourceFactory(cattr, compositeCacheManager.getConfigurationProperties());
+ final JDBCDiskCacheAttributes cattr = (JDBCDiskCacheAttributes) rawAttr;
+ final TableState tableState = getTableState( cattr.getTableName() );
+ final DataSourceFactory dsFactory = getDataSourceFactory(cattr, compositeCacheManager.getConfigurationProperties());
- JDBCDiskCache<K, V> cache = new JDBCDiskCache<>(cattr, dsFactory, tableState);
+ final JDBCDiskCache<K, V> cache = new JDBCDiskCache<>(cattr, dsFactory, tableState);
cache.setCacheEventLogger( cacheEventLogger );
cache.setElementSerializer( elementSerializer );
@@ -125,13 +125,13 @@ public class JDBCDiskCacheFactory
{
this.tableStates.clear();
- for (DataSourceFactory dsFactory : this.dsFactories.values())
+ for (final DataSourceFactory dsFactory : this.dsFactories.values())
{
try
{
dsFactory.close();
}
- catch (SQLException e)
+ catch (final SQLException e)
{
log.error("Could not close data source factory {0}", dsFactory.getName(), e);
}
@@ -148,7 +148,7 @@ public class JDBCDiskCacheFactory
* @param tableName
* @return a cached instance of the table state
*/
- protected TableState getTableState(String tableName)
+ protected TableState getTableState(final String tableName)
{
return tableStates.computeIfAbsent(tableName, TableState::new);
}
@@ -157,7 +157,7 @@ public class JDBCDiskCacheFactory
* @see org.apache.commons.jcs3.engine.behavior.IRequireScheduler#setScheduledExecutorService(java.util.concurrent.ScheduledExecutorService)
*/
@Override
- public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutor)
+ public void setScheduledExecutorService(final ScheduledExecutorService scheduledExecutor)
{
this.scheduler = scheduledExecutor;
}
@@ -178,16 +178,16 @@ public class JDBCDiskCacheFactory
* @param cattr
* @param raf
*/
- protected void createShrinkerWhenNeeded( JDBCDiskCacheAttributes cattr, JDBCDiskCache<?, ?> raf )
+ protected void createShrinkerWhenNeeded( final JDBCDiskCacheAttributes cattr, final JDBCDiskCache<?, ?> raf )
{
// add cache to shrinker.
if ( cattr.isUseDiskShrinker() )
{
- ScheduledExecutorService shrinkerService = getScheduledExecutorService();
- ShrinkerThread shrinkerThread = shrinkerThreadMap.computeIfAbsent(cattr.getTableName(), key -> {
- ShrinkerThread newShrinkerThread = new ShrinkerThread();
+ final ScheduledExecutorService shrinkerService = getScheduledExecutorService();
+ final ShrinkerThread shrinkerThread = shrinkerThreadMap.computeIfAbsent(cattr.getTableName(), key -> {
+ final ShrinkerThread newShrinkerThread = new ShrinkerThread();
- long intervalMillis = Math.max( 999, cattr.getShrinkerIntervalSeconds() * 1000 );
+ final long intervalMillis = Math.max( 999, cattr.getShrinkerIntervalSeconds() * 1000 );
log.info( "Setting the shrinker to run every [{0}] ms. for table [{1}]",
intervalMillis, key );
shrinkerService.scheduleAtFixedRate(newShrinkerThread, 0, intervalMillis, TimeUnit.MILLISECONDS);
@@ -207,8 +207,8 @@ public class JDBCDiskCacheFactory
* @return a DataSourceFactory
* @throws SQLException if a database access error occurs
*/
- protected DataSourceFactory getDataSourceFactory( JDBCDiskCacheAttributes cattr,
- Properties configProps ) throws SQLException
+ protected DataSourceFactory getDataSourceFactory( final JDBCDiskCacheAttributes cattr,
+ final Properties configProps ) throws SQLException
{
String poolName = null;
@@ -222,7 +222,7 @@ public class JDBCDiskCacheFactory
}
- DataSourceFactory dsFactory = this.dsFactories.computeIfAbsent(poolName, key -> {
+ final DataSourceFactory dsFactory = this.dsFactories.computeIfAbsent(poolName, key -> {
DataSourceFactory newDsFactory;
JDBCDiskCacheAttributes dsConfig = null;
@@ -233,7 +233,7 @@ public class JDBCDiskCacheFactory
else
{
dsConfig = new JDBCDiskCacheAttributes();
- String dsConfigAttributePrefix = POOL_CONFIGURATION_PREFIX + key + ATTRIBUTE_PREFIX;
+ final String dsConfigAttributePrefix = POOL_CONFIGURATION_PREFIX + key + ATTRIBUTE_PREFIX;
PropertySetter.setProperties( dsConfig,
configProps,
dsConfigAttributePrefix + "." );
@@ -254,7 +254,7 @@ public class JDBCDiskCacheFactory
{
newDsFactory.initialize(dsConfig);
}
- catch (SQLException e)
+ catch (final SQLException e)
{
throw new RuntimeException(e);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/ShrinkerThread.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/ShrinkerThread.java
index a9c4c08..b9e1b15 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/ShrinkerThread.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/ShrinkerThread.java
@@ -64,7 +64,7 @@ public class ShrinkerThread
* <p>
* @param diskCache
*/
- public void addDiskCacheToShrinkList( JDBCDiskCache<?, ?> diskCache )
+ public void addDiskCacheToShrinkList( final JDBCDiskCache<?, ?> diskCache )
{
// the set will prevent dupes.
// we could also just add these to a hashmap by region name
@@ -83,7 +83,7 @@ public class ShrinkerThread
{
deleteExpiredFromAllRegisteredRegions();
}
- catch ( Throwable e )
+ catch ( final Throwable e )
{
log.error( "Caught an exception while trying to delete expired items.", e );
}
@@ -97,11 +97,11 @@ public class ShrinkerThread
log.info( "Running JDBC disk cache shrinker. Number of regions [{0}]",
() -> shrinkSet.size() );
- for (Iterator<JDBCDiskCache<?, ?>> i = shrinkSet.iterator(); i.hasNext();)
+ for (final Iterator<JDBCDiskCache<?, ?>> i = shrinkSet.iterator(); i.hasNext();)
{
- JDBCDiskCache<?, ?> cache = i.next();
- ElapsedTimer timer = new ElapsedTimer();
- int deleted = cache.deleteExpired();
+ final JDBCDiskCache<?, ?> cache = i.next();
+ final ElapsedTimer timer = new ElapsedTimer();
+ final int deleted = cache.deleteExpired();
log.info( "Deleted [{0}] expired for region [{1}] for table [{2}] in {3} ms.",
deleted, cache.getCacheName(), cache.getTableName(), timer.getElapsedTime() );
@@ -116,7 +116,7 @@ public class ShrinkerThread
{
Thread.sleep( this.getPauseBetweenRegionCallsMillis() );
}
- catch ( InterruptedException e )
+ catch ( final InterruptedException e )
{
log.warn( "Interrupted while waiting to delete expired for the next region." );
}
@@ -130,7 +130,7 @@ public class ShrinkerThread
* <p>
* @param pauseBetweenRegionCallsMillis The pauseBetweenRegionCallsMillis to set.
*/
- public void setPauseBetweenRegionCallsMillis( long pauseBetweenRegionCallsMillis )
+ public void setPauseBetweenRegionCallsMillis( final long pauseBetweenRegionCallsMillis )
{
this.pauseBetweenRegionCallsMillis = pauseBetweenRegionCallsMillis;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/TableState.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/TableState.java
index 11dbad0..4786c66 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/TableState.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/TableState.java
@@ -58,7 +58,7 @@ public class TableState
* <p>
* @param tableName
*/
- public TableState( String tableName )
+ public TableState( final String tableName )
{
this.setTableName( tableName );
}
@@ -67,7 +67,7 @@ public class TableState
* @param tableName
* The tableName to set.
*/
- public void setTableName( String tableName )
+ public void setTableName( final String tableName )
{
this.tableName = tableName;
}
@@ -84,7 +84,7 @@ public class TableState
* @param state
* The state to set.
*/
- public void setState( int state )
+ public void setState( final int state )
{
this.state = state;
}
@@ -105,7 +105,7 @@ public class TableState
@Override
public String toString()
{
- StringBuilder str = new StringBuilder();
+ final StringBuilder str = new StringBuilder();
str.append( "TableState " );
str.append( "\n TableName = " + getTableName() );
str.append( "\n State = " + getState() );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/dsfactory/JndiDataSourceFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/dsfactory/JndiDataSourceFactory.java
index 6a689c3..830b42c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/dsfactory/JndiDataSourceFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/dsfactory/JndiDataSourceFactory.java
@@ -83,7 +83,7 @@ public class JndiDataSourceFactory implements DataSourceFactory
@Override
public DataSource getDataSource() throws SQLException
{
- long time = System.currentTimeMillis();
+ final long time = System.currentTimeMillis();
if (ds == null || time - lastLookup > ttl)
{
@@ -95,7 +95,7 @@ public class JndiDataSourceFactory implements DataSourceFactory
}
lastLookup = time;
}
- catch (NamingException e)
+ catch (final NamingException e)
{
throw new SQLException(e);
}
@@ -108,7 +108,7 @@ public class JndiDataSourceFactory implements DataSourceFactory
* @see org.apache.commons.jcs3.auxiliary.disk.jdbc.dsfactory.DataSourceFactory#initialize(JDBCDiskCacheAttributes)
*/
@Override
- public void initialize(JDBCDiskCacheAttributes config) throws SQLException
+ public void initialize(final JDBCDiskCacheAttributes config) throws SQLException
{
this.name = config.getConnectionPoolName();
initJNDI(config);
@@ -120,7 +120,7 @@ public class JndiDataSourceFactory implements DataSourceFactory
* @param config where to read the settings from
* @throws SQLException if a property set fails
*/
- private void initJNDI(JDBCDiskCacheAttributes config) throws SQLException
+ private void initJNDI(final JDBCDiskCacheAttributes config) throws SQLException
{
log.debug("Starting initJNDI");
@@ -132,7 +132,7 @@ public class JndiDataSourceFactory implements DataSourceFactory
this.ttl = config.getJndiTTL();
log.debug("Time between context lookups: {0}", ttl);
- Hashtable<String, Object> env = new Hashtable<>();
+ final Hashtable<String, Object> env = new Hashtable<>();
ctx = new InitialContext(env);
if (log.isTraceEnabled())
@@ -141,7 +141,7 @@ public class JndiDataSourceFactory implements DataSourceFactory
debugCtx(ctx);
}
}
- catch (NamingException e)
+ catch (final NamingException e)
{
throw new SQLException(e);
}
@@ -162,10 +162,10 @@ public class JndiDataSourceFactory implements DataSourceFactory
* @param ctx the context
* @throws NamingException
*/
- private void debugCtx(Context ctx) throws NamingException
+ private void debugCtx(final Context ctx) throws NamingException
{
log.trace("InitialContext -------------------------------");
- Map<?, ?> env = ctx.getEnvironment();
+ final Map<?, ?> env = ctx.getEnvironment();
log.trace("Environment properties: {0}", env.size());
env.forEach((key, value) -> log.trace(" {0}: {1}", key, value));
log.trace("----------------------------------------------");
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/dsfactory/SharedPoolDataSourceFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/dsfactory/SharedPoolDataSourceFactory.java
index 371ce16..7fff446 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/dsfactory/SharedPoolDataSourceFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/dsfactory/SharedPoolDataSourceFactory.java
@@ -72,11 +72,11 @@ public class SharedPoolDataSourceFactory implements DataSourceFactory
* @see org.apache.commons.jcs3.auxiliary.disk.jdbc.dsfactory.DataSourceFactory#initialize(JDBCDiskCacheAttributes)
*/
@Override
- public void initialize(JDBCDiskCacheAttributes config) throws SQLException
+ public void initialize(final JDBCDiskCacheAttributes config) throws SQLException
{
this.name = config.getConnectionPoolName();
- ConnectionPoolDataSource cpds = initCPDS(config);
- SharedPoolDataSource dataSource = new SharedPoolDataSource();
+ final ConnectionPoolDataSource cpds = initCPDS(config);
+ final SharedPoolDataSource dataSource = new SharedPoolDataSource();
initJdbc2Pool(dataSource, config);
dataSource.setConnectionPoolDataSource(cpds);
dataSource.setMaxTotal(config.getMaxTotal());
@@ -97,7 +97,7 @@ public class SharedPoolDataSourceFactory implements DataSourceFactory
ds.close();
}
}
- catch (Exception e)
+ catch (final Exception e)
{
throw new SQLException("Exception caught closing data source", e);
}
@@ -116,13 +116,13 @@ public class SharedPoolDataSourceFactory implements DataSourceFactory
{
log.debug("Starting initCPDS");
- DriverAdapterCPDS cpds = new DriverAdapterCPDS();
+ final DriverAdapterCPDS cpds = new DriverAdapterCPDS();
try
{
cpds.setDriver(config.getDriverClassName());
}
- catch (ClassNotFoundException e)
+ catch (final ClassNotFoundException e)
{
throw new SQLException("Driver class not found " + config.getDriverClassName(), e);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
index 42fe5b5..d75f681 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
@@ -59,16 +59,16 @@ public class HSQLDiskCacheFactory
* @throws SQLException if the creation of the cache instance fails
*/
@Override
- public <K, V> JDBCDiskCache<K, V> createCache( AuxiliaryCacheAttributes rawAttr,
- ICompositeCacheManager compositeCacheManager,
- ICacheEventLogger cacheEventLogger,
- IElementSerializer elementSerializer )
+ public <K, V> JDBCDiskCache<K, V> createCache( final AuxiliaryCacheAttributes rawAttr,
+ final ICompositeCacheManager compositeCacheManager,
+ final ICacheEventLogger cacheEventLogger,
+ final IElementSerializer elementSerializer )
throws SQLException
{
// TODO get this from the attributes.
System.setProperty( "hsqldb.cache_scale", "8" );
- JDBCDiskCache<K, V> cache = super.createCache(rawAttr, compositeCacheManager,
+ final JDBCDiskCache<K, V> cache = super.createCache(rawAttr, compositeCacheManager,
cacheEventLogger, elementSerializer);
setupDatabase( cache.getDataSource(), (JDBCDiskCacheAttributes) rawAttr );
@@ -82,7 +82,7 @@ public class HSQLDiskCacheFactory
* @param attributes Cache region configuration
* @throws SQLException
*/
- protected void setupDatabase( DataSource ds, JDBCDiskCacheAttributes attributes )
+ protected void setupDatabase( final DataSource ds, final JDBCDiskCacheAttributes attributes )
throws SQLException
{
try (Connection cConn = ds.getConnection())
@@ -98,15 +98,15 @@ public class HSQLDiskCacheFactory
* @param cConn
* @param tableName
*/
- protected synchronized void setupTable( Connection cConn, String tableName ) throws SQLException
+ protected synchronized void setupTable( final Connection cConn, final String tableName ) throws SQLException
{
- DatabaseMetaData dmd = cConn.getMetaData();
- ResultSet result = dmd.getTables(null, null, tableName, null);
+ final DatabaseMetaData dmd = cConn.getMetaData();
+ final ResultSet result = dmd.getTables(null, null, tableName, null);
if (!result.next())
{
// TODO make the cached nature of the table configurable
- StringBuilder createSql = new StringBuilder();
+ final StringBuilder createSql = new StringBuilder();
createSql.append( "CREATE CACHED TABLE ").append( tableName );
createSql.append( "( " );
createSql.append( "CACHE_KEY VARCHAR(250) NOT NULL, " );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
index 2030881..973f9e2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
@@ -55,8 +55,8 @@ public class MySQLDiskCache<K, V>
* @param tableState an object to track table operations
* @throws SQLException if the pool access could not be set up
*/
- public MySQLDiskCache( MySQLDiskCacheAttributes attributes, DataSourceFactory dsFactory,
- TableState tableState) throws SQLException
+ public MySQLDiskCache( final MySQLDiskCacheAttributes attributes, final DataSourceFactory dsFactory,
+ final TableState tableState) throws SQLException
{
super( attributes, dsFactory, tableState);
@@ -73,7 +73,7 @@ public class MySQLDiskCache<K, V>
* @return An object matching key, or null.
*/
@Override
- protected ICacheElement<K, V> processGet( K key )
+ protected ICacheElement<K, V> processGet( final K key )
{
if ( this.getTableState().getState() == TableState.OPTIMIZATION_RUNNING )
{
@@ -93,7 +93,7 @@ public class MySQLDiskCache<K, V>
* @return An object matching key, or null.
*/
@Override
- protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
+ protected Map<K, ICacheElement<K, V>> processGetMatching( final String pattern )
{
if ( this.getTableState().getState() == TableState.OPTIMIZATION_RUNNING )
{
@@ -110,7 +110,7 @@ public class MySQLDiskCache<K, V>
* @return String to use in the like query.
*/
@Override
- public String constructLikeParameterFromPattern( String pattern )
+ public String constructLikeParameterFromPattern( final String pattern )
{
String likePattern = pattern.replaceAll( "\\.\\+", "%" );
likePattern = likePattern.replaceAll( "\\.", "_" );
@@ -127,7 +127,7 @@ public class MySQLDiskCache<K, V>
* @param element
*/
@Override
- protected void processUpdate( ICacheElement<K, V> element )
+ protected void processUpdate( final ICacheElement<K, V> element )
{
if ( this.getTableState().getState() == TableState.OPTIMIZATION_RUNNING )
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java
index 854a932..3325714 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheAttributes.java
@@ -58,7 +58,7 @@ public class MySQLDiskCacheAttributes
/**
* @param optimizationSchedule The optimizationSchedule to set.
*/
- public void setOptimizationSchedule( String optimizationSchedule )
+ public void setOptimizationSchedule( final String optimizationSchedule )
{
this.optimizationSchedule = optimizationSchedule;
}
@@ -74,7 +74,7 @@ public class MySQLDiskCacheAttributes
/**
* @param balkDuringOptimization The balkDuringOptimization to set.
*/
- public void setBalkDuringOptimization( boolean balkDuringOptimization )
+ public void setBalkDuringOptimization( final boolean balkDuringOptimization )
{
this.balkDuringOptimization = balkDuringOptimization;
}
@@ -97,7 +97,7 @@ public class MySQLDiskCacheAttributes
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\nMySQLDiskCacheAttributes" );
buf.append( "\n OptimizationSchedule [" + getOptimizationSchedule() + "]" );
buf.append( "\n BalkDuringOptimization [" + isBalkDuringOptimization() + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java
index f3da717..5d072c3 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java
@@ -59,16 +59,16 @@ public class MySQLDiskCacheFactory
* @throws SQLException if the cache instance could not be created
*/
@Override
- public <K, V> MySQLDiskCache<K, V> createCache( AuxiliaryCacheAttributes rawAttr,
- ICompositeCacheManager compositeCacheManager,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ public <K, V> MySQLDiskCache<K, V> createCache( final AuxiliaryCacheAttributes rawAttr,
+ final ICompositeCacheManager compositeCacheManager,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
throws SQLException
{
- MySQLDiskCacheAttributes cattr = (MySQLDiskCacheAttributes) rawAttr;
- TableState tableState = getTableState( cattr.getTableName() );
- DataSourceFactory dsFactory = getDataSourceFactory(cattr, compositeCacheManager.getConfigurationProperties());
+ final MySQLDiskCacheAttributes cattr = (MySQLDiskCacheAttributes) rawAttr;
+ final TableState tableState = getTableState( cattr.getTableName() );
+ final DataSourceFactory dsFactory = getDataSourceFactory(cattr, compositeCacheManager.getConfigurationProperties());
- MySQLDiskCache<K, V> cache = new MySQLDiskCache<>( cattr, dsFactory, tableState);
+ final MySQLDiskCache<K, V> cache = new MySQLDiskCache<>( cattr, dsFactory, tableState);
cache.setCacheEventLogger( cacheEventLogger );
cache.setElementSerializer( elementSerializer );
@@ -87,7 +87,7 @@ public class MySQLDiskCacheFactory
* @param tableState for noting optimization in progress, etc.
* @param ds the DataSource
*/
- protected void scheduleOptimizations( MySQLDiskCacheAttributes attributes, TableState tableState, DataSource ds )
+ protected void scheduleOptimizations( final MySQLDiskCacheAttributes attributes, final TableState tableState, final DataSource ds )
{
if ( attributes != null )
{
@@ -96,12 +96,12 @@ public class MySQLDiskCacheFactory
log.info( "Will try to configure optimization for table [{0}] on schedule [{1}]",
() -> attributes.getTableName(), () -> attributes.getOptimizationSchedule());
- MySQLTableOptimizer optimizer = new MySQLTableOptimizer( attributes, tableState, ds );
+ final MySQLTableOptimizer optimizer = new MySQLTableOptimizer( attributes, tableState, ds );
// loop through the dates.
try
{
- Date[] dates = ScheduleParser.createDatesForSchedule( attributes.getOptimizationSchedule() );
+ final Date[] dates = ScheduleParser.createDatesForSchedule( attributes.getOptimizationSchedule() );
if ( dates != null )
{
for ( int i = 0; i < dates.length; i++ )
@@ -110,7 +110,7 @@ public class MySQLDiskCacheFactory
}
}
}
- catch ( ParseException e )
+ catch ( final ParseException e )
{
log.warn( "Problem creating optimization schedule for table [{0}]",
attributes.getTableName(), e );
@@ -130,12 +130,12 @@ public class MySQLDiskCacheFactory
* @param startTime -- HH:MM:SS format
* @param optimizer
*/
- protected void scheduleOptimization( Date startTime, MySQLTableOptimizer optimizer )
+ protected void scheduleOptimization( final Date startTime, final MySQLTableOptimizer optimizer )
{
log.info( "startTime [{0}] for optimizer {1}", startTime, optimizer );
- Date now = new Date();
- long initialDelay = startTime.getTime() - now.getTime();
+ final Date now = new Date();
+ final long initialDelay = startTime.getTime() - now.getTime();
// have the daemon execute the optimization
getScheduledExecutorService().scheduleAtFixedRate(() -> optimizeTable(optimizer),
@@ -147,11 +147,11 @@ public class MySQLDiskCacheFactory
* <p>
* @author Aaron Smuts
*/
- private void optimizeTable(MySQLTableOptimizer optimizer)
+ private void optimizeTable(final MySQLTableOptimizer optimizer)
{
if ( optimizer != null )
{
- boolean success = optimizer.optimizeTable();
+ final boolean success = optimizer.optimizeTable();
log.info( "Optimization success status [{0}]", success );
}
else
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java
index ffd2cde..ab78af4 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/MySQLTableOptimizer.java
@@ -61,7 +61,7 @@ public class MySQLTableOptimizer
* @param tableState We mark the table status as optimizing when this is happening.
* @param dataSource access to the database
*/
- public MySQLTableOptimizer( MySQLDiskCacheAttributes attributes, TableState tableState, DataSource dataSource )
+ public MySQLTableOptimizer( final MySQLDiskCacheAttributes attributes, final TableState tableState, final DataSource dataSource )
{
setTableName( attributes.getTableName() );
@@ -116,7 +116,7 @@ public class MySQLTableOptimizer
*/
public boolean optimizeTable()
{
- ElapsedTimer timer = new ElapsedTimer();
+ final ElapsedTimer timer = new ElapsedTimer();
boolean success = false;
if ( tableState.getState() == TableState.OPTIMIZATION_RUNNING )
@@ -144,8 +144,8 @@ public class MySQLTableOptimizer
// This may be mysql version specific.
if ( rs.next() )
{
- String status = rs.getString( "Msg_type" );
- String message = rs.getString( "Msg_text" );
+ final String status = rs.getString( "Msg_type" );
+ final String message = rs.getString( "Msg_text" );
log.info( "Message Type: {0}", status );
log.info( "Message: {0}", message );
@@ -166,18 +166,18 @@ public class MySQLTableOptimizer
}
// log the table status
- String statusString = getTableStatus( sStatement );
+ final String statusString = getTableStatus( sStatement );
log.info( "Table status after optimizing table [{0}]: {1}",
this.getTableName(), statusString );
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem optimizing table [{0}]",
this.getTableName(), e );
return false;
}
}
- catch ( SQLException e )
+ catch ( final SQLException e )
{
log.error( "Problem getting connection.", e );
}
@@ -200,13 +200,13 @@ public class MySQLTableOptimizer
* @return String
* @throws SQLException
*/
- protected String getTableStatus( Statement sStatement )
+ protected String getTableStatus( final Statement sStatement )
throws SQLException
{
- StringBuilder statusString = new StringBuilder();
+ final StringBuilder statusString = new StringBuilder();
try (ResultSet statusResultSet = sStatement.executeQuery( "show table status" ))
{
- int numColumns = statusResultSet.getMetaData().getColumnCount();
+ final int numColumns = statusResultSet.getMetaData().getColumnCount();
while ( statusResultSet.next() )
{
statusString.append( "\n" );
@@ -232,16 +232,16 @@ public class MySQLTableOptimizer
* @return true if successful
* @throws SQLException
*/
- protected boolean repairTable( Statement sStatement )
+ protected boolean repairTable( final Statement sStatement )
throws SQLException
{
boolean success = false;
// if( message != null && message.indexOf( ) )
- StringBuilder repairString = new StringBuilder();
+ final StringBuilder repairString = new StringBuilder();
try (ResultSet repairResult = sStatement.executeQuery( "repair table " + this.getTableName()))
{
- int numColumns = repairResult.getMetaData().getColumnCount();
+ final int numColumns = repairResult.getMetaData().getColumnCount();
while ( repairResult.next() )
{
for ( int i = 1; i <= numColumns; i++ )
@@ -252,7 +252,7 @@ public class MySQLTableOptimizer
.append("] | ");
}
- String message = repairResult.getString( "Msg_text" );
+ final String message = repairResult.getString( "Msg_text" );
if ( "OK".equals( message ) )
{
success = true;
@@ -272,7 +272,7 @@ public class MySQLTableOptimizer
/**
* @param tableName The tableName to set.
*/
- public void setTableName( String tableName )
+ public void setTableName( final String tableName )
{
this.tableName = tableName;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java
index 11e87b9..e2a489e 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/disk/jdbc/mysql/util/ScheduleParser.java
@@ -40,7 +40,7 @@ public class ScheduleParser
* @return Date[]
* @throws ParseException
*/
- public static Date[] createDatesForSchedule( String schedule )
+ public static Date[] createDatesForSchedule( final String schedule )
throws ParseException
{
if ( schedule == null )
@@ -48,12 +48,12 @@ public class ScheduleParser
throw new ParseException( "Cannot create schedules for a null String.", 0 );
}
- StringTokenizer toker = new StringTokenizer( schedule, "," );
- Date[] dates = new Date[toker.countTokens()];
+ final StringTokenizer toker = new StringTokenizer( schedule, "," );
+ final Date[] dates = new Date[toker.countTokens()];
int cnt = 0;
while ( toker.hasMoreTokens() )
{
- String time = toker.nextToken();
+ final String time = toker.nextToken();
dates[cnt] = getDateForSchedule( time );
cnt++;
}
@@ -68,7 +68,7 @@ public class ScheduleParser
* @return Date
* @throws ParseException
*/
- public static Date getDateForSchedule( String startTime )
+ public static Date getDateForSchedule( final String startTime )
throws ParseException
{
if ( startTime == null )
@@ -76,13 +76,13 @@ public class ScheduleParser
throw new ParseException( "Cannot create date for a null String.", 0 );
}
- SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
- Date date = sdf.parse(startTime);
- Calendar cal = Calendar.getInstance();
+ final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
+ final Date date = sdf.parse(startTime);
+ final Calendar cal = Calendar.getInstance();
// This will result in a date of 1/1/1970
cal.setTime(date);
- Calendar now = Calendar.getInstance();
+ final Calendar now = Calendar.getInstance();
cal.set(now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
// if the date is less than now, add a day.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
index dbeb339..4a4d4a2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCache.java
@@ -66,7 +66,7 @@ public class LateralCache<K, V>
* @param lateral
* @param monitor
*/
- public LateralCache( ILateralCacheAttributes cattr, ICacheServiceNonLocal<K, V> lateral, LateralCacheMonitor monitor )
+ public LateralCache( final ILateralCacheAttributes cattr, final ICacheServiceNonLocal<K, V> lateral, final LateralCacheMonitor monitor )
{
this.cacheName = cattr.getCacheName();
this.lateralCacheAttributes = cattr;
@@ -79,7 +79,7 @@ public class LateralCache<K, V>
* <p>
* @param cattr
*/
- public LateralCache( ILateralCacheAttributes cattr )
+ public LateralCache( final ILateralCacheAttributes cattr )
{
this.cacheName = cattr.getCacheName();
this.lateralCacheAttributes = cattr;
@@ -92,7 +92,7 @@ public class LateralCache<K, V>
* @throws IOException
*/
@Override
- protected void processUpdate( ICacheElement<K, V> ce )
+ protected void processUpdate( final ICacheElement<K, V> ce )
throws IOException
{
try
@@ -104,7 +104,7 @@ public class LateralCache<K, V>
lateralCacheService.update( ce, CacheInfo.listenerId );
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes );
}
@@ -118,7 +118,7 @@ public class LateralCache<K, V>
* @throws IOException
*/
@Override
- protected ICacheElement<K, V> processGet( K key )
+ protected ICacheElement<K, V> processGet( final K key )
throws IOException
{
ICacheElement<K, V> obj = null;
@@ -131,7 +131,7 @@ public class LateralCache<K, V>
{
obj = lateralCacheService.get( cacheName, key );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( e );
handleException( e, "Failed to get [" + key + "] from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes );
@@ -146,7 +146,7 @@ public class LateralCache<K, V>
* @throws IOException
*/
@Override
- protected Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
+ protected Map<K, ICacheElement<K, V>> processGetMatching( final String pattern )
throws IOException
{
if ( this.lateralCacheAttributes.getPutOnlyMode() )
@@ -157,7 +157,7 @@ public class LateralCache<K, V>
{
return lateralCacheService.getMatching( cacheName, pattern );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( e );
handleException( e, "Failed to getMatching [" + pattern + "] from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes );
@@ -177,7 +177,7 @@ public class LateralCache<K, V>
{
return lateralCacheService.getKeySet( cacheName );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
handleException( ex, "Failed to get key set from " + lateralCacheAttributes.getCacheName() + "@"
+ lateralCacheAttributes );
@@ -194,7 +194,7 @@ public class LateralCache<K, V>
* @throws IOException
*/
@Override
- protected boolean processRemove( K key )
+ protected boolean processRemove( final K key )
throws IOException
{
log.debug( "removing key: {0}", key );
@@ -203,7 +203,7 @@ public class LateralCache<K, V>
{
lateralCacheService.remove( cacheName, key, CacheInfo.listenerId );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
handleException( ex, "Failed to remove " + key + " from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes );
}
@@ -224,7 +224,7 @@ public class LateralCache<K, V>
{
lateralCacheService.removeAll( cacheName, CacheInfo.listenerId );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
handleException( ex, "Failed to remove all from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes );
}
@@ -250,7 +250,7 @@ public class LateralCache<K, V>
lateralCacheService.dispose( this.lateralCacheAttributes.getCacheName() );
// Should remove connection
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( "Couldn't dispose", ex );
handleException( ex, "Failed to dispose " + lateralCacheAttributes.getCacheName() );
@@ -308,7 +308,7 @@ public class LateralCache<K, V>
* @param msg
* @throws IOException
*/
- private void handleException( Exception ex, String msg )
+ private void handleException( final Exception ex, final String msg )
throws IOException
{
log.error( "Disabling lateral cache due to error {0}", msg, ex );
@@ -332,23 +332,23 @@ public class LateralCache<K, V>
* <p>
* @param restoredLateral
*/
- public void fixCache( ICacheServiceNonLocal<K, V> restoredLateral )
+ public void fixCache( final ICacheServiceNonLocal<K, V> restoredLateral )
{
if ( this.lateralCacheService instanceof ZombieCacheServiceNonLocal )
{
- ZombieCacheServiceNonLocal<K, V> zombie = (ZombieCacheServiceNonLocal<K, V>) this.lateralCacheService;
+ final ZombieCacheServiceNonLocal<K, V> zombie = (ZombieCacheServiceNonLocal<K, V>) this.lateralCacheService;
this.lateralCacheService = restoredLateral;
try
{
zombie.propagateEvents( restoredLateral );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
try
{
handleException( e, "Problem propagating events from Zombie Queue to new Lateral Service." );
}
- catch ( IOException e1 )
+ catch ( final IOException e1 )
{
// swallow, since this is just expected kick back. Handle always throws
}
@@ -386,7 +386,7 @@ public class LateralCache<K, V>
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\n LateralCache " );
buf.append( "\n Cache Name [" + lateralCacheAttributes.getCacheName() + "]" );
buf.append( "\n cattr = [" + lateralCacheAttributes + "]" );
@@ -410,7 +410,7 @@ public class LateralCache<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "LateralCache" );
return stats;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheAttributes.java
index 92e6a35..67c99c6 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheAttributes.java
@@ -74,7 +74,7 @@ public class LateralCacheAttributes
* @param val The new httpServer value
*/
@Override
- public void setHttpServer( String val )
+ public void setHttpServer( final String val )
{
httpServer = val;
}
@@ -94,7 +94,7 @@ public class LateralCacheAttributes
* @param val The new httpServers value
*/
@Override
- public void setHttpServers( String val )
+ public void setHttpServers( final String val )
{
httpServers = val;
}
@@ -114,7 +114,7 @@ public class LateralCacheAttributes
* @param val The new tcpListenerPort value
*/
@Override
- public void setHttpListenerPort( int val )
+ public void setHttpListenerPort( final int val )
{
this.httpListenerPort = val;
}
@@ -134,7 +134,7 @@ public class LateralCacheAttributes
* @param val The new udpMulticastAddr value
*/
@Override
- public void setUdpMulticastAddr( String val )
+ public void setUdpMulticastAddr( final String val )
{
udpMulticastAddr = val;
}
@@ -154,7 +154,7 @@ public class LateralCacheAttributes
* @param val The new udpMulticastPort value
*/
@Override
- public void setUdpMulticastPort( int val )
+ public void setUdpMulticastPort( final int val )
{
udpMulticastPort = val;
}
@@ -174,7 +174,7 @@ public class LateralCacheAttributes
* @param val The new transmissionType value
*/
@Override
- public void setTransmissionType( Type val )
+ public void setTransmissionType( final Type val )
{
this.transmissionType = val;
this.transmissionTypeName = val.toString();
@@ -195,7 +195,7 @@ public class LateralCacheAttributes
* @param val The new transmissionTypeName value
*/
@Override
- public void setTransmissionTypeName( String val )
+ public void setTransmissionTypeName( final String val )
{
this.transmissionTypeName = val;
this.transmissionType = Type.valueOf(val);
@@ -218,7 +218,7 @@ public class LateralCacheAttributes
* @param val The new transmissionTypeName value
*/
@Override
- public void setPutOnlyMode( boolean val )
+ public void setPutOnlyMode( final boolean val )
{
this.putOnlyMode = val;
}
@@ -236,7 +236,7 @@ public class LateralCacheAttributes
* @param receive The receive to set.
*/
@Override
- public void setReceive( boolean receive )
+ public void setReceive( final boolean receive )
{
this.receive = receive;
}
@@ -257,7 +257,7 @@ public class LateralCacheAttributes
* @param zombieQueueMaxSize The zombieQueueMaxSize to set.
*/
@Override
- public void setZombieQueueMaxSize( int zombieQueueMaxSize )
+ public void setZombieQueueMaxSize( final int zombieQueueMaxSize )
{
this.zombieQueueMaxSize = zombieQueueMaxSize;
}
@@ -280,7 +280,7 @@ public class LateralCacheAttributes
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
//buf.append( "cacheName=" + cacheName + "\n" );
//buf.append( "putOnlyMode=" + putOnlyMode + "\n" );
//buf.append( "transmissionTypeName=" + transmissionTypeName + "\n" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheMonitor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheMonitor.java
index cb8f62a..44ca757 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheMonitor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheMonitor.java
@@ -53,7 +53,7 @@ public class LateralCacheMonitor extends AbstractAuxiliaryCacheMonitor
* <p>
* @param idlePeriod
*/
- protected static void forceShortIdlePeriod( long idlePeriod )
+ protected static void forceShortIdlePeriod( final long idlePeriod )
{
LateralCacheMonitor.idlePeriod = idlePeriod;
}
@@ -65,7 +65,7 @@ public class LateralCacheMonitor extends AbstractAuxiliaryCacheMonitor
*
* @param factory a reference to the factory that manages the service instances
*/
- public LateralCacheMonitor(LateralTCPCacheFactory factory)
+ public LateralCacheMonitor(final LateralTCPCacheFactory factory)
{
super("JCS-LateralCacheMonitor");
this.factory = factory;
@@ -78,7 +78,7 @@ public class LateralCacheMonitor extends AbstractAuxiliaryCacheMonitor
*
* @param cache the cache
*/
- public void addCache(LateralCacheNoWait<?, ?> cache)
+ public void addCache(final LateralCacheNoWait<?, ?> cache)
{
this.caches.put(cache.getCacheName(), cache);
@@ -107,20 +107,21 @@ public class LateralCacheMonitor extends AbstractAuxiliaryCacheMonitor
// Monitor each cache instance one after the other.
log.info( "Number of caches to monitor = " + caches.size() );
//for
- for (Map.Entry<String, LateralCacheNoWait<?, ?>> entry : caches.entrySet())
+ for (final Map.Entry<String, LateralCacheNoWait<?, ?>> entry : caches.entrySet())
{
- String cacheName = entry.getKey();
+ final String cacheName = entry.getKey();
@SuppressWarnings("unchecked") // Downcast to match service
+ final
LateralCacheNoWait<Object, Object> c = (LateralCacheNoWait<Object, Object>) entry.getValue();
if ( c.getStatus() == CacheStatus.ERROR )
{
log.info( "Found LateralCacheNoWait in error, " + cacheName );
- ITCPLateralCacheAttributes lca = (ITCPLateralCacheAttributes)c.getAuxiliaryCacheAttributes();
+ final ITCPLateralCacheAttributes lca = (ITCPLateralCacheAttributes)c.getAuxiliaryCacheAttributes();
// Get service instance
- ICacheServiceNonLocal<Object, Object> cacheService = factory.getCSNLInstance(lca);
+ final ICacheServiceNonLocal<Object, Object> cacheService = factory.getCSNLInstance(lca);
// If we can't fix them, just skip and re-try in the
// next round.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java
index e2fff84..8aba713 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWait.java
@@ -76,13 +76,13 @@ public class LateralCacheNoWait<K, V>
* <p>
* @param cache
*/
- public LateralCacheNoWait( LateralCache<K, V> cache )
+ public LateralCacheNoWait( final LateralCache<K, V> cache )
{
this.cache = cache;
log.debug( "Constructing LateralCacheNoWait, LateralCache = [{0}]", cache );
- CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
+ final CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<>( cache ), CacheInfo.listenerId, cache
.getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache
.getAuxiliaryCacheAttributes().getEventQueueType() );
@@ -104,7 +104,7 @@ public class LateralCacheNoWait<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> ce )
+ public void update( final ICacheElement<K, V> ce )
throws IOException
{
putCount++;
@@ -112,7 +112,7 @@ public class LateralCacheNoWait<K, V>
{
eventQueue.addPutEvent( ce );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( ex );
eventQueue.destroy();
@@ -126,7 +126,7 @@ public class LateralCacheNoWait<K, V>
* @return ICacheElement<K, V> if found, else null
*/
@Override
- public ICacheElement<K, V> get( K key )
+ public ICacheElement<K, V> get( final K key )
{
getCount++;
if ( this.getStatus() != CacheStatus.ERROR )
@@ -135,20 +135,20 @@ public class LateralCacheNoWait<K, V>
{
return cache.get( key );
}
- catch ( UnmarshalException ue )
+ catch ( final UnmarshalException ue )
{
log.debug( "Retrying the get owing to UnmarshalException..." );
try
{
return cache.get( key );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( "Failed in retrying the get for the second time." );
eventQueue.destroy();
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
eventQueue.destroy();
}
@@ -164,11 +164,11 @@ public class LateralCacheNoWait<K, V>
* data in cache for any of these keys
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
+ public Map<K, ICacheElement<K, V>> getMultiple(final Set<K> keys)
{
if ( keys != null && !keys.isEmpty() )
{
- Map<K, ICacheElement<K, V>> elements = keys.stream()
+ final Map<K, ICacheElement<K, V>> elements = keys.stream()
.collect(Collectors.toMap(
key -> key,
key -> get(key))).entrySet().stream()
@@ -190,7 +190,7 @@ public class LateralCacheNoWait<K, V>
* @return ICacheElement<K, V> if found, else empty
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching(String pattern)
+ public Map<K, ICacheElement<K, V>> getMatching(final String pattern)
{
getCount++;
if ( this.getStatus() != CacheStatus.ERROR )
@@ -199,20 +199,20 @@ public class LateralCacheNoWait<K, V>
{
return cache.getMatching( pattern );
}
- catch ( UnmarshalException ue )
+ catch ( final UnmarshalException ue )
{
log.debug( "Retrying the get owing to UnmarshalException." );
try
{
return cache.getMatching( pattern );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( "Failed in retrying the get for the second time." );
eventQueue.destroy();
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
eventQueue.destroy();
}
@@ -232,7 +232,7 @@ public class LateralCacheNoWait<K, V>
{
return cache.getKeySet();
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( ex );
eventQueue.destroy();
@@ -247,14 +247,14 @@ public class LateralCacheNoWait<K, V>
* @return always false
*/
@Override
- public boolean remove( K key )
+ public boolean remove( final K key )
{
removeCount++;
try
{
eventQueue.addRemoveEvent( key );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( ex );
eventQueue.destroy();
@@ -270,7 +270,7 @@ public class LateralCacheNoWait<K, V>
{
eventQueue.addRemoveAllEvent();
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( ex );
eventQueue.destroy();
@@ -285,7 +285,7 @@ public class LateralCacheNoWait<K, V>
{
eventQueue.addDisposeEvent();
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( ex );
eventQueue.destroy();
@@ -343,7 +343,7 @@ public class LateralCacheNoWait<K, V>
* <p>
* @param lateral
*/
- public void fixCache( ICacheServiceNonLocal<K, V> lateral )
+ public void fixCache( final ICacheServiceNonLocal<K, V> lateral )
{
cache.fixCache( lateral );
resetEventQ();
@@ -358,7 +358,7 @@ public class LateralCacheNoWait<K, V>
{
eventQueue.destroy();
}
- CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
+ final CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<>( cache ), CacheInfo.listenerId, cache
.getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache
.getAuxiliaryCacheAttributes().getEventQueueType() );
@@ -400,13 +400,13 @@ public class LateralCacheNoWait<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "Lateral Cache No Wait" );
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
// get the stats from the event queue too
- IStats eqStats = this.eventQueue.getStatistics();
+ final IStats eqStats = this.eventQueue.getStatistics();
elems.addAll(eqStats.getStatElements());
elems.add(new StatElement<>( "Get Count", Integer.valueOf(this.getCount) ) );
@@ -425,7 +425,7 @@ public class LateralCacheNoWait<K, V>
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( " LateralCacheNoWait " );
buf.append( " Status = " + this.getStatus() );
buf.append( " cache = [" + cache.toString() + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java
index 7649718..0ba977a 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralCacheNoWaitFacade.java
@@ -77,7 +77,7 @@ public class LateralCacheNoWaitFacade<K, V>
* @param noWaits
* @param cattr
*/
- public LateralCacheNoWaitFacade(ILateralCacheListener<K, V> listener, LateralCacheNoWait<K, V>[] noWaits, ILateralCacheAttributes cattr )
+ public LateralCacheNoWaitFacade(final ILateralCacheListener<K, V> listener, final LateralCacheNoWait<K, V>[] noWaits, final ILateralCacheAttributes cattr )
{
log.debug( "CONSTRUCTING NO WAIT FACADE" );
this.listener = listener;
@@ -92,9 +92,9 @@ public class LateralCacheNoWaitFacade<K, V>
* @param noWait
* @return true if the noWait is in the list.
*/
- public boolean containsNoWait( LateralCacheNoWait<K, V> noWait )
+ public boolean containsNoWait( final LateralCacheNoWait<K, V> noWait )
{
- Optional<LateralCacheNoWait<K, V>> optional = Arrays.stream(noWaits)
+ final Optional<LateralCacheNoWait<K, V>> optional = Arrays.stream(noWaits)
// we know noWait isn't null
.filter(nw -> noWait.equals( nw ))
.findFirst();
@@ -108,7 +108,7 @@ public class LateralCacheNoWaitFacade<K, V>
* @param noWait
* @return true if it wasn't already contained
*/
- public synchronized boolean addNoWait( LateralCacheNoWait<K, V> noWait )
+ public synchronized boolean addNoWait( final LateralCacheNoWait<K, V> noWait )
{
if ( noWait == null )
{
@@ -122,6 +122,7 @@ public class LateralCacheNoWaitFacade<K, V>
}
@SuppressWarnings("unchecked") // No generic arrays in java
+ final
LateralCacheNoWait<K, V>[] newArray = new LateralCacheNoWait[noWaits.length + 1];
System.arraycopy( noWaits, 0, newArray, 0, noWaits.length );
@@ -140,7 +141,7 @@ public class LateralCacheNoWaitFacade<K, V>
* @param noWait
* @return true if it was already in the array
*/
- public synchronized boolean removeNoWait( LateralCacheNoWait<K, V> noWait )
+ public synchronized boolean removeNoWait( final LateralCacheNoWait<K, V> noWait )
{
if ( noWait == null )
{
@@ -164,6 +165,7 @@ public class LateralCacheNoWaitFacade<K, V>
}
@SuppressWarnings("unchecked") // No generic arrays in java
+ final
LateralCacheNoWait<K, V>[] newArray = new LateralCacheNoWait[noWaits.length - 1];
System.arraycopy( noWaits, 0, newArray, 0, position );
@@ -181,13 +183,13 @@ public class LateralCacheNoWaitFacade<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> ce )
+ public void update( final ICacheElement<K, V> ce )
throws IOException
{
log.debug( "updating through lateral cache facade, noWaits.length = {0}",
noWaits.length );
- for (LateralCacheNoWait<K, V> nw : noWaits)
+ for (final LateralCacheNoWait<K, V> nw : noWaits)
{
nw.update( ce );
}
@@ -200,9 +202,9 @@ public class LateralCacheNoWaitFacade<K, V>
* @return ICacheElement
*/
@Override
- public ICacheElement<K, V> get( K key )
+ public ICacheElement<K, V> get( final K key )
{
- Optional<ICacheElement<K, V>> optional = Arrays.stream(noWaits)
+ final Optional<ICacheElement<K, V>> optional = Arrays.stream(noWaits)
.map(nw -> nw.get( key ))
.filter(obj -> obj != null)
.findFirst();
@@ -223,11 +225,11 @@ public class LateralCacheNoWaitFacade<K, V>
* data in cache for any of these keys
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
+ public Map<K, ICacheElement<K, V>> getMultiple(final Set<K> keys)
{
if ( keys != null && !keys.isEmpty() )
{
- Map<K, ICacheElement<K, V>> elements = keys.stream()
+ final Map<K, ICacheElement<K, V>> elements = keys.stream()
.collect(Collectors.toMap(
key -> key,
key -> get(key))).entrySet().stream()
@@ -250,10 +252,10 @@ public class LateralCacheNoWaitFacade<K, V>
* @return ICacheElement
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching(String pattern)
+ public Map<K, ICacheElement<K, V>> getMatching(final String pattern)
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<>();
- for (LateralCacheNoWait<K, V> nw : noWaits)
+ final Map<K, ICacheElement<K, V>> elements = new HashMap<>();
+ for (final LateralCacheNoWait<K, V> nw : noWaits)
{
elements.putAll( nw.getMatching( pattern ) );
}
@@ -268,12 +270,12 @@ public class LateralCacheNoWaitFacade<K, V>
@Override
public Set<K> getKeySet() throws IOException
{
- HashSet<K> allKeys = new HashSet<>();
- for (LateralCacheNoWait<K, V> nw : noWaits)
+ final HashSet<K> allKeys = new HashSet<>();
+ for (final LateralCacheNoWait<K, V> nw : noWaits)
{
if ( nw != null )
{
- Set<K> keys = nw.getKeySet();
+ final Set<K> keys = nw.getKeySet();
if (keys != null)
{
allKeys.addAll( keys );
@@ -290,7 +292,7 @@ public class LateralCacheNoWaitFacade<K, V>
* @return always false.
*/
@Override
- public boolean remove( K key )
+ public boolean remove( final K key )
{
Arrays.stream(noWaits).forEach(nw -> nw.remove( key ));
return false;
@@ -376,7 +378,7 @@ public class LateralCacheNoWaitFacade<K, V>
return CacheStatus.ALIVE;
}
- List<CacheStatus> statii = Arrays.stream(noWaits)
+ final List<CacheStatus> statii = Arrays.stream(noWaits)
.map(LateralCacheNoWait::getStatus)
.collect(Collectors.toList());
@@ -441,21 +443,21 @@ public class LateralCacheNoWaitFacade<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "Lateral Cache No Wait Facade" );
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
if ( noWaits != null )
{
elems.add(new StatElement<>( "Number of No Waits", Integer.valueOf(noWaits.length) ) );
- for ( LateralCacheNoWait<K, V> lcnw : noWaits )
+ for ( final LateralCacheNoWait<K, V> lcnw : noWaits )
{
if ( lcnw != null )
{
// get the stats from the super too
- IStats sStats = lcnw.getStatistics();
+ final IStats sStats = lcnw.getStatistics();
elems.addAll(sStats.getStatElements());
}
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralElementDescriptor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralElementDescriptor.java
index d79ba48..102975f 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralElementDescriptor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/LateralElementDescriptor.java
@@ -61,7 +61,7 @@ public class LateralElementDescriptor<K, V>
* <p>
* @param ce ICacheElement<K, V> payload
*/
- public LateralElementDescriptor( ICacheElement<K, V> ce )
+ public LateralElementDescriptor( final ICacheElement<K, V> ce )
{
this.ce = ce;
}
@@ -72,7 +72,7 @@ public class LateralElementDescriptor<K, V>
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\n LateralElementDescriptor " );
buf.append( "\n command = [" + this.command + "]" );
buf.append( "\n valHashCode = [" + this.valHashCode + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
index e75936a..69a0eca 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
@@ -84,27 +84,27 @@ public class LateralTCPCacheFactory
*/
@Override
public <K, V> LateralCacheNoWaitFacade<K, V> createCache(
- AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
{
- ITCPLateralCacheAttributes lac = (ITCPLateralCacheAttributes) iaca;
- ArrayList<ICache<K, V>> noWaits = new ArrayList<>();
+ final ITCPLateralCacheAttributes lac = (ITCPLateralCacheAttributes) iaca;
+ final ArrayList<ICache<K, V>> noWaits = new ArrayList<>();
// pairs up the tcp servers and set the tcpServer value and
// get the manager and then get the cache
// no servers are required.
if ( lac.getTcpServers() != null )
{
- String servers[] = lac.getTcpServers().split("\\s*,\\s*");
+ final String servers[] = lac.getTcpServers().split("\\s*,\\s*");
log.debug( "Configured for [{0}] servers.", servers.length );
- for (String server : servers)
+ for (final String server : servers)
{
log.debug( "tcp server = {0}", server );
- ITCPLateralCacheAttributes lacC = (ITCPLateralCacheAttributes) lac.clone();
+ final ITCPLateralCacheAttributes lacC = (ITCPLateralCacheAttributes) lac.clone();
lacC.setTcpServer( server );
- LateralCacheNoWait<K, V> lateralNoWait = createCacheNoWait(lacC, cacheEventLogger, elementSerializer);
+ final LateralCacheNoWait<K, V> lateralNoWait = createCacheNoWait(lacC, cacheEventLogger, elementSerializer);
addListenerIfNeeded( lacC, cacheMgr );
monitor.addCache(lateralNoWait);
@@ -112,12 +112,13 @@ public class LateralTCPCacheFactory
}
}
- ILateralCacheListener<K, V> listener = createListener( lac, cacheMgr );
+ final ILateralCacheListener<K, V> listener = createListener( lac, cacheMgr );
// create the no wait facade.
@SuppressWarnings("unchecked") // No generic arrays in java
+ final
LateralCacheNoWait<K, V>[] lcnwArray = noWaits.toArray( new LateralCacheNoWait[0] );
- LateralCacheNoWaitFacade<K, V> lcnwf =
+ final LateralCacheNoWaitFacade<K, V> lcnwf =
new LateralCacheNoWaitFacade<>(listener, lcnwArray, lac );
// create udp discovery if available.
@@ -126,18 +127,18 @@ public class LateralTCPCacheFactory
return lcnwf;
}
- protected <K, V> LateralCacheNoWait<K, V> createCacheNoWait( ITCPLateralCacheAttributes lca,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ protected <K, V> LateralCacheNoWait<K, V> createCacheNoWait( final ITCPLateralCacheAttributes lca,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
{
- ICacheServiceNonLocal<K, V> lateralService = getCSNLInstance(lca);
+ final ICacheServiceNonLocal<K, V> lateralService = getCSNLInstance(lca);
- LateralCache<K, V> cache = new LateralCache<>( lca, lateralService, this.monitor );
+ final LateralCache<K, V> cache = new LateralCache<>( lca, lateralService, this.monitor );
cache.setCacheEventLogger( cacheEventLogger );
cache.setElementSerializer( elementSerializer );
log.debug( "Created cache for noWait, cache [{0}]", cache );
- LateralCacheNoWait<K, V> lateralNoWait = new LateralCacheNoWait<>( cache );
+ final LateralCacheNoWait<K, V> lateralNoWait = new LateralCacheNoWait<>( cache );
lateralNoWait.setCacheEventLogger( cacheEventLogger );
lateralNoWait.setElementSerializer( elementSerializer );
@@ -171,13 +172,13 @@ public class LateralTCPCacheFactory
@Override
public void dispose()
{
- for (ICacheServiceNonLocal<?, ?> service : this.csnlInstances.values())
+ for (final ICacheServiceNonLocal<?, ?> service : this.csnlInstances.values())
{
try
{
service.dispose("");
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("Could not dispose service " + service, e);
}
@@ -195,7 +196,7 @@ public class LateralTCPCacheFactory
{
this.monitor.join(5000);
}
- catch (InterruptedException e)
+ catch (final InterruptedException e)
{
// swallow
}
@@ -212,9 +213,9 @@ public class LateralTCPCacheFactory
*/
// Need to cast because of common map for all cache services
@SuppressWarnings("unchecked")
- public <K, V> ICacheServiceNonLocal<K, V> getCSNLInstance( ITCPLateralCacheAttributes lca )
+ public <K, V> ICacheServiceNonLocal<K, V> getCSNLInstance( final ITCPLateralCacheAttributes lca )
{
- String key = lca.getTcpServer();
+ final String key = lca.getTcpServer();
csnlInstances.computeIfPresent(key, (name, service) -> {
// If service creation did not succeed last time, force retry
@@ -227,7 +228,7 @@ public class LateralTCPCacheFactory
return service;
});
- ICacheServiceNonLocal<K, V> service =
+ final ICacheServiceNonLocal<K, V> service =
(ICacheServiceNonLocal<K, V>) csnlInstances.computeIfAbsent(key, name -> {
log.info( "Instance for [{0}] is null, creating", name );
@@ -239,14 +240,14 @@ public class LateralTCPCacheFactory
return new LateralTCPService<>( lca );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
// Failed to connect to the lateral server.
// Configure this LateralCacheManager instance to use the
// "zombie" services.
log.error( "Failure, lateral instance will use zombie service", ex );
- ICacheServiceNonLocal<K, V> zombieService =
+ final ICacheServiceNonLocal<K, V> zombieService =
new ZombieCacheServiceNonLocal<>( lca.getZombieQueueMaxSize() );
// Notify the cache monitor about the error, and kick off
@@ -268,11 +269,11 @@ public class LateralTCPCacheFactory
*
* @return The instance value
*/
- private LateralTCPDiscoveryListener getDiscoveryListener(ITCPLateralCacheAttributes ilca, ICompositeCacheManager cacheManager)
+ private LateralTCPDiscoveryListener getDiscoveryListener(final ITCPLateralCacheAttributes ilca, final ICompositeCacheManager cacheManager)
{
- String key = ilca.getUdpDiscoveryAddr() + ":" + ilca.getUdpDiscoveryPort();
+ final String key = ilca.getUdpDiscoveryAddr() + ":" + ilca.getUdpDiscoveryPort();
- LateralTCPDiscoveryListener ins = lTCPDLInstances.computeIfAbsent(key, key1 -> {
+ final LateralTCPDiscoveryListener ins = lTCPDLInstances.computeIfAbsent(key, key1 -> {
log.info("Created new discovery listener for cacheName {0} for request {1}",
key1, ilca.getCacheName());
return new LateralTCPDiscoveryListener( this.getName(), cacheManager);
@@ -287,7 +288,7 @@ public class LateralTCPCacheFactory
* @param iaca cache configuration attributes
* @param cacheMgr the composite cache manager
*/
- private void addListenerIfNeeded( ITCPLateralCacheAttributes iaca, ICompositeCacheManager cacheMgr )
+ private void addListenerIfNeeded( final ITCPLateralCacheAttributes iaca, final ICompositeCacheManager cacheMgr )
{
// don't create a listener if we are not receiving.
if ( iaca.isReceive() )
@@ -297,7 +298,7 @@ public class LateralTCPCacheFactory
addLateralCacheListener( iaca.getCacheName(),
LateralTCPListener.getInstance( iaca, cacheMgr ) );
}
- catch ( IOException ioe )
+ catch ( final IOException ioe )
{
log.error("Problem creating lateral listener", ioe);
}
@@ -315,7 +316,7 @@ public class LateralTCPCacheFactory
* @param listener The feature to be added to the LateralCacheListener attribute
* @throws IOException
*/
- private <K, V> void addLateralCacheListener( String cacheName, ILateralCacheListener<K, V> listener )
+ private <K, V> void addLateralCacheListener( final String cacheName, final ILateralCacheListener<K, V> listener )
throws IOException
{
synchronized ( this.lateralWatch )
@@ -335,8 +336,8 @@ public class LateralTCPCacheFactory
*
* @return the listener if created, else null
*/
- private <K, V> ILateralCacheListener<K, V> createListener( ITCPLateralCacheAttributes attr,
- ICompositeCacheManager cacheMgr )
+ private <K, V> ILateralCacheListener<K, V> createListener( final ITCPLateralCacheAttributes attr,
+ final ICompositeCacheManager cacheMgr )
{
ILateralCacheListener<K, V> listener = null;
@@ -370,11 +371,11 @@ public class LateralTCPCacheFactory
* @return null if none is created.
*/
private synchronized <K, V> UDPDiscoveryService createDiscoveryService(
- ITCPLateralCacheAttributes lac,
- LateralCacheNoWaitFacade<K, V> lcnwf,
- ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger,
- IElementSerializer elementSerializer )
+ final ITCPLateralCacheAttributes lac,
+ final LateralCacheNoWaitFacade<K, V> lcnwf,
+ final ICompositeCacheManager cacheMgr,
+ final ICacheEventLogger cacheEventLogger,
+ final IElementSerializer elementSerializer )
{
UDPDiscoveryService discovery = null;
@@ -382,7 +383,7 @@ public class LateralTCPCacheFactory
if ( lac.isUdpDiscoveryEnabled() )
{
// One can be used for all regions
- LateralTCPDiscoveryListener discoveryListener = getDiscoveryListener( lac, cacheMgr );
+ final LateralTCPDiscoveryListener discoveryListener = getDiscoveryListener( lac, cacheMgr );
discoveryListener.addNoWaitFacade( lac.getCacheName(), lcnwf );
// need a factory for this so it doesn't
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
index a1f953f..131efec 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
@@ -73,7 +73,7 @@ public class LateralTCPDiscoveryListener
* @param factoryName the name of the related cache factory
* @param cacheManager the global cache manager
*/
- protected LateralTCPDiscoveryListener( String factoryName, ICompositeCacheManager cacheManager )
+ protected LateralTCPDiscoveryListener( final String factoryName, final ICompositeCacheManager cacheManager )
{
this.factoryName = factoryName;
this.cacheManager = cacheManager;
@@ -89,9 +89,9 @@ public class LateralTCPDiscoveryListener
* @param facade - facade (for region) => multiple lateral clients.
* @return true if the facade was not already registered.
*/
- public boolean addNoWaitFacade( String cacheName, LateralCacheNoWaitFacade<?, ?> facade )
+ public boolean addNoWaitFacade( final String cacheName, final LateralCacheNoWaitFacade<?, ?> facade )
{
- boolean isNew = !containsNoWaitFacade( cacheName );
+ final boolean isNew = !containsNoWaitFacade( cacheName );
// override or put anew, it doesn't matter
facades.put( cacheName, facade );
@@ -106,7 +106,7 @@ public class LateralTCPDiscoveryListener
* @param cacheName - facades are for a region
* @return do we contain the no wait. true if so
*/
- public boolean containsNoWaitFacade( String cacheName )
+ public boolean containsNoWaitFacade( final String cacheName )
{
return facades.containsKey( cacheName );
}
@@ -118,9 +118,10 @@ public class LateralTCPDiscoveryListener
* @param noWait - is this no wait in the facade
* @return do we contain the no wait. true if so
*/
- public <K, V> boolean containsNoWait( String cacheName, LateralCacheNoWait<K, V> noWait )
+ public <K, V> boolean containsNoWait( final String cacheName, final LateralCacheNoWait<K, V> noWait )
{
@SuppressWarnings("unchecked") // Need to cast because of common map for all facades
+ final
LateralCacheNoWaitFacade<K, V> facade =
(LateralCacheNoWaitFacade<K, V>)facades.get( noWait.getCacheName() );
@@ -144,16 +145,17 @@ public class LateralTCPDiscoveryListener
* @return true if we found the no wait and added it. False if the no wait was not present or if
* we already had it.
*/
- protected <K, V> boolean addNoWait( LateralCacheNoWait<K, V> noWait )
+ protected <K, V> boolean addNoWait( final LateralCacheNoWait<K, V> noWait )
{
@SuppressWarnings("unchecked") // Need to cast because of common map for all facades
+ final
LateralCacheNoWaitFacade<K, V> facade =
(LateralCacheNoWaitFacade<K, V>)facades.get( noWait.getCacheName() );
log.debug( "addNoWait > Got facade for {0} = {1}", noWait.getCacheName(), facade );
if ( facade != null )
{
- boolean isNew = facade.addNoWait( noWait );
+ final boolean isNew = facade.addNoWait( noWait );
log.debug( "Called addNoWait, isNew = {0}", isNew );
return isNew;
}
@@ -176,16 +178,17 @@ public class LateralTCPDiscoveryListener
* @param noWait
* @return true if we found the no wait and removed it. False if the no wait was not present.
*/
- protected <K, V> boolean removeNoWait( LateralCacheNoWait<K, V> noWait )
+ protected <K, V> boolean removeNoWait( final LateralCacheNoWait<K, V> noWait )
{
@SuppressWarnings("unchecked") // Need to cast because of common map for all facades
+ final
LateralCacheNoWaitFacade<K, V> facade =
(LateralCacheNoWaitFacade<K, V>)facades.get( noWait.getCacheName() );
log.debug( "removeNoWait > Got facade for {0} = {1}", noWait.getCacheName(), facade);
if ( facade != null )
{
- boolean removed = facade.removeNoWait( noWait );
+ final boolean removed = facade.removeNoWait( noWait );
log.debug( "Called removeNoWait, removed {0}", removed );
return removed;
}
@@ -218,30 +221,30 @@ public class LateralTCPDiscoveryListener
* @param service
*/
@Override
- public void addDiscoveredService( DiscoveredService service )
+ public void addDiscoveredService( final DiscoveredService service )
{
// get a cache and add it to the no waits
// the add method should not add the same.
// we need the listener port from the original config.
- ArrayList<String> regions = service.getCacheNames();
- String serverAndPort = service.getServiceAddress() + ":" + service.getServicePort();
+ final ArrayList<String> regions = service.getCacheNames();
+ final String serverAndPort = service.getServiceAddress() + ":" + service.getServicePort();
if ( regions != null )
{
// for each region get the cache
- for (String cacheName : regions)
+ for (final String cacheName : regions)
{
- AuxiliaryCache<?, ?> ic = cacheManager.getAuxiliaryCache(factoryName, cacheName);
+ final AuxiliaryCache<?, ?> ic = cacheManager.getAuxiliaryCache(factoryName, cacheName);
log.debug( "Got cache, ic = {0}", ic );
// add this to the nowaits for this cachename
if ( ic != null )
{
- AuxiliaryCacheAttributes aca = ic.getAuxiliaryCacheAttributes();
+ final AuxiliaryCacheAttributes aca = ic.getAuxiliaryCacheAttributes();
if (aca instanceof ITCPLateralCacheAttributes)
{
- ITCPLateralCacheAttributes lca = (ITCPLateralCacheAttributes)aca;
+ final ITCPLateralCacheAttributes lca = (ITCPLateralCacheAttributes)aca;
if (lca.getTransmissionType() != LateralCacheAttributes.Type.TCP
|| !serverAndPort.equals(lca.getTcpServer()) )
{
@@ -270,30 +273,30 @@ public class LateralTCPDiscoveryListener
* @param service
*/
@Override
- public void removeDiscoveredService( DiscoveredService service )
+ public void removeDiscoveredService( final DiscoveredService service )
{
// get a cache and add it to the no waits
// the add method should not add the same.
// we need the listener port from the original config.
- ArrayList<String> regions = service.getCacheNames();
- String serverAndPort = service.getServiceAddress() + ":" + service.getServicePort();
+ final ArrayList<String> regions = service.getCacheNames();
+ final String serverAndPort = service.getServiceAddress() + ":" + service.getServicePort();
if ( regions != null )
{
// for each region get the cache
- for (String cacheName : regions)
+ for (final String cacheName : regions)
{
- AuxiliaryCache<?, ?> ic = cacheManager.getAuxiliaryCache(factoryName, cacheName);
+ final AuxiliaryCache<?, ?> ic = cacheManager.getAuxiliaryCache(factoryName, cacheName);
log.debug( "Got cache, ic = {0}", ic );
// remove this to the nowaits for this cachename
if ( ic != null )
{
- AuxiliaryCacheAttributes aca = ic.getAuxiliaryCacheAttributes();
+ final AuxiliaryCacheAttributes aca = ic.getAuxiliaryCacheAttributes();
if (aca instanceof ITCPLateralCacheAttributes)
{
- ITCPLateralCacheAttributes lca = (ITCPLateralCacheAttributes)aca;
+ final ITCPLateralCacheAttributes lca = (ITCPLateralCacheAttributes)aca;
if (lca.getTransmissionType() != LateralCacheAttributes.Type.TCP
|| !serverAndPort.equals(lca.getTcpServer()) )
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
index 7356c14..899ce2c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPListener.java
@@ -110,13 +110,14 @@ public class LateralTCPListener<K, V>
* @return The instance value
*/
public static <K, V> LateralTCPListener<K, V>
- getInstance( ITCPLateralCacheAttributes ilca, ICompositeCacheManager cacheMgr )
+ getInstance( final ITCPLateralCacheAttributes ilca, final ICompositeCacheManager cacheMgr )
{
@SuppressWarnings("unchecked") // Need to cast because of common map for all instances
+ final
LateralTCPListener<K, V> ins = (LateralTCPListener<K, V>) instances.computeIfAbsent(
String.valueOf( ilca.getTcpListenerPort() ),
k -> {
- LateralTCPListener<K, V> newIns = new LateralTCPListener<>( ilca );
+ final LateralTCPListener<K, V> newIns = new LateralTCPListener<>( ilca );
newIns.init();
newIns.setCacheManager( cacheMgr );
@@ -135,7 +136,7 @@ public class LateralTCPListener<K, V>
* <p>
* @param ilca
*/
- protected LateralTCPListener( ITCPLateralCacheAttributes ilca )
+ protected LateralTCPListener( final ITCPLateralCacheAttributes ilca )
{
this.setTcpLateralCacheAttributes( ilca );
}
@@ -148,8 +149,8 @@ public class LateralTCPListener<K, V>
{
try
{
- int port = getTcpLateralCacheAttributes().getTcpListenerPort();
- String host = getTcpLateralCacheAttributes().getTcpListenerHost();
+ final int port = getTcpLateralCacheAttributes().getTcpListenerPort();
+ final String host = getTcpLateralCacheAttributes().getTcpListenerHost();
pooledExecutor = Executors.newCachedThreadPool(
new DaemonThreadFactory("JCS-LateralTCPListener-"));
@@ -161,9 +162,9 @@ public class LateralTCPListener<K, V>
{
log.info( "Listening on {0}:{1}", host, port );
// Resolve host name
- InetAddress inetAddress = InetAddress.getByName(host);
+ final InetAddress inetAddress = InetAddress.getByName(host);
//Bind the SocketAddress with inetAddress and port
- SocketAddress endPoint = new InetSocketAddress(inetAddress, port);
+ final SocketAddress endPoint = new InetSocketAddress(inetAddress, port);
serverSocket = new ServerSocket();
serverSocket.bind(endPoint);
@@ -179,7 +180,7 @@ public class LateralTCPListener<K, V>
receiver.setDaemon( true );
receiver.start();
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
throw new IllegalStateException( ex );
}
@@ -201,7 +202,7 @@ public class LateralTCPListener<K, V>
* @throws IOException
*/
@Override
- public void setListenerId( long id )
+ public void setListenerId( final long id )
throws IOException
{
this.listenerId = id;
@@ -228,7 +229,7 @@ public class LateralTCPListener<K, V>
* @see org.apache.commons.jcs3.engine.behavior.ICacheListener#handlePut(org.apache.commons.jcs3.engine.behavior.ICacheElement)
*/
@Override
- public void handlePut( ICacheElement<K, V> element )
+ public void handlePut( final ICacheElement<K, V> element )
throws IOException
{
putCnt++;
@@ -253,7 +254,7 @@ public class LateralTCPListener<K, V>
* Object)
*/
@Override
- public void handleRemove( String cacheName, K key )
+ public void handleRemove( final String cacheName, final K key )
throws IOException
{
removeCnt++;
@@ -273,7 +274,7 @@ public class LateralTCPListener<K, V>
* @see org.apache.commons.jcs3.engine.behavior.ICacheListener#handleRemoveAll(java.lang.String)
*/
@Override
- public void handleRemoveAll( String cacheName )
+ public void handleRemoveAll( final String cacheName )
throws IOException
{
log.debug( "handleRemoveAll> cacheName={0}", cacheName );
@@ -289,7 +290,7 @@ public class LateralTCPListener<K, V>
* @return a ICacheElement
* @throws IOException
*/
- public ICacheElement<K, V> handleGet( String cacheName, K key )
+ public ICacheElement<K, V> handleGet( final String cacheName, final K key )
throws IOException
{
getCnt++;
@@ -313,7 +314,7 @@ public class LateralTCPListener<K, V>
* @return Map
* @throws IOException
*/
- public Map<K, ICacheElement<K, V>> handleGetMatching( String cacheName, String pattern )
+ public Map<K, ICacheElement<K, V>> handleGetMatching( final String cacheName, final String pattern )
throws IOException
{
getCnt++;
@@ -336,7 +337,7 @@ public class LateralTCPListener<K, V>
* @return a set of keys
* @throws IOException
*/
- public Set<K> handleGetKeySet( String cacheName ) throws IOException
+ public Set<K> handleGetKeySet( final String cacheName ) throws IOException
{
return getCache( cacheName ).getKeySet(true);
}
@@ -347,7 +348,7 @@ public class LateralTCPListener<K, V>
* @see org.apache.commons.jcs3.engine.behavior.ICacheListener#handleDispose(java.lang.String)
*/
@Override
- public void handleDispose( String cacheName )
+ public void handleDispose( final String cacheName )
throws IOException
{
log.info( "handleDispose > cacheName={0} | Ignoring message. "
@@ -375,7 +376,7 @@ public class LateralTCPListener<K, V>
* @param name
* @return CompositeCache
*/
- protected CompositeCache<K, V> getCache( String name )
+ protected CompositeCache<K, V> getCache( final String name )
{
return getCacheManager().getCache( name );
}
@@ -410,7 +411,7 @@ public class LateralTCPListener<K, V>
* @param cacheMgr The cacheMgr to set.
*/
@Override
- public void setCacheManager( ICompositeCacheManager cacheMgr )
+ public void setCacheManager( final ICompositeCacheManager cacheMgr )
{
this.cacheManager = cacheMgr;
}
@@ -427,7 +428,7 @@ public class LateralTCPListener<K, V>
/**
* @param tcpLateralCacheAttributes The tcpLateralCacheAttributes to set.
*/
- public void setTcpLateralCacheAttributes( ITCPLateralCacheAttributes tcpLateralCacheAttributes )
+ public void setTcpLateralCacheAttributes( final ITCPLateralCacheAttributes tcpLateralCacheAttributes )
{
this.tcpLateralCacheAttributes = tcpLateralCacheAttributes;
}
@@ -455,7 +456,7 @@ public class LateralTCPListener<K, V>
*
* @param serverSocket
*/
- public ListenerThread(ServerSocket serverSocket)
+ public ListenerThread(final ServerSocket serverSocket)
{
this.serverSocket = serverSocket;
}
@@ -488,7 +489,7 @@ public class LateralTCPListener<K, V>
socket = ssck.accept();
break inner;
}
- catch (SocketTimeoutException e)
+ catch (final SocketTimeoutException e)
{
// No problem! We loop back up!
continue inner;
@@ -497,7 +498,7 @@ public class LateralTCPListener<K, V>
if ( socket != null && log.isDebugEnabled() )
{
- InetAddress inetAddress = socket.getInetAddress();
+ final InetAddress inetAddress = socket.getInetAddress();
log.debug( "Connected to client at {0}", inetAddress );
}
@@ -505,7 +506,7 @@ public class LateralTCPListener<K, V>
pooledExecutor.execute( handler );
}
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( "Exception caught in TCP listener", e );
}
@@ -525,7 +526,7 @@ public class LateralTCPListener<K, V>
* Construct for a given socket
* @param socket
*/
- public ConnectionHandler( Socket socket )
+ public ConnectionHandler( final Socket socket )
{
this.socket = socket;
}
@@ -543,7 +544,7 @@ public class LateralTCPListener<K, V>
{
while ( true )
{
- LateralElementDescriptor<K, V> led =
+ final LateralElementDescriptor<K, V> led =
(LateralElementDescriptor<K, V>) ois.readObject();
if ( led == null )
@@ -564,15 +565,15 @@ public class LateralTCPListener<K, V>
}
}
}
- catch ( EOFException e )
+ catch ( final EOFException e )
{
log.info( "Caught EOFException, closing connection.", e );
}
- catch ( SocketException e )
+ catch ( final SocketException e )
{
log.info( "Caught SocketException, closing connection.", e );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( "Unexpected exception.", e );
}
@@ -586,11 +587,11 @@ public class LateralTCPListener<K, V>
* @throws IOException
*/
@SuppressWarnings("synthetic-access")
- private void handle( LateralElementDescriptor<K, V> led )
+ private void handle( final LateralElementDescriptor<K, V> led )
throws IOException
{
- String cacheName = led.ce.getCacheName();
- K key = led.ce.getKey();
+ final String cacheName = led.ce.getCacheName();
+ final K key = led.ce.getKey();
Serializable obj = null;
switch (led.command)
@@ -607,7 +608,7 @@ public class LateralTCPListener<K, V>
{
if ( getTcpLateralCacheAttributes().isFilterRemoveByHashCode() )
{
- ICacheElement<K, V> test = getCache( cacheName ).localGet( key );
+ final ICacheElement<K, V> test = getCache( cacheName ).localGet( key );
if ( test != null )
{
if ( test.getVal().hashCode() == led.valHashCode )
@@ -649,7 +650,7 @@ public class LateralTCPListener<K, V>
if (obj != null)
{
- ObjectOutputStream oos = new ObjectOutputStream( socket.getOutputStream() );
+ final ObjectOutputStream oos = new ObjectOutputStream( socket.getOutputStream() );
oos.writeObject( obj );
oos.flush();
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPSender.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPSender.java
index 3f42065..acac70d 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPSender.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPSender.java
@@ -62,20 +62,20 @@ public class LateralTCPSender
* @param lca
* @throws IOException
*/
- public LateralTCPSender( ITCPLateralCacheAttributes lca )
+ public LateralTCPSender( final ITCPLateralCacheAttributes lca )
throws IOException
{
this.socketOpenTimeOut = lca.getOpenTimeOut();
this.socketSoTimeOut = lca.getSocketTimeOut();
- String p1 = lca.getTcpServer();
+ final String p1 = lca.getTcpServer();
if ( p1 == null )
{
throw new IOException( "Invalid server (null)" );
}
- String h2 = p1.substring( 0, p1.indexOf( ":" ) );
- int po = Integer.parseInt( p1.substring( p1.indexOf( ":" ) + 1 ) );
+ final String h2 = p1.substring( 0, p1.indexOf( ":" ) );
+ final int po = Integer.parseInt( p1.substring( p1.indexOf( ":" ) + 1 ) );
log.debug( "h2 = {0}, po = {1}", h2, po );
if ( h2.length() == 0 )
@@ -93,7 +93,7 @@ public class LateralTCPSender
* @param port
* @throws IOException
*/
- protected void init( String host, int port )
+ protected void init( final String host, final int port )
throws IOException
{
try
@@ -106,7 +106,7 @@ public class LateralTCPSender
socket = new Socket();
socket.connect( new InetSocketAddress( host, port ), this.socketOpenTimeOut );
}
- catch ( IOException ioe )
+ catch ( final IOException ioe )
{
if (socket != null)
{
@@ -122,12 +122,12 @@ public class LateralTCPSender
oos = new ObjectOutputStream( socket.getOutputStream() );
}
}
- catch ( java.net.ConnectException e )
+ catch ( final java.net.ConnectException e )
{
log.debug( "Remote host [{0}] refused connection.", host );
throw e;
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.debug( "Could not connect to [{0}]", host, e );
throw e;
@@ -140,7 +140,7 @@ public class LateralTCPSender
* @param led
* @throws IOException
*/
- public <K, V> void send( LateralElementDescriptor<K, V> led )
+ public <K, V> void send( final LateralElementDescriptor<K, V> led )
throws IOException
{
sendCnt++;
@@ -178,7 +178,7 @@ public class LateralTCPSender
* @return ICacheElement
* @throws IOException
*/
- public <K, V> Object sendAndReceive( LateralElementDescriptor<K, V> led )
+ public <K, V> Object sendAndReceive( final LateralElementDescriptor<K, V> led )
throws IOException
{
if ( led == null )
@@ -209,7 +209,7 @@ public class LateralTCPSender
socket.getInputStream().read( new byte[socket.getInputStream().available()] );
}
}
- catch ( IOException ioe )
+ catch ( final IOException ioe )
{
log.error( "Problem cleaning socket before send {0}", socket, ioe );
throw ioe;
@@ -224,15 +224,15 @@ public class LateralTCPSender
socket.setSoTimeout( socketSoTimeOut );
response = ois.readObject();
}
- catch ( IOException ioe )
+ catch ( final IOException ioe )
{
- String message = "Could not open ObjectInputStream to " + socket +
+ final String message = "Could not open ObjectInputStream to " + socket +
" SoTimeout [" + socket.getSoTimeout() +
"] Connected [" + socket.isConnected() + "]";
log.error( message, ioe );
throw ioe;
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( e );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPService.java
index 0e89e4b..5173b83 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPService.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/LateralTCPService.java
@@ -65,7 +65,7 @@ public class LateralTCPService<K, V>
* @param lca ITCPLateralCacheAttributes
* @throws IOException
*/
- public LateralTCPService( ITCPLateralCacheAttributes lca )
+ public LateralTCPService( final ITCPLateralCacheAttributes lca )
throws IOException
{
this.allowGet = lca.isAllowGet();
@@ -78,7 +78,7 @@ public class LateralTCPService<K, V>
log.debug( "Created sender to [{0}]", () -> lca.getTcpServer() );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
// log.error( "Could not create sender", e );
// This gets thrown over and over in recovery mode.
@@ -93,7 +93,7 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> item )
+ public void update( final ICacheElement<K, V> item )
throws IOException
{
update( item, getListenerId() );
@@ -108,7 +108,7 @@ public class LateralTCPService<K, V>
* long)
*/
@Override
- public void update( ICacheElement<K, V> item, long requesterId )
+ public void update( final ICacheElement<K, V> item, final long requesterId )
throws IOException
{
// if we don't allow put, see if we should remove on put
@@ -122,7 +122,7 @@ public class LateralTCPService<K, V>
// if we shouldn't remove on put, then put
if ( !this.issueRemoveOnPut )
{
- LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( item );
+ final LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( item );
led.requesterId = requesterId;
led.command = LateralCommand.UPDATE;
sender.send( led );
@@ -134,8 +134,8 @@ public class LateralTCPService<K, V>
log.debug( "Issuing a remove for a put" );
// set the value to null so we don't send the item
- CacheElement<K, V> ce = new CacheElement<>( item.getCacheName(), item.getKey(), null );
- LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
+ final CacheElement<K, V> ce = new CacheElement<>( item.getCacheName(), item.getKey(), null );
+ final LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
led.requesterId = requesterId;
led.command = LateralCommand.REMOVE;
led.valHashCode = item.getVal().hashCode();
@@ -149,7 +149,7 @@ public class LateralTCPService<K, V>
* @see org.apache.commons.jcs3.engine.behavior.ICacheService#remove(String, Object)
*/
@Override
- public void remove( String cacheName, K key )
+ public void remove( final String cacheName, final K key )
throws IOException
{
remove( cacheName, key, getListenerId() );
@@ -161,11 +161,11 @@ public class LateralTCPService<K, V>
* @see org.apache.commons.jcs3.engine.behavior.ICacheServiceNonLocal#remove(String, Object, long)
*/
@Override
- public void remove( String cacheName, K key, long requesterId )
+ public void remove( final String cacheName, final K key, final long requesterId )
throws IOException
{
- CacheElement<K, V> ce = new CacheElement<>( cacheName, key, null );
- LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
+ final CacheElement<K, V> ce = new CacheElement<>( cacheName, key, null );
+ final LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
led.requesterId = requesterId;
led.command = LateralCommand.REMOVE;
sender.send( led );
@@ -190,7 +190,7 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public void dispose( String cacheName )
+ public void dispose( final String cacheName )
throws IOException
{
sender.dispose();
@@ -203,7 +203,7 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> get( String cacheName, K key )
+ public ICacheElement<K, V> get( final String cacheName, final K key )
throws IOException
{
return get( cacheName, key, getListenerId() );
@@ -219,17 +219,18 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> get( String cacheName, K key, long requesterId )
+ public ICacheElement<K, V> get( final String cacheName, final K key, final long requesterId )
throws IOException
{
// if get is not allowed return
if ( this.allowGet )
{
- CacheElement<K, V> ce = new CacheElement<>( cacheName, key, null );
- LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
+ final CacheElement<K, V> ce = new CacheElement<>( cacheName, key, null );
+ final LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
// led.requesterId = requesterId; // later
led.command = LateralCommand.GET;
@SuppressWarnings("unchecked") // Need to cast from Object
+ final
ICacheElement<K, V> response = (ICacheElement<K, V>)sender.sendAndReceive( led );
return response;
}
@@ -250,7 +251,7 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( final String cacheName, final String pattern )
throws IOException
{
return getMatching( cacheName, pattern, getListenerId() );
@@ -268,18 +269,18 @@ public class LateralTCPService<K, V>
*/
@Override
@SuppressWarnings("unchecked") // Need to cast from Object
- public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMatching( final String cacheName, final String pattern, final long requesterId )
throws IOException
{
// if get is not allowed return
if ( this.allowGet )
{
- CacheElement<String, String> ce = new CacheElement<>( cacheName, pattern, null );
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
+ final CacheElement<String, String> ce = new CacheElement<>( cacheName, pattern, null );
+ final LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
// led.requesterId = requesterId; // later
led.command = LateralCommand.GET_MATCHING;
- Object response = sender.sendAndReceive( led );
+ final Object response = sender.sendAndReceive( led );
if ( response != null )
{
return (Map<K, ICacheElement<K, V>>) response;
@@ -303,7 +304,7 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys )
+ public Map<K, ICacheElement<K, V>> getMultiple( final String cacheName, final Set<K> keys )
throws IOException
{
return getMultiple( cacheName, keys, getListenerId() );
@@ -322,16 +323,16 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMultiple( final String cacheName, final Set<K> keys, final long requesterId )
throws IOException
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<>();
+ final Map<K, ICacheElement<K, V>> elements = new HashMap<>();
if ( keys != null && !keys.isEmpty() )
{
- for (K key : keys)
+ for (final K key : keys)
{
- ICacheElement<K, V> element = get( cacheName, key );
+ final ICacheElement<K, V> element = get( cacheName, key );
if ( element != null )
{
@@ -350,13 +351,13 @@ public class LateralTCPService<K, V>
*/
@Override
@SuppressWarnings("unchecked") // Need cast from Object
- public Set<K> getKeySet(String cacheName) throws IOException
+ public Set<K> getKeySet(final String cacheName) throws IOException
{
- CacheElement<String, String> ce = new CacheElement<>(cacheName, null, null);
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>(ce);
+ final CacheElement<String, String> ce = new CacheElement<>(cacheName, null, null);
+ final LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>(ce);
// led.requesterId = requesterId; // later
led.command = LateralCommand.GET_KEYSET;
- Object response = sender.sendAndReceive(led);
+ final Object response = sender.sendAndReceive(led);
if (response != null)
{
return (Set<K>) response;
@@ -370,7 +371,7 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public void removeAll( String cacheName )
+ public void removeAll( final String cacheName )
throws IOException
{
removeAll( cacheName, getListenerId() );
@@ -382,11 +383,11 @@ public class LateralTCPService<K, V>
* @throws IOException
*/
@Override
- public void removeAll( String cacheName, long requesterId )
+ public void removeAll( final String cacheName, final long requesterId )
throws IOException
{
- CacheElement<String, String> ce = new CacheElement<>( cacheName, "ALL", null );
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
+ final CacheElement<String, String> ce = new CacheElement<>( cacheName, "ALL", null );
+ final LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
led.requesterId = requesterId;
led.command = LateralCommand.REMOVEALL;
sender.send( led );
@@ -395,17 +396,17 @@ public class LateralTCPService<K, V>
/**
* @param args
*/
- public static void main( String args[] )
+ public static void main( final String args[] )
{
try
{
- LateralTCPSender sender = new LateralTCPSender( new TCPLateralCacheAttributes() );
+ final LateralTCPSender sender = new LateralTCPSender( new TCPLateralCacheAttributes() );
// process user input till done
boolean notDone = true;
String message = null;
// wait to dispose
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
+ final BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
while ( notDone )
{
@@ -418,12 +419,12 @@ public class LateralTCPService<K, V>
continue;
}
- CacheElement<String, String> ce = new CacheElement<>( "test", "test", message );
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
+ final CacheElement<String, String> ce = new CacheElement<>( "test", "test", message );
+ final LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
sender.send( led );
}
}
- catch ( IOException e )
+ catch ( final IOException e )
{
System.out.println( e.toString() );
}
@@ -432,7 +433,7 @@ public class LateralTCPService<K, V>
/**
* @param listernId The listernId to set.
*/
- protected void setListenerId( long listernId )
+ protected void setListenerId( final long listernId )
{
this.listenerId = listernId;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java
index 9fcb5c6..935dc45 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/lateral/socket/tcp/TCPLateralCacheAttributes.java
@@ -105,7 +105,7 @@ public class TCPLateralCacheAttributes
* @param val The new tcpServer value
*/
@Override
- public void setTcpServer( String val )
+ public void setTcpServer( final String val )
{
this.tcpServer = val;
}
@@ -127,7 +127,7 @@ public class TCPLateralCacheAttributes
* @param val The new tcpServers value
*/
@Override
- public void setTcpServers( String val )
+ public void setTcpServers( final String val )
{
this.tcpServers = val;
}
@@ -149,7 +149,7 @@ public class TCPLateralCacheAttributes
* @param val The new tcpListenerPort value
*/
@Override
- public void setTcpListenerPort( int val )
+ public void setTcpListenerPort( final int val )
{
this.tcpListenerPort = val;
}
@@ -172,7 +172,7 @@ public class TCPLateralCacheAttributes
* The new tcpListenerHost value
*/
@Override
- public void setTcpListenerHost( String val )
+ public void setTcpListenerHost( final String val )
{
this.tcpListenerHost = val;
}
@@ -195,7 +195,7 @@ public class TCPLateralCacheAttributes
* @param udpDiscoveryEnabled The udpDiscoveryEnabled to set.
*/
@Override
- public void setUdpDiscoveryEnabled( boolean udpDiscoveryEnabled )
+ public void setUdpDiscoveryEnabled( final boolean udpDiscoveryEnabled )
{
this.udpDiscoveryEnabled = udpDiscoveryEnabled;
}
@@ -228,7 +228,7 @@ public class TCPLateralCacheAttributes
* @param udpDiscoveryPort The udpDiscoveryPort to set.
*/
@Override
- public void setUdpDiscoveryPort( int udpDiscoveryPort )
+ public void setUdpDiscoveryPort( final int udpDiscoveryPort )
{
this.udpDiscoveryPort = udpDiscoveryPort;
}
@@ -250,7 +250,7 @@ public class TCPLateralCacheAttributes
* @param udpDiscoveryAddr The udpDiscoveryAddr to set.
*/
@Override
- public void setUdpDiscoveryAddr( String udpDiscoveryAddr )
+ public void setUdpDiscoveryAddr( final String udpDiscoveryAddr )
{
this.udpDiscoveryAddr = udpDiscoveryAddr;
}
@@ -263,7 +263,7 @@ public class TCPLateralCacheAttributes
* @param allowGet
*/
@Override
- public void setAllowGet( boolean allowGet )
+ public void setAllowGet( final boolean allowGet )
{
this.allowGet = allowGet;
}
@@ -285,7 +285,7 @@ public class TCPLateralCacheAttributes
* @param allowPut
*/
@Override
- public void setAllowPut( boolean allowPut )
+ public void setAllowPut( final boolean allowPut )
{
this.allowPut = allowPut;
}
@@ -309,7 +309,7 @@ public class TCPLateralCacheAttributes
* @param issueRemoveOnPut
*/
@Override
- public void setIssueRemoveOnPut( boolean issueRemoveOnPut )
+ public void setIssueRemoveOnPut( final boolean issueRemoveOnPut )
{
this.issueRemoveOnPut = issueRemoveOnPut;
}
@@ -352,7 +352,7 @@ public class TCPLateralCacheAttributes
* @param filter
*/
@Override
- public void setFilterRemoveByHashCode( boolean filter )
+ public void setFilterRemoveByHashCode( final boolean filter )
{
this.filterRemoveByHashCode = filter;
}
@@ -361,7 +361,7 @@ public class TCPLateralCacheAttributes
* @param socketTimeOut the socketTimeOut to set
*/
@Override
- public void setSocketTimeOut( int socketTimeOut )
+ public void setSocketTimeOut( final int socketTimeOut )
{
this.socketTimeOut = socketTimeOut;
}
@@ -379,7 +379,7 @@ public class TCPLateralCacheAttributes
* @param openTimeOut the openTimeOut to set
*/
@Override
- public void setOpenTimeOut( int openTimeOut )
+ public void setOpenTimeOut( final int openTimeOut )
{
this.openTimeOut = openTimeOut;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
index 66009a6..f4a7d1e 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
@@ -89,8 +89,8 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
* @param remote
* @param listener
*/
- public AbstractRemoteAuxiliaryCache( IRemoteCacheAttributes cattr, ICacheServiceNonLocal<K, V> remote,
- IRemoteCacheListener<K, V> listener )
+ public AbstractRemoteAuxiliaryCache( final IRemoteCacheAttributes cattr, final ICacheServiceNonLocal<K, V> remote,
+ final IRemoteCacheListener<K, V> listener )
{
this.setRemoteCacheAttributes( cattr );
this.cacheName = cattr.getCacheName();
@@ -134,7 +134,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
getRemoteCacheListener().dispose();
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( "Couldn't dispose", ex );
handleException( ex, "Failed to dispose [" + cacheName + "]", ICacheEventLogger.DISPOSE_EVENT );
@@ -155,7 +155,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
* @throws IOException
*/
@Override
- protected ICacheElement<K, V> processGet( K key )
+ protected ICacheElement<K, V> processGet( final K key )
throws IOException
{
ICacheElement<K, V> retVal = null;
@@ -183,7 +183,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
}
}
}
- catch ( Exception ex )
+ catch ( final Exception ex )
{
handleException( ex, "Failed to get [" + key + "] from [" + cacheName + "]", ICacheEventLogger.GET_EVENT );
}
@@ -200,17 +200,17 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
public ICacheElement<K, V> getUsingPool( final K key )
throws IOException
{
- int timeout = getRemoteCacheAttributes().getGetTimeoutMillis();
+ final int timeout = getRemoteCacheAttributes().getGetTimeoutMillis();
try
{
- Callable<ICacheElement<K, V>> command = () -> getRemoteCacheService().get( cacheName, key, getListenerId() );
+ final Callable<ICacheElement<K, V>> command = () -> getRemoteCacheService().get( cacheName, key, getListenerId() );
// execute using the pool
- Future<ICacheElement<K, V>> future = pool.submit(command);
+ final Future<ICacheElement<K, V>> future = pool.submit(command);
// used timed get in order to timeout
- ICacheElement<K, V> ice = future.get(timeout, TimeUnit.MILLISECONDS);
+ final ICacheElement<K, V> ice = future.get(timeout, TimeUnit.MILLISECONDS);
if ( ice == null )
{
@@ -222,17 +222,17 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
}
return ice;
}
- catch ( TimeoutException te )
+ catch ( final TimeoutException te )
{
log.warn( "TimeoutException, Get Request timed out after {0}", timeout );
throw new IOException( "Get Request timed out after " + timeout );
}
- catch ( InterruptedException ex )
+ catch ( final InterruptedException ex )
{
log.warn( "InterruptedException, Get Request timed out after {0}", timeout );
throw new IOException( "Get Request timed out after " + timeout );
}
- catch (ExecutionException ex)
+ catch (final ExecutionException ex)
{
// assume that this is an IOException thrown by the callable.
log.error( "ExecutionException, Assuming an IO exception thrown in the background.", ex );
@@ -248,18 +248,18 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
+ public Map<K, ICacheElement<K, V>> processGetMatching( final String pattern )
throws IOException
{
- Map<K, ICacheElement<K, V>> results = new HashMap<>();
+ final Map<K, ICacheElement<K, V>> results = new HashMap<>();
try
{
- Map<K, ICacheElement<K, V>> rawResults = getRemoteCacheService().getMatching( cacheName, pattern, getListenerId() );
+ final Map<K, ICacheElement<K, V>> rawResults = getRemoteCacheService().getMatching( cacheName, pattern, getListenerId() );
// Eventually the instance of will not be necessary.
if ( rawResults != null )
{
- for (Map.Entry<K, ICacheElement<K, V>> entry : rawResults.entrySet())
+ for (final Map.Entry<K, ICacheElement<K, V>> entry : rawResults.entrySet())
{
ICacheElement<K, V> unwrappedResult = null;
if ( entry.getValue() instanceof ICacheElementSerialized )
@@ -282,7 +282,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
}
}
}
- catch ( Exception ex )
+ catch ( final Exception ex )
{
handleException( ex, "Failed to getMatching [" + pattern + "] from [" + cacheName + "]",
ICacheEventLogger.GET_EVENT );
@@ -299,7 +299,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
* @throws IOException
*/
@Override
- protected boolean processRemove( K key )
+ protected boolean processRemove( final K key )
throws IOException
{
if ( !this.getRemoteCacheAttributes().getGetOnly() )
@@ -309,7 +309,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
{
getRemoteCacheService().remove( cacheName, key, getListenerId() );
}
- catch ( Exception ex )
+ catch ( final Exception ex )
{
handleException( ex, "Failed to remove " + key + " from " + cacheName, ICacheEventLogger.REMOVE_EVENT );
}
@@ -334,7 +334,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
{
getRemoteCacheService().removeAll( cacheName, getListenerId() );
}
- catch ( Exception ex )
+ catch ( final Exception ex )
{
handleException( ex, "Failed to remove all from " + cacheName, ICacheEventLogger.REMOVEALL_EVENT );
}
@@ -350,7 +350,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
* @throws IOException
*/
@Override
- protected void processUpdate( ICacheElement<K, V> ce )
+ protected void processUpdate( final ICacheElement<K, V> ce )
throws IOException
{
if ( !getRemoteCacheAttributes().getGetOnly() )
@@ -366,11 +366,11 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
remoteCacheService.update( serialized, getListenerId() );
}
- catch ( NullPointerException npe )
+ catch ( final NullPointerException npe )
{
log.error( "npe for ce = {0} ce.attr = {1}", ce, ce.getElementAttributes(), npe );
}
- catch ( Exception ex )
+ catch ( final Exception ex )
{
// event queue will wait and retry
handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName(),
@@ -414,7 +414,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
* <p>
* @param id The new listenerId value
*/
- public void setListenerId( long id )
+ public void setListenerId( final long id )
{
if ( getRemoteCacheListener() != null )
{
@@ -424,7 +424,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
log.debug( "set listenerId = {0}", id );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( "Problem setting listenerId", e );
}
@@ -446,7 +446,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
log.debug( "get listenerId = {0}", getRemoteCacheListener().getListenerId() );
return getRemoteCacheListener().getListenerId();
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( "Problem getting listenerId", e );
}
@@ -492,10 +492,10 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "AbstractRemoteAuxiliaryCache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
elems.add(new StatElement<>( "Remote Type", this.getRemoteCacheAttributes().getRemoteTypeName() ) );
@@ -540,27 +540,28 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
* @param restoredRemote ICacheServiceNonLocal -- the remote server or proxy to the remote server
*/
@Override
- public void fixCache( ICacheServiceNonLocal<?, ?> restoredRemote )
+ public void fixCache( final ICacheServiceNonLocal<?, ?> restoredRemote )
{
@SuppressWarnings("unchecked") // Don't know how to do this properly
+ final
ICacheServiceNonLocal<K, V> remote = (ICacheServiceNonLocal<K, V>)restoredRemote;
- ICacheServiceNonLocal<K, V> prevRemote = getRemoteCacheService();
+ final ICacheServiceNonLocal<K, V> prevRemote = getRemoteCacheService();
if ( prevRemote instanceof ZombieCacheServiceNonLocal )
{
- ZombieCacheServiceNonLocal<K, V> zombie = (ZombieCacheServiceNonLocal<K, V>) prevRemote;
+ final ZombieCacheServiceNonLocal<K, V> zombie = (ZombieCacheServiceNonLocal<K, V>) prevRemote;
setRemoteCacheService( remote );
try
{
zombie.propagateEvents( remote );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
try
{
handleException( e, "Problem propagating events from Zombie Queue to new Remote Service.",
"fixCache" );
}
- catch ( IOException e1 )
+ catch ( final IOException e1 )
{
// swallow, since this is just expected kick back. Handle always throws
}
@@ -597,7 +598,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
/**
* @param remote the remote to set
*/
- protected void setRemoteCacheService( ICacheServiceNonLocal<K, V> remote )
+ protected void setRemoteCacheService( final ICacheServiceNonLocal<K, V> remote )
{
this.remoteCacheService = remote;
}
@@ -622,7 +623,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
/**
* @param remoteCacheAttributes the remoteCacheAttributes to set
*/
- protected void setRemoteCacheAttributes( IRemoteCacheAttributes remoteCacheAttributes )
+ protected void setRemoteCacheAttributes( final IRemoteCacheAttributes remoteCacheAttributes )
{
this.remoteCacheAttributes = remoteCacheAttributes;
}
@@ -638,7 +639,7 @@ public abstract class AbstractRemoteAuxiliaryCache<K, V>
/**
* @param remoteCacheListener the remoteCacheListener to set
*/
- protected void setRemoteCacheListener( IRemoteCacheListener<K, V> remoteCacheListener )
+ protected void setRemoteCacheListener( final IRemoteCacheListener<K, V> remoteCacheListener )
{
this.remoteCacheListener = remoteCacheListener;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheListener.java
index 451c71b..1db3bcb 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheListener.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheListener.java
@@ -69,7 +69,7 @@ public abstract class AbstractRemoteCacheListener<K, V>
* @param cacheMgr the cache hub
* @param elementSerializer a custom serializer
*/
- public AbstractRemoteCacheListener( IRemoteCacheAttributes irca, ICompositeCacheManager cacheMgr, IElementSerializer elementSerializer )
+ public AbstractRemoteCacheListener( final IRemoteCacheAttributes irca, final ICompositeCacheManager cacheMgr, final IElementSerializer elementSerializer )
{
this.irca = irca;
this.cacheMgr = cacheMgr;
@@ -85,7 +85,7 @@ public abstract class AbstractRemoteCacheListener<K, V>
* @throws IOException
*/
@Override
- public void setListenerId( long id )
+ public void setListenerId( final long id )
throws IOException
{
listenerId = id;
@@ -156,11 +156,11 @@ public abstract class AbstractRemoteCacheListener<K, V>
(ICacheElementSerialized<K, V>) cb, this.elementSerializer );
log.debug( "Deserialized result = {0}", cb );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
throw e;
}
- catch ( ClassNotFoundException e )
+ catch ( final ClassNotFoundException e )
{
log.error( "Received a serialized version of a class that we don't know about.", e );
}
@@ -178,7 +178,7 @@ public abstract class AbstractRemoteCacheListener<K, V>
* @throws IOException
*/
@Override
- public void handleRemove( String cacheName, K key )
+ public void handleRemove( final String cacheName, final K key )
throws IOException
{
log.debug( "handleRemove> cacheName={0}, key={1}", cacheName, key );
@@ -193,7 +193,7 @@ public abstract class AbstractRemoteCacheListener<K, V>
* @throws IOException
*/
@Override
- public void handleRemoveAll( String cacheName )
+ public void handleRemoveAll( final String cacheName )
throws IOException
{
log.debug( "handleRemoveAll> cacheName={0}", cacheName );
@@ -206,7 +206,7 @@ public abstract class AbstractRemoteCacheListener<K, V>
* @throws IOException
*/
@Override
- public void handleDispose( String cacheName )
+ public void handleDispose( final String cacheName )
throws IOException
{
log.debug( "handleDispose> cacheName={0}", cacheName );
@@ -241,7 +241,7 @@ public abstract class AbstractRemoteCacheListener<K, V>
{
localHostName = HostNameUtil.getLocalHostAddress();
}
- catch ( UnknownHostException uhe )
+ catch ( final UnknownHostException uhe )
{
localHostName = "unknown";
}
@@ -257,7 +257,7 @@ public abstract class AbstractRemoteCacheListener<K, V>
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\n AbstractRemoteCacheListener: " )
.append( "\n RemoteHost = ").append(irca.getRemoteLocation())
.append( "\n ListenerId = ").append(listenerId);
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
index cdc2baf..42429ac 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
@@ -61,15 +61,15 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
* @param cacheEventLogger
* @param elementSerializer
*/
- public AbstractRemoteCacheNoWaitFacade( List<RemoteCacheNoWait<K,V>> noWaits, IRemoteCacheAttributes rca,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ public AbstractRemoteCacheNoWaitFacade( final List<RemoteCacheNoWait<K,V>> noWaits, final IRemoteCacheAttributes rca,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
{
log.debug( "CONSTRUCTING NO WAIT FACADE" );
this.remoteCacheAttributes = rca;
setCacheEventLogger( cacheEventLogger );
setElementSerializer( elementSerializer );
this.noWaits = new ArrayList<>(noWaits);
- for (RemoteCacheNoWait<K,V> nw : this.noWaits)
+ for (final RemoteCacheNoWait<K,V> nw : this.noWaits)
{
// FIXME: This cast is very brave. Remove this.
((RemoteCache<K, V>)nw.getRemoteCache()).setFacade(this);
@@ -83,13 +83,13 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> ce )
+ public void update( final ICacheElement<K, V> ce )
throws IOException
{
log.debug( "updating through cache facade, noWaits.length = {0}",
() -> noWaits.size() );
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
try
{
@@ -99,9 +99,9 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
// reconnect
// and subsequent error
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
- String message = "Problem updating no wait. Will initiate failover if the noWait is in error.";
+ final String message = "Problem updating no wait. Will initiate failover if the noWait is in error.";
log.error( message, ex );
if ( getCacheEventLogger() != null )
@@ -132,19 +132,19 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
* @return Either an ICacheElement<K, V> or null if it is not found.
*/
@Override
- public ICacheElement<K, V> get( K key )
+ public ICacheElement<K, V> get( final K key )
{
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
try
{
- ICacheElement<K, V> obj = nw.get( key );
+ final ICacheElement<K, V> obj = nw.get( key );
if ( obj != null )
{
return obj;
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.debug( "Failed to get." );
return null;
@@ -161,16 +161,16 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( final String pattern )
throws IOException
{
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
try
{
return nw.getMatching( pattern );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.debug( "Failed to getMatching." );
}
@@ -186,17 +186,17 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
* data in cache for any of these keys
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple( Set<K> keys )
+ public Map<K, ICacheElement<K, V>> getMultiple( final Set<K> keys )
{
if ( keys != null && !keys.isEmpty() )
{
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
try
{
return nw.getMultiple( keys );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.debug( "Failed to get." );
}
@@ -214,12 +214,12 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
@Override
public Set<K> getKeySet() throws IOException
{
- HashSet<K> allKeys = new HashSet<>();
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ final HashSet<K> allKeys = new HashSet<>();
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
if ( nw != null )
{
- Set<K> keys = nw.getKeySet();
+ final Set<K> keys = nw.getKeySet();
if(keys != null)
{
allKeys.addAll( keys );
@@ -236,16 +236,16 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
* @return whether or not it was removed, right now it return false.
*/
@Override
- public boolean remove( K key )
+ public boolean remove( final K key )
{
try
{
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
nw.remove( key );
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( ex );
}
@@ -260,12 +260,12 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
{
try
{
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
nw.removeAll();
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( ex );
}
@@ -275,7 +275,7 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
@Override
public void dispose()
{
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
nw.dispose();
}
@@ -325,7 +325,7 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
@Override
public CacheStatus getStatus()
{
- for (RemoteCacheNoWait<K, V> nw : noWaits)
+ for (final RemoteCacheNoWait<K, V> nw : noWaits)
{
if ( nw.getStatus() == CacheStatus.ALIVE )
{
@@ -368,7 +368,7 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
* restore the primary server in the list of failovers
*
*/
- public void restorePrimaryServer(RemoteCacheNoWait<K, V> rcnw)
+ public void restorePrimaryServer(final RemoteCacheNoWait<K, V> rcnw)
{
noWaits.clear();
noWaits.add(rcnw);
@@ -399,19 +399,19 @@ public abstract class AbstractRemoteCacheNoWaitFacade<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "Remote Cache No Wait Facade" );
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
if ( noWaits != null )
{
elems.add(new StatElement<>( "Number of No Waits", Integer.valueOf(noWaits.size()) ) );
- for ( RemoteCacheNoWait<K, V> rcnw : noWaits )
+ for ( final RemoteCacheNoWait<K, V> rcnw : noWaits )
{
// get the stats from the super too
- IStats sStats = rcnw.getStatistics();
+ final IStats sStats = rcnw.getStatistics();
elems.addAll(sStats.getStatElements());
}
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/CommonRemoteCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/CommonRemoteCacheAttributes.java
index 829bdfe..a0960f5 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/CommonRemoteCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/CommonRemoteCacheAttributes.java
@@ -80,9 +80,9 @@ public class CommonRemoteCacheAttributes
* @param s The new remoteTypeName value
*/
@Override
- public void setRemoteTypeName( String s )
+ public void setRemoteTypeName( final String s )
{
- RemoteType rt = RemoteType.valueOf(s);
+ final RemoteType rt = RemoteType.valueOf(s);
if (rt != null)
{
this.remoteType = rt;
@@ -106,7 +106,7 @@ public class CommonRemoteCacheAttributes
* @param p The new remoteType value
*/
@Override
- public void setRemoteType( RemoteType p )
+ public void setRemoteType( final RemoteType p )
{
this.remoteType = p;
}
@@ -128,7 +128,7 @@ public class CommonRemoteCacheAttributes
* @param s The new remoteServiceName value
*/
@Override
- public void setRemoteServiceName( String s )
+ public void setRemoteServiceName( final String s )
{
this.remoteServiceName = s;
}
@@ -139,7 +139,7 @@ public class CommonRemoteCacheAttributes
* @param location The new location value
*/
@Override
- public void setRemoteLocation( RemoteLocation location )
+ public void setRemoteLocation( final RemoteLocation location )
{
this.location = location;
}
@@ -151,7 +151,7 @@ public class CommonRemoteCacheAttributes
* @param port The new remotePort value
*/
@Override
- public void setRemoteLocation( String host, int port )
+ public void setRemoteLocation( final String host, final int port )
{
this.location = new RemoteLocation(host, port);
}
@@ -184,7 +184,7 @@ public class CommonRemoteCacheAttributes
* @param s The new clusterServers value
*/
@Override
- public void setClusterServers( String s )
+ public void setClusterServers( final String s )
{
this.clusterServers = s;
}
@@ -206,7 +206,7 @@ public class CommonRemoteCacheAttributes
* @param r The new removeUponRemotePut value
*/
@Override
- public void setRemoveUponRemotePut( boolean r )
+ public void setRemoveUponRemotePut( final boolean r )
{
this.removeUponRemotePut = r;
}
@@ -227,7 +227,7 @@ public class CommonRemoteCacheAttributes
* @param r The new getOnly value
*/
@Override
- public void setGetOnly( boolean r )
+ public void setGetOnly( final boolean r )
{
this.getOnly = r;
}
@@ -249,7 +249,7 @@ public class CommonRemoteCacheAttributes
* @param r The new localClusterConsistency value
*/
@Override
- public void setLocalClusterConsistency( boolean r )
+ public void setLocalClusterConsistency( final boolean r )
{
this.localClusterConsistency = r;
}
@@ -258,7 +258,7 @@ public class CommonRemoteCacheAttributes
* @param rmiSocketFactoryTimeoutMillis The rmiSocketFactoryTimeoutMillis to set.
*/
@Override
- public void setRmiSocketFactoryTimeoutMillis( int rmiSocketFactoryTimeoutMillis )
+ public void setRmiSocketFactoryTimeoutMillis( final int rmiSocketFactoryTimeoutMillis )
{
this.rmiSocketFactoryTimeoutMillis = rmiSocketFactoryTimeoutMillis;
}
@@ -278,7 +278,7 @@ public class CommonRemoteCacheAttributes
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\n RemoteCacheAttributes " );
if (this.location != null)
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCache.java
index 6a62adb..9a40033 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCache.java
@@ -63,10 +63,10 @@ public class RemoteCache<K, V>
* @param listener a listener
* @param monitor the cache monitor
*/
- public RemoteCache( IRemoteCacheAttributes cattr,
- ICacheServiceNonLocal<K, V> remote,
- IRemoteCacheListener<K, V> listener,
- RemoteCacheMonitor monitor )
+ public RemoteCache( final IRemoteCacheAttributes cattr,
+ final ICacheServiceNonLocal<K, V> remote,
+ final IRemoteCacheListener<K, V> listener,
+ final RemoteCacheMonitor monitor )
{
super( cattr, remote, listener );
this.monitor = monitor;
@@ -80,10 +80,10 @@ public class RemoteCache<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "Remote Cache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
elems.add(new StatElement<>( "Remote Host:Port", getIPAddressForService() ) );
elems.add(new StatElement<>( "Remote Type", this.getRemoteCacheAttributes().getRemoteTypeName() ) );
@@ -94,7 +94,7 @@ public class RemoteCache<K, V>
// }
// get the stats from the super too
- IStats sStats = super.getStatistics();
+ final IStats sStats = super.getStatistics();
elems.addAll(sStats.getStatElements());
stats.setStatElements( elems );
@@ -107,7 +107,7 @@ public class RemoteCache<K, V>
*
* @param facade the facade to set
*/
- protected void setFacade(AbstractRemoteCacheNoWaitFacade<K, V> facade)
+ protected void setFacade(final AbstractRemoteCacheNoWaitFacade<K, V> facade)
{
this.facade = facade;
}
@@ -132,10 +132,10 @@ public class RemoteCache<K, V>
* @throws IOException
*/
@Override
- protected void handleException( Exception ex, String msg, String eventName )
+ protected void handleException( final Exception ex, final String msg, final String eventName )
throws IOException
{
- String message = "Disabling remote cache due to error: " + msg;
+ final String message = "Disabling remote cache due to error: " + msg;
logError( cacheName, "", message );
log.error( message, ex );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheAttributes.java
index e13b9ff..3637f60 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheAttributes.java
@@ -86,7 +86,7 @@ public class RemoteCacheAttributes
* @param p The new failoverIndex value
*/
@Override
- public void setFailoverIndex( int p )
+ public void setFailoverIndex( final int p )
{
this.failoverIndex = p;
}
@@ -108,7 +108,7 @@ public class RemoteCacheAttributes
* @param failovers The new failovers value
*/
@Override
- public void setFailovers( List<RemoteLocation> failovers )
+ public void setFailovers( final List<RemoteLocation> failovers )
{
this.failovers = failovers;
}
@@ -130,7 +130,7 @@ public class RemoteCacheAttributes
* @param s The new failoverServers value
*/
@Override
- public void setFailoverServers( String s )
+ public void setFailoverServers( final String s )
{
this.failoverServers = s;
}
@@ -151,7 +151,7 @@ public class RemoteCacheAttributes
* @param p The new localPort value
*/
@Override
- public void setLocalPort( int p )
+ public void setLocalPort( final int p )
{
this.localPort = p;
}
@@ -169,7 +169,7 @@ public class RemoteCacheAttributes
* @param name
*/
@Override
- public void setThreadPoolName( String name )
+ public void setThreadPoolName( final String name )
{
threadPoolName = name;
}
@@ -187,7 +187,7 @@ public class RemoteCacheAttributes
* @param millis
*/
@Override
- public void setGetTimeoutMillis( int millis )
+ public void setGetTimeoutMillis( final int millis )
{
getTimeoutMillis = millis;
}
@@ -199,7 +199,7 @@ public class RemoteCacheAttributes
* @param receive
*/
@Override
- public void setReceive( boolean receive )
+ public void setReceive( final boolean receive )
{
this.receive = receive;
}
@@ -228,7 +228,7 @@ public class RemoteCacheAttributes
* @param zombieQueueMaxSize The zombieQueueMaxSize to set.
*/
@Override
- public void setZombieQueueMaxSize( int zombieQueueMaxSize )
+ public void setZombieQueueMaxSize( final int zombieQueueMaxSize )
{
this.zombieQueueMaxSize = zombieQueueMaxSize;
}
@@ -251,7 +251,7 @@ public class RemoteCacheAttributes
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder(super.toString());
+ final StringBuilder buf = new StringBuilder(super.toString());
buf.append( "\n receive = [" + isReceive() + "]" );
buf.append( "\n getTimeoutMillis = [" + getGetTimeoutMillis() + "]" );
buf.append( "\n threadPoolName = [" + getThreadPoolName() + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFactory.java
index 46b5c67..5ab84b7 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFactory.java
@@ -69,18 +69,18 @@ public class RemoteCacheFactory
*/
@Override
public <K, V> AuxiliaryCache<K, V> createCache(
- AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
{
- RemoteCacheAttributes rca = (RemoteCacheAttributes) iaca;
+ final RemoteCacheAttributes rca = (RemoteCacheAttributes) iaca;
- ArrayList<RemoteCacheNoWait<K,V>> noWaits = new ArrayList<>();
+ final ArrayList<RemoteCacheNoWait<K,V>> noWaits = new ArrayList<>();
switch (rca.getRemoteType())
{
case LOCAL:
// a list to be turned into an array of failover server information
- ArrayList<RemoteLocation> failovers = new ArrayList<>();
+ final ArrayList<RemoteLocation> failovers = new ArrayList<>();
// not necessary if a failover list is defined
// REGISTER PRIMARY LISTENER
@@ -91,35 +91,35 @@ public class RemoteCacheFactory
primaryDefined = true;
failovers.add( rca.getRemoteLocation() );
- RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer );
- RemoteCacheNoWait<K,V> ic = rcm.getCache( rca );
+ final RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer );
+ final RemoteCacheNoWait<K,V> ic = rcm.getCache( rca );
noWaits.add( ic );
}
// GET HANDLE BUT DONT REGISTER A LISTENER FOR FAILOVERS
- String failoverList = rca.getFailoverServers();
+ final String failoverList = rca.getFailoverServers();
if ( failoverList != null )
{
- StringTokenizer fit = new StringTokenizer( failoverList, "," );
+ final StringTokenizer fit = new StringTokenizer( failoverList, "," );
int fCnt = 0;
while ( fit.hasMoreTokens() )
{
fCnt++;
- String server = fit.nextToken();
- RemoteLocation location = RemoteLocation.parseServerAndPort(server);
+ final String server = fit.nextToken();
+ final RemoteLocation location = RemoteLocation.parseServerAndPort(server);
if (location != null)
{
failovers.add( location );
rca.setRemoteLocation(location);
- RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer );
+ final RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer );
// add a listener if there are none, need to tell rca what
// number it is at
if (!primaryDefined && fCnt == 1 || noWaits.size() <= 0)
{
- RemoteCacheNoWait<K,V> ic = rcm.getCache( rca );
+ final RemoteCacheNoWait<K,V> ic = rcm.getCache( rca );
noWaits.add( ic );
}
}
@@ -133,25 +133,25 @@ public class RemoteCacheFactory
case CLUSTER:
// REGISTER LISTENERS FOR EACH SYSTEM CLUSTERED CACHEs
- StringTokenizer it = new StringTokenizer( rca.getClusterServers(), "," );
+ final StringTokenizer it = new StringTokenizer( rca.getClusterServers(), "," );
while ( it.hasMoreElements() )
{
- String server = (String) it.nextElement();
- RemoteLocation location = RemoteLocation.parseServerAndPort(server);
+ final String server = (String) it.nextElement();
+ final RemoteLocation location = RemoteLocation.parseServerAndPort(server);
if (location != null)
{
rca.setRemoteLocation(location);
- RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer );
+ final RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer );
rca.setRemoteType( RemoteType.CLUSTER );
- RemoteCacheNoWait<K,V> ic = rcm.getCache( rca );
+ final RemoteCacheNoWait<K,V> ic = rcm.getCache( rca );
noWaits.add( ic );
}
}
break;
}
- RemoteCacheNoWaitFacade<K, V> rcnwf =
+ final RemoteCacheNoWaitFacade<K, V> rcnwf =
new RemoteCacheNoWaitFacade<>(noWaits, rca, cacheEventLogger, elementSerializer, this );
return rcnwf;
@@ -168,15 +168,15 @@ public class RemoteCacheFactory
*
* @return The instance value or null if no such manager exists
*/
- public RemoteCacheManager getManager( IRemoteCacheAttributes cattr )
+ public RemoteCacheManager getManager( final IRemoteCacheAttributes cattr )
{
if ( cattr.getRemoteLocation() == null )
{
cattr.setRemoteLocation("", Registry.REGISTRY_PORT);
}
- RemoteLocation loc = cattr.getRemoteLocation();
- RemoteCacheManager ins = managers.get( loc );
+ final RemoteLocation loc = cattr.getRemoteLocation();
+ final RemoteCacheManager ins = managers.get( loc );
return ins;
}
@@ -195,9 +195,9 @@ public class RemoteCacheFactory
* @param elementSerializer
* @return The instance value, never null
*/
- public RemoteCacheManager getManager( IRemoteCacheAttributes cattr, ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger,
- IElementSerializer elementSerializer )
+ public RemoteCacheManager getManager( final IRemoteCacheAttributes cattr, final ICompositeCacheManager cacheMgr,
+ final ICacheEventLogger cacheEventLogger,
+ final IElementSerializer elementSerializer )
{
RemoteCacheManager ins = getManager( cattr );
@@ -246,7 +246,7 @@ public class RemoteCacheFactory
@Override
public void dispose()
{
- for (RemoteCacheManager manager : managers.values())
+ for (final RemoteCacheManager manager : managers.values())
{
manager.release();
}
@@ -260,7 +260,7 @@ public class RemoteCacheFactory
{
monitor.join(5000);
}
- catch (InterruptedException e)
+ catch (final InterruptedException e)
{
// swallow
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFailoverRunner.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFailoverRunner.java
index c1fe592..04f5a91 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFailoverRunner.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheFailoverRunner.java
@@ -62,7 +62,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
* @param facade the facade the CompositeCache talks to.
* @param cacheFactory the cache factory instance
*/
- public RemoteCacheFailoverRunner( RemoteCacheNoWaitFacade<K, V> facade, RemoteCacheFactory cacheFactory )
+ public RemoteCacheFailoverRunner( final RemoteCacheNoWaitFacade<K, V> facade, final RemoteCacheFactory cacheFactory )
{
super("JCS-RemoteCacheFailoverRunner");
this.facade = facade;
@@ -111,7 +111,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
if ( log.isInfoEnabled() )
{
- int failoverIndex = facade.getAuxiliaryCacheAttributes().getFailoverIndex();
+ final int failoverIndex = facade.getAuxiliaryCacheAttributes().getFailoverIndex();
log.info( "Exiting failover runner. Failover index = {0}", failoverIndex);
if ( failoverIndex <= 0 )
@@ -133,7 +133,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
*/
private void connectAndRestore()
{
- IRemoteCacheAttributes rca0 = facade.getAuxiliaryCacheAttributes();
+ final IRemoteCacheAttributes rca0 = facade.getAuxiliaryCacheAttributes();
do
{
@@ -144,7 +144,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
{
// Monitor each RemoteCacheManager instance one after the other.
// Each RemoteCacheManager corresponds to one remote connection.
- List<RemoteLocation> failovers = rca0.getFailovers();
+ final List<RemoteLocation> failovers = rca0.getFailovers();
// we should probably check to see if there are any failovers,
// even though the caller
// should have already.
@@ -161,7 +161,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
return;
}
- int fidx = rca0.getFailoverIndex();
+ final int fidx = rca0.getFailoverIndex();
log.debug( "fidx = {0} failovers.size = {1}", () -> fidx,
() -> failovers.size() );
@@ -169,18 +169,18 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
// If we don't check the primary, if it gets connected in the
// background,
// we will disconnect it only to put it right back
- ListIterator<RemoteLocation> i = failovers.listIterator(fidx); // + 1; // +1 skips the primary
+ final ListIterator<RemoteLocation> i = failovers.listIterator(fidx); // + 1; // +1 skips the primary
log.debug( "starting at failover i = {0}", i );
// try them one at a time until successful
while (i.hasNext() && !allright.get())
{
- RemoteLocation server = i.next();
+ final RemoteLocation server = i.next();
log.debug( "Trying server [{0}] at failover index i = {1}", server, i );
- RemoteCacheAttributes rca = (RemoteCacheAttributes) rca0.clone();
+ final RemoteCacheAttributes rca = (RemoteCacheAttributes) rca0.clone();
rca.setRemoteLocation(server);
- RemoteCacheManager rcm = cacheFactory.getManager( rca );
+ final RemoteCacheManager rcm = cacheFactory.getManager( rca );
log.debug( "RemoteCacheAttributes for failover = {0}", rca );
@@ -188,7 +188,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
{
// add a listener if there are none, need to tell rca
// what number it is at
- ICache<K, V> ic = rcm.getCache( rca );
+ final ICache<K, V> ic = rcm.getCache( rca );
if ( ic.getStatus() == CacheStatus.ALIVE )
{
// may need to do this more gracefully
@@ -245,7 +245,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
+ "{0} milliseconds.", idlePeriod );
Thread.sleep( idlePeriod );
}
- catch ( InterruptedException ex )
+ catch ( final InterruptedException ex )
{
// ignore;
}
@@ -269,22 +269,22 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
*/
private boolean restorePrimary()
{
- IRemoteCacheAttributes rca0 = facade.getAuxiliaryCacheAttributes();
+ final IRemoteCacheAttributes rca0 = facade.getAuxiliaryCacheAttributes();
// try to move back to the primary
- RemoteLocation server = rca0.getFailovers().get(0);
+ final RemoteLocation server = rca0.getFailovers().get(0);
log.info( "Trying to restore connection to primary remote server "
+ "[{0}]", server );
- RemoteCacheAttributes rca = (RemoteCacheAttributes) rca0.clone();
+ final RemoteCacheAttributes rca = (RemoteCacheAttributes) rca0.clone();
rca.setRemoteLocation(server);
- RemoteCacheManager rcm = cacheFactory.getManager( rca );
+ final RemoteCacheManager rcm = cacheFactory.getManager( rca );
if (rcm != null)
{
// add a listener if there are none, need to tell rca what number it
// is at
- ICache<K, V> ic = rcm.getCache( rca );
+ final ICache<K, V> ic = rcm.getCache( rca );
// by default the listener id should be 0, else it will be the
// listener
// Originally associated with the remote cache. either way is fine.
@@ -302,11 +302,11 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
// stop duplicate listening.
if ( facade.getPrimaryServer() != null && facade.getPrimaryServer().getStatus() == CacheStatus.ALIVE )
{
- int fidx = rca0.getFailoverIndex();
+ final int fidx = rca0.getFailoverIndex();
if ( fidx > 0 )
{
- RemoteLocation serverOld = rca0.getFailovers().get(fidx);
+ final RemoteLocation serverOld = rca0.getFailovers().get(fidx);
log.debug( "Failover Index = {0} the server at that "
+ "index is [{1}]", fidx, serverOld );
@@ -315,9 +315,9 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
{
// create attributes that reflect the
// previous failed over configuration.
- RemoteCacheAttributes rcaOld = (RemoteCacheAttributes) rca0.clone();
+ final RemoteCacheAttributes rcaOld = (RemoteCacheAttributes) rca0.clone();
rcaOld.setRemoteLocation(serverOld);
- RemoteCacheManager rcmOld = cacheFactory.getManager( rcaOld );
+ final RemoteCacheManager rcmOld = cacheFactory.getManager( rcaOld );
if ( rcmOld != null )
{
@@ -346,7 +346,7 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
}
}
}
- catch ( IOException e )
+ catch ( final IOException e )
{
// TODO, should try again, or somehow stop the listener
log.error("Trouble trying to deregister old failover "
@@ -356,13 +356,13 @@ public class RemoteCacheFailoverRunner<K, V> extends AbstractAuxiliaryCacheMonit
// Restore primary
// may need to do this more gracefully, letting the failover finish in the background
- RemoteCacheNoWait<K, V> failoverNoWait = facade.getPrimaryServer();
+ final RemoteCacheNoWait<K, V> failoverNoWait = facade.getPrimaryServer();
// swap in a new one
facade.restorePrimaryServer((RemoteCacheNoWait<K, V>) ic);
rca0.setFailoverIndex( 0 );
- String message = "Successfully reconnected to PRIMARY "
+ final String message = "Successfully reconnected to PRIMARY "
+ "remote server. Substituted primary for "
+ "failoverNoWait [" + failoverNoWait + "]";
log.info( message );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheListener.java
index 4b5a93b..64fbfc8 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheListener.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheListener.java
@@ -57,7 +57,7 @@ public class RemoteCacheListener<K, V>
* @param cacheMgr the cache hub
* @param elementSerializer a custom serializer
*/
- public RemoteCacheListener( IRemoteCacheAttributes irca, ICompositeCacheManager cacheMgr, IElementSerializer elementSerializer )
+ public RemoteCacheListener( final IRemoteCacheAttributes irca, final ICompositeCacheManager cacheMgr, final IElementSerializer elementSerializer )
{
super( irca, cacheMgr, elementSerializer );
@@ -67,7 +67,7 @@ public class RemoteCacheListener<K, V>
{
UnicastRemoteObject.exportObject( this, irca.getLocalPort() );
}
- catch ( RemoteException ex )
+ catch ( final RemoteException ex )
{
log.error( "Problem exporting object.", ex );
throw new IllegalStateException( ex.getMessage() );
@@ -90,7 +90,7 @@ public class RemoteCacheListener<K, V>
{
UnicastRemoteObject.unexportObject( this, true );
}
- catch ( RemoteException ex )
+ catch ( final RemoteException ex )
{
log.error( "Problem unexporting the listener.", ex );
throw new IllegalStateException( ex.getMessage() );
@@ -107,7 +107,7 @@ public class RemoteCacheListener<K, V>
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\n RemoteCacheListener: " );
buf.append( super.toString() );
return buf.toString();
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
index ccd9dd5..e9df6d6 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheManager.java
@@ -94,9 +94,9 @@ public class RemoteCacheManager
* @param cacheEventLogger
* @param elementSerializer
*/
- protected RemoteCacheManager( IRemoteCacheAttributes cattr, ICompositeCacheManager cacheMgr,
- RemoteCacheMonitor monitor,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer)
+ protected RemoteCacheManager( final IRemoteCacheAttributes cattr, final ICompositeCacheManager cacheMgr,
+ final RemoteCacheMonitor monitor,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer)
{
this.cacheMgr = cacheMgr;
this.monitor = monitor;
@@ -110,7 +110,7 @@ public class RemoteCacheManager
{
lookupRemoteService();
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("Could not find server", e);
// Notify the cache monitor about the error, and kick off the
@@ -129,7 +129,7 @@ public class RemoteCacheManager
log.info( "Looking up server [{0}]", registry );
try
{
- Object obj = Naming.lookup( registry );
+ final Object obj = Naming.lookup( registry );
log.info( "Server found: {0}", obj );
// Successful connection to the remote server.
@@ -137,7 +137,7 @@ public class RemoteCacheManager
log.debug( "Remote Service = {0}", remoteService );
remoteWatch.setCacheWatch( (ICacheObserver) remoteService );
}
- catch ( Exception ex )
+ catch ( final Exception ex )
{
// Failed to connect to the remote server.
// Configure this RemoteCacheManager instance to use the "zombie"
@@ -155,7 +155,7 @@ public class RemoteCacheManager
* @param listener The feature to be added to the RemoteCacheListener attribute
* @throws IOException
*/
- public <K, V> void addRemoteCacheListener( IRemoteCacheAttributes cattr, IRemoteCacheListener<K, V> listener )
+ public <K, V> void addRemoteCacheListener( final IRemoteCacheAttributes cattr, final IRemoteCacheListener<K, V> listener )
throws IOException
{
if ( cattr.isReceive() )
@@ -182,10 +182,10 @@ public class RemoteCacheManager
* @param cattr
* @throws IOException
*/
- public void removeRemoteCacheListener( IRemoteCacheAttributes cattr )
+ public void removeRemoteCacheListener( final IRemoteCacheAttributes cattr )
throws IOException
{
- RemoteCacheNoWait<?, ?> cache = caches.get( cattr.getCacheName() );
+ final RemoteCacheNoWait<?, ?> cache = caches.get( cattr.getCacheName() );
if ( cache != null )
{
removeListenerFromCache(cache);
@@ -205,13 +205,13 @@ public class RemoteCacheManager
}
// common helper method
- private void removeListenerFromCache(RemoteCacheNoWait<?, ?> cache) throws IOException
+ private void removeListenerFromCache(final RemoteCacheNoWait<?, ?> cache) throws IOException
{
- IRemoteCacheClient<?, ?> rc = cache.getRemoteCache();
+ final IRemoteCacheClient<?, ?> rc = cache.getRemoteCache();
log.debug( "Found cache for [{0}], deregistering listener.",
() -> cache.getCacheName() );
// could also store the listener for a server in the manager.
- IRemoteCacheListener<?, ?> listener = rc.getListener();
+ final IRemoteCacheListener<?, ?> listener = rc.getListener();
remoteWatch.removeCacheListener( cache.getCacheName(), listener );
}
@@ -226,9 +226,9 @@ public class RemoteCacheManager
* @return The cache value
*/
@SuppressWarnings("unchecked") // Need to cast because of common map for all caches
- public <K, V> RemoteCacheNoWait<K, V> getCache( IRemoteCacheAttributes cattr )
+ public <K, V> RemoteCacheNoWait<K, V> getCache( final IRemoteCacheAttributes cattr )
{
- RemoteCacheNoWait<K, V> remoteCacheNoWait =
+ final RemoteCacheNoWait<K, V> remoteCacheNoWait =
(RemoteCacheNoWait<K, V>) caches.computeIfAbsent(cattr.getCacheName(), key -> newRemoteCacheNoWait(cattr));
// might want to do some listener sanity checking here.
@@ -241,7 +241,7 @@ public class RemoteCacheManager
* @param cattr the cache configuration
* @return the instance
*/
- protected <K, V> RemoteCacheNoWait<K, V> newRemoteCacheNoWait(IRemoteCacheAttributes cattr)
+ protected <K, V> RemoteCacheNoWait<K, V> newRemoteCacheNoWait(final IRemoteCacheAttributes cattr)
{
RemoteCacheNoWait<K, V> remoteCacheNoWait;
// create a listener first and pass it to the remotecache
@@ -252,13 +252,13 @@ public class RemoteCacheManager
listener = new RemoteCacheListener<>( cattr, cacheMgr, elementSerializer );
addRemoteCacheListener( cattr, listener );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( "Problem adding listener. RemoteCacheListener = {0}",
listener, e );
}
- IRemoteCacheClient<K, V> remoteCacheClient =
+ final IRemoteCacheClient<K, V> remoteCacheClient =
new RemoteCache<>( cattr, (ICacheServiceNonLocal<K, V>) remoteService, listener, monitor );
remoteCacheClient.setCacheEventLogger( cacheEventLogger );
remoteCacheClient.setElementSerializer( elementSerializer );
@@ -273,7 +273,7 @@ public class RemoteCacheManager
/** Shutdown all. */
public void release()
{
- for (RemoteCacheNoWait<?, ?> c : caches.values())
+ for (final RemoteCacheNoWait<?, ?> c : caches.values())
{
try
{
@@ -282,7 +282,7 @@ public class RemoteCacheManager
removeListenerFromCache(c);
c.dispose();
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.error( "Problem releasing {0}", c.getCacheName(), ex );
}
@@ -304,7 +304,7 @@ public class RemoteCacheManager
log.info( "Fixing caches. ICacheServiceNonLocal {0} | IRemoteCacheObserver {1}",
remoteService, remoteWatch );
- for (RemoteCacheNoWait<?, ?> c : caches.values())
+ for (final RemoteCacheNoWait<?, ?> c : caches.values())
{
if (c.getStatus() == CacheStatus.ERROR)
{
@@ -314,7 +314,7 @@ public class RemoteCacheManager
if ( log.isInfoEnabled() )
{
- String msg = "Remote connection to " + registry + " resumed.";
+ final String msg = "Remote connection to " + registry + " resumed.";
if ( cacheEventLogger != null )
{
cacheEventLogger.logApplicationEvent( "RemoteCacheManager", "fix", msg );
@@ -335,7 +335,7 @@ public class RemoteCacheManager
{
lookupRemoteService();
}
- catch (IOException e)
+ catch (final IOException e)
{
log.error("Could not find server", e);
canFix = false;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheMonitor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheMonitor.java
index 8ef72ef..f69c7f4 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheMonitor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheMonitor.java
@@ -53,7 +53,7 @@ public class RemoteCacheMonitor extends AbstractAuxiliaryCacheMonitor
*
* @param manager the remote cache manager
*/
- public void addManager(RemoteCacheManager manager)
+ public void addManager(final RemoteCacheManager manager)
{
this.managers.put(manager, manager);
@@ -83,7 +83,7 @@ public class RemoteCacheMonitor extends AbstractAuxiliaryCacheMonitor
{
// Monitor each RemoteCacheManager instance one after the other.
// Each RemoteCacheManager corresponds to one remote connection.
- for (RemoteCacheManager mgr : managers.values())
+ for (final RemoteCacheManager mgr : managers.values())
{
// If we can't fix them, just skip and re-try in
// the next round.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWait.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWait.java
index bf683a9..01d47cb 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWait.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWait.java
@@ -96,7 +96,7 @@ public class RemoteCacheNoWait<K, V>
* <p>
* @param cache
*/
- public RemoteCacheNoWait( IRemoteCacheClient<K, V> cache )
+ public RemoteCacheNoWait( final IRemoteCacheClient<K, V> cache )
{
remoteCacheClient = cache;
this.cacheEventQueue = createCacheEventQueue(cache);
@@ -111,10 +111,10 @@ public class RemoteCacheNoWait<K, V>
* Create a cache event queue from the parameters of the remote client
* @param client the remote client
*/
- private ICacheEventQueue<K, V> createCacheEventQueue( IRemoteCacheClient<K, V> client )
+ private ICacheEventQueue<K, V> createCacheEventQueue( final IRemoteCacheClient<K, V> client )
{
- CacheEventQueueFactory<K, V> factory = new CacheEventQueueFactory<>();
- ICacheEventQueue<K, V> ceq = factory.createCacheEventQueue(
+ final CacheEventQueueFactory<K, V> factory = new CacheEventQueueFactory<>();
+ final ICacheEventQueue<K, V> ceq = factory.createCacheEventQueue(
new CacheAdaptor<>( client ),
client.getListenerId(),
client.getCacheName(),
@@ -130,7 +130,7 @@ public class RemoteCacheNoWait<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> element )
+ public void update( final ICacheElement<K, V> element )
throws IOException
{
putCount++;
@@ -138,7 +138,7 @@ public class RemoteCacheNoWait<K, V>
{
cacheEventQueue.addPutEvent( element );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( "Problem adding putEvent to queue.", e );
cacheEventQueue.destroy();
@@ -154,7 +154,7 @@ public class RemoteCacheNoWait<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> get( K key )
+ public ICacheElement<K, V> get( final K key )
throws IOException
{
getCount++;
@@ -162,7 +162,7 @@ public class RemoteCacheNoWait<K, V>
{
return remoteCacheClient.get( key );
}
- catch ( UnmarshalException ue )
+ catch ( final UnmarshalException ue )
{
log.debug( "Retrying the get owing to UnmarshalException." );
@@ -170,12 +170,12 @@ public class RemoteCacheNoWait<K, V>
{
return remoteCacheClient.get( key );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.info( "Failed in retrying the get for the second time. ", ex );
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
// We don't want to destroy the queue on a get failure.
// The RemoteCache will Zombie and queue.
@@ -193,7 +193,7 @@ public class RemoteCacheNoWait<K, V>
*
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( final String pattern )
throws IOException
{
getMatchingCount++;
@@ -201,7 +201,7 @@ public class RemoteCacheNoWait<K, V>
{
return remoteCacheClient.getMatching( pattern );
}
- catch ( UnmarshalException ue )
+ catch ( final UnmarshalException ue )
{
log.debug( "Retrying the getMatching owing to UnmarshalException." );
@@ -209,12 +209,12 @@ public class RemoteCacheNoWait<K, V>
{
return remoteCacheClient.getMatching( pattern );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.info( "Failed in retrying the getMatching for the second time.", ex );
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
// We don't want to destroy the queue on a get failure.
// The RemoteCache will Zombie and queue.
@@ -235,7 +235,7 @@ public class RemoteCacheNoWait<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple( Set<K> keys )
+ public Map<K, ICacheElement<K, V>> getMultiple( final Set<K> keys )
throws IOException
{
getMultipleCount++;
@@ -243,7 +243,7 @@ public class RemoteCacheNoWait<K, V>
{
return remoteCacheClient.getMultiple( keys );
}
- catch ( UnmarshalException ue )
+ catch ( final UnmarshalException ue )
{
log.debug( "Retrying the getMultiple owing to UnmarshalException..." );
@@ -251,12 +251,12 @@ public class RemoteCacheNoWait<K, V>
{
return remoteCacheClient.getMultiple( keys );
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
log.info( "Failed in retrying the getMultiple for the second time.", ex );
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
// We don't want to destroy the queue on a get failure.
// The RemoteCache will Zombie and queue.
@@ -286,7 +286,7 @@ public class RemoteCacheNoWait<K, V>
* @throws IOException
*/
@Override
- public boolean remove( K key )
+ public boolean remove( final K key )
throws IOException
{
removeCount++;
@@ -294,7 +294,7 @@ public class RemoteCacheNoWait<K, V>
{
cacheEventQueue.addRemoveEvent( key );
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( "Problem adding RemoveEvent to queue.", e );
cacheEventQueue.destroy();
@@ -316,7 +316,7 @@ public class RemoteCacheNoWait<K, V>
{
cacheEventQueue.addRemoveAllEvent();
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( "Problem adding RemoveAllEvent to queue.", e );
cacheEventQueue.destroy();
@@ -332,7 +332,7 @@ public class RemoteCacheNoWait<K, V>
{
cacheEventQueue.addDisposeEvent();
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( "Problem adding DisposeEvent to queue.", e );
cacheEventQueue.destroy();
@@ -390,7 +390,7 @@ public class RemoteCacheNoWait<K, V>
* <p>
* @param remote
*/
- public void fixCache( ICacheServiceNonLocal<?, ?> remote )
+ public void fixCache( final ICacheServiceNonLocal<?, ?> remote )
{
remoteCacheClient.fixCache( remote );
resetEventQ();
@@ -405,7 +405,7 @@ public class RemoteCacheNoWait<K, V>
*/
public void resetEventQ()
{
- ICacheEventQueue<K, V> previousQueue = cacheEventQueue;
+ final ICacheEventQueue<K, V> previousQueue = cacheEventQueue;
this.cacheEventQueue = createCacheEventQueue(this.remoteCacheClient);
@@ -475,22 +475,22 @@ public class RemoteCacheNoWait<K, V>
@Override
public IStats getStatistics()
{
- IStats stats = new Stats();
+ final IStats stats = new Stats();
stats.setTypeName( "Remote Cache No Wait" );
- ArrayList<IStatElement<?>> elems = new ArrayList<>();
+ final ArrayList<IStatElement<?>> elems = new ArrayList<>();
elems.add(new StatElement<>( "Status", getStatus() ) );
// get the stats from the cache queue too
- IStats cStats = this.remoteCacheClient.getStatistics();
+ final IStats cStats = this.remoteCacheClient.getStatistics();
if ( cStats != null )
{
elems.addAll(cStats.getStatElements());
}
// get the stats from the event queue too
- IStats eqStats = this.cacheEventQueue.getStatistics();
+ final IStats eqStats = this.cacheEventQueue.getStatistics();
elems.addAll(eqStats.getStatElements());
elems.add(new StatElement<>( "Get Count", Integer.valueOf(this.getCount) ) );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWaitFacade.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWaitFacade.java
index 0ec1615..8744c1c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWaitFacade.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteCacheNoWaitFacade.java
@@ -55,11 +55,11 @@ public class RemoteCacheNoWaitFacade<K, V>
* @param elementSerializer
* @param cacheFactory
*/
- public RemoteCacheNoWaitFacade( List<RemoteCacheNoWait<K,V>> noWaits,
- IRemoteCacheAttributes rca,
- ICacheEventLogger cacheEventLogger,
- IElementSerializer elementSerializer,
- RemoteCacheFactory cacheFactory)
+ public RemoteCacheNoWaitFacade( final List<RemoteCacheNoWait<K,V>> noWaits,
+ final IRemoteCacheAttributes rca,
+ final ICacheEventLogger cacheEventLogger,
+ final IElementSerializer elementSerializer,
+ final RemoteCacheFactory cacheFactory)
{
super( noWaits, rca, cacheEventLogger, elementSerializer );
this.cacheFactory = cacheFactory;
@@ -71,7 +71,7 @@ public class RemoteCacheNoWaitFacade<K, V>
* @param rcnw The no wait in error.
*/
@Override
- protected void failover( RemoteCacheNoWait<K, V> rcnw )
+ protected void failover( final RemoteCacheNoWait<K, V> rcnw )
{
log.debug( "in failover for {0}", rcnw );
@@ -80,7 +80,7 @@ public class RemoteCacheNoWaitFacade<K, V>
if ( rcnw.getStatus() == CacheStatus.ERROR )
{
// start failover, primary recovery process
- RemoteCacheFailoverRunner<K, V> runner = new RemoteCacheFailoverRunner<>( this, this.cacheFactory );
+ final RemoteCacheFailoverRunner<K, V> runner = new RemoteCacheFailoverRunner<>( this, this.cacheFactory );
runner.setDaemon( true );
runner.start();
runner.notifyError();
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteLocation.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteLocation.java
index ec2e19e..cf41990 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteLocation.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteLocation.java
@@ -48,7 +48,7 @@ public final class RemoteLocation
* @param host
* @param port
*/
- public RemoteLocation( String host, int port )
+ public RemoteLocation( final String host, final int port )
{
this.host = host;
this.port = port;
@@ -75,7 +75,7 @@ public final class RemoteLocation
* @return true if the host and port are equal
*/
@Override
- public boolean equals( Object obj )
+ public boolean equals( final Object obj )
{
if ( obj == this )
{
@@ -85,7 +85,7 @@ public final class RemoteLocation
{
return false;
}
- RemoteLocation l = (RemoteLocation) obj;
+ final RemoteLocation l = (RemoteLocation) obj;
if ( this.host == null )
{
return l.host == null && port == l.port;
@@ -108,7 +108,7 @@ public final class RemoteLocation
@Override
public String toString()
{
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
if (this.host != null)
{
sb.append(this.host);
@@ -127,11 +127,11 @@ public final class RemoteLocation
*/
public static RemoteLocation parseServerAndPort(final String server)
{
- Matcher match = SERVER_COLON_PORT.matcher(server);
+ final Matcher match = SERVER_COLON_PORT.matcher(server);
if (match.find() && match.groupCount() == 2)
{
- RemoteLocation location = new RemoteLocation( match.group(1), Integer.parseInt( match.group(2) ) );
+ final RemoteLocation location = new RemoteLocation( match.group(1), Integer.parseInt( match.group(2) ) );
return location;
}
else
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java
index b12daa0..fdd02a4 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/RemoteUtils.java
@@ -80,12 +80,12 @@ public class RemoteUtils
registry = LocateRegistry.createRegistry(port);
log.info("createRegistry> Created the registry on port {0}", port);
}
- catch (RemoteException e)
+ catch (final RemoteException e)
{
log.warn("createRegistry> Problem creating registry. It may already be started.",
e);
}
- catch (Throwable t)
+ catch (final Throwable t)
{
log.error("createRegistry> Problem creating registry.", t);
}
@@ -96,7 +96,7 @@ public class RemoteUtils
{
registry = LocateRegistry.getRegistry(port);
}
- catch (RemoteException e)
+ catch (final RemoteException e)
{
log.error("createRegistry> Problem getting a registry reference.", e);
}
@@ -114,7 +114,7 @@ public class RemoteUtils
* @return The properties object for the file
* @throws IOException
*/
- public static Properties loadProps(String propFile)
+ public static Properties loadProps(final String propFile)
throws IOException
{
InputStream is = RemoteUtils.class.getResourceAsStream(propFile);
@@ -142,7 +142,7 @@ public class RemoteUtils
}
}
- Properties props = new Properties();
+ final Properties props = new Properties();
try
{
props.load(is);
@@ -150,14 +150,14 @@ public class RemoteUtils
if (log.isTraceEnabled())
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
props.forEach((key, value)
-> buf.append('\n').append(key).append(" = ").append(value));
log.trace(buf.toString());
}
}
- catch (IOException ex)
+ catch (final IOException ex)
{
log.error("Error loading remote properties, for file name "
+ "[{0}]", propFile, ex);
@@ -194,10 +194,10 @@ public class RemoteUtils
RMISocketFactory.setSocketFactory(new RMISocketFactory()
{
@Override
- public Socket createSocket(String host, int port)
+ public Socket createSocket(final String host, final int port)
throws IOException
{
- Socket socket = new Socket();
+ final Socket socket = new Socket();
socket.setSoTimeout(timeoutMillis);
socket.setSoLinger(false, 0);
socket.connect(new InetSocketAddress(host, port), timeoutMillis);
@@ -205,7 +205,7 @@ public class RemoteUtils
}
@Override
- public ServerSocket createServerSocket(int port)
+ public ServerSocket createServerSocket(final int port)
throws IOException
{
return new ServerSocket(port);
@@ -213,11 +213,11 @@ public class RemoteUtils
});
}
}
- catch (IOException e)
+ catch (final IOException e)
{
// Only try to do it once. Otherwise we
// Generate errors for each region on construction.
- RMISocketFactory factoryInUse = RMISocketFactory.getSocketFactory();
+ final RMISocketFactory factoryInUse = RMISocketFactory.getSocketFactory();
if (factoryInUse != null && !factoryInUse.getClass().getName().startsWith("org.apache.commons.jcs3"))
{
log.info("Could not create new custom socket factory. {0} Factory in use = {1}",
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/AbstractHttpClient.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/AbstractHttpClient.java
index 832a75b..d9a01c7 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/AbstractHttpClient.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/AbstractHttpClient.java
@@ -57,11 +57,11 @@ public abstract class AbstractHttpClient
* <p>
* @param remoteHttpCacheAttributes
*/
- public AbstractHttpClient( RemoteHttpCacheAttributes remoteHttpCacheAttributes )
+ public AbstractHttpClient( final RemoteHttpCacheAttributes remoteHttpCacheAttributes )
{
this.remoteHttpCacheAttributes = remoteHttpCacheAttributes;
- String httpVersion = getRemoteHttpCacheAttributes().getHttpVersion();
+ final String httpVersion = getRemoteHttpCacheAttributes().getHttpVersion();
if ( "1.1".equals( httpVersion ) )
{
this.httpVersion = HttpVersion.HTTP_1_1;
@@ -77,7 +77,7 @@ public abstract class AbstractHttpClient
this.httpVersion = HttpVersion.HTTP_1_1;
}
- HttpClientBuilder builder = HttpClientBuilder.create();
+ final HttpClientBuilder builder = HttpClientBuilder.create();
configureClient(builder);
this.httpClient = builder.build();
}
@@ -87,7 +87,7 @@ public abstract class AbstractHttpClient
*
* @param builder client builder to configure
*/
- protected void configureClient(HttpClientBuilder builder)
+ protected void configureClient(final HttpClientBuilder builder)
{
if ( getRemoteHttpCacheAttributes().getMaxConnectionsPerHost() > 0 )
{
@@ -112,12 +112,12 @@ public abstract class AbstractHttpClient
*
* @throws IOException on i/o error
*/
- protected final HttpResponse doWebserviceCall( RequestBuilder builder )
+ protected final HttpResponse doWebserviceCall( final RequestBuilder builder )
throws IOException
{
preProcessWebserviceCall( builder.setVersion(httpVersion) );
- HttpUriRequest request = builder.build();
- HttpResponse httpResponse = this.httpClient.execute( request );
+ final HttpUriRequest request = builder.build();
+ final HttpResponse httpResponse = this.httpClient.execute( request );
postProcessWebserviceCall( request, httpResponse );
return httpResponse;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCache.java
index 340be23..7a49738 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCache.java
@@ -54,8 +54,8 @@ public class RemoteHttpCache<K, V>
* @param listener
* @param monitor the cache monitor
*/
- public RemoteHttpCache( RemoteHttpCacheAttributes remoteHttpCacheAttributes, ICacheServiceNonLocal<K, V> remote,
- IRemoteCacheListener<K, V> listener, RemoteHttpCacheMonitor monitor )
+ public RemoteHttpCache( final RemoteHttpCacheAttributes remoteHttpCacheAttributes, final ICacheServiceNonLocal<K, V> remote,
+ final IRemoteCacheListener<K, V> listener, final RemoteHttpCacheMonitor monitor )
{
super( remoteHttpCacheAttributes, remote, listener );
@@ -72,13 +72,13 @@ public class RemoteHttpCache<K, V>
* @throws IOException
*/
@Override
- protected void handleException( Exception ex, String msg, String eventName )
+ protected void handleException( final Exception ex, final String msg, final String eventName )
throws IOException
{
// we should not switch if the existing is a zombie.
if ( !( getRemoteCacheService() instanceof ZombieCacheServiceNonLocal ) )
{
- String message = "Disabling remote cache due to error: " + msg;
+ final String message = "Disabling remote cache due to error: " + msg;
logError( cacheName, "", message );
log.error( message, ex );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheAttributes.java
index 68d008a..2ee5357 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheAttributes.java
@@ -64,7 +64,7 @@ public class RemoteHttpCacheAttributes
/**
* @param maxConnectionsPerHost the maxConnectionsPerHost to set
*/
- public void setMaxConnectionsPerHost( int maxConnectionsPerHost )
+ public void setMaxConnectionsPerHost( final int maxConnectionsPerHost )
{
this.maxConnectionsPerHost = maxConnectionsPerHost;
}
@@ -80,7 +80,7 @@ public class RemoteHttpCacheAttributes
/**
* @param socketTimeoutMillis the socketTimeoutMillis to set
*/
- public void setSocketTimeoutMillis( int socketTimeoutMillis )
+ public void setSocketTimeoutMillis( final int socketTimeoutMillis )
{
this.socketTimeoutMillis = socketTimeoutMillis;
}
@@ -96,7 +96,7 @@ public class RemoteHttpCacheAttributes
/**
* @param httpVersion the httpVersion to set
*/
- public void setHttpVersion( String httpVersion )
+ public void setHttpVersion( final String httpVersion )
{
this.httpVersion = httpVersion;
}
@@ -112,7 +112,7 @@ public class RemoteHttpCacheAttributes
/**
* @param connectionTimeoutMillis the connectionTimeoutMillis to set
*/
- public void setConnectionTimeoutMillis( int connectionTimeoutMillis )
+ public void setConnectionTimeoutMillis( final int connectionTimeoutMillis )
{
this.connectionTimeoutMillis = connectionTimeoutMillis;
}
@@ -128,7 +128,7 @@ public class RemoteHttpCacheAttributes
/**
* @param includeCacheNameInURL the includeCacheNameInURL to set
*/
- public void setIncludeCacheNameAsParameter( boolean includeCacheNameInURL )
+ public void setIncludeCacheNameAsParameter( final boolean includeCacheNameInURL )
{
this.includeCacheNameAsParameter = includeCacheNameInURL;
}
@@ -144,7 +144,7 @@ public class RemoteHttpCacheAttributes
/**
* @param includeKeysAndPatternsInURL the includeKeysAndPatternsInURL to set
*/
- public void setIncludeKeysAndPatternsAsParameter( boolean includeKeysAndPatternsInURL )
+ public void setIncludeKeysAndPatternsAsParameter( final boolean includeKeysAndPatternsInURL )
{
this.includeKeysAndPatternsAsParameter = includeKeysAndPatternsInURL;
}
@@ -160,7 +160,7 @@ public class RemoteHttpCacheAttributes
/**
* @param includeRequestTypeasAsParameter the includeRequestTypeasAsParameter to set
*/
- public void setIncludeRequestTypeasAsParameter( boolean includeRequestTypeasAsParameter )
+ public void setIncludeRequestTypeasAsParameter( final boolean includeRequestTypeasAsParameter )
{
this.includeRequestTypeasAsParameter = includeRequestTypeasAsParameter;
}
@@ -176,7 +176,7 @@ public class RemoteHttpCacheAttributes
/**
* @param url the url to set
*/
- public void setUrl( String url )
+ public void setUrl( final String url )
{
this.url = url;
}
@@ -192,7 +192,7 @@ public class RemoteHttpCacheAttributes
/**
* @param remoteHttpClientClassName the remoteHttpClientClassName to set
*/
- public void setRemoteHttpClientClassName( String remoteHttpClientClassName )
+ public void setRemoteHttpClientClassName( final String remoteHttpClientClassName )
{
this.remoteHttpClientClassName = remoteHttpClientClassName;
}
@@ -211,7 +211,7 @@ public class RemoteHttpCacheAttributes
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\n RemoteHttpCacheAttributes" );
buf.append( "\n maxConnectionsPerHost = [" + getMaxConnectionsPerHost() + "]" );
buf.append( "\n socketTimeoutMillis = [" + getSocketTimeoutMillis() + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheClient.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheClient.java
index 444240f..76b33a4 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheClient.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheClient.java
@@ -61,7 +61,7 @@ public class RemoteHttpCacheClient<K, V>
* <p>
* @param attributes
*/
- public RemoteHttpCacheClient( RemoteHttpCacheAttributes attributes )
+ public RemoteHttpCacheClient( final RemoteHttpCacheAttributes attributes )
{
setRemoteHttpCacheAttributes( attributes );
initialize( attributes );
@@ -74,7 +74,7 @@ public class RemoteHttpCacheClient<K, V>
* @param attributes
*/
@Override
- public void initialize( RemoteHttpCacheAttributes attributes )
+ public void initialize( final RemoteHttpCacheAttributes attributes )
{
setRemoteDispatcher( new RemoteHttpCacheDispatcher( attributes ) );
@@ -91,7 +91,7 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> get( String cacheName, K key )
+ public ICacheElement<K, V> get( final String cacheName, final K key )
throws IOException
{
return get( cacheName, key, 0 );
@@ -107,19 +107,19 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> get( String cacheName, K key, long requesterId )
+ public ICacheElement<K, V> get( final String cacheName, final K key, final long requesterId )
throws IOException
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<K, Serializable> remoteHttpCacheRequest =
+ final RemoteCacheRequest<K, Serializable> remoteHttpCacheRequest =
RemoteCacheRequestFactory.createGetRequest( cacheName, key, requesterId );
- RemoteCacheResponse<ICacheElement<K, V>> remoteHttpCacheResponse =
+ final RemoteCacheResponse<ICacheElement<K, V>> remoteHttpCacheResponse =
getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
log.debug( "Get [{0}] = {1}", key, remoteHttpCacheResponse );
@@ -142,7 +142,7 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( final String cacheName, final String pattern )
throws IOException
{
return getMatching( cacheName, pattern, 0 );
@@ -159,20 +159,20 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMatching( final String cacheName, final String pattern, final long requesterId )
throws IOException
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<K, V> remoteHttpCacheRequest =
+ final RemoteCacheRequest<K, V> remoteHttpCacheRequest =
RemoteCacheRequestFactory.createGetMatchingRequest( cacheName, pattern, requesterId );
- RemoteCacheResponse<Map<K, ICacheElement<K, V>>> remoteHttpCacheResponse =
+ final RemoteCacheResponse<Map<K, ICacheElement<K, V>>> remoteHttpCacheResponse =
getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
log.debug( "GetMatching [{0}] = {1}", pattern, remoteHttpCacheResponse );
@@ -190,7 +190,7 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys )
+ public Map<K, ICacheElement<K, V>> getMultiple( final String cacheName, final Set<K> keys )
throws IOException
{
return getMultiple( cacheName, keys, 0 );
@@ -207,20 +207,20 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMultiple( final String cacheName, final Set<K> keys, final long requesterId )
throws IOException
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<K, V> remoteHttpCacheRequest =
+ final RemoteCacheRequest<K, V> remoteHttpCacheRequest =
RemoteCacheRequestFactory.createGetMultipleRequest( cacheName, keys, requesterId );
- RemoteCacheResponse<Map<K, ICacheElement<K, V>>> remoteHttpCacheResponse =
+ final RemoteCacheResponse<Map<K, ICacheElement<K, V>>> remoteHttpCacheResponse =
getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
log.debug( "GetMultiple [{0}] = {1}", keys, remoteHttpCacheResponse );
@@ -236,7 +236,7 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public void remove( String cacheName, K key )
+ public void remove( final String cacheName, final K key )
throws IOException
{
remove( cacheName, key, 0 );
@@ -251,17 +251,17 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public void remove( String cacheName, K key, long requesterId )
+ public void remove( final String cacheName, final K key, final long requesterId )
throws IOException
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<K, V> remoteHttpCacheRequest =
+ final RemoteCacheRequest<K, V> remoteHttpCacheRequest =
RemoteCacheRequestFactory.createRemoveRequest( cacheName, key, requesterId );
getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
@@ -274,7 +274,7 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public void removeAll( String cacheName )
+ public void removeAll( final String cacheName )
throws IOException
{
removeAll( cacheName, 0 );
@@ -288,17 +288,17 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public void removeAll( String cacheName, long requesterId )
+ public void removeAll( final String cacheName, final long requesterId )
throws IOException
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<K, V> remoteHttpCacheRequest =
+ final RemoteCacheRequest<K, V> remoteHttpCacheRequest =
RemoteCacheRequestFactory.createRemoveAllRequest( cacheName, requesterId );
getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
@@ -311,7 +311,7 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> item )
+ public void update( final ICacheElement<K, V> item )
throws IOException
{
update( item, 0 );
@@ -325,17 +325,17 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> cacheElement, long requesterId )
+ public void update( final ICacheElement<K, V> cacheElement, final long requesterId )
throws IOException
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<K, V> remoteHttpCacheRequest =
+ final RemoteCacheRequest<K, V> remoteHttpCacheRequest =
RemoteCacheRequestFactory.createUpdateRequest( cacheElement, requesterId );
getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
@@ -348,17 +348,17 @@ public class RemoteHttpCacheClient<K, V>
* @throws IOException
*/
@Override
- public void dispose( String cacheName )
+ public void dispose( final String cacheName )
throws IOException
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<K, V> remoteHttpCacheRequest =
+ final RemoteCacheRequest<K, V> remoteHttpCacheRequest =
RemoteCacheRequestFactory.createDisposeRequest( cacheName, 0 );
getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
@@ -383,19 +383,19 @@ public class RemoteHttpCacheClient<K, V>
* @see org.apache.commons.jcs3.auxiliary.AuxiliaryCache#getKeySet()
*/
@Override
- public Set<K> getKeySet( String cacheName ) throws IOException
+ public Set<K> getKeySet( final String cacheName ) throws IOException
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<String, String> remoteHttpCacheRequest =
+ final RemoteCacheRequest<String, String> remoteHttpCacheRequest =
RemoteCacheRequestFactory.createGetKeySetRequest(cacheName, 0 );
- RemoteCacheResponse<Set<K>> remoteHttpCacheResponse = getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
+ final RemoteCacheResponse<Set<K>> remoteHttpCacheResponse = getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
if ( remoteHttpCacheResponse != null && remoteHttpCacheResponse.getPayload() != null )
{
@@ -417,13 +417,13 @@ public class RemoteHttpCacheClient<K, V>
{
if ( !isInitialized() )
{
- String message = "The Remote Http Client is not initialized. Cannot process request.";
+ final String message = "The Remote Http Client is not initialized. Cannot process request.";
log.warn( message );
throw new IOException( message );
}
- RemoteCacheRequest<K, V> remoteHttpCacheRequest = RemoteCacheRequestFactory.createAliveCheckRequest( 0 );
- RemoteCacheResponse<String> remoteHttpCacheResponse =
+ final RemoteCacheRequest<K, V> remoteHttpCacheRequest = RemoteCacheRequestFactory.createAliveCheckRequest( 0 );
+ final RemoteCacheResponse<String> remoteHttpCacheResponse =
getRemoteDispatcher().dispatchRequest( remoteHttpCacheRequest );
if ( remoteHttpCacheResponse != null )
@@ -437,7 +437,7 @@ public class RemoteHttpCacheClient<K, V>
/**
* @param remoteDispatcher the remoteDispatcher to set
*/
- public void setRemoteDispatcher( IRemoteCacheDispatcher remoteDispatcher )
+ public void setRemoteDispatcher( final IRemoteCacheDispatcher remoteDispatcher )
{
this.remoteDispatcher = remoteDispatcher;
}
@@ -453,7 +453,7 @@ public class RemoteHttpCacheClient<K, V>
/**
* @param remoteHttpCacheAttributes the remoteHttpCacheAttributes to set
*/
- public void setRemoteHttpCacheAttributes( RemoteHttpCacheAttributes remoteHttpCacheAttributes )
+ public void setRemoteHttpCacheAttributes( final RemoteHttpCacheAttributes remoteHttpCacheAttributes )
{
this.remoteHttpCacheAttributes = remoteHttpCacheAttributes;
}
@@ -469,7 +469,7 @@ public class RemoteHttpCacheClient<K, V>
/**
* @param initialized the initialized to set
*/
- protected void setInitialized( boolean initialized )
+ protected void setInitialized( final boolean initialized )
{
this.initialized = initialized;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java
index 6073771..3a8f14b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheDispatcher.java
@@ -62,7 +62,7 @@ public class RemoteHttpCacheDispatcher
/**
* @param remoteHttpCacheAttributes
*/
- public RemoteHttpCacheDispatcher( RemoteHttpCacheAttributes remoteHttpCacheAttributes )
+ public RemoteHttpCacheDispatcher( final RemoteHttpCacheAttributes remoteHttpCacheAttributes )
{
super( remoteHttpCacheAttributes );
}
@@ -78,14 +78,14 @@ public class RemoteHttpCacheDispatcher
*/
@Override
public <K, V, T>
- RemoteCacheResponse<T> dispatchRequest( RemoteCacheRequest<K, V> remoteCacheRequest )
+ RemoteCacheResponse<T> dispatchRequest( final RemoteCacheRequest<K, V> remoteCacheRequest )
throws IOException
{
try
{
- byte[] requestAsByteArray = serializer.serialize( remoteCacheRequest );
+ final byte[] requestAsByteArray = serializer.serialize( remoteCacheRequest );
- byte[] responseAsByteArray = processRequest( requestAsByteArray,
+ final byte[] responseAsByteArray = processRequest( requestAsByteArray,
remoteCacheRequest,
getRemoteHttpCacheAttributes().getUrl());
@@ -94,13 +94,13 @@ public class RemoteHttpCacheDispatcher
{
remoteCacheResponse = serializer.deSerialize( responseAsByteArray, null );
}
- catch ( ClassNotFoundException e )
+ catch ( final ClassNotFoundException e )
{
log.error( "Couldn't deserialize the response.", e );
}
return remoteCacheResponse;
}
- catch ( Exception e )
+ catch ( final Exception e )
{
throw new IOException("Problem dispatching request.", e);
}
@@ -118,11 +118,11 @@ public class RemoteHttpCacheDispatcher
* @throws IOException
* @throws HttpException
*/
- protected <K, V> byte[] processRequest( byte[] requestAsByteArray,
- RemoteCacheRequest<K, V> remoteCacheRequest, String url )
+ protected <K, V> byte[] processRequest( final byte[] requestAsByteArray,
+ final RemoteCacheRequest<K, V> remoteCacheRequest, final String url )
throws IOException, HttpException
{
- RequestBuilder builder = RequestBuilder.post( url ).setCharset( DEFAULT_ENCODING );
+ final RequestBuilder builder = RequestBuilder.post( url ).setCharset( DEFAULT_ENCODING );
if ( getRemoteHttpCacheAttributes().isIncludeCacheNameAsParameter()
&& remoteCacheRequest.getCacheName() != null )
@@ -160,8 +160,8 @@ public class RemoteHttpCacheDispatcher
}
builder.setEntity(new ByteArrayEntity( requestAsByteArray ));
- HttpResponse httpResponse = doWebserviceCall( builder );
- byte[] response = EntityUtils.toByteArray( httpResponse.getEntity() );
+ final HttpResponse httpResponse = doWebserviceCall( builder );
+ final byte[] response = EntityUtils.toByteArray( httpResponse.getEntity() );
return response;
}
@@ -173,7 +173,7 @@ public class RemoteHttpCacheDispatcher
* @throws IOException
*/
@Override
- protected void preProcessWebserviceCall( RequestBuilder requestBuilder )
+ protected void preProcessWebserviceCall( final RequestBuilder requestBuilder )
throws IOException
{
// do nothing. Child can override.
@@ -188,7 +188,7 @@ public class RemoteHttpCacheDispatcher
* @throws IOException
*/
@Override
- protected void postProcessWebserviceCall( HttpUriRequest request, HttpResponse httpState )
+ protected void postProcessWebserviceCall( final HttpUriRequest request, final HttpResponse httpState )
throws IOException
{
// do nothing. Child can override.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheFactory.java
index 91e4281..7b83103 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheFactory.java
@@ -62,24 +62,24 @@ public class RemoteHttpCacheFactory
* @return AuxiliaryCache
*/
@Override
- public <K, V> AuxiliaryCache<K, V> createCache( AuxiliaryCacheAttributes iaca, ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
+ public <K, V> AuxiliaryCache<K, V> createCache( final AuxiliaryCacheAttributes iaca, final ICompositeCacheManager cacheMgr,
+ final ICacheEventLogger cacheEventLogger, final IElementSerializer elementSerializer )
{
- RemoteHttpCacheAttributes rca = (RemoteHttpCacheAttributes) iaca;
+ final RemoteHttpCacheAttributes rca = (RemoteHttpCacheAttributes) iaca;
// TODO, use the configured value.
rca.setRemoteType( RemoteType.LOCAL );
- RemoteHttpClientListener<K, V> listener = new RemoteHttpClientListener<>( rca, cacheMgr, elementSerializer );
+ final RemoteHttpClientListener<K, V> listener = new RemoteHttpClientListener<>( rca, cacheMgr, elementSerializer );
- IRemoteHttpCacheClient<K, V> remoteService = createRemoteHttpCacheClientForAttributes(rca);
+ final IRemoteHttpCacheClient<K, V> remoteService = createRemoteHttpCacheClientForAttributes(rca);
- IRemoteCacheClient<K, V> remoteCacheClient =
+ final IRemoteCacheClient<K, V> remoteCacheClient =
new RemoteHttpCache<>( rca, remoteService, listener, monitor );
remoteCacheClient.setCacheEventLogger( cacheEventLogger );
remoteCacheClient.setElementSerializer( elementSerializer );
- RemoteCacheNoWait<K, V> remoteCacheNoWait = new RemoteCacheNoWait<>( remoteCacheClient );
+ final RemoteCacheNoWait<K, V> remoteCacheNoWait = new RemoteCacheNoWait<>( remoteCacheClient );
remoteCacheNoWait.setCacheEventLogger( cacheEventLogger );
remoteCacheNoWait.setElementSerializer( elementSerializer );
@@ -93,7 +93,7 @@ public class RemoteHttpCacheFactory
* @param cattr the cache configuration
* @return the client instance
*/
- protected <V, K> IRemoteHttpCacheClient<K, V> createRemoteHttpCacheClientForAttributes(RemoteHttpCacheAttributes cattr)
+ protected <V, K> IRemoteHttpCacheClient<K, V> createRemoteHttpCacheClientForAttributes(final RemoteHttpCacheAttributes cattr)
{
IRemoteHttpCacheClient<K, V> remoteService = OptionConverter.instantiateByClassName( cattr
.getRemoteHttpClientClassName(), null );
@@ -134,7 +134,7 @@ public class RemoteHttpCacheFactory
{
monitor.join(5000);
}
- catch (InterruptedException e)
+ catch (final InterruptedException e)
{
// swallow
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java
index 34e3ae4..2644672 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java
@@ -45,7 +45,7 @@ public class RemoteHttpCacheMonitor extends AbstractAuxiliaryCacheMonitor
*
* @param factory the factory to set
*/
- public RemoteHttpCacheMonitor(RemoteHttpCacheFactory factory)
+ public RemoteHttpCacheMonitor(final RemoteHttpCacheFactory factory)
{
super("JCS-RemoteHttpCacheMonitor");
this.factory = factory;
@@ -58,7 +58,7 @@ public class RemoteHttpCacheMonitor extends AbstractAuxiliaryCacheMonitor
* <p>
* @param remoteCache
*/
- public void notifyError( RemoteHttpCache<?, ?> remoteCache )
+ public void notifyError( final RemoteHttpCache<?, ?> remoteCache )
{
if ( log.isInfoEnabled() )
{
@@ -95,15 +95,15 @@ public class RemoteHttpCacheMonitor extends AbstractAuxiliaryCacheMonitor
// If any cache is in error, it strongly suggests all caches
// managed by the same RmicCacheManager instance are in error. So we fix
// them once and for all.
- for (RemoteHttpCache<?, ?> remoteCache : this.remoteHttpCaches.values())
+ for (final RemoteHttpCache<?, ?> remoteCache : this.remoteHttpCaches.values())
{
try
{
if ( remoteCache.getStatus() == CacheStatus.ERROR )
{
- RemoteHttpCacheAttributes attributes = remoteCache.getRemoteHttpCacheAttributes();
+ final RemoteHttpCacheAttributes attributes = remoteCache.getRemoteHttpCacheAttributes();
- IRemoteHttpCacheClient<Serializable, Serializable> remoteService =
+ final IRemoteHttpCacheClient<Serializable, Serializable> remoteService =
factory.createRemoteHttpCacheClientForAttributes( attributes );
if ( log.isInfoEnabled() )
@@ -123,7 +123,7 @@ public class RemoteHttpCacheMonitor extends AbstractAuxiliaryCacheMonitor
break;
}
}
- catch ( IOException ex )
+ catch ( final IOException ex )
{
allright.set(false);
// Problem encountered in fixing the caches managed by a
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpClientListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpClientListener.java
index 0247204..b4b0b8a 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpClientListener.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/client/RemoteHttpClientListener.java
@@ -38,7 +38,7 @@ public class RemoteHttpClientListener<K, V>
* @param cacheMgr the cache hub
* @param elementSerializer a custom serializer
*/
- public RemoteHttpClientListener( IRemoteCacheAttributes irca, ICompositeCacheManager cacheMgr, IElementSerializer elementSerializer )
+ public RemoteHttpClientListener( final IRemoteCacheAttributes irca, final ICompositeCacheManager cacheMgr, final IElementSerializer elementSerializer )
{
super( irca, cacheMgr, elementSerializer );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/AbstractRemoteCacheService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/AbstractRemoteCacheService.java
index e84e575..3ee7f4c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/AbstractRemoteCacheService.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/AbstractRemoteCacheService.java
@@ -65,7 +65,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @param cacheManager
* @param cacheEventLogger
*/
- public AbstractRemoteCacheService( ICompositeCacheManager cacheManager, ICacheEventLogger cacheEventLogger )
+ public AbstractRemoteCacheService( final ICompositeCacheManager cacheManager, final ICacheEventLogger cacheEventLogger )
{
this.cacheManager = cacheManager;
this.cacheEventLogger = cacheEventLogger;
@@ -76,7 +76,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> item )
+ public void update( final ICacheElement<K, V> item )
throws IOException
{
update( item, 0 );
@@ -90,10 +90,10 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public void update( ICacheElement<K, V> item, long requesterId )
+ public void update( final ICacheElement<K, V> item, final long requesterId )
throws IOException
{
- ICacheEvent<ICacheElement<K, V>> cacheEvent = createICacheEvent( item, requesterId, ICacheEventLogger.UPDATE_EVENT );
+ final ICacheEvent<ICacheElement<K, V>> cacheEvent = createICacheEvent( item, requesterId, ICacheEventLogger.UPDATE_EVENT );
try
{
logUpdateInfo( item );
@@ -121,7 +121,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* <p>
* @param item
*/
- private void logUpdateInfo( ICacheElement<K, V> item )
+ private void logUpdateInfo( final ICacheElement<K, V> item )
{
if ( log.isInfoEnabled() )
{
@@ -147,7 +147,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> get( String cacheName, K key )
+ public ICacheElement<K, V> get( final String cacheName, final K key )
throws IOException
{
return this.get( cacheName, key, 0 );
@@ -167,11 +167,11 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> get( String cacheName, K key, long requesterId )
+ public ICacheElement<K, V> get( final String cacheName, final K key, final long requesterId )
throws IOException
{
ICacheElement<K, V> element = null;
- ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.GET_EVENT );
+ final ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.GET_EVENT );
try
{
element = processGet( cacheName, key, requesterId );
@@ -206,7 +206,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern )
+ public Map<K, ICacheElement<K, V>> getMatching( final String cacheName, final String pattern )
throws IOException
{
return getMatching( cacheName, pattern, 0 );
@@ -222,10 +222,10 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMatching( String cacheName, String pattern, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMatching( final String cacheName, final String pattern, final long requesterId )
throws IOException
{
- ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, pattern, requesterId,
+ final ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, pattern, requesterId,
ICacheEventLogger.GETMATCHING_EVENT );
try
{
@@ -259,7 +259,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys )
+ public Map<K, ICacheElement<K, V>> getMultiple( final String cacheName, final Set<K> keys )
throws IOException
{
return this.getMultiple( cacheName, keys, 0 );
@@ -278,10 +278,10 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
+ public Map<K, ICacheElement<K, V>> getMultiple( final String cacheName, final Set<K> keys, final long requesterId )
throws IOException
{
- ICacheEvent<Serializable> cacheEvent = createICacheEvent( cacheName, (Serializable) keys, requesterId,
+ final ICacheEvent<Serializable> cacheEvent = createICacheEvent( cacheName, (Serializable) keys, requesterId,
ICacheEventLogger.GETMULTIPLE_EVENT );
try
{
@@ -312,7 +312,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @see org.apache.commons.jcs3.auxiliary.AuxiliaryCache#getKeySet()
*/
@Override
- public Set<K> getKeySet( String cacheName )
+ public Set<K> getKeySet( final String cacheName )
{
return processGetKeySet( cacheName );
}
@@ -323,9 +323,9 @@ public abstract class AbstractRemoteCacheService<K, V>
* @param cacheName
* @return Set
*/
- public Set<K> processGetKeySet( String cacheName )
+ public Set<K> processGetKeySet( final String cacheName )
{
- CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
return cache.getKeySet();
}
@@ -338,7 +338,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public void remove( String cacheName, K key )
+ public void remove( final String cacheName, final K key )
throws IOException
{
remove( cacheName, key, 0 );
@@ -355,10 +355,10 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public void remove( String cacheName, K key, long requesterId )
+ public void remove( final String cacheName, final K key, final long requesterId )
throws IOException
{
- ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.REMOVE_EVENT );
+ final ICacheEvent<K> cacheEvent = createICacheEvent( cacheName, key, requesterId, ICacheEventLogger.REMOVE_EVENT );
try
{
processRemove( cacheName, key, requesterId );
@@ -387,7 +387,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public void removeAll( String cacheName )
+ public void removeAll( final String cacheName )
throws IOException
{
removeAll( cacheName, 0 );
@@ -403,10 +403,10 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public void removeAll( String cacheName, long requesterId )
+ public void removeAll( final String cacheName, final long requesterId )
throws IOException
{
- ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "all", requesterId, ICacheEventLogger.REMOVEALL_EVENT );
+ final ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "all", requesterId, ICacheEventLogger.REMOVEALL_EVENT );
try
{
processRemoveAll( cacheName, requesterId );
@@ -434,7 +434,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @throws IOException
*/
@Override
- public void dispose( String cacheName )
+ public void dispose( final String cacheName )
throws IOException
{
dispose( cacheName, 0 );
@@ -447,10 +447,10 @@ public abstract class AbstractRemoteCacheService<K, V>
* @param requesterId
* @throws IOException
*/
- public void dispose( String cacheName, long requesterId )
+ public void dispose( final String cacheName, final long requesterId )
throws IOException
{
- ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "none", requesterId, ICacheEventLogger.DISPOSE_EVENT );
+ final ICacheEvent<String> cacheEvent = createICacheEvent( cacheName, "none", requesterId, ICacheEventLogger.DISPOSE_EVENT );
try
{
processDispose( cacheName, requesterId );
@@ -489,13 +489,13 @@ public abstract class AbstractRemoteCacheService<K, V>
* @param eventName
* @return ICacheEvent
*/
- protected ICacheEvent<ICacheElement<K, V>> createICacheEvent( ICacheElement<K, V> item, long requesterId, String eventName )
+ protected ICacheEvent<ICacheElement<K, V>> createICacheEvent( final ICacheElement<K, V> item, final long requesterId, final String eventName )
{
if ( cacheEventLogger == null )
{
return new CacheEvent<>();
}
- String ipAddress = getExtraInfoForRequesterId( requesterId );
+ final String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger.createICacheEvent( getEventLogSourceName(), item.getCacheName(), eventName, ipAddress,
item );
}
@@ -509,13 +509,13 @@ public abstract class AbstractRemoteCacheService<K, V>
* @param eventName
* @return ICacheEvent
*/
- protected <T> ICacheEvent<T> createICacheEvent( String cacheName, T key, long requesterId, String eventName )
+ protected <T> ICacheEvent<T> createICacheEvent( final String cacheName, final T key, final long requesterId, final String eventName )
{
if ( cacheEventLogger == null )
{
return new CacheEvent<>();
}
- String ipAddress = getExtraInfoForRequesterId( requesterId );
+ final String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger.createICacheEvent( getEventLogSourceName(), cacheName, eventName, ipAddress, key );
}
@@ -526,7 +526,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* @param eventName
* @param optionalDetails
*/
- protected void logApplicationEvent( String source, String eventName, String optionalDetails )
+ protected void logApplicationEvent( final String source, final String eventName, final String optionalDetails )
{
if ( cacheEventLogger != null )
{
@@ -539,7 +539,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* <p>
* @param cacheEvent
*/
- protected <T> void logICacheEvent( ICacheEvent<T> cacheEvent )
+ protected <T> void logICacheEvent( final ICacheEvent<T> cacheEvent )
{
if ( cacheEventLogger != null )
{
@@ -562,7 +562,7 @@ public abstract class AbstractRemoteCacheService<K, V>
* <p>
* @param cacheEventLogger
*/
- public void setCacheEventLogger( ICacheEventLogger cacheEventLogger )
+ public void setCacheEventLogger( final ICacheEventLogger cacheEventLogger )
{
this.cacheEventLogger = cacheEventLogger;
}
@@ -570,7 +570,7 @@ public abstract class AbstractRemoteCacheService<K, V>
/**
* @param cacheManager the cacheManager to set
*/
- protected void setCacheManager( ICompositeCacheManager cacheManager )
+ protected void setCacheManager( final ICompositeCacheManager cacheManager )
{
this.cacheManager = cacheManager;
}
@@ -586,7 +586,7 @@ public abstract class AbstractRemoteCacheService<K, V>
/**
* @param eventLogSourceName the eventLogSourceName to set
*/
- protected void setEventLogSourceName( String eventLogSourceName )
+ protected void setEventLogSourceName( final String eventLogSourceName )
{
this.eventLogSourceName = eventLogSourceName;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServerAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServerAttributes.java
index aa14823..1347572 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServerAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServerAttributes.java
@@ -52,7 +52,7 @@ public class RemoteHttpCacheServerAttributes
* <p>
* @param r The new localClusterConsistency value
*/
- public void setLocalClusterConsistency( boolean r )
+ public void setLocalClusterConsistency( final boolean r )
{
this.localClusterConsistency = r;
}
@@ -72,7 +72,7 @@ public class RemoteHttpCacheServerAttributes
* <p>
* @param r The new localClusterConsistency value
*/
- public void setAllowClusterGet( boolean r )
+ public void setAllowClusterGet( final boolean r )
{
allowClusterGet = r;
}
@@ -83,7 +83,7 @@ public class RemoteHttpCacheServerAttributes
@Override
public String toString()
{
- StringBuilder buf = new StringBuilder();
+ final StringBuilder buf = new StringBuilder();
buf.append( "\nRemoteHttpCacheServiceAttributes" );
buf.append( "\n cacheName = [" + this.getCacheName() + "]" );
buf.append( "\n allowClusterGet = [" + this.isAllowClusterGet() + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheService.java
index 4f0c251..0888ee9 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheService.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheService.java
@@ -51,9 +51,9 @@ public class RemoteHttpCacheService<K, V>
* @param remoteHttpCacheServerAttributes
* @param cacheEventLogger
*/
- public RemoteHttpCacheService( ICompositeCacheManager cacheManager,
- RemoteHttpCacheServerAttributes remoteHttpCacheServerAttributes,
- ICacheEventLogger cacheEventLogger )
+ public RemoteHttpCacheService( final ICompositeCacheManager cacheManager,
+ final RemoteHttpCacheServerAttributes remoteHttpCacheServerAttributes,
+ final ICacheEventLogger cacheEventLogger )
{
super( cacheManager, cacheEventLogger );
setEventLogSourceName( EVENT_LOG_SOURCE_NAME );
@@ -72,12 +72,12 @@ public class RemoteHttpCacheService<K, V>
* @throws IOException
*/
@Override
- public ICacheElement<K, V> processGet( String cacheName, K key, long requesterId )
+ public ICacheElement<K, V> processGet( final String cacheName, final K key, final long requesterId )
throws IOException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
- boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
+ final boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
if ( keepLocal )
{
return cache.localGet( key );
@@ -101,12 +101,12 @@ public class RemoteHttpCacheService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> processGetMultiple( String cacheName, Set<K> keys, long requesterId )
+ public Map<K, ICacheElement<K, V>> processGetMultiple( final String cacheName, final Set<K> keys, final long requesterId )
throws IOException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
- boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
+ final boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
if ( keepLocal )
{
return cache.localGetMultiple( keys );
@@ -130,12 +130,12 @@ public class RemoteHttpCacheService<K, V>
* @throws IOException
*/
@Override
- public Map<K, ICacheElement<K, V>> processGetMatching( String cacheName, String pattern, long requesterId )
+ public Map<K, ICacheElement<K, V>> processGetMatching( final String cacheName, final String pattern, final long requesterId )
throws IOException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
- boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
+ final boolean keepLocal = !remoteHttpCacheServerAttributes.isAllowClusterGet();
if ( keepLocal )
{
return cache.localGetMatching( pattern );
@@ -157,12 +157,12 @@ public class RemoteHttpCacheService<K, V>
* @throws IOException
*/
@Override
- public void processUpdate( ICacheElement<K, V> item, long requesterId )
+ public void processUpdate( final ICacheElement<K, V> item, final long requesterId )
throws IOException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( item.getCacheName() );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( item.getCacheName() );
- boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
+ final boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
if ( keepLocal )
{
cache.localUpdate( item );
@@ -185,12 +185,12 @@ public class RemoteHttpCacheService<K, V>
* @throws IOException
*/
@Override
- public void processRemove( String cacheName, K key, long requesterId )
+ public void processRemove( final String cacheName, final K key, final long requesterId )
throws IOException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
- boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
+ final boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
if ( keepLocal )
{
cache.localRemove( key );
@@ -212,12 +212,12 @@ public class RemoteHttpCacheService<K, V>
* @throws IOException
*/
@Override
- public void processRemoveAll( String cacheName, long requesterId )
+ public void processRemoveAll( final String cacheName, final long requesterId )
throws IOException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
- boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
+ final boolean keepLocal = !remoteHttpCacheServerAttributes.isLocalClusterConsistency();
if ( keepLocal )
{
cache.localRemoveAll();
@@ -236,10 +236,10 @@ public class RemoteHttpCacheService<K, V>
* @throws IOException
*/
@Override
- public void processDispose( String cacheName, long requesterId )
+ public void processDispose( final String cacheName, final long requesterId )
throws IOException
{
- CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
+ final CompositeCache<K, V> cache = getCacheManager().getCache( cacheName );
cache.dispose();
}
@@ -262,7 +262,7 @@ public class RemoteHttpCacheService<K, V>
* @return requesterId + ""
*/
@Override
- protected String getExtraInfoForRequesterId( long requesterId )
+ protected String getExtraInfoForRequesterId( final long requesterId )
{
return requesterId + "";
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
index 20bff1c..daa93bc 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs3/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
@@ -88,14 +88,14 @@ public class RemoteHttpCacheServlet
* @throws ServletException
*/
@Override
- public void init( ServletConfig config )
+ public void init( final ServletConfig config )
throws ServletException
{
try
{
cacheMgr = CompositeCacheManager.getInstance();
}
- catch (CacheException e)
+ catch (final CacheException e)
{
throw new ServletException(e);
}
@@ -114,14 +114,14 @@ public class RemoteHttpCacheServlet
* @throws IOException
*/
@Override
- public void service( HttpServletRequest request, HttpServletResponse response )
+ public void service( final HttpServletRequest request, final HttpServletResponse response )
throws ServletException, IOException
{
incrementServiceCallCount();
log.debug( "Servicing a request. {0}", request );
- RemoteCacheRequest<Serializable, Serializable> remoteRequest = readRequest( request );
- RemoteCacheResponse<Object> cacheResponse = processRequest( remoteRequest );
+ final RemoteCacheRequest<Serializable, Serializable> remoteRequest = readRequest( request );
+ final RemoteCacheResponse<Object> cacheResponse = processRequest( remoteRequest );
writeResponse( response, cacheResponse );
}
@@ -132,17 +132,17 @@ public class RemoteHttpCacheServlet
* @param request
* @return RemoteHttpCacheRequest
*/
- protected RemoteCacheRequest<Serializable, Serializable> readRequest( HttpServletRequest request )
+ protected RemoteCacheRequest<Serializable, Serializable> readRequest( final HttpServletRequest request )
{
RemoteCacheRequest<Serializable, Serializable> remoteRequest = null;
try
{
- InputStream inputStream = request.getInputStream();
+ final InputStream inputStream = request.getInputStream();
log.debug( "After getting input stream and before reading it" );
remoteRequest = readRequestFromStream( inputStream );
}
- catch ( Exception e )
+ catch ( final Exception e )
{
log.error( "Could not get a RemoteHttpCacheRequest object from the input stream.", e );
}
@@ -157,12 +157,13 @@ public class RemoteHttpCacheServlet
* @throws IOException
* @throws ClassNotFoundException
*/
- protected RemoteCacheRequest<Serializable, Serializable> readRequestFromStream( InputStream inputStream )
+ protected RemoteCacheRequest<Serializable, Serializable> readRequestFromStream( final InputStream inputStream )
throws IOException, ClassNotFoundException
{
- ObjectInputStream ois = new ObjectInputStreamClassLoaderAware( inputStream, null );
+ final ObjectInputStream ois = new ObjectInputStreamClassLoaderAware( inputStream, null );
@SuppressWarnings("unchecked") // Need to cast from Object
+ final
RemoteCacheRequest<Serializable, Serializable> remoteRequest
= (RemoteCacheRequest<Serializable, Serializable>) ois.readObject();
ois.close();
@@ -175,16 +176,16 @@ public class RemoteHttpCacheServlet
* @param response
* @param cacheResponse
*/
- protected void writeResponse( HttpServletResponse response, RemoteCacheResponse<Object> cacheResponse )
+ protected void writeResponse( final HttpServletResponse response, final RemoteCacheResponse<Object> cacheResponse )
{
try
{
response.setContentType( "application/octet-stream" );
- byte[] responseAsByteAray = serializer.serialize( cacheResponse );
+ final byte[] responseAsByteAray = serializer.serialize( cacheResponse );
response.setContentLength( responseAsByteAray.length );
- OutputStream outputStream = response.getOutputStream();
+ final OutputStream outputStream = response.getOutputStream();
log.debug( "Opened output stream. Response size: {0}",
() -> responseAsByteAray.length );
// WRITE
@@ -192,7 +193,7 @@ public class RemoteHttpCacheServlet
outputStream.flush();
outputStream.close();
}
- catch ( IOException e )
+ catch ( final IOException e )
{
log.error( "Problem writing response. {0}", cacheResponse, e );
}
@@ -204,13 +205,13 @@ public class RemoteHttpCacheServlet
* @param request
* @return RemoteHttpCacheResponse, never null
*/
- protected RemoteCacheResponse<Object> processRequest( RemoteCacheRequest<Serializable, Serializable> request )
+ protected RemoteCacheResponse<Object> processRequest( final RemoteCacheRequest<Serializable, Serializable> request )
{
- RemoteCacheResponse<Object> response = new RemoteCacheResponse<>();
+ final RemoteCacheResponse<Object> response = new RemoteCacheResponse<>();
if ( request == null )
{
- String message = "The request is null. Cannot process";
+ final String message = "The request is null. Cannot process";
log.warn( message );
response.setSuccess( false );
response.setErrorMessage( message );
@@ -222,12 +223,12 @@ public class RemoteHttpCacheServlet
switch ( request.getRequestType() )
{
case GET:
- ICacheElement<Serializable, Serializable> element =
+ final ICacheElement<Serializable, Serializable> element =
remoteCacheService.get( request.getCacheName(), request.getKey(), request.getRequesterId() );
response.setPayload(element);
break;
case GET_MULTIPLE:
- Map<Serializable, ICacheElement<Serializable, Serializable>> elementMap =
+ final Map<Serializable, ICacheElement<Serializable, Serializable>> elementMap =
remoteCacheService.getMultiple( request.getCacheName(), request.getKeySet(), request.getRequesterId() );
if ( elementMap != null )
{
@@ -235,7 +236,7 @@ public class RemoteHttpCacheServlet
}
break;
case GET_MATCHING:
- Map<Serializable, ICacheElement<Serializable, Serializable>> elementMapMatching =
+ final Map<Serializable, ICacheElement<Serializable, Serializable>> elementMapMatching =
remoteCacheService.getMatching( request.getCacheName(), request.getPattern(), request.getRequesterId() );
if ( elementMapMatching != null )
{
@@ -257,20 +258,20 @@ public class RemoteHttpCacheServlet
// DO NOTHING
break;
case GET_KEYSET:
- Set<Serializable> keys = remoteCacheService.getKeySet( request.getCacheName() );
+ final Set<Serializable> keys = remoteCacheService.getKeySet( request.getCacheName() );
response.setPayload( keys );
break;
default:
- String message = "Unknown event type. Cannot process " + request;
+ final String message = "Unknown event type. Cannot process " + request;
log.warn( message );
response.setSuccess( false );
response.setErrorMessage( message );
break;
}
}
- catch ( IOException e )
+ catch ( final IOException e )
{
- String message = "Problem processing request. " + request + " Error: " + e.getMessage();
+ final String message = "Problem processing request. " + request + " Error: " + e.getMessage();
log.error( message, e );
response.setSuccess( false );
response.setErrorMessage( message );
@@ -286,13 +287,13 @@ public class RemoteHttpCacheServlet
* @param cacheManager
* @return RemoteHttpCacheService
*/
- protected <K, V> RemoteHttpCacheService<K, V> createRemoteHttpCacheService( ICompositeCacheManager cacheManager )
+ protected <K, V> RemoteHttpCacheService<K, V> createRemoteHttpCacheService( final ICompositeCacheManager cacheManager )
{
- Properties props = cacheManager.getConfigurationProperties();
- ICacheEventLogger cacheEventLogger = configureCacheEventLogger( props );
- RemoteHttpCacheServerAttributes attributes = configureRemoteHttpCacheServerAttributes( props );
+ final Properties props = cacheManager.getConfigurationProperties();
+ final ICacheEventLogger cacheEventLogger = configureCacheEventLogger( props );
+ final RemoteHttpCacheServerAttributes attributes = configureRemoteHttpCacheServerAttributes( props );
- RemoteHttpCacheService<K, V> service = new RemoteHttpCacheService<>( cacheManager, attributes, cacheEventLogger );
+ final RemoteHttpCacheService<K, V> service = new RemoteHttpCacheService<>( cacheManager, attributes, cacheEventLogger );
log.info( "Created new RemoteHttpCacheService {0}", service );
return service;
}
@@ -303,9 +304,9 @@ public class RemoteHttpCacheServlet
* @param props
* @return ICacheEventLogger
*/
- protected ICacheEventLogger configureCacheEventLogger( Properties props )
+ protected ICacheEventLogger configureCacheEventLogger( final Properties props )
{
- ICacheEventLogger cacheEventLogger = AuxiliaryCacheConfigurator
+ final ICacheEventLogger cacheEventLogger = AuxiliaryCacheConfigurator
.parseCacheEventLogger( props, IRemoteHttpCacheConstants.HTTP_CACHE_SERVER_PREFIX );
return cacheEventLogger;
@@ -319,9 +320,9 @@ public class RemoteHttpCacheServlet
* @param prop
* @return RemoteCacheServerAttributesconfigureRemoteCacheServerAttributes
*/
- protected RemoteHttpCacheServerAttributes configureRemoteHttpCacheServerAttributes( Properties prop )
+ protected RemoteHttpCacheServerAttributes configureRemoteHttpCacheServerAttributes( final Properties prop )
{
- RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes();
+ final RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes();
// configure automatically
PropertySetter.setProperties( rcsa, prop,
@@ -333,7 +334,7 @@ public class RemoteHttpCacheServlet
/**
... 22218 lines suppressed ...