public abstract class AbstractCacheService extends Object implements ICacheService, PostJoinAwareService, PartitionAwareService, QuorumAwareService, SplitBrainHandlerService
Modifier and Type | Field and Description |
---|---|
protected ConstructorFunction<String,CacheContext> |
cacheContexesConstructorFunction |
protected ConcurrentMap<String,CacheContext> |
cacheContexts |
protected com.hazelcast.cache.impl.CacheEventHandler |
cacheEventHandler |
protected com.hazelcast.cache.impl.CacheSplitBrainHandler |
cacheSplitBrainHandler |
protected ConstructorFunction<String,CacheStatisticsImpl> |
cacheStatisticsConstructorFunction |
protected ConcurrentMap<String,Closeable> |
closeableListeners |
protected ConcurrentMap<String,CacheConfig> |
configs |
protected NodeEngine |
nodeEngine |
protected ConcurrentMap<String,CacheOperationProvider> |
operationProviderCache |
protected ConcurrentMap<String,Set<Closeable>> |
resources |
protected CachePartitionSegment[] |
segments |
protected ConcurrentMap<String,CacheStatisticsImpl> |
statistics |
SERVICE_NAME
Constructor and Description |
---|
AbstractCacheService() |
Modifier and Type | Method and Description |
---|---|
void |
addCacheResource(String name,
Closeable resource) |
String |
addInvalidationListener(String name,
CacheEventListener listener,
boolean localOnly)
Registers and
CacheInvalidationListener for specified cacheName . |
void |
beforeMigration(PartitionMigrationEvent event) |
void |
cacheEntryListenerDeregistered(String name,
javax.cache.configuration.CacheEntryListenerConfiguration cacheEntryListenerConfiguration) |
void |
cacheEntryListenerRegistered(String name,
javax.cache.configuration.CacheEntryListenerConfiguration cacheEntryListenerConfiguration) |
void |
clearPartitionReplica(int partitionId) |
protected void |
closeSegments(String name) |
void |
commitMigration(PartitionMigrationEvent event) |
CacheStatisticsImpl |
createCacheStatIfAbsent(String name) |
DistributedObject |
createDistributedObject(String objectName)
Creates a distributed object.
|
protected abstract ICacheRecordStore |
createNewRecordStore(String name,
int partitionId) |
protected abstract CacheOperationProvider |
createOperationProvider(String nameWithPrefix,
InMemoryFormat inMemoryFormat) |
void |
deleteCache(String name,
boolean isLocal,
String callerUuid,
boolean destroy) |
CacheConfig |
deleteCacheConfig(String name) |
void |
deleteCacheStat(String name) |
void |
deregisterAllListener(String name) |
boolean |
deregisterListener(String name,
String registrationId) |
protected void |
destroyCacheOnAllMembers(String name,
String callerUuid) |
void |
destroyDistributedObject(String objectName)
Destroys a distributed object.
|
protected void |
destroySegments(String name) |
void |
dispatchEvent(Object event,
CacheEventListener listener) |
CacheSimpleConfig |
findCacheConfig(String simpleName) |
CacheConfig |
getCacheConfig(String name) |
Collection<CacheConfig> |
getCacheConfigs() |
CacheContext |
getCacheContext(String name) |
CacheOperationProvider |
getCacheOperationProvider(String nameWithPrefix,
InMemoryFormat inMemoryFormat)
Creates cache operations according to the storage-type of the cache
|
NodeEngine |
getNodeEngine() |
CacheContext |
getOrCreateCacheContext(String name) |
ICacheRecordStore |
getOrCreateRecordStore(String name,
int partitionId) |
Operation |
getPostJoinOperation()
Post join operations must be lock free, meaning no locks at all:
no partition locks, no key-based locks, no service level locks,
no database interaction!
|
String |
getQuorumName(String cacheName)
Gets the name of the quorum associated with specified cache
|
ICacheRecordStore |
getRecordStore(String name,
int partitionId) |
CachePartitionSegment |
getSegment(int partitionId) |
CacheStatisticsImpl |
getStatistics(String name) |
void |
init(NodeEngine nodeEngine,
Properties properties)
Initializes this ManagedService
|
protected abstract CachePartitionSegment |
newPartitionSegment(int partitionId) |
void |
onPartitionLost(InternalPartitionLostEvent partitionLostEvent)
Invoked when a partition lost is detected
|
protected void |
postInit(NodeEngine nodeEngine,
Properties properties) |
Runnable |
prepareMergeRunnable()
When the 2 separate clusters merge (resolve a split brain), this method is called to return
a Runnable that will merge the clusters.
|
protected void |
publishCachePartitionLostEvent(String cacheName,
int partitionId) |
void |
publishEvent(CacheEventContext cacheEventContext) |
void |
publishEvent(String cacheName,
CacheEventSet eventSet,
int orderKey) |
CacheConfig |
putCacheConfigIfAbsent(CacheConfig config) |
String |
registerListener(String name,
CacheEventListener listener,
boolean isLocal) |
String |
registerListener(String name,
CacheEventListener listener,
EventFilter eventFilter,
boolean isLocal) |
protected String |
registerListenerInternal(String name,
CacheEventListener listener,
EventFilter eventFilter,
boolean isLocal) |
void |
reset()
reset this ManagedService back to initial state.
|
void |
rollbackMigration(PartitionMigrationEvent event) |
void |
sendInvalidationEvent(String name,
Data key,
String sourceUuid)
Sends an invalidation event for given
cacheName with specified key
from mentioned source with sourceUuid . |
void |
setManagementEnabled(CacheConfig cacheConfig,
String cacheNameWithPrefix,
boolean enabled) |
void |
setStatisticsEnabled(CacheConfig cacheConfig,
String cacheNameWithPrefix,
boolean enabled) |
void |
shutdown(boolean terminate)
Shuts down this ManagedService.
|
Data |
toData(Object object) |
Object |
toObject(Object data) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCacheWanEventPublisher, isWanReplicationEnabled
prepareReplicationOperation
protected final ConcurrentMap<String,CacheConfig> configs
protected final ConcurrentMap<String,CacheContext> cacheContexts
protected final ConcurrentMap<String,CacheStatisticsImpl> statistics
protected final ConcurrentMap<String,Set<Closeable>> resources
protected final ConcurrentMap<String,Closeable> closeableListeners
protected final ConcurrentMap<String,CacheOperationProvider> operationProviderCache
protected final ConstructorFunction<String,CacheContext> cacheContexesConstructorFunction
protected final ConstructorFunction<String,CacheStatisticsImpl> cacheStatisticsConstructorFunction
protected NodeEngine nodeEngine
protected CachePartitionSegment[] segments
protected com.hazelcast.cache.impl.CacheEventHandler cacheEventHandler
protected com.hazelcast.cache.impl.CacheSplitBrainHandler cacheSplitBrainHandler
public final void init(NodeEngine nodeEngine, Properties properties)
ManagedService
init
in interface ManagedService
nodeEngine
- the NodeEngine that this ManagedService belongs to.properties
- the Properties. Can be used to pass settings to the service.protected void postInit(NodeEngine nodeEngine, Properties properties)
protected abstract CachePartitionSegment newPartitionSegment(int partitionId)
protected abstract ICacheRecordStore createNewRecordStore(String name, int partitionId)
public void reset()
ManagedService
reset
in interface ManagedService
public void shutdown(boolean terminate)
ManagedService
shutdown
in interface ManagedService
terminate
- true to shut down the ManagedServicepublic DistributedObject createDistributedObject(String objectName)
RemoteService
createDistributedObject
in interface RemoteService
objectName
- the name for the created distributed objectpublic void destroyDistributedObject(String objectName)
RemoteService
destroyDistributedObject
in interface RemoteService
objectName
- the name of the distributed object to destroypublic void beforeMigration(PartitionMigrationEvent event)
beforeMigration
in interface MigrationAwareService
public void commitMigration(PartitionMigrationEvent event)
commitMigration
in interface MigrationAwareService
public void rollbackMigration(PartitionMigrationEvent event)
rollbackMigration
in interface MigrationAwareService
public void clearPartitionReplica(int partitionId)
clearPartitionReplica
in interface MigrationAwareService
public ICacheRecordStore getOrCreateRecordStore(String name, int partitionId)
getOrCreateRecordStore
in interface ICacheService
public ICacheRecordStore getRecordStore(String name, int partitionId)
getRecordStore
in interface ICacheService
public CachePartitionSegment getSegment(int partitionId)
getSegment
in interface ICacheService
protected void destroySegments(String name)
protected void closeSegments(String name)
public void deleteCache(String name, boolean isLocal, String callerUuid, boolean destroy)
deleteCache
in interface ICacheService
public CacheConfig putCacheConfigIfAbsent(CacheConfig config)
putCacheConfigIfAbsent
in interface ICacheService
public CacheConfig deleteCacheConfig(String name)
deleteCacheConfig
in interface ICacheService
public CacheStatisticsImpl createCacheStatIfAbsent(String name)
createCacheStatIfAbsent
in interface ICacheService
public CacheContext getCacheContext(String name)
public CacheContext getOrCreateCacheContext(String name)
getOrCreateCacheContext
in interface ICacheService
public void deleteCacheStat(String name)
deleteCacheStat
in interface ICacheService
public void setStatisticsEnabled(CacheConfig cacheConfig, String cacheNameWithPrefix, boolean enabled)
setStatisticsEnabled
in interface ICacheService
public void setManagementEnabled(CacheConfig cacheConfig, String cacheNameWithPrefix, boolean enabled)
setManagementEnabled
in interface ICacheService
public CacheConfig getCacheConfig(String name)
getCacheConfig
in interface ICacheService
public CacheSimpleConfig findCacheConfig(String simpleName)
findCacheConfig
in interface ICacheService
public Collection<CacheConfig> getCacheConfigs()
getCacheConfigs
in interface ICacheService
public void publishEvent(CacheEventContext cacheEventContext)
publishEvent
in interface ICacheService
public void publishEvent(String cacheName, CacheEventSet eventSet, int orderKey)
publishEvent
in interface ICacheService
public NodeEngine getNodeEngine()
getNodeEngine
in interface ICacheService
public void dispatchEvent(Object event, CacheEventListener listener)
dispatchEvent
in interface EventPublishingService<Object,CacheEventListener>
public String registerListener(String name, CacheEventListener listener, boolean isLocal)
registerListener
in interface ICacheService
public String registerListener(String name, CacheEventListener listener, EventFilter eventFilter, boolean isLocal)
registerListener
in interface ICacheService
protected String registerListenerInternal(String name, CacheEventListener listener, EventFilter eventFilter, boolean isLocal)
public boolean deregisterListener(String name, String registrationId)
deregisterListener
in interface ICacheService
public void deregisterAllListener(String name)
deregisterAllListener
in interface ICacheService
public CacheStatisticsImpl getStatistics(String name)
getStatistics
in interface ICacheService
public CacheOperationProvider getCacheOperationProvider(String nameWithPrefix, InMemoryFormat inMemoryFormat)
ICacheService
getCacheOperationProvider
in interface ICacheService
protected abstract CacheOperationProvider createOperationProvider(String nameWithPrefix, InMemoryFormat inMemoryFormat)
public Operation getPostJoinOperation()
PostJoinAwareService
Post join operations should return response, at least a null response.
getPostJoinOperation
in interface PostJoinAwareService
protected void publishCachePartitionLostEvent(String cacheName, int partitionId)
public void onPartitionLost(InternalPartitionLostEvent partitionLostEvent)
PartitionAwareService
onPartitionLost
in interface PartitionAwareService
partitionLostEvent
- The event object that contains the partition id and the number of replicas that is lostpublic void cacheEntryListenerRegistered(String name, javax.cache.configuration.CacheEntryListenerConfiguration cacheEntryListenerConfiguration)
public void cacheEntryListenerDeregistered(String name, javax.cache.configuration.CacheEntryListenerConfiguration cacheEntryListenerConfiguration)
public String getQuorumName(String cacheName)
getQuorumName
in interface QuorumAwareService
cacheName
- name of the cachepublic String addInvalidationListener(String name, CacheEventListener listener, boolean localOnly)
CacheInvalidationListener
for specified cacheName
.addInvalidationListener
in interface ICacheService
name
- the name of the cache that CacheEventListener
will be registered forlistener
- the CacheEventListener
to be registered for specified cache
localOnly
- true if only events originated from this member wants be listened, false if all invalidation events in the
cluster wants to be listenedpublic void sendInvalidationEvent(String name, Data key, String sourceUuid)
cacheName
with specified key
from mentioned source with sourceUuid
.sendInvalidationEvent
in interface ICacheService
name
- the name of the cache that invalidation event is sent forkey
- the Data
represents the invalidation eventsourceUuid
- an id that represents the source for invalidation eventpublic Runnable prepareMergeRunnable()
SplitBrainHandlerService
prepareMergeRunnable
in interface SplitBrainHandlerService
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.