public class MapService extends Object implements ManagedService, MigrationAwareService, TransactionalService, RemoteService, EventPublishingService<Object,ListenerAdapter>, PostJoinAwareService, SplitBrainHandlerService, ReplicationSupportingService, StatisticsAwareService, PartitionAwareService, ClientAwareService, QuorumAwareService, NotifiableEventListener
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 DelegatingMigrationAwareService |
migrationAwareService |
protected PartitionAwareService |
partitionAwareService |
protected PostJoinAwareService |
postJoinAwareService |
protected QuorumAwareService |
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) |
MapServiceContext |
getMapServiceContext() |
int |
getOwnerMigrationsInFlight() |
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 name) |
Map<String,LocalMapStats> |
getStats() |
void |
init(NodeEngine nodeEngine,
Properties properties)
Initializes this ManagedService
|
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) |
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.
|
Operation |
prepareReplicationOperation(PartitionReplicationEvent event)
Returns an operation to replicate service data and/or state for a specific partition replica
on another cluster member.
|
void |
reset()
reset this ManagedService back to 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 ManagedService.
|
public static final String SERVICE_NAME
protected ManagedService managedService
protected DelegatingMigrationAwareService 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 QuorumAwareService quorumAwareService
protected MapServiceContext mapServiceContext
public void dispatchEvent(Object event, ListenerAdapter listener)
dispatchEvent
in interface EventPublishingService<Object,ListenerAdapter>
public 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.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 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.
prepareReplicationOperation
in interface MigrationAwareService
event
- replicationpublic void beforeMigration(PartitionMigrationEvent event)
MigrationAwareService
Service 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 MigrationAwareService
event
- migration eventpublic 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
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
event
- migration eventpublic Operation getPostJoinOperation()
PostJoinAwareService
Post join operations should return response, at least a null response.
getPostJoinOperation
in interface PostJoinAwareService
public 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 onReplicationEvent(WanReplicationEvent replicationEvent)
onReplicationEvent
in interface ReplicationSupportingService
public void onPartitionLost(IPartitionLostEvent partitionLostEvent)
PartitionAwareService
onPartitionLost
in interface PartitionAwareService
partitionLostEvent
- The event object that contains the partition id and the number of replicas that is lostpublic Runnable prepareMergeRunnable()
SplitBrainHandlerService
prepareMergeRunnable
in interface SplitBrainHandlerService
public <T extends TransactionalObject> T createTransactionalObject(String name, Transaction transaction)
createTransactionalObject
in interface TransactionalService
public void rollbackTransaction(String transactionId)
rollbackTransaction
in interface TransactionalService
public Map<String,LocalMapStats> getStats()
getStats
in interface StatisticsAwareService
public String getQuorumName(String name)
getQuorumName
in interface QuorumAwareService
public MapServiceContext getMapServiceContext()
public void clientDisconnected(String clientUuid)
ClientAwareService
clientDisconnected
in interface ClientAwareService
clientUuid
- the Uuid of the client that disconnected from a memberpublic void onRegister(Object service, String serviceName, String topic, EventRegistration registration)
NotifiableEventListener
EventService
.onRegister
in interface NotifiableEventListener
service
- 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)
NotifiableEventListener
EventService
.onDeregister
in interface NotifiableEventListener
service
- 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 getOwnerMigrationsInFlight()
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.