Search in sources :

Example 6 with BackupAwareOperation

use of com.hazelcast.spi.impl.operationservice.BackupAwareOperation in project hazelcast by hazelcast.

the class OperationBackupHandlerTest method backup_whenNegativeAsyncBackupCount.

@Test(expected = IllegalArgumentException.class)
public void backup_whenNegativeAsyncBackupCount() throws Exception {
    setup(BACKPRESSURE_ENABLED);
    BackupAwareOperation op = makeOperation(0, -1);
    backupHandler.sendBackups0(op);
}
Also used : BackupAwareOperation(com.hazelcast.spi.impl.operationservice.BackupAwareOperation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with BackupAwareOperation

use of com.hazelcast.spi.impl.operationservice.BackupAwareOperation in project hazelcast by hazelcast.

the class OperationBackupHandler method sendBackups.

/**
 * Sends the appropriate backups. This call will not wait till the backups have ACK'ed.
 *
 * If this call is made with a none BackupAwareOperation, then 0 is returned.
 *
 * @param op the Operation to backup.
 * @return the number of ACKS required to complete the invocation.
 */
int sendBackups(Operation op) {
    if (!(op instanceof BackupAwareOperation)) {
        return 0;
    }
    int backupAcks = 0;
    BackupAwareOperation backupAwareOp = (BackupAwareOperation) op;
    if (backupAwareOp.shouldBackup()) {
        backupAcks = sendBackups0(backupAwareOp);
    }
    return backupAcks;
}
Also used : BackupAwareOperation(com.hazelcast.spi.impl.operationservice.BackupAwareOperation)

Example 8 with BackupAwareOperation

use of com.hazelcast.spi.impl.operationservice.BackupAwareOperation 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)

Example 9 with BackupAwareOperation

use of com.hazelcast.spi.impl.operationservice.BackupAwareOperation in project hazelcast by hazelcast.

the class OperationBackupHandler method getBackupOperation.

private Operation getBackupOperation(BackupAwareOperation backupAwareOp) {
    Operation backupOp = backupAwareOp.getBackupOperation();
    if (backupOp == null) {
        throw new IllegalArgumentException("Backup operation must not be null! " + backupAwareOp);
    }
    if (ASSERTION_ENABLED) {
        checkServiceNamespaces(backupAwareOp, backupOp);
    }
    Operation op = (Operation) backupAwareOp;
    // set service name of backup operation.
    // if getServiceName() method is overridden to return the same name
    // then this will have no effect.
    backupOp.setServiceName(op.getServiceName());
    backupOp.setNodeEngine(nodeEngine);
    return backupOp;
}
Also used : BackupAwareOperation(com.hazelcast.spi.impl.operationservice.BackupAwareOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 10 with BackupAwareOperation

use of com.hazelcast.spi.impl.operationservice.BackupAwareOperation in project hazelcast by hazelcast.

the class OperationBackupHandlerTest method backup_whenTooLargeSyncBackupCount.

@Test(expected = IllegalArgumentException.class)
public void backup_whenTooLargeSyncBackupCount() throws Exception {
    setup(BACKPRESSURE_ENABLED);
    BackupAwareOperation op = makeOperation(MAX_BACKUP_COUNT + 1, 0);
    backupHandler.sendBackups0(op);
}
Also used : BackupAwareOperation(com.hazelcast.spi.impl.operationservice.BackupAwareOperation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

BackupAwareOperation (com.hazelcast.spi.impl.operationservice.BackupAwareOperation)13 Operation (com.hazelcast.spi.impl.operationservice.Operation)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 Backup (com.hazelcast.spi.impl.operationservice.impl.operations.Backup)3 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)2 Data (com.hazelcast.internal.serialization.Data)2 TargetAware (com.hazelcast.spi.impl.operationservice.TargetAware)2 FragmentedMigrationAwareService (com.hazelcast.internal.partition.FragmentedMigrationAwareService)1 PartitionReplicaVersionManager (com.hazelcast.internal.partition.PartitionReplicaVersionManager)1 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)1 ServiceNamespaceAware (com.hazelcast.internal.services.ServiceNamespaceAware)1