public class MapService extends Object implements ManagedService, FragmentedMigrationAwareService, TransactionalService, RemoteService, EventPublishingService<Object,ListenerAdapter>, PostJoinAwareService, SplitBrainHandlerService, ReplicationSupportingService, StatisticsAwareService<LocalMapStats>, PartitionAwareService, ClientAwareService, QuorumAwareService, NotifiableEventListener, ClusterStateListener, LockInterceptorService<Data>
MapManagedService,
MapMigrationAwareService,
MapTransactionalService,
MapRemoteService,
MapEventPublishingService,
MapPostJoinAwareService,
MapSplitBrainHandlerService,
MapReplicationSupportingService,
MapStatisticsAwareService,
MapPartitionAwareService,
MapQuorumAwareService,
MapClientAwareService,
MapServiceContext| Modifier and Type | Field and Description |
|---|---|
protected ClientAwareService |
clientAwareService |
protected EventPublishingService |
eventPublishingService |
protected ManagedService |
managedService |
protected MapServiceContext |
mapServiceContext |
protected CountingMigrationAwareService |
migrationAwareService |
protected PartitionAwareService |
partitionAwareService |
protected PostJoinAwareService |
postJoinAwareService |
protected MapQuorumAwareService |
quorumAwareService |
protected RemoteService |
remoteService |
protected ReplicationSupportingService |
replicationSupportingService |
static String |
SERVICE_NAME |
protected SplitBrainHandlerService |
splitBrainHandlerService |
protected StatisticsAwareService |
statisticsAwareService |
protected TransactionalService |
transactionalService |
| Constructor and Description |
|---|
MapService() |
| Modifier and Type | Method and Description |
|---|---|
void |
beforeMigration(PartitionMigrationEvent event)
Called before migration process starts, on both source and destination members.
|
void |
clientDisconnected(String clientUuid)
Invoked when a client disconnects from a member.
|
void |
commitMigration(PartitionMigrationEvent event)
Commits the migration process for this service, on both source and destination members.
|
DistributedObject |
createDistributedObject(String objectName)
Creates a distributed object.
|
<T extends TransactionalObject> |
createTransactionalObject(String name,
Transaction transaction) |
void |
destroyDistributedObject(String objectName)
Destroys a distributed object.
|
void |
dispatchEvent(Object event,
ListenerAdapter listener)
Notifies the service of a published event.
|
Collection<ServiceNamespace> |
getAllServiceNamespaces(PartitionReplicationEvent event)
Returns all known namespaces for given replication event.
|
MapServiceContext |
getMapServiceContext() |
int |
getMigrationStamp() |
static ObjectNamespace |
getObjectNamespace(String mapName) |
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!
The
Operation.getPartitionId() method should return a negative value. |
String |
getQuorumName(String name)
Gets the name of the quorum associated with specified operation name.
|
Map<String,LocalMapStats> |
getStats()
Return the service statistics for the local instance.
|
void |
init(NodeEngine nodeEngine,
Properties properties)
Initializes this service.
|
boolean |
isKnownServiceNamespace(ServiceNamespace namespace)
Returns true if namespace is known by this service, false otherwise
|
void |
onBeforeLock(String distributedObjectName,
Data key) |
void |
onClusterStateChange(ClusterState newState)
Called when cluster state is changed
|
void |
onDeregister(Object service,
String serviceName,
String topic,
EventRegistration registration)
Called when this listener deregistered from
EventService. |
void |
onPartitionLost(IPartitionLostEvent partitionLostEvent)
Invoked when a partition lost is detected
|
void |
onRegister(Object service,
String serviceName,
String topic,
EventRegistration registration)
Called when this listener registered to
EventService. |
void |
onReplicationEvent(WanReplicationEvent replicationEvent)
Processes a WAN replication event
|
Runnable |
prepareMergeRunnable()
When the two separate clusters merge (resolve a split-brain), this method is called to return
a
Runnable, that will merge the clusters. |
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 |
reset()
Resets this service back to its initial state.
|
void |
rollbackMigration(PartitionMigrationEvent event)
Rollback the migration process for this service, on both source and destination members.
|
void |
rollbackTransaction(String transactionId) |
void |
shutdown(boolean terminate)
Shuts down this service.
|
boolean |
validateMigrationStamp(int stamp) |
public static final String SERVICE_NAME
protected ManagedService managedService
protected CountingMigrationAwareService migrationAwareService
protected TransactionalService transactionalService
protected RemoteService remoteService
protected EventPublishingService eventPublishingService
protected PostJoinAwareService postJoinAwareService
protected SplitBrainHandlerService splitBrainHandlerService
protected ReplicationSupportingService replicationSupportingService
protected StatisticsAwareService statisticsAwareService
protected PartitionAwareService partitionAwareService
protected ClientAwareService clientAwareService
protected MapQuorumAwareService quorumAwareService
protected MapServiceContext mapServiceContext
public void dispatchEvent(Object event, ListenerAdapter listener)
EventPublishingServicedispatchEvent in interface EventPublishingService<Object,ListenerAdapter>event - the published eventlistener - the listener registered for this eventpublic void init(NodeEngine nodeEngine, Properties properties)
ManagedServiceinit in interface ManagedServicenodeEngine - the NodeEngine that this service belongs toproperties - the Properties (can be used to pass settings to the service)public void reset()
ManagedServiceTODO: what is the purpose of reset
reset in interface ManagedServicepublic void shutdown(boolean terminate)
ManagedServiceTODO: what is the purpose of the terminate variable
shutdown in interface ManagedServiceterminate - true to shut down this servicepublic Collection<ServiceNamespace> getAllServiceNamespaces(PartitionReplicationEvent event)
FragmentedMigrationAwareServicegetAllServiceNamespaces in interface FragmentedMigrationAwareServiceevent - replication eventpublic boolean isKnownServiceNamespace(ServiceNamespace namespace)
FragmentedMigrationAwareServiceisKnownServiceNamespace in interface FragmentedMigrationAwareServicenamespace - namespacepublic Operation prepareReplicationOperation(PartitionReplicationEvent event)
MigrationAwareServiceThis 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.
prepareReplicationOperation in interface MigrationAwareServiceevent - replicationpublic Operation prepareReplicationOperation(PartitionReplicationEvent event, Collection<ServiceNamespace> namespaces)
FragmentedMigrationAwareServiceMigrationAwareService.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.
prepareReplicationOperation in interface FragmentedMigrationAwareServiceevent - replication eventnamespaces - replica fragment namespaces to replicateMigrationAwareService.prepareReplicationOperation(PartitionReplicationEvent)public void beforeMigration(PartitionMigrationEvent event)
MigrationAwareServiceService can take actions required before migration. Migration process will block until this method returns. If this method fails by throwing an exception, migration process for specific partition will fail and will be rolled back.
beforeMigration in interface MigrationAwareServiceevent - migration eventpublic void commitMigration(PartitionMigrationEvent event)
MigrationAwareServiceCommit is not expected to fail at this point, all exceptions will be suppressed and logged. Implementations of this method must be thread safe as this method may be called concurrently for different migrations on different partitions.
commitMigration in interface MigrationAwareServiceevent - migration eventpublic void rollbackMigration(PartitionMigrationEvent event)
MigrationAwareServiceRollback is not expected to fail at this point, all exceptions will be suppressed and logged. Implementations of this method must be thread safe as this method may be called concurrently for different migrations on different partitions.
rollbackMigration in interface MigrationAwareServiceevent - migration eventpublic Operation getPostJoinOperation()
PostJoinAwareServiceOperation.getPartitionId() method should return a negative value.
This means that the operations should not implement PartitionAwareOperation.
Post join operations should return response, at least a null response.
getPostJoinOperation in interface PostJoinAwareServicenull.public DistributedObject createDistributedObject(String objectName)
RemoteServicecreateDistributedObject in interface RemoteServiceobjectName - the name for the created distributed objectpublic void destroyDistributedObject(String objectName)
RemoteServicedestroyDistributedObject in interface RemoteServiceobjectName - the name of the distributed object to destroypublic void onReplicationEvent(WanReplicationEvent replicationEvent)
ReplicationSupportingServiceonReplicationEvent in interface ReplicationSupportingServicereplicationEvent - the eventpublic void onPartitionLost(IPartitionLostEvent partitionLostEvent)
PartitionAwareServiceonPartitionLost in interface PartitionAwareServicepartitionLostEvent - The event object that contains the partition ID and the number of replicas that is lostpublic Runnable prepareMergeRunnable()
SplitBrainHandlerServiceRunnable, that will merge the clusters.prepareMergeRunnable in interface SplitBrainHandlerServiceRunnable that will merge the clusterspublic <T extends TransactionalObject> T createTransactionalObject(String name, Transaction transaction)
createTransactionalObject in interface TransactionalServicepublic void rollbackTransaction(String transactionId)
rollbackTransaction in interface TransactionalServicepublic Map<String,LocalMapStats> getStats()
StatisticsAwareServicegetStats in interface StatisticsAwareService<LocalMapStats>public String getQuorumName(String name)
QuorumAwareServicegetQuorumName in interface QuorumAwareServicename - the operation name for which the quorum name is returedpublic MapServiceContext getMapServiceContext()
public void clientDisconnected(String clientUuid)
ClientAwareServiceclientDisconnected in interface ClientAwareServiceclientUuid - the UUID of the client that disconnected from a memberpublic void onRegister(Object service, String serviceName, String topic, EventRegistration registration)
NotifiableEventListenerEventService.onRegister in interface NotifiableEventListenerservice - the service instance that event belongs toserviceName - name of the service that event belongs totopic - name of the topic that event belongs toregistration - the EventRegistration instance
that holds information about the registrationpublic void onDeregister(Object service, String serviceName, String topic, EventRegistration registration)
NotifiableEventListenerEventService.onDeregister in interface NotifiableEventListenerservice - the service instance that event belongs toserviceName - name of the service that event belongs totopic - name of the topic that event belongs toregistration - the EventRegistration instance
that holds information about the registrationpublic int getMigrationStamp()
public boolean validateMigrationStamp(int stamp)
public void onClusterStateChange(ClusterState newState)
ClusterStateListeneronClusterStateChange in interface ClusterStateListenernewState - new cluster stateClusterStatepublic void onBeforeLock(String distributedObjectName, Data key)
onBeforeLock in interface LockInterceptorService<Data>public static ObjectNamespace getObjectNamespace(String mapName)
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.