use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ClearOperation method replicateClearOperation.
private void replicateClearOperation(long version) {
OperationService operationService = getNodeEngine().getOperationService();
Collection<Address> members = getMemberAddresses();
for (Address address : members) {
Operation op = new ClearOperation(mapName, false, version).setPartitionId(getPartitionId()).setValidateTarget(false);
operationService.createInvocationBuilder(getServiceName(), op, address).setTryCount(INVOCATION_TRY_COUNT).invoke();
}
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class NodeEngineImpl method getPostJoinOperations.
/**
* Collects all post-join operations from {@link PostJoinAwareService}s.
* <p>
* Post join operations should return response, at least a {@code null} response.
* <p>
* <b>Note</b>: Post join operations must be lock free, meaning no locks at all:
* no partition locks, no key-based locks, no service level locks, no database interaction!
* The {@link Operation#getPartitionId()} method should return a negative value.
* This means that the operations should not implement {@link PartitionAwareOperation}.
*
* @return the operations to be executed at the end of a finalized join
*/
public Collection<Operation> getPostJoinOperations() {
Collection<Operation> postJoinOps = new LinkedList<>();
Collection<PostJoinAwareService> services = getServices(PostJoinAwareService.class);
for (PostJoinAwareService service : services) {
Operation postJoinOperation = service.getPostJoinOperation();
if (postJoinOperation != null) {
if (postJoinOperation.getPartitionId() >= 0) {
logger.severe("Post-join operations should not have partition ID set! Service: " + service + ", Operation: " + postJoinOperation);
continue;
}
postJoinOps.add(postJoinOperation);
}
}
return postJoinOps;
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class NodeEngineImpl method getPreJoinOperations.
public Collection<Operation> getPreJoinOperations() {
Collection<Operation> preJoinOps = new LinkedList<>();
Collection<PreJoinAwareService> services = getServices(PreJoinAwareService.class);
for (PreJoinAwareService service : services) {
Operation preJoinOperation = service.getPreJoinOperation();
if (preJoinOperation != null) {
if (preJoinOperation.getPartitionId() >= 0) {
logger.severe("Pre-join operations operations should not have partition ID set! Service: " + service + ", Operation: " + preJoinOperation);
continue;
}
preJoinOps.add(preJoinOperation);
}
}
return preJoinOps;
}
use of com.hazelcast.spi.impl.operationservice.Operation 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.Operation in project hazelcast by hazelcast.
the class OperationBackupHandler method sendBackups0.
int sendBackups0(BackupAwareOperation backupAwareOp) {
int requestedSyncBackups = requestedSyncBackups(backupAwareOp);
int requestedAsyncBackups = requestedAsyncBackups(backupAwareOp);
int requestedTotalBackups = requestedTotalBackups(backupAwareOp);
if (requestedTotalBackups == 0) {
return 0;
}
Operation op = (Operation) backupAwareOp;
PartitionReplicaVersionManager versionManager = node.getPartitionService().getPartitionReplicaVersionManager();
ServiceNamespace namespace = versionManager.getServiceNamespace(op);
long[] replicaVersions = versionManager.incrementPartitionReplicaVersions(op.getPartitionId(), namespace, requestedTotalBackups);
boolean syncForced = backpressureRegulator.isSyncForced(backupAwareOp);
int syncBackups = syncBackups(requestedSyncBackups, requestedAsyncBackups, syncForced);
int asyncBackups = asyncBackups(requestedSyncBackups, requestedAsyncBackups, syncForced);
// TODO: This could cause a problem with back pressure
if (!op.returnsResponse()) {
asyncBackups += syncBackups;
syncBackups = 0;
}
if (syncBackups + asyncBackups == 0) {
return 0;
}
return makeBackups(backupAwareOp, op.getPartitionId(), replicaVersions, syncBackups, asyncBackups);
}
Aggregations