mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-20 03:45:02 +00:00
JVM GC monitor settings
This commit converts the GC monitor settings "monitor.jvm.gc.*" to the new settings infrastructure.
This commit is contained in:
parent
3f53e143a5
commit
ea56bfad9a
@ -68,6 +68,7 @@ import org.elasticsearch.indices.recovery.RecoverySettings;
|
|||||||
import org.elasticsearch.indices.store.IndicesStore;
|
import org.elasticsearch.indices.store.IndicesStore;
|
||||||
import org.elasticsearch.indices.ttl.IndicesTTLService;
|
import org.elasticsearch.indices.ttl.IndicesTTLService;
|
||||||
import org.elasticsearch.monitor.fs.FsService;
|
import org.elasticsearch.monitor.fs.FsService;
|
||||||
|
import org.elasticsearch.monitor.jvm.JvmGcMonitorService;
|
||||||
import org.elasticsearch.monitor.jvm.JvmService;
|
import org.elasticsearch.monitor.jvm.JvmService;
|
||||||
import org.elasticsearch.monitor.os.OsService;
|
import org.elasticsearch.monitor.os.OsService;
|
||||||
import org.elasticsearch.monitor.process.ProcessService;
|
import org.elasticsearch.monitor.process.ProcessService;
|
||||||
@ -325,6 +326,9 @@ public final class ClusterSettings extends AbstractScopedSettings {
|
|||||||
OsService.REFRESH_INTERVAL_SETTING,
|
OsService.REFRESH_INTERVAL_SETTING,
|
||||||
ProcessService.REFRESH_INTERVAL_SETTING,
|
ProcessService.REFRESH_INTERVAL_SETTING,
|
||||||
JvmService.REFRESH_INTERVAL_SETTING,
|
JvmService.REFRESH_INTERVAL_SETTING,
|
||||||
FsService.REFRESH_INTERVAL_SETTING
|
FsService.REFRESH_INTERVAL_SETTING,
|
||||||
|
JvmGcMonitorService.ENABLED_SETTING,
|
||||||
|
JvmGcMonitorService.REFRESH_INTERVAL_SETTING,
|
||||||
|
JvmGcMonitorService.GC_SETTING
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
|||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.env.NodeEnvironment;
|
import org.elasticsearch.env.NodeEnvironment;
|
||||||
import org.elasticsearch.monitor.fs.FsService;
|
import org.elasticsearch.monitor.fs.FsService;
|
||||||
import org.elasticsearch.monitor.jvm.JvmMonitorService;
|
import org.elasticsearch.monitor.jvm.JvmGcMonitorService;
|
||||||
import org.elasticsearch.monitor.jvm.JvmService;
|
import org.elasticsearch.monitor.jvm.JvmService;
|
||||||
import org.elasticsearch.monitor.os.OsService;
|
import org.elasticsearch.monitor.os.OsService;
|
||||||
import org.elasticsearch.monitor.process.ProcessService;
|
import org.elasticsearch.monitor.process.ProcessService;
|
||||||
@ -36,7 +36,7 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class MonitorService extends AbstractLifecycleComponent<MonitorService> {
|
public class MonitorService extends AbstractLifecycleComponent<MonitorService> {
|
||||||
|
|
||||||
private final JvmMonitorService jvmMonitorService;
|
private final JvmGcMonitorService jvmGcMonitorService;
|
||||||
|
|
||||||
private final OsService osService;
|
private final OsService osService;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class MonitorService extends AbstractLifecycleComponent<MonitorService> {
|
|||||||
|
|
||||||
public MonitorService(Settings settings, NodeEnvironment nodeEnvironment, ThreadPool threadPool) throws IOException {
|
public MonitorService(Settings settings, NodeEnvironment nodeEnvironment, ThreadPool threadPool) throws IOException {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.jvmMonitorService = new JvmMonitorService(settings, threadPool);
|
this.jvmGcMonitorService = new JvmGcMonitorService(settings, threadPool);
|
||||||
this.osService = new OsService(settings);
|
this.osService = new OsService(settings);
|
||||||
this.processService = new ProcessService(settings);
|
this.processService = new ProcessService(settings);
|
||||||
this.jvmService = new JvmService(settings);
|
this.jvmService = new JvmService(settings);
|
||||||
@ -73,16 +73,16 @@ public class MonitorService extends AbstractLifecycleComponent<MonitorService> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() {
|
protected void doStart() {
|
||||||
jvmMonitorService.start();
|
jvmGcMonitorService.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doStop() {
|
protected void doStop() {
|
||||||
jvmMonitorService.stop();
|
jvmGcMonitorService.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doClose() {
|
protected void doClose() {
|
||||||
jvmMonitorService.close();
|
jvmGcMonitorService.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
package org.elasticsearch.monitor.jvm;
|
package org.elasticsearch.monitor.jvm;
|
||||||
|
|
||||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||||
|
import org.elasticsearch.common.settings.Setting;
|
||||||
|
import org.elasticsearch.common.settings.Setting.Scope;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.util.concurrent.FutureUtils;
|
import org.elasticsearch.common.util.concurrent.FutureUtils;
|
||||||
@ -31,13 +33,12 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
|
|
||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
|
|
||||||
import static org.elasticsearch.monitor.jvm.JvmStats.jvmStats;
|
import static org.elasticsearch.monitor.jvm.JvmStats.jvmStats;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class JvmMonitorService extends AbstractLifecycleComponent<JvmMonitorService> {
|
public class JvmGcMonitorService extends AbstractLifecycleComponent<JvmGcMonitorService> {
|
||||||
|
|
||||||
private final ThreadPool threadPool;
|
private final ThreadPool threadPool;
|
||||||
private final boolean enabled;
|
private final boolean enabled;
|
||||||
@ -46,6 +47,11 @@ public class JvmMonitorService extends AbstractLifecycleComponent<JvmMonitorServ
|
|||||||
|
|
||||||
private volatile ScheduledFuture scheduledFuture;
|
private volatile ScheduledFuture scheduledFuture;
|
||||||
|
|
||||||
|
public final static Setting<Boolean> ENABLED_SETTING = Setting.boolSetting("monitor.jvm.gc.enabled", true, false, Scope.CLUSTER);
|
||||||
|
public final static Setting<TimeValue> REFRESH_INTERVAL_SETTING =
|
||||||
|
Setting.timeSetting("monitor.jvm.gc.refresh_interval", TimeValue.timeValueSeconds(1), TimeValue.timeValueSeconds(1), false, Scope.CLUSTER);
|
||||||
|
public final static Setting<Settings> GC_SETTING = Setting.groupSetting("monitor.jvm.gc.collector.", false, Scope.CLUSTER);
|
||||||
|
|
||||||
static class GcThreshold {
|
static class GcThreshold {
|
||||||
public final String name;
|
public final String name;
|
||||||
public final long warnThreshold;
|
public final long warnThreshold;
|
||||||
@ -70,15 +76,15 @@ public class JvmMonitorService extends AbstractLifecycleComponent<JvmMonitorServ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JvmMonitorService(Settings settings, ThreadPool threadPool) {
|
public JvmGcMonitorService(Settings settings, ThreadPool threadPool) {
|
||||||
super(settings);
|
super(settings);
|
||||||
this.threadPool = threadPool;
|
this.threadPool = threadPool;
|
||||||
|
|
||||||
this.enabled = this.settings.getAsBoolean("monitor.jvm.enabled", true);
|
this.enabled = ENABLED_SETTING.get(settings);
|
||||||
this.interval = this.settings.getAsTime("monitor.jvm.interval", timeValueSeconds(1));
|
this.interval = REFRESH_INTERVAL_SETTING.get(settings);
|
||||||
|
|
||||||
Map<String, GcThreshold> gcThresholds = new HashMap<>();
|
Map<String, GcThreshold> gcThresholds = new HashMap<>();
|
||||||
Map<String, Settings> gcThresholdGroups = this.settings.getGroups("monitor.jvm.gc");
|
Map<String, Settings> gcThresholdGroups = GC_SETTING.get(settings).getAsGroups();
|
||||||
for (Map.Entry<String, Settings> entry : gcThresholdGroups.entrySet()) {
|
for (Map.Entry<String, Settings> entry : gcThresholdGroups.entrySet()) {
|
||||||
String name = entry.getKey();
|
String name = entry.getKey();
|
||||||
TimeValue warn = entry.getValue().getAsTime("warn", null);
|
TimeValue warn = entry.getValue().getAsTime("warn", null);
|
Loading…
x
Reference in New Issue
Block a user