dlmarion commented on code in PR #3508:
URL: https://github.com/apache/accumulo/pull/3508#discussion_r1235651796
##########
test/src/main/java/org/apache/accumulo/test/functional/MemoryFreeingIterator.java:
##########
@@ -28,23 +28,51 @@
import org.apache.accumulo.core.iterators.IteratorEnvironment;
import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
import org.apache.accumulo.core.iterators.WrappingIterator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
public class MemoryFreeingIterator extends WrappingIterator {
- @Override
- public void init(SortedKeyValueIterator<Key,Value> source,
Map<String,String> options,
- IteratorEnvironment env) throws IOException {
- super.init(source, options, env);
+ private static final Logger LOG =
LoggerFactory.getLogger(MemoryFreeingIterator.class);
+
+ @SuppressFBWarnings(value = "DM_GC", justification = "gc is okay for test")
+ public MemoryFreeingIterator() {
+ super();
+ LOG.info("Freeing consumed memory");
MemoryConsumingIterator.freeBuffers();
while (this.isRunningLowOnMemory()) {
+ System.gc();
// wait for LowMemoryDetector to recognize the memory is free.
try {
Thread.sleep(SECONDS.toMillis(1));
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
- throw new IOException("wait for low memory detector interrupted", ex);
+ throw new RuntimeException("wait for low memory detector interrupted",
ex);
}
}
+ LOG.info("Consumed memory freed");
+ }
+
+ @Override
+ @SuppressFBWarnings(value = "DM_GC", justification = "gc is okay for test")
+ public void init(SortedKeyValueIterator<Key,Value> source,
Map<String,String> options,
+ IteratorEnvironment env) throws IOException {
+ super.init(source, options, env);
+ // LOG.info("Freeing consumed memory");
Review Comment:
this commented code can be removed. This method might be able to be removed
entirely.
##########
server/base/src/main/java/org/apache/accumulo/server/mem/LowMemoryDetector.java:
##########
@@ -105,68 +101,50 @@ public void logGCInfo(AccumuloConfiguration conf) {
try {
final long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
- List<GarbageCollectorMXBean> gcmBeans =
ManagementFactory.getGarbageCollectorMXBeans();
Runtime rt = Runtime.getRuntime();
StringBuilder sb = new StringBuilder("gc");
boolean sawChange = false;
- long maxIncreaseInCollectionTime = 0;
-
- for (GarbageCollectorMXBean gcBean : gcmBeans) {
- Long prevTime = prevGcTime.get(gcBean.getName());
- long pt = 0;
- if (prevTime != null) {
- pt = prevTime;
- }
-
- long time = gcBean.getCollectionTime();
-
- if (time - pt != 0) {
- sawChange = true;
+ final long maxConfiguredMemory = rt.maxMemory();
+ final long allocatedMemory = rt.totalMemory();
+ final long allocatedFreeMemory = rt.freeMemory();
+ final long freeMemory = maxConfiguredMemory - (allocatedMemory -
allocatedFreeMemory);
+ final double lowMemoryThreshold = maxConfiguredMemory *
freeMemoryPercentage;
+ log.trace("Memory info: max={}, allocated={}, free={}, free
threshold={}",
+ maxConfiguredMemory, allocatedMemory, freeMemory, (long)
lowMemoryThreshold);
+
+ if (freeMemory < (long) lowMemoryThreshold) {
+ lowMemCount++;
+ if (lowMemCount > 3 && !runningLowOnMemory) {
+ runningLowOnMemory = true;
+ log.info("Running low on memory: max={}, allocated={}, free={}, free
threshold={}",
Review Comment:
should this be warn?
##########
server/base/src/main/java/org/apache/accumulo/server/mem/LowMemoryDetector.java:
##########
@@ -185,11 +163,11 @@ public void logGCInfo(AccumuloConfiguration conf) {
return;
}
- if (maxIncreaseInCollectionTime > keepAliveTimeout) {
- Halt.halt("Garbage collection may be interfering with lock keep-alive.
Halting.", -1);
- }
+ // if (maxIncreaseInCollectionTime > keepAliveTimeout) {
Review Comment:
I think this should be uncommented.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]