GEODE-2632: change dependencies on GemFireCacheImpl to InternalCache * misc cleanup of code where possible
Project: http://git-wip-us.apache.org/repos/asf/geode/repo Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/0d0bf253 Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/0d0bf253 Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/0d0bf253 Branch: refs/heads/feature/GEODE-2632-11 Commit: 0d0bf253f80aac30eba053df38ba9c2dc786ba31 Parents: aebd11f Author: Kirk Lund <kl...@apache.org> Authored: Mon May 1 12:48:06 2017 -0700 Committer: Kirk Lund <kl...@apache.org> Committed: Wed May 3 17:06:17 2017 -0700 ---------------------------------------------------------------------- .../session/internal/common/CacheProperty.java | 9 +- .../internal/filter/GemfireSessionManager.java | 332 +- .../session/catalina/DeltaSessionManager.java | 250 +- .../modules/util/CreateRegionFunction.java | 62 +- .../internal/ra/spi/JCALocalTransaction.java | 88 +- .../internal/ra/spi/JCAManagedConnection.java | 225 +- .../java/org/apache/geode/DataSerializer.java | 3 +- .../apache/geode/admin/GemFireMemberStatus.java | 27 +- .../admin/internal/CacheHealthEvaluator.java | 71 +- .../admin/internal/FinishBackupRequest.java | 3 +- .../admin/internal/FlushToDiskRequest.java | 9 +- .../admin/internal/MemberHealthEvaluator.java | 102 +- .../admin/internal/PrepareBackupRequest.java | 5 +- .../apache/geode/cache/AttributesFactory.java | 279 +- .../geode/cache/CacheClosedException.java | 18 +- .../org/apache/geode/cache/CacheFactory.java | 66 +- .../geode/cache/DynamicRegionFactory.java | 291 +- .../org/apache/geode/cache/GemFireCache.java | 54 +- .../java/org/apache/geode/cache/Region.java | 1 + .../org/apache/geode/cache/RegionFactory.java | 114 +- .../TransactionDataRebalancedException.java | 8 + .../internal/AsyncEventQueueFactoryImpl.java | 13 +- .../internal/AsyncEventQueueImpl.java | 8 +- .../internal/ParallelAsyncEventQueueImpl.java | 7 +- .../internal/SerialAsyncEventQueueImpl.java | 3 +- .../geode/cache/client/ClientCacheFactory.java | 26 +- .../internal/ClientRegionFactoryImpl.java | 11 +- .../cache/client/internal/ConnectionImpl.java | 33 +- .../cache/client/internal/ExecutablePool.java | 1 - .../client/internal/ExecuteFunctionOp.java | 7 +- .../internal/ExecuteRegionFunctionOp.java | 7 +- .../ExecuteRegionFunctionSingleHopOp.java | 29 +- .../geode/cache/client/internal/GetOp.java | 3 +- .../client/internal/InternalClientCache.java | 37 + .../cache/client/internal/LiveServerPinger.java | 3 +- .../internal/PdxRegistryRecoveryListener.java | 3 +- .../geode/cache/client/internal/PoolImpl.java | 113 +- .../geode/cache/client/internal/ProxyCache.java | 73 +- .../cache/client/internal/QueueManagerImpl.java | 22 +- .../client/internal/RegisterInterestOp.java | 56 +- .../internal/FunctionServiceManager.java | 105 +- .../cache/partition/PartitionRegionHelper.java | 35 +- .../query/internal/AbstractCompiledValue.java | 2 +- .../internal/CompiledAggregateFunction.java | 2 +- .../query/internal/CompiledBindArgument.java | 2 +- .../query/internal/CompiledComparison.java | 2 +- .../cache/query/internal/CompiledFunction.java | 4 +- .../query/internal/CompiledGroupBySelect.java | 8 +- .../geode/cache/query/internal/CompiledID.java | 2 +- .../geode/cache/query/internal/CompiledIn.java | 185 +- .../query/internal/CompiledIndexOperation.java | 2 +- .../query/internal/CompiledIteratorDef.java | 87 +- .../cache/query/internal/CompiledLike.java | 70 +- .../cache/query/internal/CompiledLiteral.java | 2 +- .../cache/query/internal/CompiledNegation.java | 2 +- .../cache/query/internal/CompiledOperation.java | 2 +- .../cache/query/internal/CompiledPath.java | 2 +- .../cache/query/internal/CompiledRegion.java | 3 +- .../cache/query/internal/CompiledSelect.java | 128 +- .../query/internal/CompiledSortCriterion.java | 57 +- .../cache/query/internal/CompiledUndefined.java | 5 +- .../cache/query/internal/CompiledValue.java | 118 +- .../cache/query/internal/DefaultQuery.java | 393 +- .../cache/query/internal/ExecutionContext.java | 226 +- .../query/internal/IndexConditioningHelper.java | 245 + .../internal/IndexCutDownExpansionHelper.java | 80 + .../query/internal/QueryExecutionContext.java | 54 +- .../cache/query/internal/QueryMonitor.java | 86 +- .../geode/cache/query/internal/QueryUtils.java | 862 +--- .../cache/query/internal/RangeJunction.java | 6 +- .../cache/query/internal/RuntimeIterator.java | 2 +- .../query/internal/index/AbstractIndex.java | 962 ++-- .../query/internal/index/AbstractMapIndex.java | 14 +- .../internal/index/CompactMapRangeIndex.java | 6 +- .../query/internal/index/CompactRangeIndex.java | 211 +- .../query/internal/index/DummyQRegion.java | 20 +- .../index/FunctionalIndexCreationHelper.java | 409 +- .../cache/query/internal/index/HashIndex.java | 251 +- .../internal/index/IndexCreationHelper.java | 81 +- .../query/internal/index/IndexManager.java | 155 +- .../cache/query/internal/index/IndexStats.java | 27 +- .../cache/query/internal/index/IndexUtils.java | 40 +- .../query/internal/index/MemoryIndexStore.java | 125 +- .../query/internal/index/PartitionedIndex.java | 2 +- .../query/internal/index/PrimaryKeyIndex.java | 57 +- .../index/PrimaryKeyIndexCreationHelper.java | 21 +- .../cache/query/internal/index/RangeIndex.java | 21 +- .../geode/distributed/ServerLauncher.java | 69 +- .../internal/ClusterConfigurationService.java | 238 +- .../geode/distributed/internal/DSClock.java | 7 +- .../internal/InternalDistributedSystem.java | 25 +- .../distributed/internal/InternalLocator.java | 465 +- .../gms/mgr/GMSMembershipManager.java | 6 +- .../internal/tcpserver/TcpServer.java | 91 +- .../org/apache/geode/internal/DSFIDFactory.java | 34 +- .../org/apache/geode/internal/DeployedJar.java | 91 +- .../geode/internal/InternalDataSerializer.java | 1058 ++--- .../geode/internal/InternalInstantiator.java | 77 +- .../apache/geode/internal/MigrationClient.java | 82 +- .../apache/geode/internal/MigrationServer.java | 159 +- .../geode/internal/PdxSerializerObject.java | 2 +- .../admin/ClientHealthMonitoringRegion.java | 32 +- .../internal/admin/ClientStatsManager.java | 150 +- .../admin/remote/BridgeServerResponse.java | 40 +- .../admin/remote/CacheConfigResponse.java | 38 +- .../admin/remote/CacheInfoResponse.java | 34 +- .../internal/admin/remote/CompactRequest.java | 31 +- .../admin/remote/DurableClientInfoResponse.java | 38 +- .../remote/MissingPersistentIDsRequest.java | 32 +- .../PrepareRevokePersistentIDRequest.java | 36 +- .../remote/RefreshMemberSnapshotResponse.java | 18 +- .../remote/RegionSubRegionsSizeResponse.java | 57 +- .../internal/admin/remote/RemoteCacheInfo.java | 74 +- .../admin/remote/RevokePersistentIDRequest.java | 25 +- .../admin/remote/RootRegionResponse.java | 60 +- .../admin/remote/ShutdownAllRequest.java | 75 +- .../cache/AbstractBucketRegionQueue.java | 13 +- .../internal/cache/AbstractCacheServer.java | 8 +- .../internal/cache/AbstractDiskRegionEntry.java | 6 - .../cache/AbstractOplogDiskRegionEntry.java | 4 +- .../geode/internal/cache/AbstractRegion.java | 721 +-- .../internal/cache/AbstractRegionEntry.java | 724 ++- .../geode/internal/cache/AbstractRegionMap.java | 87 +- .../cache/AddCacheServerProfileMessage.java | 33 +- .../geode/internal/cache/BucketAdvisor.java | 40 +- .../geode/internal/cache/BucketRegion.java | 41 +- .../geode/internal/cache/BucketRegionQueue.java | 27 +- .../geode/internal/cache/CacheConfig.java | 3 +- .../cache/CacheDistributionAdvisee.java | 3 +- .../internal/cache/CacheLifecycleListener.java | 10 +- .../geode/internal/cache/CachePerfStats.java | 5 +- .../geode/internal/cache/CacheServerImpl.java | 137 +- .../internal/cache/CacheServerLauncher.java | 39 +- .../cache/CachedDeserializableFactory.java | 7 +- .../geode/internal/cache/ColocationHelper.java | 29 +- .../internal/cache/CreateRegionProcessor.java | 104 +- .../cache/DestroyPartitionedRegionMessage.java | 2 +- .../internal/cache/DestroyRegionOperation.java | 37 +- .../apache/geode/internal/cache/DiskEntry.java | 126 +- .../apache/geode/internal/cache/DiskRegion.java | 24 +- .../geode/internal/cache/DiskStoreBackup.java | 2 - .../internal/cache/DiskStoreFactoryImpl.java | 62 +- .../geode/internal/cache/DiskStoreImpl.java | 292 +- .../geode/internal/cache/DiskStoreMonitor.java | 75 +- .../internal/cache/DistTXCommitMessage.java | 23 +- .../internal/cache/DistTXPrecommitMessage.java | 66 +- .../internal/cache/DistTXRollbackMessage.java | 27 +- .../DistTXStateProxyImplOnCoordinator.java | 228 +- .../cache/DistributedCacheOperation.java | 120 +- .../geode/internal/cache/DistributedRegion.java | 1030 ++-- ...stributedRegionFunctionStreamingMessage.java | 17 +- .../cache/DynamicRegionFactoryImpl.java | 10 +- .../geode/internal/cache/EntryEventImpl.java | 116 +- .../apache/geode/internal/cache/EventID.java | 25 +- .../geode/internal/cache/EventTracker.java | 51 +- .../apache/geode/internal/cache/ExpiryTask.java | 32 +- .../geode/internal/cache/FilterProfile.java | 58 +- .../geode/internal/cache/FilterRoutingInfo.java | 49 +- .../cache/FindDurableQueueProcessor.java | 25 +- .../internal/cache/FindRemoteTXMessage.java | 15 +- .../internal/cache/FindVersionTagOperation.java | 15 +- .../geode/internal/cache/GemFireCacheImpl.java | 88 +- .../geode/internal/cache/GridAdvisor.java | 48 +- .../apache/geode/internal/cache/HARegion.java | 20 +- .../internal/cache/InitialImageOperation.java | 2 +- .../geode/internal/cache/InternalCache.java | 110 +- .../cache/JtaAfterCompletionMessage.java | 27 - .../cache/JtaBeforeCompletionMessage.java | 23 +- .../geode/internal/cache/LeafRegionEntry.cpp | 4 +- .../geode/internal/cache/LocalDataSet.java | 2 +- .../geode/internal/cache/LocalRegion.java | 4434 ++++++++---------- .../cache/MemberFunctionStreamingMessage.java | 37 +- .../internal/cache/NonLocalRegionEntry.java | 7 - .../org/apache/geode/internal/cache/Oplog.java | 642 +-- .../geode/internal/cache/OverflowOplog.java | 277 +- .../internal/cache/PRHARedundancyProvider.java | 5 +- .../geode/internal/cache/PRQueryProcessor.java | 96 +- .../internal/cache/PartitionAttributesImpl.java | 121 +- .../geode/internal/cache/PartitionedRegion.java | 1464 +++--- .../internal/cache/PartitionedRegionHelper.java | 176 +- .../geode/internal/cache/PoolFactoryImpl.java | 29 +- .../geode/internal/cache/ProxyBucketRegion.java | 2 +- .../geode/internal/cache/ProxyRegionMap.java | 15 +- .../geode/internal/cache/RegionEvictorTask.java | 25 +- .../geode/internal/cache/RegionFactoryImpl.java | 20 +- .../internal/cache/RemoteOperationMessage.java | 76 +- .../geode/internal/cache/RemotePutMessage.java | 11 - .../cache/SearchLoadAndWriteProcessor.java | 209 +- .../geode/internal/cache/ServerPingMessage.java | 2 +- .../internal/cache/StateFlushOperation.java | 35 +- .../geode/internal/cache/TXCommitMessage.java | 286 +- .../geode/internal/cache/TXManagerImpl.java | 179 +- .../apache/geode/internal/cache/TXMessage.java | 17 +- .../internal/cache/TXRegionLockRequestImpl.java | 31 +- .../geode/internal/cache/TXRegionState.java | 2 +- .../internal/cache/TXRemoteCommitMessage.java | 21 +- .../internal/cache/TXRemoteRollbackMessage.java | 11 +- .../geode/internal/cache/TXStateProxyImpl.java | 339 +- .../cache/TXSynchronizationRunnable.java | 22 +- .../geode/internal/cache/TombstoneService.java | 55 +- .../VMStatsDiskLRURegionEntryHeapIntKey.java | 3 +- .../VMStatsDiskLRURegionEntryHeapLongKey.java | 3 +- .../VMStatsDiskLRURegionEntryHeapObjectKey.java | 3 +- ...VMStatsDiskLRURegionEntryHeapStringKey1.java | 3 +- ...VMStatsDiskLRURegionEntryHeapStringKey2.java | 3 +- .../VMStatsDiskLRURegionEntryHeapUUIDKey.java | 3 +- .../VMStatsDiskLRURegionEntryOffHeapIntKey.java | 3 +- ...VMStatsDiskLRURegionEntryOffHeapLongKey.java | 3 +- ...StatsDiskLRURegionEntryOffHeapObjectKey.java | 3 +- ...tatsDiskLRURegionEntryOffHeapStringKey1.java | 3 +- ...tatsDiskLRURegionEntryOffHeapStringKey2.java | 3 +- ...VMStatsDiskLRURegionEntryOffHeapUUIDKey.java | 3 +- .../internal/cache/VMStatsDiskRegionEntry.java | 3 - .../cache/VMStatsDiskRegionEntryHeapIntKey.java | 2 +- .../VMStatsDiskRegionEntryHeapLongKey.java | 2 +- .../VMStatsDiskRegionEntryHeapObjectKey.java | 2 +- .../VMStatsDiskRegionEntryHeapStringKey1.java | 2 +- .../VMStatsDiskRegionEntryHeapStringKey2.java | 2 +- .../VMStatsDiskRegionEntryHeapUUIDKey.java | 2 +- .../VMStatsDiskRegionEntryOffHeapIntKey.java | 2 +- .../VMStatsDiskRegionEntryOffHeapLongKey.java | 2 +- .../VMStatsDiskRegionEntryOffHeapObjectKey.java | 2 +- ...VMStatsDiskRegionEntryOffHeapStringKey1.java | 2 +- ...VMStatsDiskRegionEntryOffHeapStringKey2.java | 2 +- .../VMStatsDiskRegionEntryOffHeapUUIDKey.java | 2 +- .../cache/VMStatsLRURegionEntryHeapIntKey.java | 3 +- .../cache/VMStatsLRURegionEntryHeapLongKey.java | 3 +- .../VMStatsLRURegionEntryHeapObjectKey.java | 3 +- .../VMStatsLRURegionEntryHeapStringKey1.java | 3 +- .../VMStatsLRURegionEntryHeapStringKey2.java | 3 +- .../cache/VMStatsLRURegionEntryHeapUUIDKey.java | 3 +- .../VMStatsLRURegionEntryOffHeapIntKey.java | 3 +- .../VMStatsLRURegionEntryOffHeapLongKey.java | 3 +- .../VMStatsLRURegionEntryOffHeapObjectKey.java | 3 +- .../VMStatsLRURegionEntryOffHeapStringKey1.java | 3 +- .../VMStatsLRURegionEntryOffHeapStringKey2.java | 3 +- .../VMStatsLRURegionEntryOffHeapUUIDKey.java | 3 +- .../cache/VMStatsRegionEntryHeapIntKey.java | 2 +- .../cache/VMStatsRegionEntryHeapLongKey.java | 2 +- .../cache/VMStatsRegionEntryHeapObjectKey.java | 2 +- .../cache/VMStatsRegionEntryHeapStringKey1.java | 2 +- .../cache/VMStatsRegionEntryHeapStringKey2.java | 2 +- .../cache/VMStatsRegionEntryHeapUUIDKey.java | 2 +- .../cache/VMStatsRegionEntryOffHeapIntKey.java | 2 +- .../cache/VMStatsRegionEntryOffHeapLongKey.java | 2 +- .../VMStatsRegionEntryOffHeapObjectKey.java | 2 +- .../VMStatsRegionEntryOffHeapStringKey1.java | 2 +- .../VMStatsRegionEntryOffHeapStringKey2.java | 2 +- .../cache/VMStatsRegionEntryOffHeapUUIDKey.java | 2 +- .../VMThinDiskLRURegionEntryHeapIntKey.java | 2 +- .../VMThinDiskLRURegionEntryHeapLongKey.java | 2 +- .../VMThinDiskLRURegionEntryHeapObjectKey.java | 2 +- .../VMThinDiskLRURegionEntryHeapStringKey1.java | 2 +- .../VMThinDiskLRURegionEntryHeapStringKey2.java | 2 +- .../VMThinDiskLRURegionEntryHeapUUIDKey.java | 2 +- .../VMThinDiskLRURegionEntryOffHeapIntKey.java | 2 +- .../VMThinDiskLRURegionEntryOffHeapLongKey.java | 2 +- ...MThinDiskLRURegionEntryOffHeapObjectKey.java | 2 +- ...ThinDiskLRURegionEntryOffHeapStringKey1.java | 2 +- ...ThinDiskLRURegionEntryOffHeapStringKey2.java | 2 +- .../VMThinDiskLRURegionEntryOffHeapUUIDKey.java | 2 +- .../cache/VMThinDiskRegionEntryHeapIntKey.java | 2 +- .../cache/VMThinDiskRegionEntryHeapLongKey.java | 2 +- .../VMThinDiskRegionEntryHeapObjectKey.java | 2 +- .../VMThinDiskRegionEntryHeapStringKey1.java | 2 +- .../VMThinDiskRegionEntryHeapStringKey2.java | 2 +- .../cache/VMThinDiskRegionEntryHeapUUIDKey.java | 2 +- .../VMThinDiskRegionEntryOffHeapIntKey.java | 2 +- .../VMThinDiskRegionEntryOffHeapLongKey.java | 2 +- .../VMThinDiskRegionEntryOffHeapObjectKey.java | 2 +- .../VMThinDiskRegionEntryOffHeapStringKey1.java | 2 +- .../VMThinDiskRegionEntryOffHeapStringKey2.java | 2 +- .../VMThinDiskRegionEntryOffHeapUUIDKey.java | 2 +- .../cache/VMThinLRURegionEntryHeapIntKey.java | 2 +- .../cache/VMThinLRURegionEntryHeapLongKey.java | 2 +- .../VMThinLRURegionEntryHeapObjectKey.java | 2 +- .../VMThinLRURegionEntryHeapStringKey1.java | 2 +- .../VMThinLRURegionEntryHeapStringKey2.java | 2 +- .../cache/VMThinLRURegionEntryHeapUUIDKey.java | 2 +- .../VMThinLRURegionEntryOffHeapIntKey.java | 2 +- .../VMThinLRURegionEntryOffHeapLongKey.java | 2 +- .../VMThinLRURegionEntryOffHeapObjectKey.java | 2 +- .../VMThinLRURegionEntryOffHeapStringKey1.java | 2 +- .../VMThinLRURegionEntryOffHeapStringKey2.java | 2 +- .../VMThinLRURegionEntryOffHeapUUIDKey.java | 2 +- .../cache/VMThinRegionEntryHeapIntKey.java | 2 +- .../cache/VMThinRegionEntryHeapLongKey.java | 2 +- .../cache/VMThinRegionEntryHeapObjectKey.java | 2 +- .../cache/VMThinRegionEntryHeapStringKey1.java | 2 +- .../cache/VMThinRegionEntryHeapStringKey2.java | 2 +- .../cache/VMThinRegionEntryHeapUUIDKey.java | 2 +- .../cache/VMThinRegionEntryOffHeapIntKey.java | 2 +- .../cache/VMThinRegionEntryOffHeapLongKey.java | 2 +- .../VMThinRegionEntryOffHeapObjectKey.java | 2 +- .../VMThinRegionEntryOffHeapStringKey1.java | 2 +- .../VMThinRegionEntryOffHeapStringKey2.java | 2 +- .../cache/VMThinRegionEntryOffHeapUUIDKey.java | 2 +- ...sionedStatsDiskLRURegionEntryHeapIntKey.java | 3 +- ...ionedStatsDiskLRURegionEntryHeapLongKey.java | 7 +- ...nedStatsDiskLRURegionEntryHeapObjectKey.java | 3 +- ...edStatsDiskLRURegionEntryHeapStringKey1.java | 3 +- ...edStatsDiskLRURegionEntryHeapStringKey2.java | 3 +- ...ionedStatsDiskLRURegionEntryHeapUUIDKey.java | 3 +- ...nedStatsDiskLRURegionEntryOffHeapIntKey.java | 3 +- ...edStatsDiskLRURegionEntryOffHeapLongKey.java | 3 +- ...StatsDiskLRURegionEntryOffHeapObjectKey.java | 3 +- ...tatsDiskLRURegionEntryOffHeapStringKey1.java | 3 +- ...tatsDiskLRURegionEntryOffHeapStringKey2.java | 3 +- ...edStatsDiskLRURegionEntryOffHeapUUIDKey.java | 3 +- ...VersionedStatsDiskRegionEntryHeapIntKey.java | 2 +- ...ersionedStatsDiskRegionEntryHeapLongKey.java | 2 +- ...sionedStatsDiskRegionEntryHeapObjectKey.java | 2 +- ...ionedStatsDiskRegionEntryHeapStringKey1.java | 2 +- ...ionedStatsDiskRegionEntryHeapStringKey2.java | 2 +- ...ersionedStatsDiskRegionEntryHeapUUIDKey.java | 2 +- ...sionedStatsDiskRegionEntryOffHeapIntKey.java | 2 +- ...ionedStatsDiskRegionEntryOffHeapLongKey.java | 2 +- ...nedStatsDiskRegionEntryOffHeapObjectKey.java | 2 +- ...edStatsDiskRegionEntryOffHeapStringKey1.java | 2 +- ...edStatsDiskRegionEntryOffHeapStringKey2.java | 2 +- ...ionedStatsDiskRegionEntryOffHeapUUIDKey.java | 2 +- .../VersionedStatsLRURegionEntryHeapIntKey.java | 3 +- ...VersionedStatsLRURegionEntryHeapLongKey.java | 3 +- ...rsionedStatsLRURegionEntryHeapObjectKey.java | 3 +- ...sionedStatsLRURegionEntryHeapStringKey1.java | 3 +- ...sionedStatsLRURegionEntryHeapStringKey2.java | 3 +- ...VersionedStatsLRURegionEntryHeapUUIDKey.java | 3 +- ...rsionedStatsLRURegionEntryOffHeapIntKey.java | 3 +- ...sionedStatsLRURegionEntryOffHeapLongKey.java | 3 +- ...onedStatsLRURegionEntryOffHeapObjectKey.java | 3 +- ...nedStatsLRURegionEntryOffHeapStringKey1.java | 3 +- ...nedStatsLRURegionEntryOffHeapStringKey2.java | 3 +- ...sionedStatsLRURegionEntryOffHeapUUIDKey.java | 3 +- .../VersionedStatsRegionEntryHeapIntKey.java | 2 +- .../VersionedStatsRegionEntryHeapLongKey.java | 2 +- .../VersionedStatsRegionEntryHeapObjectKey.java | 2 +- ...VersionedStatsRegionEntryHeapStringKey1.java | 2 +- ...VersionedStatsRegionEntryHeapStringKey2.java | 2 +- .../VersionedStatsRegionEntryHeapUUIDKey.java | 2 +- .../VersionedStatsRegionEntryOffHeapIntKey.java | 2 +- ...VersionedStatsRegionEntryOffHeapLongKey.java | 2 +- ...rsionedStatsRegionEntryOffHeapObjectKey.java | 2 +- ...sionedStatsRegionEntryOffHeapStringKey1.java | 2 +- ...sionedStatsRegionEntryOffHeapStringKey2.java | 2 +- ...VersionedStatsRegionEntryOffHeapUUIDKey.java | 2 +- ...rsionedThinDiskLRURegionEntryHeapIntKey.java | 4 +- ...sionedThinDiskLRURegionEntryHeapLongKey.java | 4 +- ...onedThinDiskLRURegionEntryHeapObjectKey.java | 4 +- ...nedThinDiskLRURegionEntryHeapStringKey1.java | 4 +- ...nedThinDiskLRURegionEntryHeapStringKey2.java | 4 +- ...sionedThinDiskLRURegionEntryHeapUUIDKey.java | 4 +- ...onedThinDiskLRURegionEntryOffHeapIntKey.java | 4 +- ...nedThinDiskLRURegionEntryOffHeapLongKey.java | 4 +- ...dThinDiskLRURegionEntryOffHeapObjectKey.java | 4 +- ...ThinDiskLRURegionEntryOffHeapStringKey1.java | 4 +- ...ThinDiskLRURegionEntryOffHeapStringKey2.java | 4 +- ...nedThinDiskLRURegionEntryOffHeapUUIDKey.java | 4 +- .../VersionedThinDiskRegionEntryHeapIntKey.java | 2 +- ...VersionedThinDiskRegionEntryHeapLongKey.java | 2 +- ...rsionedThinDiskRegionEntryHeapObjectKey.java | 2 +- ...sionedThinDiskRegionEntryHeapStringKey1.java | 2 +- ...sionedThinDiskRegionEntryHeapStringKey2.java | 2 +- ...VersionedThinDiskRegionEntryHeapUUIDKey.java | 2 +- ...rsionedThinDiskRegionEntryOffHeapIntKey.java | 2 +- ...sionedThinDiskRegionEntryOffHeapLongKey.java | 2 +- ...onedThinDiskRegionEntryOffHeapObjectKey.java | 2 +- ...nedThinDiskRegionEntryOffHeapStringKey1.java | 2 +- ...nedThinDiskRegionEntryOffHeapStringKey2.java | 2 +- ...sionedThinDiskRegionEntryOffHeapUUIDKey.java | 2 +- .../VersionedThinLRURegionEntryHeapIntKey.java | 4 +- .../VersionedThinLRURegionEntryHeapLongKey.java | 4 +- ...ersionedThinLRURegionEntryHeapObjectKey.java | 4 +- ...rsionedThinLRURegionEntryHeapStringKey1.java | 4 +- ...rsionedThinLRURegionEntryHeapStringKey2.java | 4 +- .../VersionedThinLRURegionEntryHeapUUIDKey.java | 4 +- ...ersionedThinLRURegionEntryOffHeapIntKey.java | 4 +- ...rsionedThinLRURegionEntryOffHeapLongKey.java | 4 +- ...ionedThinLRURegionEntryOffHeapObjectKey.java | 4 +- ...onedThinLRURegionEntryOffHeapStringKey1.java | 4 +- ...onedThinLRURegionEntryOffHeapStringKey2.java | 4 +- ...rsionedThinLRURegionEntryOffHeapUUIDKey.java | 4 +- .../VersionedThinRegionEntryHeapIntKey.java | 2 +- .../VersionedThinRegionEntryHeapLongKey.java | 2 +- .../VersionedThinRegionEntryHeapObjectKey.java | 2 +- .../VersionedThinRegionEntryHeapStringKey1.java | 2 +- .../VersionedThinRegionEntryHeapStringKey2.java | 2 +- .../VersionedThinRegionEntryHeapUUIDKey.java | 2 +- .../VersionedThinRegionEntryOffHeapIntKey.java | 2 +- .../VersionedThinRegionEntryOffHeapLongKey.java | 2 +- ...ersionedThinRegionEntryOffHeapObjectKey.java | 2 +- ...rsionedThinRegionEntryOffHeapStringKey1.java | 2 +- ...rsionedThinRegionEntryOffHeapStringKey2.java | 2 +- .../VersionedThinRegionEntryOffHeapUUIDKey.java | 2 +- .../cache/control/HeapMemoryMonitor.java | 71 +- .../cache/control/InternalResourceManager.java | 47 +- .../cache/control/OffHeapMemoryMonitor.java | 10 +- .../cache/control/RebalanceOperationImpl.java | 35 +- .../internal/cache/control/ResourceAdvisor.java | 22 +- .../DistributedRegionFunctionExecutor.java | 10 +- .../DistributedRegionFunctionResultSender.java | 7 +- .../execute/FunctionExecutionNodePruner.java | 2 +- .../cache/execute/LocalResultCollectorImpl.java | 3 +- .../cache/execute/MemberFunctionExecutor.java | 11 +- .../execute/MultiRegionFunctionExecutor.java | 29 +- .../PartitionedRegionFunctionExecutor.java | 19 +- .../execute/ServerRegionFunctionExecutor.java | 35 +- .../util/FindRestEnabledServersFunction.java | 13 +- .../geode/internal/cache/ha/HARegionQueue.java | 676 +-- .../internal/cache/ha/QueueRemovalMessage.java | 51 +- .../partitioned/BecomePrimaryBucketMessage.java | 2 +- .../cache/partitioned/BucketSizeMessage.java | 2 +- .../partitioned/ContainsKeyValueMessage.java | 2 +- .../cache/partitioned/CreateBucketMessage.java | 3 +- .../partitioned/DeposePrimaryBucketMessage.java | 2 +- .../cache/partitioned/DestroyMessage.java | 3 +- .../cache/partitioned/DumpB2NRegion.java | 2 +- .../partitioned/EndBucketCreationMessage.java | 2 +- .../partitioned/FetchBulkEntriesMessage.java | 3 +- .../cache/partitioned/FetchEntriesMessage.java | 2 +- .../cache/partitioned/FetchEntryMessage.java | 2 +- .../cache/partitioned/FetchKeysMessage.java | 2 +- .../FetchPartitionDetailsMessage.java | 2 +- .../internal/cache/partitioned/GetMessage.java | 2 +- .../cache/partitioned/InterestEventMessage.java | 2 +- .../partitioned/ManageBackupBucketMessage.java | 3 +- .../cache/partitioned/ManageBucketMessage.java | 3 +- .../cache/partitioned/MoveBucketMessage.java | 2 +- .../cache/partitioned/PRSanityCheckMessage.java | 2 +- .../cache/partitioned/PRTombstoneMessage.java | 3 +- .../PRUpdateEntryVersionMessage.java | 3 +- .../cache/partitioned/PartitionMessage.java | 31 +- .../PartitionMessageWithDirectReply.java | 2 +- ...rtitionedRegionFunctionStreamingMessage.java | 2 +- .../cache/partitioned/PutAllPRMessage.java | 60 +- .../internal/cache/partitioned/PutMessage.java | 5 +- .../cache/partitioned/QueryMessage.java | 122 +- .../cache/partitioned/RemoveAllPRMessage.java | 3 +- .../cache/partitioned/RemoveBucketMessage.java | 2 +- .../internal/cache/partitioned/SizeMessage.java | 2 +- .../cache/persistence/BackupManager.java | 48 +- .../tier/sockets/command/ExecuteFunction66.java | 4 +- .../command/ExecuteRegionFunction66.java | 4 +- .../command/ExecuteRegionFunctionSingleHop.java | 4 +- .../cache/wan/AbstractGatewaySender.java | 2 +- .../internal/cache/xmlcache/CacheCreation.java | 814 ++-- .../cache/xmlcache/ClientCacheCreation.java | 132 +- .../xmlcache/DiskStoreAttributesCreation.java | 2 +- .../internal/cache/xmlcache/RegionCreation.java | 3 +- .../apache/geode/internal/lang/SystemUtils.java | 41 +- .../management/internal/JmxManagerLocator.java | 29 +- .../internal/beans/MemberMBeanBridge.java | 72 +- .../handlers/ConfigurationRequestHandler.java | 2 +- .../apache/geode/pdx/PdxInstanceFactory.java | 96 +- .../pdx/internal/ClientTypeRegistration.java | 6 +- .../pdx/internal/LonerTypeRegistration.java | 12 +- .../pdx/internal/PdxInstanceFactoryImpl.java | 111 +- .../pdx/internal/PeerTypeRegistration.java | 42 +- .../apache/geode/pdx/internal/TypeRegistry.java | 176 +- .../apache/geode/cache/query/CacheUtils.java | 181 +- .../query/functional/FunctionJUnitTest.java | 4 +- .../CompiledAggregateFunctionJUnitTest.java | 5 +- .../CompiledJunctionInternalsJUnitTest.java | 28 +- .../internal/ExecutionContextJUnitTest.java | 10 +- .../query/internal/IndexManagerJUnitTest.java | 16 +- ...ueryFromClauseCanonicalizationJUnitTest.java | 14 +- .../query/internal/QueryUtilsJUnitTest.java | 4 +- .../internal/index/RangeIndexAPIJUnitTest.java | 13 +- .../internal/cache/AbstractRegionEntryTest.java | 2 +- .../internal/cache/AbstractRegionJUnitTest.java | 5 +- .../geode/internal/cache/BackupJUnitTest.java | 55 +- .../cache/CacheLifecycleListenerJUnitTest.java | 90 +- .../internal/cache/DiskRegionTestingBase.java | 19 +- .../cache/IncrementalBackupDUnitTest.java | 183 +- .../PartitionedRegionCacheCloseDUnitTest.java | 2 +- .../PartitionedRegionCreationDUnitTest.java | 2 +- .../PartitionedRegionDestroyDUnitTest.java | 2 +- ...onedRegionHAFailureAndRecoveryDUnitTest.java | 10 +- ...onedRegionQueryEvaluatorIntegrationTest.java | 2 +- .../cache/PartitionedRegionTestHelper.java | 10 +- .../geode/internal/cache/TXManagerImplTest.java | 2 +- .../cache/ha/BlockingHARegionJUnitTest.java | 5 +- .../internal/cache/ha/HAExpiryDUnitTest.java | 39 +- .../internal/cache/ha/HAGIIBugDUnitTest.java | 5 +- .../geode/internal/cache/ha/HAHelper.java | 4 +- .../cache/ha/HARQAddOperationJUnitTest.java | 8 +- .../internal/cache/ha/HARegionDUnitTest.java | 9 +- .../cache/ha/HARegionQueueDUnitTest.java | 11 +- .../cache/ha/HARegionQueueJUnitTest.java | 11 +- .../ha/HARegionQueueStartStopJUnitTest.java | 9 +- .../cache/ha/HARegionQueueStatsJUnitTest.java | 7 +- .../cache/ha/TestBlockingHARegionQueue.java | 3 +- .../cache/partitioned/ShutdownAllDUnitTest.java | 36 +- .../fixed/FixedPartitioningTestBase.java | 5 +- .../ParallelQueueRemovalMessageJUnitTest.java | 29 +- .../cache/xmlcache/CacheCreationJUnitTest.java | 142 +- .../commands/DiskStoreCommandsDUnitTest.java | 19 +- .../cache/internal/JUnit3CacheTestCase.java | 12 +- .../cache/internal/JUnit4CacheTestCase.java | 30 +- .../test/dunit/standalone/RemoteDUnitVM.java | 53 +- .../test/dunit/standalone/RemoteDUnitVMIF.java | 6 +- .../cache/query/internal/cq/CqQueryImpl.java | 3 +- 501 files changed, 12711 insertions(+), 16135 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode/blob/0d0bf253/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java index fe16fc3..aa1a621 100644 --- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java +++ b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/common/CacheProperty.java @@ -12,7 +12,6 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.modules.session.internal.common; /** @@ -37,7 +36,7 @@ public enum CacheProperty { /** * This parameter can take the following values which match the respective attribute container * classes - * <p/> + * <p> * delta_queued : QueuedDeltaSessionAttributes delta_immediate : DeltaSessionAttributes immediate * : ImmediateSessionAttributes queued : QueuedSessionAttributes */ @@ -45,18 +44,18 @@ public enum CacheProperty { /** * This parameter can take the following values: - * <p/> + * <p> * set (default) set_and_get */ REPLICATION_TRIGGER(String.class); - Class clazz; + private final Class clazz; CacheProperty(Class clazz) { this.clazz = clazz; } public Class getClazz() { - return clazz; + return this.clazz; } } http://git-wip-us.apache.org/repos/asf/geode/blob/0d0bf253/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java index 20cfeca..f240a97 100644 --- a/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java +++ b/extensions/geode-modules-session-internal/src/main/java/org/apache/geode/modules/session/internal/filter/GemfireSessionManager.java @@ -12,15 +12,35 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. */ - package org.apache.geode.modules.session.internal.filter; +import java.util.EnumMap; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.management.InstanceAlreadyExistsException; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.NotCompliantMBeanException; +import javax.management.ObjectName; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import javax.servlet.FilterConfig; +import javax.servlet.http.HttpSession; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.geode.cache.CacheClosedException; import org.apache.geode.cache.CacheFactory; import org.apache.geode.cache.EntryNotFoundException; +import org.apache.geode.cache.client.ClientCache; import org.apache.geode.cache.control.ResourceManager; import org.apache.geode.distributed.internal.DistributionConfig; -import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.modules.session.bootstrap.AbstractCache; import org.apache.geode.modules.session.bootstrap.ClientServerCache; import org.apache.geode.modules.session.bootstrap.LifecycleTypeAdapter; @@ -33,21 +53,8 @@ import org.apache.geode.modules.session.internal.filter.attributes.AbstractSessi import org.apache.geode.modules.session.internal.filter.attributes.DeltaQueuedSessionAttributes; import org.apache.geode.modules.session.internal.filter.attributes.DeltaSessionAttributes; import org.apache.geode.modules.session.internal.filter.attributes.ImmediateSessionAttributes; -import org.apache.geode.modules.session.internal.filter.util.TypeAwareMap; import org.apache.geode.modules.session.internal.jmx.SessionStatistics; import org.apache.geode.modules.util.RegionHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.naming.InitialContext; -import javax.servlet.FilterConfig; -import javax.servlet.http.HttpSession; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; /** * This class implements the session management using a Gemfire distributedCache as a persistent @@ -55,7 +62,7 @@ import java.util.UUID; */ public class GemfireSessionManager implements SessionManager { - private final Logger LOG; + private final Logger logger; /** * Prefix of init param string used to set gemfire properties @@ -95,12 +102,12 @@ public class GemfireSessionManager implements SessionManager { /** * Map of wrapping GemFire session id to native session id */ - private Map<String, String> nativeSessionMap = new HashMap<String, String>(); + private final Map<String, String> nativeSessionMap = new HashMap<>(); /** * MBean for statistics */ - private SessionStatistics mbean; + private final SessionStatistics sessionStatisticsMBean; /** * This CL is used to compare against the class loader of attributes getting pulled out of the @@ -118,138 +125,114 @@ public class GemfireSessionManager implements SessionManager { /** * Set up properties with default values */ - private TypeAwareMap<CacheProperty, Object> properties = - new TypeAwareMap<CacheProperty, Object>(CacheProperty.class) { - { - put(CacheProperty.REGION_NAME, RegionHelper.NAME + "_sessions"); - put(CacheProperty.ENABLE_GATEWAY_DELTA_REPLICATION, Boolean.FALSE); - put(CacheProperty.ENABLE_GATEWAY_REPLICATION, Boolean.FALSE); - put(CacheProperty.ENABLE_DEBUG_LISTENER, Boolean.FALSE); - put(CacheProperty.STATISTICS_NAME, "gemfire_statistics"); - put(CacheProperty.SESSION_DELTA_POLICY, "delta_queued"); - put(CacheProperty.REPLICATION_TRIGGER, "set"); - /** - * For REGION_ATTRIBUTES_ID and ENABLE_LOCAL_CACHE the default is different for - * ClientServerCache and PeerToPeerCache so those values are set in the relevant - * constructors when these properties are passed in to them. - */ - } - }; + private final EnumMap<CacheProperty, Object> properties = createPropertiesEnumMap(); public GemfireSessionManager() { - LOG = LoggerFactory.getLogger(GemfireSessionManager.class.getName()); + this.logger = LoggerFactory.getLogger(GemfireSessionManager.class.getName()); + this.sessionStatisticsMBean = new SessionStatistics(); } - /** - * {@inheritDoc} - */ @Override - public void start(Object conf, ClassLoader loader) { + public void start(Object config, ClassLoader loader) { this.referenceClassLoader = loader; - FilterConfig config = (FilterConfig) conf; + FilterConfig filterConfig = (FilterConfig) config; - startDistributedSystem(config); - initializeSessionCache(config); + startDistributedSystem(filterConfig); + initializeSessionCache(filterConfig); // Register MBean - registerMBean(); + try { + registerMBean(this.sessionStatisticsMBean); + } catch (NamingException e) { + this.logger.warn("Unable to register statistics MBean. Error: {}", e.getMessage(), e); + } - if (distributedCache.getClass().getClassLoader() == loader) { - isolated = true; + if (this.distributedCache.getClass().getClassLoader() == loader) { + this.isolated = true; } - String sessionCookieName = config.getInitParameter(INIT_PARAM_SESSION_COOKIE_NAME); + String sessionCookieName = filterConfig.getInitParameter(INIT_PARAM_SESSION_COOKIE_NAME); if (sessionCookieName != null && !sessionCookieName.isEmpty()) { this.sessionCookieName = sessionCookieName; - LOG.info("Session cookie name set to: {}", this.sessionCookieName); + this.logger.info("Session cookie name set to: {}", this.sessionCookieName); } - jvmId = config.getInitParameter(INIT_PARAM_JVM_ID); - if (jvmId == null || jvmId.isEmpty()) { - jvmId = DEFAULT_JVM_ID; + this.jvmId = filterConfig.getInitParameter(INIT_PARAM_JVM_ID); + if (this.jvmId == null || this.jvmId.isEmpty()) { + this.jvmId = DEFAULT_JVM_ID; } - LOG.info("Started GemfireSessionManager (isolated={}, jvmId={})", isolated, jvmId); + this.logger.info("Started GemfireSessionManager (isolated={}, jvmId={})", this.isolated, + this.jvmId); } - /** - * {@inheritDoc} - */ @Override public void stop() { - isStopping = true; + this.isStopping = true; - if (isolated) { - if (distributedCache != null) { - LOG.info("Closing distributed cache - assuming isolated cache"); - distributedCache.close(); + if (this.isolated) { + if (this.distributedCache != null) { + this.logger.info("Closing distributed cache - assuming isolated cache"); + this.distributedCache.close(); } } else { - LOG.info("Not closing distributed cache - assuming common cache"); + this.logger.info("Not closing distributed cache - assuming common cache"); } } - /** - * {@inheritDoc} - */ @Override public HttpSession getSession(String id) { - GemfireHttpSession session = (GemfireHttpSession) sessionCache.getOperatingRegion().get(id); + GemfireHttpSession session = + (GemfireHttpSession) this.sessionCache.getOperatingRegion().get(id); if (session != null) { if (session.justSerialized()) { session.setManager(this); - LOG.debug("Recovered serialized session {} (jvmId={})", id, session.getJvmOwnerId()); + this.logger.debug("Recovered serialized session {} (jvmId={})", id, + session.getJvmOwnerId()); } - LOG.debug("Retrieved session id {}", id); + this.logger.debug("Retrieved session id {}", id); } else { - LOG.debug("Session id {} not found", id); + this.logger.debug("Session id {} not found", id); } return session; } - /** - * {@inheritDoc} - */ @Override public HttpSession wrapSession(HttpSession nativeSession) { String id = generateId(); GemfireHttpSession session = new GemfireHttpSession(id, nativeSession); - /** - * Set up the attribute container depending on how things are configured - */ + // Set up the attribute container depending on how things are configured AbstractSessionAttributes attributes; - if ("delta_queued".equals(properties.get(CacheProperty.SESSION_DELTA_POLICY))) { + if ("delta_queued".equals(this.properties.get(CacheProperty.SESSION_DELTA_POLICY))) { attributes = new DeltaQueuedSessionAttributes(); ((DeltaQueuedSessionAttributes) attributes) - .setReplicationTrigger((String) properties.get(CacheProperty.REPLICATION_TRIGGER)); - } else if ("delta_immediate".equals(properties.get(CacheProperty.SESSION_DELTA_POLICY))) { + .setReplicationTrigger((String) this.properties.get(CacheProperty.REPLICATION_TRIGGER)); + } else if ("delta_immediate".equals(this.properties.get(CacheProperty.SESSION_DELTA_POLICY))) { attributes = new DeltaSessionAttributes(); - } else if ("immediate".equals(properties.get(CacheProperty.SESSION_DELTA_POLICY))) { + } else if ("immediate".equals(this.properties.get(CacheProperty.SESSION_DELTA_POLICY))) { attributes = new ImmediateSessionAttributes(); } else { attributes = new DeltaSessionAttributes(); - LOG.warn("No session delta policy specified - using default of 'delta_immediate'"); + this.logger.warn("No session delta policy specified - using default of 'delta_immediate'"); } attributes.setSession(session); - attributes.setJvmOwnerId(jvmId); + attributes.setJvmOwnerId(this.jvmId); session.setManager(this); session.setAttributes(attributes); - LOG.debug("Creating new session {}", id); - sessionCache.getOperatingRegion().put(id, session); + this.logger.debug("Creating new session {}", id); + this.sessionCache.getOperatingRegion().put(id, session); - mbean.incActiveSessions(); + this.sessionStatisticsMBean.incActiveSessions(); return session; } - /** - * {@inheritDoc} - */ + @Override public HttpSession getWrappingSession(String nativeId) { HttpSession session = null; String gemfireId = getGemfireSessionIdFromNativeId(nativeId); @@ -260,112 +243,81 @@ public class GemfireSessionManager implements SessionManager { return session; } - /** - * {@inheritDoc} - */ @Override public void destroySession(String id) { - if (!isStopping) { + if (!this.isStopping) { try { - GemfireHttpSession session = (GemfireHttpSession) sessionCache.getOperatingRegion().get(id); - if (session != null && session.getJvmOwnerId().equals(jvmId)) { - LOG.debug("Destroying session {}", id); - sessionCache.getOperatingRegion().destroy(id); - mbean.decActiveSessions(); + GemfireHttpSession session = + (GemfireHttpSession) this.sessionCache.getOperatingRegion().get(id); + if (session != null && session.getJvmOwnerId().equals(this.jvmId)) { + this.logger.debug("Destroying session {}", id); + this.sessionCache.getOperatingRegion().destroy(id); + this.sessionStatisticsMBean.decActiveSessions(); } - } catch (EntryNotFoundException nex) { + } catch (EntryNotFoundException ignore) { } } else { - if (sessionCache.isClientServer()) { - LOG.debug("Destroying session {}", id); + if (this.sessionCache.isClientServer()) { + this.logger.debug("Destroying session {}", id); try { - sessionCache.getOperatingRegion().localDestroy(id); - } catch (EntryNotFoundException nex) { - // Ignored - } catch (CacheClosedException ccex) { + this.sessionCache.getOperatingRegion().localDestroy(id); + } catch (EntryNotFoundException | CacheClosedException ignore) { // Ignored } } else { - GemfireHttpSession session = (GemfireHttpSession) sessionCache.getOperatingRegion().get(id); + GemfireHttpSession session = + (GemfireHttpSession) this.sessionCache.getOperatingRegion().get(id); if (session != null) { session.setNativeSession(null); } } } - synchronized (nativeSessionMap) { - String nativeId = nativeSessionMap.remove(id); - LOG.debug("destroySession called for {} wrapping {}", id, nativeId); + synchronized (this.nativeSessionMap) { + String nativeId = this.nativeSessionMap.remove(id); + this.logger.debug("destroySession called for {} wrapping {}", id, nativeId); } } - /** - * {@inheritDoc} - */ @Override public void putSession(HttpSession session) { - sessionCache.getOperatingRegion().put(session.getId(), session); - mbean.incRegionUpdates(); - nativeSessionMap.put(session.getId(), + this.sessionCache.getOperatingRegion().put(session.getId(), session); + this.sessionStatisticsMBean.incRegionUpdates(); + this.nativeSessionMap.put(session.getId(), ((GemfireHttpSession) session).getNativeSession().getId()); } @Override - public String destroyNativeSession(String nativeId) { - String gemfireSessionId = getGemfireSessionIdFromNativeId(nativeId); + public String destroyNativeSession(String id) { + String gemfireSessionId = getGemfireSessionIdFromNativeId(id); if (gemfireSessionId != null) { destroySession(gemfireSessionId); } return gemfireSessionId; } - public ClassLoader getReferenceClassLoader() { - return referenceClassLoader; - } - - /** - * This method is called when a native session gets destroyed. It will check if the GemFire - * session is actually still valid/not expired and will then attach a new, native session. - * - * @param nativeId the id of the native session - * @return the id of the newly attached native session or null if the GemFire session was already - * invalid - */ - public String refreshSession(String nativeId) { - String gemfireId = getGemfireSessionIdFromNativeId(nativeId); - if (gemfireId == null) { - return null; - } - - GemfireHttpSession session = - (GemfireHttpSession) sessionCache.getOperatingRegion().get(gemfireId); - if (session.isValid()) { - - } - - return null; + ClassLoader getReferenceClassLoader() { + return this.referenceClassLoader; } + @Override public String getSessionCookieName() { - return sessionCookieName; + return this.sessionCookieName; } + @Override public String getJvmId() { - return jvmId; + return this.jvmId; } - - /////////////////////////////////////////////////////////////////////// - // Private methods - private String getGemfireSessionIdFromNativeId(String nativeId) { if (nativeId == null) { return null; } - for (Map.Entry<String, String> e : nativeSessionMap.entrySet()) { - if (nativeId.equals(e.getValue())) { - return e.getKey(); + for (Map.Entry<String, String> entry : this.nativeSessionMap.entrySet()) { + if (nativeId.equals(entry.getValue())) { + return entry.getKey(); } } return null; @@ -373,23 +325,21 @@ public class GemfireSessionManager implements SessionManager { /** * Start the underlying distributed system - * - * @param config */ private void startDistributedSystem(FilterConfig config) { // Get the distributedCache type final String cacheType = config.getInitParameter(INIT_PARAM_CACHE_TYPE); if (CACHE_TYPE_CLIENT_SERVER.equals(cacheType)) { - distributedCache = ClientServerCache.getInstance(); + this.distributedCache = ClientServerCache.getInstance(); } else if (CACHE_TYPE_PEER_TO_PEER.equals(cacheType)) { - distributedCache = PeerToPeerCache.getInstance(); + this.distributedCache = PeerToPeerCache.getInstance(); } else { - LOG.error("No 'cache-type' initialization param set. " + "Cache will not be started"); + this.logger.error("No 'cache-type' initialization param set. " + "Cache will not be started"); return; } - if (!distributedCache.isStarted()) { - /** + if (!this.distributedCache.isStarted()) { + /* * Process all the init params and see if any apply to the distributed system. */ for (Enumeration<String> e = config.getInitParameterNames(); e.hasMoreElements();) { @@ -399,12 +349,12 @@ public class GemfireSessionManager implements SessionManager { } String gemfireProperty = param.substring(GEMFIRE_PROPERTY.length()); - LOG.info("Setting gemfire property: {} = {}", gemfireProperty, + this.logger.info("Setting gemfire property: {} = {}", gemfireProperty, config.getInitParameter(param)); - distributedCache.setProperty(gemfireProperty, config.getInitParameter(param)); + this.distributedCache.setProperty(gemfireProperty, config.getInitParameter(param)); } - distributedCache.lifecycleEvent(LifecycleTypeAdapter.START); + this.distributedCache.lifecycleEvent(LifecycleTypeAdapter.START); } } @@ -413,21 +363,18 @@ public class GemfireSessionManager implements SessionManager { */ private void initializeSessionCache(FilterConfig config) { // Retrieve the distributedCache - GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance(); + InternalCache cache = (InternalCache) CacheFactory.getAnyInstance(); if (cache == null) { throw new IllegalStateException( - "No cache exists. Please configure " + "either a PeerToPeerCacheLifecycleListener or " - + "ClientServerCacheLifecycleListener in the " + "server.xml file."); + "No cache exists. Please configure either a PeerToPeerCacheLifecycleListener or ClientServerCacheLifecycleListener in the server.xml file."); } - /** - * Process all the init params and see if any apply to the distributedCache - */ + // Process all the init params and see if any apply to the distributedCache ResourceManager rm = cache.getResourceManager(); for (Enumeration<String> e = config.getInitParameterNames(); e.hasMoreElements();) { String param = e.nextElement(); - // Uggh - don't like this non-generic stuff + // Ugh - don't like this non-generic stuff if (param.equalsIgnoreCase("criticalHeapPercentage")) { float val = Float.parseFloat(config.getInitParameter(param)); rm.setCriticalHeapPercentage(val); @@ -444,37 +391,41 @@ public class GemfireSessionManager implements SessionManager { } String gemfireWebParam = param.substring(GEMFIRE_CACHE.length()); - LOG.info("Setting cache parameter: {} = {}", gemfireWebParam, config.getInitParameter(param)); - properties.put(CacheProperty.valueOf(gemfireWebParam.toUpperCase()), + this.logger.info("Setting cache parameter: {} = {}", gemfireWebParam, + config.getInitParameter(param)); + this.properties.put(CacheProperty.valueOf(gemfireWebParam.toUpperCase()), config.getInitParameter(param)); } // Create the appropriate session distributedCache - sessionCache = cache.isClient() ? new ClientServerSessionCache(cache, properties) - : new PeerToPeerSessionCache(cache, properties); + if (cache.isClient()) { + this.sessionCache = new ClientServerSessionCache((ClientCache) cache, this.properties); + } else { + this.sessionCache = new PeerToPeerSessionCache(cache, this.properties); + } // Initialize the session distributedCache - sessionCache.initialize(); + this.sessionCache.initialize(); } /** * Register a bean for statistic gathering purposes */ - private void registerMBean() { - mbean = new SessionStatistics(); - + private void registerMBean(final SessionStatistics mBean) throws NamingException { + InitialContext ctx = new InitialContext(); try { - InitialContext ctx = new InitialContext(); - MBeanServer mbs = MBeanServer.class.cast(ctx.lookup("java:comp/env/jmx/runtime")); - ObjectName oname = new ObjectName(Constants.SESSION_STATISTICS_MBEAN_NAME); - - mbs.registerMBean(mbean, oname); - } catch (Exception ex) { - LOG.warn("Unable to register statistics MBean. Error: {}", ex.getMessage()); + MBeanServer mBeanServer = MBeanServer.class.cast(ctx.lookup("java:comp/env/jmx/runtime")); + ObjectName objectName = new ObjectName(Constants.SESSION_STATISTICS_MBEAN_NAME); + + mBeanServer.registerMBean(mBean, objectName); + } catch (MalformedObjectNameException | NotCompliantMBeanException + | InstanceAlreadyExistsException | MBeanRegistrationException e) { + this.logger.warn("Unable to register statistics MBean. Error: {}", e.getMessage(), e); + } finally { + ctx.close(); } } - /** * Generate an ID string */ @@ -483,6 +434,23 @@ public class GemfireSessionManager implements SessionManager { } AbstractCache getCache() { - return distributedCache; + return this.distributedCache; + } + + private EnumMap<CacheProperty, Object> createPropertiesEnumMap() { + EnumMap<CacheProperty, Object> cacheProperties = new EnumMap<>(CacheProperty.class); + cacheProperties.put(CacheProperty.REGION_NAME, RegionHelper.NAME + "_sessions"); + cacheProperties.put(CacheProperty.ENABLE_GATEWAY_DELTA_REPLICATION, Boolean.FALSE); + cacheProperties.put(CacheProperty.ENABLE_GATEWAY_REPLICATION, Boolean.FALSE); + cacheProperties.put(CacheProperty.ENABLE_DEBUG_LISTENER, Boolean.FALSE); + cacheProperties.put(CacheProperty.STATISTICS_NAME, "gemfire_statistics"); + cacheProperties.put(CacheProperty.SESSION_DELTA_POLICY, "delta_queued"); + cacheProperties.put(CacheProperty.REPLICATION_TRIGGER, "set"); + /* + * For REGION_ATTRIBUTES_ID and ENABLE_LOCAL_CACHE the default is different for + * ClientServerCache and PeerToPeerCache so those values are set in the relevant constructors + * when these properties are passed in to them. + */ + return cacheProperties; } } http://git-wip-us.apache.org/repos/asf/geode/blob/0d0bf253/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java index edc2b7d..98a3db4 100644 --- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java +++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/session/catalina/DeltaSessionManager.java @@ -14,33 +14,11 @@ */ package org.apache.geode.modules.session.catalina; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.query.Query; -import org.apache.geode.cache.query.QueryService; -import org.apache.geode.cache.query.SelectResults; -import org.apache.geode.internal.cache.GemFireCacheImpl; -import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics; -import org.apache.geode.modules.util.ContextMapper; -import org.apache.geode.modules.util.RegionConfiguration; -import org.apache.geode.modules.util.RegionHelper; -import org.apache.catalina.Container; -import org.apache.catalina.Context; -import org.apache.catalina.Lifecycle; -import org.apache.catalina.Loader; -import org.apache.catalina.Pipeline; -import org.apache.catalina.Session; -import org.apache.catalina.Valve; -import org.apache.catalina.session.ManagerBase; -import org.apache.catalina.session.StandardSession; -import org.apache.catalina.util.CustomObjectInputStream; -import org.apache.juli.logging.Log; -import org.apache.juli.logging.LogFactory; - import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -58,10 +36,41 @@ import java.util.TimerTask; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; -abstract public class DeltaSessionManager extends ManagerBase +import javax.servlet.http.HttpSession; + +import org.apache.catalina.Container; +import org.apache.catalina.Context; +import org.apache.catalina.Lifecycle; +import org.apache.catalina.Loader; +import org.apache.catalina.Pipeline; +import org.apache.catalina.Session; +import org.apache.catalina.Valve; +import org.apache.catalina.session.ManagerBase; +import org.apache.catalina.session.StandardSession; +import org.apache.catalina.util.CustomObjectInputStream; +import org.apache.juli.logging.Log; +import org.apache.juli.logging.LogFactory; + +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.query.Query; +import org.apache.geode.cache.query.QueryService; +import org.apache.geode.cache.query.SelectResults; +import org.apache.geode.internal.cache.InternalCache; +import org.apache.geode.modules.session.catalina.internal.DeltaSessionStatistics; +import org.apache.geode.modules.util.ContextMapper; +import org.apache.geode.modules.util.RegionConfiguration; +import org.apache.geode.modules.util.RegionHelper; + +public abstract class DeltaSessionManager extends ManagerBase implements Lifecycle, PropertyChangeListener, SessionManager { + private static final Pattern PATTERN_SLASH = Pattern.compile("/", Pattern.LITERAL); + /** * The number of rejected sessions. */ @@ -73,12 +82,12 @@ abstract public class DeltaSessionManager extends ManagerBase protected int maxActiveSessions = -1; /** - * Has this <code>Manager</code> been started? + * Has this {@code Manager} been started? */ protected AtomicBoolean started = new AtomicBoolean(false); /** - * The name of this <code>Manager</code> + * The name of this {@code Manager} */ protected String name; @@ -106,7 +115,7 @@ abstract public class DeltaSessionManager extends ManagerBase * This *MUST* only be assigned during start/startInternal otherwise it will be associated with * the incorrect context class loader. */ - protected Log LOGGER; + protected Log logger; protected String regionName = DEFAULT_REGION_NAME; @@ -137,7 +146,7 @@ abstract public class DeltaSessionManager extends ManagerBase private static final long TIMER_TASK_DELAY = Long.getLong("gemfiremodules.sessionTimerTaskDelay", 10000); - public DeltaSessionManager() { + protected DeltaSessionManager() { // Create the set to store sessions to be touched after get attribute requests this.sessionsToTouch = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); } @@ -193,7 +202,7 @@ abstract public class DeltaSessionManager extends ManagerBase public void setMaxActiveSessions(int maxActiveSessions) { int oldMaxActiveSessions = this.maxActiveSessions; this.maxActiveSessions = maxActiveSessions; - support.firePropertyChange("maxActiveSessions", new Integer(oldMaxActiveSessions), + this.support.firePropertyChange("maxActiveSessions", new Integer(oldMaxActiveSessions), new Integer(this.maxActiveSessions)); } @@ -245,7 +254,7 @@ abstract public class DeltaSessionManager extends ManagerBase @Override public boolean isBackingCacheAvailable() { - return sessionCache.isBackingCacheAvailable(); + return this.sessionCache.isBackingCacheAvailable(); } public void setPreferDeserializedForm(boolean enable) { @@ -259,15 +268,15 @@ abstract public class DeltaSessionManager extends ManagerBase @Override public String getStatisticsName() { - return getContextName().replace("/", ""); + return PATTERN_SLASH.matcher(getContextName()).replaceAll(Matcher.quoteReplacement("")); } @Override public Log getLogger() { - if (LOGGER == null) { - LOGGER = LogFactory.getLog(DeltaSessionManager.class); + if (this.logger == null) { + this.logger = LogFactory.getLog(DeltaSessionManager.class); } - return LOGGER; + return this.logger; } public SessionCache getSessionCache() { @@ -298,18 +307,18 @@ abstract public class DeltaSessionManager extends ManagerBase @Override public void setContainer(Container container) { // De-register from the old Container (if any) - if ((this.container != null) && (this.container instanceof Context)) { - ((Context) this.container).removePropertyChangeListener(this); + if (Context.class.isInstance(this.container)) { + this.container.removePropertyChangeListener(this); } // Default processing provided by our superclass super.setContainer(container); // Register with the new Container (if any) - if ((this.container != null) && (this.container instanceof Context)) { + if (Context.class.isInstance(this.container)) { // Overwrite the max inactive interval with the context's session timeout. setMaxInactiveInterval(((Context) this.container).getSessionTimeout() * 60); - ((Context) this.container).addPropertyChangeListener(this); + this.container.addPropertyChangeListener(this); } } @@ -363,15 +372,18 @@ abstract public class DeltaSessionManager extends ManagerBase protected void initializeSessionCache() { // Retrieve the cache - GemFireCacheImpl cache = (GemFireCacheImpl) CacheFactory.getAnyInstance(); + InternalCache cache = (InternalCache) CacheFactory.getAnyInstance(); if (cache == null) { throw new IllegalStateException( "No cache exists. Please configure either a PeerToPeerCacheLifecycleListener or ClientServerCacheLifecycleListener in the server.xml file."); } // Create the appropriate session cache - this.sessionCache = cache.isClient() ? new ClientServerSessionCache(this, cache) - : new PeerToPeerSessionCache(this, cache); + if (cache.isClient()) { + this.sessionCache = new ClientServerSessionCache(this, (ClientCache) cache); + } else { + this.sessionCache = new PeerToPeerSessionCache(this, cache); + } // Initialize the session cache this.sessionCache.initialize(); @@ -430,6 +442,7 @@ abstract public class DeltaSessionManager extends ManagerBase return this.rejectedSessions.get(); } + @Override public void setRejectedSessions(int rejectedSessions) { this.rejectedSessions.set(rejectedSessions); } @@ -458,7 +471,7 @@ abstract public class DeltaSessionManager extends ManagerBase while (sessionIds.hasNext()) { builder.append(sessionIds.next()); if (sessionIds.hasNext()) { - builder.append(" "); + builder.append(' '); } } return builder.toString(); @@ -504,12 +517,11 @@ abstract public class DeltaSessionManager extends ManagerBase @Override public void run() { // Get the sessionIds to touch and clear the set inside synchronization - Set<String> sessionIds = null; - sessionIds = new HashSet<String>(getSessionsToTouch()); + Set<String> sessionIds = new HashSet<>(getSessionsToTouch()); getSessionsToTouch().clear(); // Touch the sessions we currently have - if (sessionIds != null && (!sessionIds.isEmpty())) { + if (!sessionIds.isEmpty()) { getSessionCache().touchSessions(sessionIds); if (getLogger().isDebugEnabled()) { getLogger().debug(DeltaSessionManager.this + ": Touched sessions: " + sessionIds); @@ -521,7 +533,7 @@ abstract public class DeltaSessionManager extends ManagerBase } protected void cancelTimer() { - if (timer != null) { + if (this.timer != null) { this.timer.cancel(); } } @@ -559,8 +571,8 @@ abstract public class DeltaSessionManager extends ManagerBase if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Registering JVM route binder valve"); } - jvmRouteBinderValve = new JvmRouteBinderValve(); - getPipeline().addValve(jvmRouteBinderValve); + this.jvmRouteBinderValve = new JvmRouteBinderValve(); + getPipeline().addValve(this.jvmRouteBinderValve); } protected Pipeline getPipeline() { @@ -571,8 +583,8 @@ abstract public class DeltaSessionManager extends ManagerBase if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Unregistering JVM route binder valve"); } - if (jvmRouteBinderValve != null) { - getPipeline().removeValve(jvmRouteBinderValve); + if (this.jvmRouteBinderValve != null) { + getPipeline().removeValve(this.jvmRouteBinderValve); } } @@ -580,21 +592,19 @@ abstract public class DeltaSessionManager extends ManagerBase if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Registering CommitSessionValve"); } - commitSessionValve = new CommitSessionValve(); - getPipeline().addValve(commitSessionValve); + this.commitSessionValve = new CommitSessionValve(); + getPipeline().addValve(this.commitSessionValve); } protected void unregisterCommitSessionValve() { if (getLogger().isDebugEnabled()) { getLogger().debug(this + ": Unregistering CommitSessionValve"); } - if (commitSessionValve != null) { - getPipeline().removeValve(commitSessionValve); + if (this.commitSessionValve != null) { + getPipeline().removeValve(this.commitSessionValve); } } - // ------------------------------ Lifecycle Methods - /** * Process property change events from our associated Context. * <p> @@ -604,7 +614,6 @@ abstract public class DeltaSessionManager extends ManagerBase * session timeout value specified in the web.xml. * <p> * The precedence order for setting the session timeout value is: - * <p> * <ol> * <li>the max inactive interval is set based on the Manager defined in the context.xml * <li>the max inactive interval is then overwritten by the value of the Context's session timeout @@ -622,17 +631,16 @@ abstract public class DeltaSessionManager extends ManagerBase if (!(event.getSource() instanceof Context)) { return; } - Context context = (Context) event.getSource(); // Process a relevant property change if (event.getPropertyName().equals("sessionTimeout")) { try { - int interval = ((Integer) event.getNewValue()).intValue(); + int interval = (Integer) event.getNewValue(); if (interval < RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL) { getLogger().warn("The configured session timeout of " + interval + " minutes is invalid. Using the original value of " + event.getOldValue() + " minutes."); - interval = ((Integer) event.getOldValue()).intValue();; + interval = (Integer) event.getOldValue(); } // StandardContext.setSessionTimeout passes -1 if the configured timeout // is 0; otherwise it passes the value set in web.xml. If the interval @@ -640,7 +648,7 @@ abstract public class DeltaSessionManager extends ManagerBase // default (no expiration); otherwise set it in seconds. setMaxInactiveInterval(interval == RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL ? RegionConfiguration.DEFAULT_MAX_INACTIVE_INTERVAL : interval * 60); - } catch (NumberFormatException e) { + } catch (NumberFormatException ignore) { getLogger() .error(sm.getString("standardManager.sessionTimeout", event.getNewValue().toString())); } @@ -654,7 +662,7 @@ abstract public class DeltaSessionManager extends ManagerBase * @throws IOException if an input/output error occurs */ protected void doUnload() throws IOException { - QueryService querySvc = sessionCache.getCache().getQueryService(); + QueryService querySvc = this.sessionCache.getCache().getQueryService(); Context context = getTheContext(); if (context == null) { return; @@ -663,10 +671,10 @@ abstract public class DeltaSessionManager extends ManagerBase if (getRegionName().startsWith("/")) { regionName = getRegionName(); } else { - regionName = "/" + getRegionName(); + regionName = '/' + getRegionName(); } Query query = querySvc.newQuery("select s.id from " + regionName - + " as s where s.contextName = '" + context.getPath() + "'"); + + " as s where s.contextName = '" + context.getPath() + '\''); getLogger().debug("Query: " + query.getQueryString()); SelectResults results; @@ -690,9 +698,11 @@ abstract public class DeltaSessionManager extends ManagerBase if (getLogger().isDebugEnabled()) { getLogger().debug("Unloading sessions to " + store.getAbsolutePath()); } + FileOutputStream fos = null; BufferedOutputStream bos = null; ObjectOutputStream oos = null; + boolean error = false; try { fos = new FileOutputStream(store.getAbsolutePath()); @@ -704,31 +714,13 @@ abstract public class DeltaSessionManager extends ManagerBase throw e; } finally { if (error) { - if (oos != null) { - try { - oos.close(); - } catch (IOException ioe) { - // Ignore - } - } - if (bos != null) { - try { - bos.close(); - } catch (IOException ioe) { - // Ignore - } - } - if (fos != null) { - try { - fos.close(); - } catch (IOException ioe) { - // Ignore - } - } + closeQuietly(oos); + closeQuietly(bos); + closeQuietly(fos); } } - ArrayList<DeltaSessionInterface> list = new ArrayList<DeltaSessionInterface>(); + ArrayList<DeltaSessionInterface> list = new ArrayList<>(); Iterator<String> elements = results.iterator(); while (elements.hasNext()) { String id = elements.next(); @@ -742,7 +734,7 @@ abstract public class DeltaSessionManager extends ManagerBase if (getLogger().isDebugEnabled()) getLogger().debug("Unloading " + list.size() + " sessions"); try { - oos.writeObject(new Integer(list.size())); + oos.writeObject(list.size()); for (DeltaSessionInterface session : list) { if (session instanceof StandardSession) { StandardSession standardSession = (StandardSession) session; @@ -755,24 +747,12 @@ abstract public class DeltaSessionManager extends ManagerBase } } catch (IOException e) { getLogger().error("Exception unloading sessions", e); - try { - oos.close(); - } catch (IOException f) { - // Ignore - } + closeQuietly(oos); throw e; } // Flush and close the output stream - try { - oos.flush(); - } finally { - try { - oos.close(); - } catch (IOException f) { - // Ignore - } - } + closeQuietly(oos); // Locally destroy the sessions we just wrote if (getSessionCache().isClientServer()) { @@ -784,22 +764,6 @@ abstract public class DeltaSessionManager extends ManagerBase } } - // // Expire all the sessions we just wrote - // if (getLogger().isDebugEnabled()) { - // getLogger().debug("Expiring " + list.size() + " persisted sessions"); - // } - // Iterator<StandardSession> expires = list.iterator(); - // while (expires.hasNext()) { - // StandardSession session = expires.next(); - // try { - // session.expire(false); - // } catch (Throwable t) { - //// ExceptionUtils.handleThrowable(t); - // } finally { - // session.recycle(); - // } - // } - if (getLogger().isDebugEnabled()) { getLogger().debug("Unloading complete"); } @@ -827,17 +791,18 @@ abstract public class DeltaSessionManager extends ManagerBase if (getLogger().isDebugEnabled()) { getLogger().debug("Loading sessions from " + store.getAbsolutePath()); } + FileInputStream fis = null; BufferedInputStream bis = null; - ObjectInputStream ois = null; - Loader loader = null; - ClassLoader classLoader = null; + ObjectInputStream ois; try { fis = new FileInputStream(store.getAbsolutePath()); bis = new BufferedInputStream(fis); + Loader loader = null; if (getTheContext() != null) { loader = getTheContext().getLoader(); } + ClassLoader classLoader = null; if (loader != null) { classLoader = loader.getClassLoader(); } @@ -854,7 +819,7 @@ abstract public class DeltaSessionManager extends ManagerBase } } catch (FileNotFoundException e) { if (getLogger().isDebugEnabled()) { - getLogger().debug("No persisted data file found"); + getLogger().debug("No persisted data file found", e); } return; } catch (IOException e) { @@ -862,14 +827,14 @@ abstract public class DeltaSessionManager extends ManagerBase if (fis != null) { try { fis.close(); - } catch (IOException f) { + } catch (IOException ignore) { // Ignore } } if (bis != null) { try { bis.close(); - } catch (IOException f) { + } catch (IOException ignore) { // Ignore } } @@ -878,8 +843,7 @@ abstract public class DeltaSessionManager extends ManagerBase // Load the previously unloaded active sessions try { - Integer count = (Integer) ois.readObject(); - int n = count.intValue(); + int n = (Integer) ois.readObject(); if (getLogger().isDebugEnabled()) { getLogger().debug("Loading " + n + " persisted sessions"); } @@ -888,7 +852,7 @@ abstract public class DeltaSessionManager extends ManagerBase session.readObjectData(ois); session.setManager(this); - Region region = getSessionCache().getOperatingRegion(); + Region<String, HttpSession> region = getSessionCache().getOperatingRegion(); DeltaSessionInterface existingSession = (DeltaSessionInterface) region.get(session.getId()); // Check whether the existing session is newer if (existingSession != null @@ -911,19 +875,11 @@ abstract public class DeltaSessionManager extends ManagerBase session.activate(); add(session); } - } catch (ClassNotFoundException e) { + } catch (ClassNotFoundException | IOException e) { getLogger().error(e); try { ois.close(); - } catch (IOException f) { - // Ignore - } - throw e; - } catch (IOException e) { - getLogger().error(e); - try { - ois.close(); - } catch (IOException f) { + } catch (IOException ignore) { // Ignore } throw e; @@ -931,7 +887,7 @@ abstract public class DeltaSessionManager extends ManagerBase // Close the input stream try { ois.close(); - } catch (IOException f) { + } catch (IOException ignore) { // ignored } @@ -952,16 +908,14 @@ abstract public class DeltaSessionManager extends ManagerBase } else { storeDir += System.getProperty("file.separator") + "temp"; } - File file = new File(storeDir, ctxPath.replaceAll("/", "_") + ".sessions.ser"); - - return (file); + return new File(storeDir, PATTERN_SLASH.matcher(ctxPath).replaceAll("_") + ".sessions.ser"); } @Override public String toString() { - return new StringBuilder().append(getClass().getSimpleName()).append("[").append("container=") + return new StringBuilder().append(getClass().getSimpleName()).append('[').append("container=") .append(getTheContext()).append("; regionName=").append(this.regionName) - .append("; regionAttributesId=").append(this.regionAttributesId).append("]").toString(); + .append("; regionAttributesId=").append(this.regionAttributesId).append(']').toString(); } protected String getContextName() { @@ -969,7 +923,7 @@ abstract public class DeltaSessionManager extends ManagerBase } public Context getTheContext() { - if (getContainer() instanceof Context) { + if (Context.class.isInstance(getContainer())) { return (Context) getContainer(); } else { getLogger().error("Unable to unload sessions - container is of type " @@ -977,4 +931,14 @@ abstract public class DeltaSessionManager extends ManagerBase return null; } } + + private static void closeQuietly(Closeable closeable) { + if (closeable == null) { + return; + } + try { + closeable.close(); + } catch (IOException ignore) { + } + } } http://git-wip-us.apache.org/repos/asf/geode/blob/0d0bf253/extensions/geode-modules/src/main/java/org/apache/geode/modules/util/CreateRegionFunction.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules/src/main/java/org/apache/geode/modules/util/CreateRegionFunction.java b/extensions/geode-modules/src/main/java/org/apache/geode/modules/util/CreateRegionFunction.java index 4e9e9fd..d10ff2a 100644 --- a/extensions/geode-modules/src/main/java/org/apache/geode/modules/util/CreateRegionFunction.java +++ b/extensions/geode-modules/src/main/java/org/apache/geode/modules/util/CreateRegionFunction.java @@ -24,19 +24,18 @@ import org.apache.geode.InternalGemFireError; import org.apache.geode.cache.AttributesFactory; import org.apache.geode.cache.Cache; import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.CacheWriterException; import org.apache.geode.cache.Declarable; import org.apache.geode.cache.Region; import org.apache.geode.cache.RegionAttributes; -import org.apache.geode.cache.RegionFactory; -import org.apache.geode.cache.RegionShortcut; import org.apache.geode.cache.Scope; -import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.TimeoutException; import org.apache.geode.cache.execute.Function; import org.apache.geode.cache.execute.FunctionContext; import org.apache.geode.cache.partition.PartitionRegionHelper; import org.apache.geode.distributed.DistributedLockService; import org.apache.geode.distributed.internal.locks.DistributedMemberLock; -import org.apache.geode.internal.cache.GemFireCacheImpl; +import org.apache.geode.internal.cache.InternalCache; import org.apache.geode.internal.cache.InternalRegionArguments; import org.apache.geode.internal.cache.PartitionedRegion; import org.apache.geode.internal.cache.xmlcache.CacheXmlGenerator; @@ -58,20 +57,16 @@ public class CreateRegionFunction implements Function, Declarable { private static final String REGION_CONFIGURATION_METADATA_REGION = "__regionConfigurationMetadata"; - public CreateRegionFunction() { + CreateRegionFunction() { this(CacheFactory.getAnyInstance()); } - public CreateRegionFunction(Cache cache) { + private CreateRegionFunction(Cache cache) { this.cache = cache; this.regionConfigurationsRegion = createRegionConfigurationMetadataRegion(); } - public CreateRegionFunction(ClientCache cache) { - this.cache = null; - this.regionConfigurationsRegion = null; - } - + @Override public void execute(FunctionContext context) { RegionConfiguration configuration = (RegionConfiguration) context.getArguments(); if (this.cache.getLogger().fineEnabled()) { @@ -92,19 +87,19 @@ public class CreateRegionFunction implements Function, Declarable { } private RegionStatus createOrRetrieveRegion(RegionConfiguration configuration) { - RegionStatus status = null; String regionName = configuration.getRegionName(); if (this.cache.getLogger().fineEnabled()) { this.cache.getLogger().fine("Function " + ID + " retrieving region named: " + regionName); } - Region region = this.cache.getRegion(regionName); + Region<Object, Object> region = this.cache.getRegion(regionName); + RegionStatus status; if (region == null) { status = createRegion(configuration); } else { status = RegionStatus.VALID; try { RegionHelper.validateRegion(this.cache, configuration, region); - } catch (Exception e) { + } catch (RuntimeException e) { if (!e.getMessage() .equals(LocalizedStrings.RegionAttributesCreation_CACHELISTENERS_ARE_NOT_THE_SAME .toLocalizedString())) { @@ -116,23 +111,28 @@ public class CreateRegionFunction implements Function, Declarable { return status; } + @Override public String getId() { return ID; } + @Override public boolean optimizeForWrite() { return false; } + @Override public boolean isHA() { return true; } + @Override public boolean hasResult() { return true; } - public void init(Properties properties) {} + @Override + public void init(Properties props) {} private RegionStatus createRegion(RegionConfiguration configuration) { // Get a distributed lock @@ -140,23 +140,23 @@ public class CreateRegionFunction implements Function, Declarable { if (this.cache.getLogger().fineEnabled()) { this.cache.getLogger().fine(this + ": Attempting to lock " + dml); } - long start = 0, end = 0; - RegionStatus status = null; + RegionStatus status; try { + long start = 0; if (this.cache.getLogger().fineEnabled()) { start = System.currentTimeMillis(); } // Obtain a lock on the distributed lock dml.lockInterruptibly(); if (this.cache.getLogger().fineEnabled()) { - end = System.currentTimeMillis(); + long end = System.currentTimeMillis(); this.cache.getLogger() .fine(this + ": Obtained lock on " + dml + " in " + (end - start) + " ms"); } // Attempt to get the region again after the lock has been obtained String regionName = configuration.getRegionName(); - Region region = this.cache.getRegion(regionName); + Region<Object, Object> region = this.cache.getRegion(regionName); // If it exists now, validate it. // Else put an entry into the sessionRegionConfigurationsRegion @@ -182,7 +182,7 @@ public class CreateRegionFunction implements Function, Declarable { status = RegionStatus.VALID; try { RegionHelper.validateRegion(this.cache, configuration, region); - } catch (Exception e) { + } catch (RuntimeException e) { if (!e.getMessage() .equals(LocalizedStrings.RegionAttributesCreation_CACHELISTENERS_ARE_NOT_THE_SAME .toLocalizedString())) { @@ -191,17 +191,17 @@ public class CreateRegionFunction implements Function, Declarable { status = RegionStatus.INVALID; } } - } catch (Exception e) { + } catch (InterruptedException | CacheWriterException | TimeoutException e) { StringBuilder builder = new StringBuilder(); builder.append(this).append(": Caught Exception attempting to create region named ") - .append(configuration.getRegionName()).append(":"); + .append(configuration.getRegionName()).append(':'); this.cache.getLogger().warning(builder.toString(), e); status = RegionStatus.INVALID; } finally { // Unlock the distributed lock try { dml.unlock(); - } catch (Exception ignore) { + } catch (RuntimeException ignore) { } } return status; @@ -219,19 +219,17 @@ public class CreateRegionFunction implements Function, Declarable { if (r != null) { return r; } - GemFireCacheImpl gemFireCache = (GemFireCacheImpl) cache; + InternalCache internalCache = (InternalCache) this.cache; InternalRegionArguments ira = new InternalRegionArguments().setInternalRegion(true); - AttributesFactory af = new AttributesFactory(); + AttributesFactory<String, RegionConfiguration> af = new AttributesFactory<>(); af.setScope(Scope.LOCAL); af.addCacheListener(new RegionConfigurationCacheListener()); - RegionAttributes ra = af.create(); + RegionAttributes<String, RegionConfiguration> ra = af.create(); try { - return gemFireCache.createVMRegion(REGION_CONFIGURATION_METADATA_REGION, ra, ira); + return internalCache.createVMRegion(REGION_CONFIGURATION_METADATA_REGION, ra, ira); } catch (IOException | ClassNotFoundException e) { - InternalGemFireError assErr = new InternalGemFireError( - LocalizedStrings.GemFireCache_UNEXPECTED_EXCEPTION.toLocalizedString()); - assErr.initCause(e); - throw assErr; + throw new InternalGemFireError( + LocalizedStrings.GemFireCache_UNEXPECTED_EXCEPTION.toLocalizedString(), e); } } @@ -241,7 +239,7 @@ public class CreateRegionFunction implements Function, Declarable { PrintWriter pw = new PrintWriter(new FileWriter(file), true); CacheXmlGenerator.generate(this.cache, pw); pw.close(); - } catch (IOException e) { + } catch (IOException ignore) { } }