use of com.hazelcast.spi.impl.operationservice.impl.operations.Backup in project hazelcast by hazelcast.
the class OperationOutOfOrderBackupTest method runBackup.
private void runBackup(NodeEngine nodeEngine, int value, long[] replicaVersions, Address sender) throws InterruptedException {
Backup backup = new Backup(new SampleBackupOperation(value), sender, replicaVersions, false);
backup.setPartitionId(partitionId).setReplicaIndex(1).setNodeEngine(nodeEngine);
nodeEngine.getOperationService().execute(backup);
LatchOperation latchOp = new LatchOperation(1);
nodeEngine.getOperationService().execute(latchOp.setPartitionId(partitionId));
assertTrue(latchOp.latch.await(1, TimeUnit.MINUTES));
}
use of com.hazelcast.spi.impl.operationservice.impl.operations.Backup in project hazelcast by hazelcast.
the class OperationBackupHandler method sendMultipleBackups.
private int sendMultipleBackups(BackupAwareOperation backupAwareOp, InternalPartition partition, long[] replicaVersions, int syncBackups, int totalBackups) {
int sendSyncBackups = 0;
Operation backupOp = getBackupOperation(backupAwareOp);
if (!(backupOp instanceof TargetAware)) {
// optimize common case: serialize operation once and send to multiple targets
Data backupOpData = nodeEngine.getSerializationService().toData(backupOp);
for (int replicaIndex = 1; replicaIndex <= totalBackups; replicaIndex++) {
PartitionReplica target = partition.getReplica(replicaIndex);
if (target == null) {
continue;
}
if (skipSendingBackupToTarget(partition, target)) {
continue;
}
boolean isSyncBackup = replicaIndex <= syncBackups;
Backup backup = newBackup(backupAwareOp, backupOpData, replicaVersions, replicaIndex, isSyncBackup);
outboundOperationHandler.send(backup, target.address());
if (isSyncBackup) {
sendSyncBackups++;
}
}
} else {
for (int replicaIndex = 1; replicaIndex <= totalBackups; replicaIndex++) {
int syncBackupSent = sendSingleBackup(backupAwareOp, partition, replicaVersions, syncBackups, replicaIndex);
sendSyncBackups += syncBackupSent;
}
}
return sendSyncBackups;
}
Aggregations