Skip to content

Commit

Permalink
Merge pull request #33 from qunarcorp/dev
Browse files Browse the repository at this point in the history
bug fix
  • Loading branch information
xleiy authored Aug 30, 2019
2 parents de2e108 + 225198d commit a386374
Show file tree
Hide file tree
Showing 34 changed files with 149 additions and 59 deletions.
2 changes: 1 addition & 1 deletion bistoury-agent-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static List<PidHandler> initPidHandler() {
Collections.sort(handlers, new Comparator<PidHandler>() {
@Override
public int compare(PidHandler o1, PidHandler o2) {
return o1.priority() - o2.priority();
return Integer.compare(o1.priority(), o2.priority());
}
});
return ImmutableList.copyOf(handlers);
Expand Down
2 changes: 1 addition & 1 deletion bistoury-agent-task/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-application/bistoury-application-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury-application</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-application/bistoury-application-mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury-application</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-attach-arthas/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-attach-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-clientside-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-commands/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public class HostTask implements Task {

private final ResponseHandler handler;
private final long maxRunningMs;
private VirtualMachineUtil.VMConnector connect;

private volatile VirtualMachineUtil.VMConnector connect;
private Map<String, Counter> counters;
private RuntimeMXBean runtimeBean;
private OperatingSystemMXBean osBean;
Expand All @@ -75,26 +76,20 @@ public HostTask(String id, int pid, ResponseHandler handler, long maxRunningMs)
this.pid = pid;
this.handler = handler;
this.maxRunningMs = maxRunningMs;
connect = VirtualMachineUtil.connect(pid);
init();
}

private void init() {
try {
PerfData prefData = PerfData.connect(pid);
counters = prefData.getAllCounters();

this.runtimeBean = connect.getRuntimeMXBean();
this.osBean = connect.getOperatingSystemMXBean();
this.memoryMXBean = connect.getMemoryMXBean();
this.threadBean = connect.getThreadMXBean();
this.classLoadingBean = connect.getClassLoadingMXBean();
this.gcMxBeans = connect.getGarbageCollectorMXBeans();
this.memoryPoolMXBeans = connect.getMemoryPoolMXBeans();
} catch (Exception e) {
logger.error("get MXBean error ", e);
throw new RuntimeException(e);
}
private void init() throws Exception {
connect = VirtualMachineUtil.connect(pid);
PerfData prefData = PerfData.connect(pid);
counters = prefData.getAllCounters();

this.runtimeBean = connect.getRuntimeMXBean();
this.osBean = connect.getOperatingSystemMXBean();
this.memoryMXBean = connect.getMemoryMXBean();
this.threadBean = connect.getThreadMXBean();
this.classLoadingBean = connect.getClassLoadingMXBean();
this.gcMxBeans = connect.getGarbageCollectorMXBeans();
this.memoryPoolMXBeans = connect.getMemoryPoolMXBeans();
}

@Override
Expand All @@ -112,16 +107,20 @@ public ListenableFuture<Integer> execute() {
this.future = agentExecutor.submit(new Callable<Integer>() {
@Override
public Integer call() throws Exception {

Map<String, Object> result = new HashMap<>();
try {
init();
Map<String, Object> result = new HashMap<>();
result.put("type", "hostInfo");
result.put("jvm", getJvmInfo());
result.put("host", getHostInfo());
result.put("memPool", getMemoryPoolMXBeansInfo());
result.put("visuaGC", getVisuaGCInfo());
String jsonString = JacksonSerializer.serialize(result);
handler.handle(jsonString);
return null;
} catch (Exception e) {
logger.error("get MXBean error", e);
throw new RuntimeException(e);
} finally {
try {
if (connect != null) {
Expand All @@ -131,7 +130,6 @@ public Integer call() throws Exception {
logger.error("disconnect vm error ", e);
}
}
return null;
}
});
return future;
Expand Down Expand Up @@ -371,14 +369,22 @@ private void getDiskInfo(HostInfo hostInfo) {
@Override
public void cancel() {
try {
connect.disconnect();
if (future != null) {
future.cancel(true);
future = null;
}
} catch (Exception e) {
logger.error("destroy host task error", e);
}

try {
VirtualMachineUtil.VMConnector connect = this.connect;
if (connect != null) {
connect.disconnect();
}
} catch (Exception e) {
logger.error("destroy host task error", e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class ThreadInfoTask implements Task {

private volatile ListenableFuture<Integer> future;

private VirtualMachineUtil.VMConnector connect;
private volatile VirtualMachineUtil.VMConnector connect;

public ThreadInfoTask(String id, int pid, long threadId, int commandType, int maxDepth, ResponseHandler handler, long maxRunningMs) {
this.id = id;
Expand All @@ -81,7 +81,6 @@ public ThreadInfoTask(String id, int pid, long threadId, int commandType, int ma
this.maxDepth = maxDepth;
this.handler = handler;
this.maxRunningMs = maxRunningMs;
connect = VirtualMachineUtil.connect(pid);
}


Expand All @@ -91,6 +90,7 @@ public ListenableFuture<Integer> execute() {
@Override
public Integer call() throws Exception {
try {
connect = VirtualMachineUtil.connect(pid);
Map<String, Object> result = new HashMap<>();
if (ALL_THREADS_INFO == commandType) {
result.put(TYPE, "allThreadInfo");
Expand All @@ -110,9 +110,10 @@ public Integer call() throws Exception {
result.put(THREADS, threads);
}
handler.handle(JacksonSerializer.serializeToBytes(result));
return null;
} catch (Exception e) {
logger.error("get thread info error", e);
return null;
throw new RuntimeException(e);
} finally {
try {
if (connect != null) {
Expand All @@ -122,7 +123,6 @@ public Integer call() throws Exception {
logger.error("disconnect vm error ", e);
}
}
return null;
}
});
return future;
Expand Down Expand Up @@ -204,14 +204,22 @@ public long getMaxRunningMs() {
@Override
public void cancel() {
try {
connect.disconnect();
if (future != null) {
future.cancel(true);
future = null;
}
} catch (Exception e) {
logger.error("cancel host thread info task error", e);
}

try {
VirtualMachineUtil.VMConnector connect = this.connect;
if (connect != null) {
connect.disconnect();
}
} catch (Exception e) {
logger.error("cancel host thread info task error", e);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static String getLocalConnectorAddress(VirtualMachine vm) throws IOExcep
}

static class VMConnector {
private JMXConnector connector;
private final JMXConnector connector;

VMConnector(JMXConnector connector) {
this.connector = connector;
Expand Down
2 changes: 1 addition & 1 deletion bistoury-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class BistouryConstants {
public static final String SPY_CLASSNAME = "qunar.tc.bistoury.instrument.spy.BistourySpys1";

// todo: 先这么写吧
public static final String CURRENT_VERSION = "2.0.3";
public static final String CURRENT_VERSION = "2.0.4";

public static final String BISTOURY_VERSION_LINE_PREFIX = "bistoury version:";

Expand Down
2 changes: 1 addition & 1 deletion bistoury-decompiler-fernflower/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-independent-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-instrument-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-instrument-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-instrument-spy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-magic-classes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-magic-loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-metrics-prometheus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion bistoury-proxy/conf/agent_config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ agent.refresh.interval.min=10
#可选,动态更新,agent将配置推送到应用中的时间间隔,默认1分钟
agent.push.interval.min=1
#可选,动态更新,获取应用配置时排除掉的文件的后缀名,默认 class,vm,css,js,jar
app.config.exclusion.file.suffix=class,vm,css,js,vue,ts,jsp,sql
app.config.exclusion.file.suffix=class,vm,css,js,vue,ts,jsp,sql,jar
#可选,动态更新,获取应用配置时排除掉的文件
app.config.exclusion.file.equal=web.xml
#可选,动态更新,应用运行的tomcat的用户名,[ps aux | grep java] 结果的第1列,默认 tomcat
Expand Down
2 changes: 1 addition & 1 deletion bistoury-proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>bistoury</artifactId>
<groupId>qunar.tc.bistoury</groupId>
<version>2.0.3</version>
<version>2.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading

0 comments on commit a386374

Please sign in to comment.