use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class OperationBackupHandler method makeBackups.
private int makeBackups(BackupAwareOperation backupAwareOp, int partitionId, long[] replicaVersions, int syncBackups, int asyncBackups) {
int sendSyncBackups;
int totalBackups = syncBackups + asyncBackups;
InternalPartitionService partitionService = node.getPartitionService();
InternalPartition partition = partitionService.getPartition(partitionId);
if (totalBackups == 1) {
sendSyncBackups = sendSingleBackup(backupAwareOp, partition, replicaVersions, syncBackups);
} else {
sendSyncBackups = sendMultipleBackups(backupAwareOp, partition, replicaVersions, syncBackups, totalBackups);
}
return sendSyncBackups;
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldCommitMigrationWhenSourceFailsDuringCommit.
@Test
public void shouldCommitMigrationWhenSourceFailsDuringCommit() {
CountDownLatch migrationStartLatch = new CountDownLatch(1);
Config config1 = createConfig();
config1.setLiteMember(true);
TerminateOtherMemberOnMigrationComplete masterListener = new TerminateOtherMemberOnMigrationComplete(migrationStartLatch);
config1.addListenerConfig(new ListenerConfig(masterListener));
HazelcastInstance hz1 = factory.newHazelcastInstance(config1);
HazelcastInstance hz2 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz1, hz2);
waitAllForSafeState(hz1, hz2);
Config config3 = createConfig();
InternalMigrationListenerImpl targetListener = new InternalMigrationListenerImpl();
config3.addListenerConfig(new ListenerConfig(targetListener));
HazelcastInstance hz3 = factory.newHazelcastInstance(config3);
masterListener.other = hz2;
migrationStartLatch.countDown();
waitAllForSafeState(hz1, hz3);
InternalPartition partition0 = getPartitionService(hz3).getPartition(0);
InternalPartition partition1 = getPartitionService(hz3).getPartition(1);
assertEquals(getAddress(hz3), partition0.getOwnerOrNull());
assertEquals(getAddress(hz3), partition1.getOwnerOrNull());
assertFalse(partition0.isMigrating());
assertFalse(partition1.isMigrating());
assertFalse(masterListener.rollback);
List<MigrationProgressNotification> notifications = targetListener.getNotifications();
assertFalse(notifications.isEmpty());
assertEquals(COMMIT, notifications.get(notifications.size() - 1).event);
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldCommitMigrationWhenMasterCrashesAfterDestinationCommit.
@Test
public void shouldCommitMigrationWhenMasterCrashesAfterDestinationCommit() {
CountDownLatch migrationStartLatch = new CountDownLatch(1);
Config config1 = createConfig();
config1.setLiteMember(true);
HazelcastInstance hz1 = factory.newHazelcastInstance(config1);
Config config2 = createConfig();
final CollectMigrationTaskOnCommit sourceListener = new CollectMigrationTaskOnCommit();
config2.addListenerConfig(new ListenerConfig(sourceListener));
HazelcastInstance hz2 = factory.newHazelcastInstance(config2);
warmUpPartitions(hz1, hz2);
waitAllForSafeState(hz1, hz2);
Config config3 = createConfig();
TerminateOtherMemberOnMigrationCommit destinationListener = new TerminateOtherMemberOnMigrationCommit(migrationStartLatch);
destinationListener.other = hz1;
config3.addListenerConfig(new ListenerConfig(destinationListener));
HazelcastInstance hz3 = factory.newHazelcastInstance(config3);
migrationStartLatch.countDown();
waitAllForSafeState(hz2, hz3);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(sourceListener.commit);
}
});
InternalPartition hz2Partition = getOwnedPartition(hz2);
InternalPartition hz3Partition = getOwnedPartition(hz3);
assertNotNull(hz2Partition);
assertNotNull(hz3Partition);
assertNotEquals(hz2Partition, hz3Partition);
assertFalse(hz2Partition.isMigrating());
assertFalse(hz3Partition.isMigrating());
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldRollbackMigrationWhenDestinationCrashesDuringCommit.
@Test
public void shouldRollbackMigrationWhenDestinationCrashesDuringCommit() {
CountDownLatch migrationStartLatch = new CountDownLatch(1);
Config config1 = createConfig();
config1.setLiteMember(true);
DelayMigrationStartOnMaster masterListener = new DelayMigrationStartOnMaster(migrationStartLatch);
config1.addListenerConfig(new ListenerConfig(masterListener));
HazelcastInstance hz1 = factory.newHazelcastInstance(config1);
HazelcastInstance hz2 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz1, hz2);
waitAllForSafeState(hz1, hz2);
CountDownLatch terminationLatch = new CountDownLatch(1);
TerminateOnMigrationCommit memberListener = new TerminateOnMigrationCommit(terminationLatch);
Config config3 = createConfig();
config3.addListenerConfig(new ListenerConfig(memberListener));
HazelcastInstance hz3 = factory.newHazelcastInstance(config3);
warmUpPartitions(hz1, hz2, hz3);
migrationStartLatch.countDown();
waitAllForSafeState(hz1, hz2);
InternalPartition partition0 = getPartitionService(hz1).getPartition(0);
InternalPartition partition1 = getPartitionService(hz1).getPartition(1);
assertEquals(getAddress(hz2), partition0.getOwnerOrNull());
assertEquals(getAddress(hz2), partition1.getOwnerOrNull());
assertFalse(partition0.isMigrating());
assertFalse(partition1.isMigrating());
assertTrue(masterListener.rollback.get());
terminationLatch.countDown();
}
use of com.hazelcast.internal.partition.InternalPartition in project hazelcast by hazelcast.
the class MigrationCommitTest method shouldCommitMigrationWhenMasterIsMigrationSource.
@Test
public void shouldCommitMigrationWhenMasterIsMigrationSource() {
HazelcastInstance hz1 = factory.newHazelcastInstance(createConfig());
Config config2 = createConfig();
config2.setLiteMember(true);
HazelcastInstance hz2 = factory.newHazelcastInstance(config2);
warmUpPartitions(hz1, hz2);
waitAllForSafeState(hz1, hz2);
HazelcastInstance hz3 = factory.newHazelcastInstance(createConfig());
warmUpPartitions(hz3);
waitAllForSafeState(hz1, hz2, hz3);
InternalPartition hz1Partition = getOwnedPartition(hz1);
InternalPartition hz3Partition = getOwnedPartition(hz3);
assertNotNull(hz1Partition);
assertNotNull(hz3Partition);
assertNotEquals(hz1Partition, hz3Partition);
assertFalse(hz1Partition.isMigrating());
assertFalse(hz3Partition.isMigrating());
}
Aggregations