use of com.hazelcast.memory.NativeOutOfMemoryError in project hazelcast by hazelcast.
the class MultipleRecordStoreForcedEviction method forceEvictAndRun.
@Override
public boolean forceEvictAndRun(MapOperation mapOperation, double evictionPercentage) {
assert evictionPercentage > 0 && evictionPercentage <= 1;
int partitionCount = numberOfPartitions(mapOperation);
int threadCount = threadCount(mapOperation);
int mod = mod(mapOperation, threadCount);
ILogger logger = mapOperation.logger();
int evictionRetryTimes = retryCount(evictionPercentage);
for (int i = 0; i < evictionRetryTimes; i++) {
try {
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
if ((partitionId % threadCount) != mod) {
continue;
}
Collection<RecordStore> recordStores = partitionMaps(mapOperation, partitionId).values();
for (RecordStore recordStore : recordStores) {
// used for logging
int sizeBeforeEviction = recordStore.size();
MapContainer mapContainer = recordStore.getMapContainer();
Evictor evictor = mapContainer.getEvictor();
evictor.forceEvictByPercentage(recordStore, evictionPercentage);
if (logger.isFineEnabled()) {
logForcedEviction(logger, mapOperation, recordStore, evictionPercentage, (i + 1), sizeBeforeEviction);
}
}
}
mapOperation.runInternal();
return true;
} catch (NativeOutOfMemoryError e) {
// see #retryCount javaDoc
if (evictionPercentage == 1D) {
throw e;
} else {
ignore(e);
}
}
}
return false;
}
use of com.hazelcast.memory.NativeOutOfMemoryError in project hazelcast by hazelcast.
the class MapOperation method logError.
@Override
public void logError(Throwable e) {
ILogger logger = getLogger();
if (e instanceof NativeOutOfMemoryError) {
Level level = this instanceof BackupOperation ? Level.FINEST : Level.WARNING;
logger.log(level, "Cannot complete operation! -> " + e.getMessage());
} else {
// we need to introduce a proper method to handle operation failures (at the moment
// this is the only place where we can dispose native memory allocations on failure)
disposeDeferredBlocks();
super.logError(e);
}
}
use of com.hazelcast.memory.NativeOutOfMemoryError in project hazelcast by hazelcast.
the class SingleRecordStoreForcedEviction method forceEvictAndRun.
@Override
public boolean forceEvictAndRun(MapOperation mapOperation, double evictionPercentage) {
assert evictionPercentage > 0 && evictionPercentage <= 1;
RecordStore recordStore = mapOperation.recordStore;
if (!ForcedEviction.isValid(recordStore)) {
return false;
}
ILogger logger = mapOperation.logger();
int retryCount = retryCount(evictionPercentage);
for (int i = 0; i < retryCount; i++) {
if (logger.isFineEnabled()) {
if (logger.isFineEnabled()) {
String msg = "Single record store forced eviction [attemptNumber: %d, mapName: %s, " + "evictionPercentage:%.2f, partitionId: %d]";
logger.fine(format(msg, (i + 1), mapOperation.getName(), evictionPercentage, mapOperation.getPartitionId()));
}
}
try {
Evictor evictor = recordStore.getMapContainer().getEvictor();
evictor.forceEvictByPercentage(recordStore, evictionPercentage);
mapOperation.runInternal();
return true;
} catch (NativeOutOfMemoryError e) {
ignore(e);
}
}
return false;
}
Aggregations