use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class EvictionMaxSizePolicyTest method setMockRuntimeMemoryInfoAccessor.
public static void setMockRuntimeMemoryInfoAccessor(IMap map, final long totalMemoryMB, final long freeMemoryMB, final long maxMemoryMB) {
final MapProxyImpl mapProxy = (MapProxyImpl) map;
final MapService mapService = (MapService) mapProxy.getService();
final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MemoryInfoAccessor memoryInfoAccessor = new MemoryInfoAccessor() {
@Override
public long getTotalMemory() {
return MEGABYTES.toBytes(totalMemoryMB);
}
@Override
public long getFreeMemory() {
return MEGABYTES.toBytes(freeMemoryMB);
}
@Override
public long getMaxMemory() {
return MEGABYTES.toBytes(maxMemoryMB);
}
};
MapContainer mapContainer = mapServiceContext.getMapContainer(map.getName());
MapEvictionPolicy mapEvictionPolicy = mapContainer.getMapConfig().getMapEvictionPolicy();
EvictionChecker evictionChecker = new EvictionChecker(memoryInfoAccessor, mapServiceContext);
IPartitionService partitionService = mapServiceContext.getNodeEngine().getPartitionService();
Evictor evictor = new TestEvictor(mapEvictionPolicy, evictionChecker, partitionService);
mapContainer.setEvictor(evictor);
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class MapGetInvalidationMetaDataOperation method getOwnedPartitions.
private List<Integer> getOwnedPartitions() {
List<Integer> ownedPartitions = new ArrayList<Integer>();
IPartitionService partitionService = getNodeEngine().getPartitionService();
for (int i = 0; i < partitionService.getPartitionCount(); i++) {
if (partitionService.isPartitionOwner(i)) {
ownedPartitions.add(i);
}
}
return ownedPartitions;
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class RequestPartitionMapping method run.
@Override
public void run() throws Exception {
MapReduceService mapReduceService = getService();
JobSupervisor supervisor = mapReduceService.getJobSupervisor(getName(), getJobId());
if (supervisor == null) {
result = new RequestPartitionResult(NO_SUPERVISOR, -1);
return;
}
IPartitionService ps = getNodeEngine().getPartitionService();
List<Integer> memberPartitions = ps.getMemberPartitions(getCallerAddress());
JobProcessInformationImpl processInformation = supervisor.getJobProcessInformation();
while (true) {
int selectedPartition = searchMemberPartitionToProcess(processInformation, memberPartitions);
if (selectedPartition == -1) {
// All partitions seem to be assigned so give up
result = new RequestPartitionResult(NO_MORE_PARTITIONS, -1);
return;
}
JobPartitionState.State nextState = stateChange(getCallerAddress(), selectedPartition, WAITING, processInformation, supervisor.getConfiguration());
if (nextState == MAPPING) {
result = new RequestPartitionResult(SUCCESSFUL, selectedPartition);
return;
}
}
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class MapKeyValueSource method open.
@Override
public boolean open(NodeEngine nodeEngine) {
NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
IPartitionService ps = nei.getPartitionService();
MapService mapService = nei.getService(MapService.SERVICE_NAME);
ss = nei.getSerializationService();
Address partitionOwner = ps.getPartitionOwner(partitionId);
if (partitionOwner == null) {
return false;
}
RecordStore recordStore = mapService.getMapServiceContext().getRecordStore(partitionId, mapName);
iterator = recordStore.iterator();
return true;
}
use of com.hazelcast.spi.partition.IPartitionService in project hazelcast by hazelcast.
the class MultiMapKeyValueSource method open.
@Override
public boolean open(NodeEngine nodeEngine) {
NodeEngineImpl nei = (NodeEngineImpl) nodeEngine;
IPartitionService ps = nei.getPartitionService();
MultiMapService multiMapService = nei.getService(MultiMapService.SERVICE_NAME);
ss = nei.getSerializationService();
Address partitionOwner = ps.getPartitionOwner(partitionId);
if (partitionOwner == null) {
return false;
}
multiMapContainer = multiMapService.getOrCreateCollectionContainer(partitionId, multiMapName);
isBinary = multiMapContainer.getConfig().isBinary();
keyIterator = multiMapContainer.keySet().iterator();
return true;
}
Aggregations