public class CacheService extends AbstractCacheService
This service is responsible for:
CacheRecordStore
.ICache
.MigrationAwareService
.WARNING:This service is an optionally registered service which is enabled when JCache
is located on the classpath, as determined by JCacheDetector.isJCacheAvailable(ClassLoader)
.
If registered, it will provide all the above cache operations for all partitions of the node which it is registered on.
Distributed Cache Name is used for providing a unique name to a cache object to overcome cache manager
scoping which depends on URI and class loader parameters. It's a simple concatenation of CacheNamePrefix and
cache name where CacheNamePrefix is calculated by each cache manager
using AbstractHazelcastCacheManager.cacheNamePrefix()
.
cacheContexts, cacheContextsConstructorFunction, cacheEventHandler, cacheResourcesConstructorFunction, cacheResourcesMutexFactory, cacheSplitBrainHandler, cacheStatisticsConstructorFunction, closeableListeners, configs, eventJournal, logger, nodeEngine, operationProviderCache, resources, segments, statistics
CACHE_SUPPORT_NOT_AVAILABLE_ERROR_MESSAGE, SERVICE_NAME
Constructor and Description |
---|
CacheService() |
Modifier and Type | Method and Description |
---|---|
void |
commitMigration(PartitionMigrationEvent event)
Commits the migration process for this service, on both source and destination members.
|
protected ICacheRecordStore |
createNewRecordStore(String name,
int partitionId) |
protected CacheOperationProvider |
createOperationProvider(String nameWithPrefix,
InMemoryFormat inMemoryFormat) |
Collection<ServiceNamespace> |
getAllServiceNamespaces(PartitionReplicationEvent event)
Returns all known namespaces for given replication event.
|
CacheWanEventPublisher |
getCacheWanEventPublisher() |
boolean |
isKnownServiceNamespace(ServiceNamespace namespace)
Returns true if namespace is known by this service, false otherwise
|
boolean |
isWanReplicationEnabled(String cacheName) |
protected CacheReplicationOperation |
newCacheReplicationOperation() |
protected CachePartitionSegment |
newPartitionSegment(int partitionId) |
Operation |
prepareReplicationOperation(PartitionReplicationEvent event)
Returns an operation to replicate service data and/or state for a specific partition replica
on another cluster member.
|
Operation |
prepareReplicationOperation(PartitionReplicationEvent event,
Collection<ServiceNamespace> namespaces)
Returns an operation to replicate service data and/or state for a specific partition replica and namespaces
on another cluster member.
|
void |
rollbackMigration(PartitionMigrationEvent event)
Rollback the migration process for this service, on both source and destination members.
|
String |
toString() |
addCacheResource, addInvalidationListener, beforeMigration, cacheEntryListenerDeregistered, cacheEntryListenerRegistered, checkCacheConfig, checkCacheSimpleConfig, closeSegments, createCacheStatIfAbsent, createDistributedObject, deleteCache, deleteCacheConfig, deleteCacheStat, deregisterAllListener, deregisterListener, destroyDistributedObject, destroySegments, dispatchEvent, findCacheConfig, getCacheConfig, getCacheConfigs, getCacheContext, getCacheEventHandler, getCacheOperationProvider, getEventJournal, getNodeEngine, getOrCreateCacheContext, getOrCreateRecordStore, getPostJoinOperation, getQuorumName, getRecordStore, getSegment, getStatistics, init, isNativeInMemoryFormatSupported, onPartitionLost, postInit, prepareMergeRunnable, publishCachePartitionLostEvent, publishEvent, publishEvent, putCacheConfigIfAbsent, registerListener, registerListener, registerListenerInternal, reset, sendInvalidationEvent, setManagementEnabled, setStatisticsEnabled, shutdown, toData, toObject
protected CachePartitionSegment newPartitionSegment(int partitionId)
newPartitionSegment
in class AbstractCacheService
protected ICacheRecordStore createNewRecordStore(String name, int partitionId)
createNewRecordStore
in class AbstractCacheService
protected CacheOperationProvider createOperationProvider(String nameWithPrefix, InMemoryFormat inMemoryFormat)
createOperationProvider
in class AbstractCacheService
public Collection<ServiceNamespace> getAllServiceNamespaces(PartitionReplicationEvent event)
FragmentedMigrationAwareService
event
- replication eventpublic boolean isKnownServiceNamespace(ServiceNamespace namespace)
FragmentedMigrationAwareService
namespace
- namespacepublic Operation prepareReplicationOperation(PartitionReplicationEvent event)
MigrationAwareService
This method will be called on source member whenever partitioning system requires to copy/replicate a partition replica. Returned operation will be executed on destination member. If operation fails by throwing exception, migration process will fail and will be rolled back.
Returning null is allowed and means service does not have anything to replicate.
event
- replicationpublic Operation prepareReplicationOperation(PartitionReplicationEvent event, Collection<ServiceNamespace> namespaces)
FragmentedMigrationAwareService
MigrationAwareService.prepareReplicationOperation(PartitionReplicationEvent)
,
instead of copying whole partition replica, allows copying only some portion of replica,
specified by given namespaces.
This method will be called on source member whenever partitioning system requires to copy/replicate a partition replica. Returned operation will be executed on destination member. If operation fails by throwing exception, migration process will fail and will be rolled back.
Returning null is allowed and means service does not have anything to replicate.
event
- replication eventnamespaces
- replica fragment namespaces to replicateMigrationAwareService.prepareReplicationOperation(PartitionReplicationEvent)
protected CacheReplicationOperation newCacheReplicationOperation()
public void commitMigration(PartitionMigrationEvent event)
MigrationAwareService
Commit is not expected to fail at this point, all exceptions will be suppressed and logged.
commitMigration
in interface MigrationAwareService
commitMigration
in class AbstractCacheService
event
- migration eventpublic void rollbackMigration(PartitionMigrationEvent event)
MigrationAwareService
Rollback is not expected to fail at this point, all exceptions will be suppressed and logged.
rollbackMigration
in interface MigrationAwareService
rollbackMigration
in class AbstractCacheService
event
- migration eventpublic boolean isWanReplicationEnabled(String cacheName)
public CacheWanEventPublisher getCacheWanEventPublisher()
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.