Search in sources :

Example 31 with IPartitionService

use of com.hazelcast.internal.partition.IPartitionService in project hazelcast by hazelcast.

the class QueueEvictionProcessor method process.

@Override
public void process(EntryTaskScheduler<String, Void> scheduler, Collection<ScheduledEntry<String, Void>> entries) {
    if (entries.isEmpty()) {
        return;
    }
    IPartitionService partitionService = nodeEngine.getPartitionService();
    OperationService operationService = nodeEngine.getOperationService();
    for (ScheduledEntry<String, Void> entry : entries) {
        String name = entry.getKey();
        int partitionId = partitionService.getPartitionId(nodeEngine.toData(name));
        Operation op = new CheckAndEvictOperation(entry.getKey()).setPartitionId(partitionId);
        operationService.invokeOnPartition(op).joinInternal();
    }
}
Also used : CheckAndEvictOperation(com.hazelcast.collection.impl.queue.operations.CheckAndEvictOperation) IPartitionService(com.hazelcast.internal.partition.IPartitionService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) CheckAndEvictOperation(com.hazelcast.collection.impl.queue.operations.CheckAndEvictOperation)

Example 32 with IPartitionService

use of com.hazelcast.internal.partition.IPartitionService in project hazelcast by hazelcast.

the class LongRegisterService method getPartitionId.

private int getPartitionId(String name) {
    IPartitionService partitionService = nodeEngine.getPartitionService();
    String partitionKey = getPartitionKey(name);
    return partitionService.getPartitionId(partitionKey);
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService)

Example 33 with IPartitionService

use of com.hazelcast.internal.partition.IPartitionService 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.impl.NodeEngine) Address(com.hazelcast.cluster.Address) IPartitionService(com.hazelcast.internal.partition.IPartitionService) IPartition(com.hazelcast.internal.partition.IPartition)

Example 34 with IPartitionService

use of com.hazelcast.internal.partition.IPartitionService in project hazelcast by hazelcast.

the class RecordStoreTest method getRecordStore.

private DefaultRecordStore getRecordStore(IMap<Object, Object> map, int key) {
    MapServiceContext mapServiceContext = getMapServiceContext((MapProxyImpl) map);
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    int partitionId = partitionService.getPartitionId(key);
    PartitionContainer container = mapServiceContext.getPartitionContainer(partitionId);
    RecordStore recordStore = container.getRecordStore(map.getName());
    return (DefaultRecordStore) recordStore;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) IPartitionService(com.hazelcast.internal.partition.IPartitionService) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) DefaultRecordStore(com.hazelcast.map.impl.recordstore.DefaultRecordStore) DefaultRecordStore(com.hazelcast.map.impl.recordstore.DefaultRecordStore)

Example 35 with IPartitionService

use of com.hazelcast.internal.partition.IPartitionService in project hazelcast by hazelcast.

the class ParallelPartitionScanExecutorTest method execute_success.

@Test
public void execute_success() {
    IPartitionService partitionService = mock(IPartitionService.class);
    when(partitionService.getPartitionCount()).thenReturn(271);
    PartitionScanRunner runner = mock(PartitionScanRunner.class);
    Whitebox.setInternalState(runner, "partitionService", partitionService);
    ParallelPartitionScanExecutor executor = executor(runner);
    Predicate predicate = Predicates.equal("attribute", 1);
    QueryResult queryResult = new QueryResult(IterationType.ENTRY, null, null, Long.MAX_VALUE, false);
    executor.execute("Map", predicate, asList(1, 2, 3), queryResult);
    List<QueryResultRow> result = queryResult.getRows();
    assertEquals(0, result.size());
}
Also used : IPartitionService(com.hazelcast.internal.partition.IPartitionService) Predicate(com.hazelcast.query.Predicate) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

IPartitionService (com.hazelcast.internal.partition.IPartitionService)36 Data (com.hazelcast.internal.serialization.Data)10 NodeEngine (com.hazelcast.spi.impl.NodeEngine)10 Address (com.hazelcast.cluster.Address)8 List (java.util.List)7 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)6 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)6 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)5 IPartition (com.hazelcast.internal.partition.IPartition)4 PartitionIdSet (com.hazelcast.internal.util.collection.PartitionIdSet)4 MapService (com.hazelcast.map.impl.MapService)4 ClusterService (com.hazelcast.internal.cluster.ClusterService)3 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)3 ICacheService (com.hazelcast.cache.impl.ICacheService)2 Connection (com.hazelcast.internal.nio.Connection)2 JobConfig (com.hazelcast.jet.config.JobConfig)2 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)2 JetServiceBackend (com.hazelcast.jet.impl.JetServiceBackend)2