use of com.hazelcast.spi.impl.operationservice.impl.operations.Backup in project hazelcast by hazelcast.
the class OperationDescriptors method toOperationDesc.
public static String toOperationDesc(Operation op) {
Class<? extends Operation> operationClass = op.getClass();
if (PartitionIteratingOperation.class.isAssignableFrom(operationClass)) {
PartitionIteratingOperation partitionIteratingOperation = (PartitionIteratingOperation) op;
OperationFactory operationFactory = partitionIteratingOperation.getOperationFactory();
String desc = DESCRIPTORS.get(operationFactory.getClass().getName());
if (desc == null) {
desc = PartitionIteratingOperation.class.getSimpleName() + "(" + operationFactory.getClass().getName() + ")";
DESCRIPTORS.put(operationFactory.getClass().getName(), desc);
}
return desc;
} else if (Backup.class.isAssignableFrom(operationClass)) {
Backup backup = (Backup) op;
Operation backupOperation = backup.getBackupOp();
String desc = DESCRIPTORS.get(backupOperation.getClass().getName());
if (desc == null) {
desc = Backup.class.getSimpleName() + "(" + backup.getBackupOp().getClass().getName() + ")";
DESCRIPTORS.put(backupOperation.getClass().getName(), desc);
}
return desc;
} else {
return operationClass.getName();
}
}
use of com.hazelcast.spi.impl.operationservice.impl.operations.Backup in project hazelcast by hazelcast.
the class OperationBackupHandler method newBackup.
private static Backup newBackup(BackupAwareOperation backupAwareOp, Object backupOp, long[] replicaVersions, int replicaIndex, boolean respondBack) {
Operation op = (Operation) backupAwareOp;
Backup backup;
if (backupOp instanceof Operation) {
backup = new Backup((Operation) backupOp, op.getCallerAddress(), replicaVersions, respondBack, op.getClientCallId());
} else if (backupOp instanceof Data) {
backup = new Backup((Data) backupOp, op.getCallerAddress(), replicaVersions, respondBack, op.getClientCallId());
} else {
throw new IllegalArgumentException("Only 'Data' or 'Operation' typed backup operation is supported!");
}
backup.setPartitionId(op.getPartitionId()).setReplicaIndex(replicaIndex).setCallerUuid(op.getCallerUuid());
if (hasActiveInvocation(op)) {
setCallId(backup, op.getCallId());
}
return backup;
}
use of com.hazelcast.spi.impl.operationservice.impl.operations.Backup in project hazelcast by hazelcast.
the class OperationBackupHandler method sendSingleBackup.
private int sendSingleBackup(BackupAwareOperation backupAwareOp, InternalPartition partition, long[] replicaVersions, int syncBackups, int replica) {
Operation backupOp = getBackupOperation(backupAwareOp);
PartitionReplica target = partition.getReplica(replica);
if (target != null) {
if (skipSendingBackupToTarget(partition, target)) {
return 0;
}
// without any unnecessary memory allocation and copy when it is used as object inside `Backup`.
if (backupOp instanceof TargetAware) {
((TargetAware) backupOp).setTarget(target.address());
}
boolean isSyncBackup = syncBackups == 1;
Backup backup = newBackup(backupAwareOp, backupOp, replicaVersions, 1, isSyncBackup);
outboundOperationHandler.send(backup, target.address());
if (isSyncBackup) {
return 1;
}
}
return 0;
}
use of com.hazelcast.spi.impl.operationservice.impl.operations.Backup in project hazelcast by hazelcast.
the class OperationDescriptorsTest method testBackupOperation.
@Test
public void testBackupOperation() throws UnknownHostException {
Backup backup = new Backup(new DummyBackupOperation(), new Address("127.0.0.1", 5701), new long[] {}, false);
String result = toOperationDesc(backup);
assertEquals(format("Backup(%s)", DummyBackupOperation.class.getName()), result);
}
use of com.hazelcast.spi.impl.operationservice.impl.operations.Backup in project hazelcast by hazelcast.
the class OverloadedConnectionsPluginTest method toKey.
@Test
@SuppressWarnings("UnnecessaryBoxing")
public void toKey() {
assertToKey(DummyOperation.class.getName(), new DummyOperation());
assertToKey(Integer.class.getName(), Integer.valueOf(10));
assertToKey("Backup(" + DummyOperation.class.getName() + ")", new Backup(new DummyOperation(), getAddress(local), new long[0], true));
}
Aggregations