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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations