public class CountingMigrationAwareService extends Object implements MigrationAwareService
MigrationAwareService
that delegates to another MigrationAwareService
and keeps track of the number of
migrations concerning the partition owner (either as current or new replica index) currently in-flight.Constructor and Description |
---|
CountingMigrationAwareService(MigrationAwareService migrationAwareService) |
Modifier and Type | Method and Description |
---|---|
void |
beforeMigration(PartitionMigrationEvent event)
Called before migration process starts, on both source and destination members.
|
void |
commitMigration(PartitionMigrationEvent event)
Commits the migration process for this service, on both source and destination members.
|
int |
getMigrationStamp()
Returns a stamp to denote current migration state which can later be validated
using
validateMigrationStamp(int) . |
Operation |
prepareReplicationOperation(PartitionReplicationEvent event)
Returns an operation to replicate service data and/or state for a specific partition replica
on another cluster member.
|
void |
rollbackMigration(PartitionMigrationEvent event)
Rollback the migration process for this service, on both source and destination members.
|
boolean |
validateMigrationStamp(int stamp)
Returns true if there's no primary replica migrations started and/or completed
since issuance of the given stamp.
|
public CountingMigrationAwareService(MigrationAwareService migrationAwareService)
public 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 int getMigrationStamp()
validateMigrationStamp(int)
.public boolean validateMigrationStamp(int stamp)
stamp
- a stampCopyright © 2017 Hazelcast, Inc.. All Rights Reserved.