Search in sources :

Example 6 with Backup

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));
}
Also used : Backup(com.hazelcast.spi.impl.operationservice.impl.operations.Backup)

Example 7 with Backup

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;
}
Also used : PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) Backup(com.hazelcast.spi.impl.operationservice.impl.operations.Backup) TargetAware(com.hazelcast.spi.impl.operationservice.TargetAware) Data(com.hazelcast.internal.serialization.Data) BackupAwareOperation(com.hazelcast.spi.impl.operationservice.BackupAwareOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Aggregations

Backup (com.hazelcast.spi.impl.operationservice.impl.operations.Backup)7 Operation (com.hazelcast.spi.impl.operationservice.Operation)4 BackupAwareOperation (com.hazelcast.spi.impl.operationservice.BackupAwareOperation)3 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)2 Data (com.hazelcast.internal.serialization.Data)2 TargetAware (com.hazelcast.spi.impl.operationservice.TargetAware)2 Test (org.junit.Test)2 Address (com.hazelcast.cluster.Address)1 OperationFactory (com.hazelcast.spi.impl.operationservice.OperationFactory)1 DummyOperation (com.hazelcast.spi.impl.operationservice.impl.DummyOperation)1 PartitionIteratingOperation (com.hazelcast.spi.impl.operationservice.impl.operations.PartitionIteratingOperation)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1