use of com.creditease.agent.helpers.jvmtool.JVMPropertyFilter in project uavstack by uavorg.
the class JVMLocalOSDetector method run.
@Override
public void run() {
/**
* step 1: build the skip local attach support set which contains those jvm with management.jar attached
*/
Set<String> skipLocalAttachSupportSet = new HashSet<String>();
for (JVMAgentInfo agentInfo : jvmAgentInfos.values()) {
skipLocalAttachSupportSet.add(agentInfo.getId());
}
/**
* step 2: scan out all java processes
*/
List<JVMAgentInfo> appServerJVMInfos = JVMToolHelper.getAllLocalJvmInfo(new JVMPropertyFilter() {
@Override
public boolean isMatchAgentProperties(Properties jvmProperties) {
/**
* exclude all java tools
*/
Enumeration<?> e = jvmProperties.propertyNames();
while (e.hasMoreElements()) {
String key = (String) e.nextElement();
String val = jvmProperties.getProperty(key);
for (String t : excludeJavaProc) {
if (val.indexOf(t) > -1) {
return false;
}
}
}
return true;
}
@Override
public boolean isMatchSystemProperties(Properties systemProperties) {
return true;
}
}, true, skipLocalAttachSupportSet);
if (appServerJVMInfos.isEmpty()) {
return;
}
/**
* step 3: see if need start a new worker to catch data for each JVM
*/
for (JVMAgentInfo appServerInfo : appServerJVMInfos) {
try {
addWorker(appServerInfo);
} catch (Exception e) {
log.err(this, "JVMLocalOSDetector[" + this.cName + "] start worker FAIL: java process id=" + appServerInfo.getId(), e);
}
}
}
Aggregations