Addendum HBASE-17522 missed some branch-1 specific direct uses of MemoryMXBean
This commit is contained in:
parent
3d4639f34d
commit
fab0b2e603
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.regionserver;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
@ -203,7 +203,11 @@ public class MemStoreChunkPool {
|
|||
if (poolSizePercentage > 1.0) {
|
||||
throw new IllegalArgumentException(CHUNK_POOL_MAXSIZE_KEY + " must be between 0.0 and 1.0");
|
||||
}
|
||||
long heapMax = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax();
|
||||
long heapMax = -1L;
|
||||
final MemoryUsage usage = HeapMemorySizeUtil.safeGetHeapMemoryUsage();
|
||||
if (usage != null) {
|
||||
heapMax = usage.getMax();
|
||||
}
|
||||
long globalMemStoreLimit = (long) (heapMax * HeapMemorySizeUtil.getGlobalMemStorePercent(conf,
|
||||
false));
|
||||
int chunkSize = conf.getInt(HeapMemStoreLAB.CHUNK_SIZE_KEY,
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.apache.hadoop.util.StringUtils.humanReadableInt;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashMap;
|
||||
|
@ -110,7 +110,11 @@ class MemStoreFlusher implements FlushRequester {
|
|||
this.server = server;
|
||||
this.threadWakeFrequency =
|
||||
conf.getLong(HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000);
|
||||
long max = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax();
|
||||
long max = -1L;
|
||||
final MemoryUsage usage = HeapMemorySizeUtil.safeGetHeapMemoryUsage();
|
||||
if (usage != null) {
|
||||
max = usage.getMax();
|
||||
}
|
||||
float globalMemStorePercent = HeapMemorySizeUtil.getGlobalMemStorePercent(conf, true);
|
||||
this.globalMemStoreLimit = (long) (max * globalMemStorePercent);
|
||||
this.globalMemStoreLimitLowMarkPercent =
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URLEncoder;
|
||||
|
@ -574,8 +573,12 @@ public class FSHLog implements WAL {
|
|||
}
|
||||
|
||||
private int calculateMaxLogFiles(float memstoreSizeRatio, long logRollSize) {
|
||||
MemoryUsage mu = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||
int maxLogs = Math.round(mu.getMax() * memstoreSizeRatio * 2 / logRollSize);
|
||||
long max = -1L;
|
||||
final MemoryUsage usage = HeapMemorySizeUtil.safeGetHeapMemoryUsage();
|
||||
if (usage != null) {
|
||||
max = usage.getMax();
|
||||
}
|
||||
int maxLogs = Math.round(max * memstoreSizeRatio * 2 / logRollSize);
|
||||
return maxLogs;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue