use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class CacheLoadAllOperation method run.
@Override
public void run() throws Exception {
int partitionId = getPartitionId();
IPartitionService partitionService = getNodeEngine().getPartitionService();
Set<Data> filteredKeys = null;
if (keys != null) {
filteredKeys = new HashSet<Data>();
for (Data k : keys) {
if (partitionService.getPartitionId(k) == partitionId) {
filteredKeys.add(k);
}
}
}
if (filteredKeys == null || filteredKeys.isEmpty()) {
return;
}
try {
ICacheService service = getService();
cache = service.getOrCreateRecordStore(name, partitionId);
Set<Data> keysLoaded = cache.loadAll(filteredKeys, replaceExistingValues);
int loadedKeyCount = keysLoaded.size();
if (loadedKeyCount > 0) {
backupRecords = new HashMap<Data, CacheRecord>(loadedKeyCount);
for (Data key : keysLoaded) {
CacheRecord record = cache.getRecord(key);
// So if the loaded key is evicted, don't send it to backup.
if (record != null) {
backupRecords.put(key, record);
}
}
shouldBackup = !backupRecords.isEmpty();
}
} catch (CacheException e) {
response = new CacheClearResponse(e);
}
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class PartitionContainer method createRecordStore.
private RecordStore createRecordStore(String name) {
MapServiceContext serviceContext = mapService.getMapServiceContext();
MapContainer mapContainer = serviceContext.getMapContainer(name);
MapConfig mapConfig = mapContainer.getMapConfig();
NodeEngine nodeEngine = serviceContext.getNodeEngine();
IPartitionService ps = nodeEngine.getPartitionService();
OperationService opService = nodeEngine.getOperationService();
ExecutionService execService = nodeEngine.getExecutionService();
HazelcastProperties hazelcastProperties = nodeEngine.getProperties();
MapKeyLoader keyLoader = new MapKeyLoader(name, opService, ps, nodeEngine.getClusterService(), execService, mapContainer.toData());
keyLoader.setMaxBatch(hazelcastProperties.getInteger(GroupProperty.MAP_LOAD_CHUNK_SIZE));
keyLoader.setMaxSize(getMaxSizePerNode(mapConfig.getMaxSizeConfig()));
keyLoader.setHasBackup(mapConfig.getTotalBackupCount() > 0);
keyLoader.setMapOperationProvider(serviceContext.getMapOperationProvider(name));
RecordStore recordStore = serviceContext.createRecordStore(mapContainer, partitionId, keyLoader);
recordStore.init();
return recordStore;
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class EvictionChecker method isOwnerOrBackup.
protected boolean isOwnerOrBackup(int partitionId) {
final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
final IPartitionService partitionService = nodeEngine.getPartitionService();
final IPartition partition = partitionService.getPartition(partitionId, false);
final Address thisAddress = nodeEngine.getThisAddress();
return partition.isOwnerOrBackup(thisAddress);
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class EvictionChecker method findPartitionIds.
protected List<Integer> findPartitionIds() {
final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
final IPartitionService partitionService = nodeEngine.getPartitionService();
final int partitionCount = partitionService.getPartitionCount();
List<Integer> partitionIds = null;
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
if (isOwnerOrBackup(partitionId)) {
if (partitionIds == null) {
partitionIds = new ArrayList<Integer>();
}
partitionIds.add(partitionId);
}
}
return partitionIds == null ? Collections.<Integer>emptyList() : partitionIds;
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class GetAllOperation method run.
@Override
public void run() {
IPartitionService partitionService = getNodeEngine().getPartitionService();
int partitionId = getPartitionId();
Set<Data> partitionKeySet = new HashSet<Data>();
for (Data key : keys) {
if (partitionId == partitionService.getPartitionId(key)) {
partitionKeySet.add(key);
}
}
entries = recordStore.getAll(partitionKeySet);
}
Aggregations