use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class PartitionIteratingOperation method executePartitionAwareOperations.
private void executePartitionAwareOperations(PartitionAwareOperationFactory givenFactory) {
PartitionAwareOperationFactory factory = givenFactory.createFactoryOnRunner(getNodeEngine());
NodeEngine nodeEngine = getNodeEngine();
int[] operationFactoryPartitions = factory.getPartitions();
partitions = operationFactoryPartitions == null ? partitions : operationFactoryPartitions;
OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions);
OperationService operationService = nodeEngine.getOperationService();
Object service = getServiceName() == null ? null : getService();
for (int partitionId : partitions) {
Operation op = factory.createPartitionOperation(partitionId).setNodeEngine(nodeEngine).setPartitionId(partitionId).setReplicaIndex(getReplicaIndex()).setOperationResponseHandler(responseHandler).setServiceName(getServiceName()).setService(service).setCallerUuid(extractCallerUuid());
OperationAccessor.setCallerAddress(op, getCallerAddress());
operationService.execute(op);
}
}
use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class LockStoreContainer method createScheduler.
private EntryTaskScheduler<Data, Integer> createScheduler(ObjectNamespace namespace) {
NodeEngine nodeEngine = lockService.getNodeEngine();
LockEvictionProcessor entryProcessor = new LockEvictionProcessor(nodeEngine, namespace);
TaskScheduler globalScheduler = nodeEngine.getExecutionService().getGlobalTaskScheduler();
return EntryTaskSchedulerFactory.newScheduler(globalScheduler, entryProcessor, ScheduleType.FOR_EACH);
}
use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class AlterAndGetOperation method run.
@Override
public void run() throws Exception {
NodeEngine nodeEngine = getNodeEngine();
IFunction f = nodeEngine.toObject(function);
AtomicReferenceContainer atomicReferenceContainer = getReferenceContainer();
Data originalData = atomicReferenceContainer.get();
Object input = nodeEngine.toObject(originalData);
//noinspection unchecked
Object output = f.apply(input);
Data serializedOutput = nodeEngine.toData(output);
shouldBackup = !isEquals(originalData, serializedOutput);
if (shouldBackup) {
backup = serializedOutput;
atomicReferenceContainer.set(backup);
}
response = output;
}
use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class LocalLockCleanupOperation method shouldBackup.
@Override
public boolean shouldBackup() {
final NodeEngine nodeEngine = getNodeEngine();
IPartitionService partitionService = nodeEngine.getPartitionService();
IPartition partition = partitionService.getPartition(getPartitionId());
return partition.isLocal() && Boolean.TRUE.equals(response);
}
use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class UnlockIfLeaseExpiredOperation method shouldBackup.
/**
* This operation runs on both primary and backup
* If it is running on backup we should not send a backup operation
* @return
*/
@Override
public boolean shouldBackup() {
NodeEngine nodeEngine = getNodeEngine();
IPartitionService partitionService = nodeEngine.getPartitionService();
Address thisAddress = nodeEngine.getThisAddress();
IPartition partition = partitionService.getPartition(getPartitionId());
if (!thisAddress.equals(partition.getOwnerOrNull())) {
return false;
}
return super.shouldBackup();
}
Aggregations