Search in sources :

Example 66 with NodeEngine

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);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler)

Example 67 with NodeEngine

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);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) TaskScheduler(com.hazelcast.spi.TaskScheduler) EntryTaskScheduler(com.hazelcast.util.scheduler.EntryTaskScheduler)

Example 68 with NodeEngine

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;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) AtomicReferenceContainer(com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer) Data(com.hazelcast.nio.serialization.Data) IFunction(com.hazelcast.core.IFunction)

Example 69 with NodeEngine

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);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) IPartitionService(com.hazelcast.spi.partition.IPartitionService) IPartition(com.hazelcast.spi.partition.IPartition)

Example 70 with NodeEngine

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();
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) IPartitionService(com.hazelcast.spi.partition.IPartitionService) IPartition(com.hazelcast.spi.partition.IPartition)

Aggregations

NodeEngine (com.hazelcast.spi.NodeEngine)75 Data (com.hazelcast.nio.serialization.Data)23 Address (com.hazelcast.nio.Address)14 ILogger (com.hazelcast.logging.ILogger)13 OperationService (com.hazelcast.spi.OperationService)9 IPartitionService (com.hazelcast.spi.partition.IPartitionService)9 Map (java.util.Map)7 Operation (com.hazelcast.spi.Operation)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)5 IPartition (com.hazelcast.spi.partition.IPartition)5 Member (com.hazelcast.core.Member)4 SenderTasklet (com.hazelcast.jet.impl.execution.SenderTasklet)4 Collection (java.util.Collection)4 AtomicReferenceContainer (com.hazelcast.concurrent.atomicreference.AtomicReferenceContainer)3 IFunction (com.hazelcast.core.IFunction)3 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)3 JetInstance (com.hazelcast.jet.JetInstance)3 JobConfig (com.hazelcast.jet.config.JobConfig)3 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)3 Util.getJetInstance (com.hazelcast.jet.impl.util.Util.getJetInstance)3