Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-2938 : Warn when multiple references to OperatingSystem/SystemCpuLoad (Payara 4.x) #3283

Merged
merged 1 commit into from Oct 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -58,6 +58,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.xml.bind.JAXB;
Expand All @@ -82,6 +83,8 @@
@RunLevel(StartupRunLevel.VAL)
public class MetricsService implements EventListener {

private static final Logger LOGGER = Logger.getLogger(MetricsService.class.getName());

@Inject
Events events;

Expand Down Expand Up @@ -120,10 +123,32 @@ public void init() {
@Override
public void run() {
MBeanMetadataConfig metadataConfig = getConfig();
checkSystemCpuLoadIssue(metadataConfig);// PAYARA 2938
initMetadataConfig(metadataConfig.getBaseMetadata(), metadataConfig.getVendorMetadata(), false);
}
});

}
}

private void checkSystemCpuLoadIssue(MBeanMetadataConfig metadataConfig) {
// Could be constant but placed it in method as it is a workaround until fixed in JVM.
// TODO Make this check dependent on the JDK version (as it hopefully will get solved in the future) -> Azul fix request made?
String mbeanSystemCPULoad = "java.lang:type=OperatingSystem/SystemCpuLoad";

long count = 0;
for (MBeanMetadata metadata : metadataConfig.getBaseMetadata()) {
if (mbeanSystemCPULoad.equals(metadata.getMBean())) {
count++;
}
}
for (MBeanMetadata metadata : metadataConfig.getVendorMetadata()) {
if (mbeanSystemCPULoad.equals(metadata.getMBean())) {
count++;
}
}
if (count > 1) {

LOGGER.warning(String.format("Referencing the MBean value %s multiple times possibly leads to inconsistent values for the MBean value.", mbeanSystemCPULoad));
}
}

Expand Down