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();
}
}
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);
}
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();
}
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;
}
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());
}
Aggregations