Skip to content

Commit

Permalink
监控数据查询页面 增加JVM指标展示
Browse files Browse the repository at this point in the history
  • Loading branch information
qq254963746 committed Mar 13, 2016
1 parent a7ba66e commit bf24bc0
Show file tree
Hide file tree
Showing 24 changed files with 584 additions and 58 deletions.
98 changes: 85 additions & 13 deletions lts-admin/src/main/java/com/lts/admin/access/RshHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import com.lts.admin.web.vo.NodeInfo;
import com.lts.core.cluster.Node;
import com.lts.core.cluster.NodeType;
import com.lts.monitor.access.domain.JobClientMDataPo;
import com.lts.monitor.access.domain.JobTrackerMDataPo;
import com.lts.monitor.access.domain.TaskTrackerMDataPo;
import com.lts.monitor.access.domain.*;
import com.lts.store.jdbc.dbutils.JdbcTypeUtils;
import com.lts.store.jdbc.dbutils.ResultSetHandler;

Expand Down Expand Up @@ -103,12 +101,7 @@ public List<TaskTrackerMDataPo> handle(ResultSet rs) throws SQLException {

while (rs.next()) {
TaskTrackerMDataPo po = new TaskTrackerMDataPo();
// po.setId(rs.getString("id"));
// po.setGmtCreated(rs.getLong("gmt_created"));
po.setTimestamp(rs.getLong("timestamp"));
// po.setNodeType(NodeType.convert(rs.getString("node_type")));
// po.setNodeGroup(rs.getString("node_group"));
// po.setIdentity(rs.getString("identity"));

po.setExeSuccessNum(rs.getLong("exe_success_num"));
po.setExeFailedNum(rs.getLong("exe_failed_num"));
Expand All @@ -129,12 +122,7 @@ public List<JobClientMDataPo> handle(ResultSet rs) throws SQLException {

while (rs.next()) {
JobClientMDataPo po = new JobClientMDataPo();
// po.setId(rs.getString("id"));
// po.setGmtCreated(rs.getLong("gmt_created"));
po.setTimestamp(rs.getLong("timestamp"));
// po.setNodeType(NodeType.convert(rs.getString("node_type")));
// po.setNodeGroup(rs.getString("node_group"));
// po.setIdentity(rs.getString("identity"));

po.setSubmitSuccessNum(rs.getLong("submit_success_num"));
po.setSubmitFailedNum(rs.getLong("submit_failed_num"));
Expand All @@ -161,4 +149,88 @@ public List<NodeInfo> handle(ResultSet rs) throws SQLException {
return list;
}
};

public static final ResultSetHandler<List<JVMMemoryDataPo>> JVM_MEMORY_SUM_M_DATA_RSH = new ResultSetHandler<List<JVMMemoryDataPo>>() {
@Override
public List<JVMMemoryDataPo> handle(ResultSet rs) throws SQLException {
List<JVMMemoryDataPo> list = new ArrayList<JVMMemoryDataPo>();

while (rs.next()) {
JVMMemoryDataPo po = new JVMMemoryDataPo();
po.setTimestamp(rs.getLong("timestamp"));

po.setHeapMemoryCommitted(rs.getLong("heap_memory_committed"));
po.setHeapMemoryInit(rs.getLong("heap_memory_init"));
po.setHeapMemoryMax(rs.getLong("heap_memory_max"));
po.setHeapMemoryUsed(rs.getLong("heap_memory_used"));
po.setNonHeapMemoryCommitted(rs.getLong("non_heap_memory_committed"));
po.setNonHeapMemoryInit(rs.getLong("non_heap_memory_init"));
po.setNonHeapMemoryMax(rs.getLong("non_heap_memory_max"));
po.setNonHeapMemoryUsed(rs.getLong("non_heap_memory_used"));
po.setPermGenCommitted(rs.getLong("perm_gen_committed"));
po.setPermGenInit(rs.getLong("perm_gen_init"));
po.setPermGenMax(rs.getLong("perm_gen_max"));
po.setPermGenUsed(rs.getLong("perm_gen_used"));
po.setOldGenCommitted(rs.getLong("old_gen_committed"));
po.setOldGenInit(rs.getLong("old_gen_init"));
po.setOldGenMax(rs.getLong("old_gen_max"));
po.setOldGenUsed(rs.getLong("old_gen_used"));
po.setEdenSpaceCommitted(rs.getLong("eden_space_committed"));
po.setEdenSpaceInit(rs.getLong("eden_space_init"));
po.setEdenSpaceMax(rs.getLong("eden_space_max"));
po.setEdenSpaceUsed(rs.getLong("eden_space_used"));
po.setSurvivorCommitted(rs.getLong("survivor_committed"));
po.setSurvivorInit(rs.getLong("survivor_init"));
po.setSurvivorMax(rs.getLong("survivor_max"));
po.setSurvivorUsed(rs.getLong("survivor_used"));

list.add(po);
}
return list;
}
};

public static final ResultSetHandler<List<JVMGCDataPo>> JVM_GC_SUM_M_DATA_RSH = new ResultSetHandler<List<JVMGCDataPo>>() {
@Override
public List<JVMGCDataPo> handle(ResultSet rs) throws SQLException {
List<JVMGCDataPo> list = new ArrayList<JVMGCDataPo>();

while (rs.next()) {
JVMGCDataPo po = new JVMGCDataPo();
po.setTimestamp(rs.getLong("timestamp"));

po.setYoungGCCollectionCount(rs.getLong("young_gc_collection_count"));
po.setYoungGCCollectionTime(rs.getLong("young_gc_collection_time"));
po.setFullGCCollectionCount(rs.getLong("full_gc_collection_count"));
po.setFullGCCollectionTime(rs.getLong("full_gc_collection_time"));
po.setSpanYoungGCCollectionCount(rs.getLong("span_young_gc_collection_count"));
po.setSpanYoungGCCollectionTime(rs.getLong("span_young_gc_collection_time"));
po.setSpanFullGCCollectionCount(rs.getLong("span_full_gc_collection_count"));
po.setSpanFullGCCollectionTime(rs.getLong("span_full_gc_collection_time"));

list.add(po);
}
return list;
}
};

public static final ResultSetHandler<List<JVMThreadDataPo>> JVM_THREAD_SUM_M_DATA_RSH = new ResultSetHandler<List<JVMThreadDataPo>>() {
@Override
public List<JVMThreadDataPo> handle(ResultSet rs) throws SQLException {
List<JVMThreadDataPo> list = new ArrayList<JVMThreadDataPo>();

while (rs.next()) {
JVMThreadDataPo po = new JVMThreadDataPo();
po.setTimestamp(rs.getLong("timestamp"));

po.setDaemonThreadCount(rs.getInt("daemon_thread_count"));
po.setThreadCount(rs.getInt("thread_count"));
po.setTotalStartedThreadCount(rs.getLong("total_started_thread_count"));
po.setDeadLockedThreadCount(rs.getInt("dead_locked_thread_count"));
po.setProcessCpuTimeRate(rs.getDouble("process_cpu_time_rate"));
list.add(po);
}
return list;
}
};
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.lts.admin.access.face;

import com.lts.admin.request.JvmDataReq;
import com.lts.admin.request.MDataPaginationReq;
import com.lts.monitor.access.domain.JVMGCDataPo;
import com.lts.monitor.access.face.JVMGCAccess;

import java.util.List;

/**
* @author Robert HG ([email protected]) on 9/28/15.
*/
public interface BackendJVMGCAccess extends JVMGCAccess{
public interface BackendJVMGCAccess extends JVMGCAccess {

void delete(JvmDataReq request);

List<JVMGCDataPo> queryAvg(MDataPaginationReq request);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.lts.admin.access.face;

import com.lts.admin.request.JvmDataReq;
import com.lts.admin.request.MDataPaginationReq;
import com.lts.monitor.access.domain.JVMMemoryDataPo;
import com.lts.monitor.access.face.JVMMemoryAccess;

import java.util.List;

/**
* @author Robert HG ([email protected]) on 9/28/15.
*/
public interface BackendJVMMemoryAccess extends JVMMemoryAccess{

void delete(JvmDataReq request);

List<JVMMemoryDataPo> queryAvg(MDataPaginationReq request);
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.lts.admin.access.face;

import com.lts.admin.request.JvmDataReq;
import com.lts.admin.request.MDataPaginationReq;
import com.lts.monitor.access.domain.JVMThreadDataPo;
import com.lts.monitor.access.face.JVMThreadAccess;

import java.util.List;

/**
* @author Robert HG ([email protected]) on 9/28/15.
*/
public interface BackendJVMThreadAccess extends JVMThreadAccess {

void delete(JvmDataReq request);

List<JVMThreadDataPo> queryAvg(MDataPaginationReq request);

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.lts.admin.access.mysql;

import com.lts.admin.access.RshHandler;
import com.lts.admin.access.face.BackendJVMGCAccess;
import com.lts.admin.request.JvmDataReq;
import com.lts.admin.request.MDataPaginationReq;
import com.lts.core.cluster.Config;
import com.lts.monitor.access.domain.JVMGCDataPo;
import com.lts.monitor.access.mysql.MysqlJVMGCAccess;
import com.lts.store.jdbc.builder.DeleteSql;
import com.lts.store.jdbc.builder.SelectSql;
import com.lts.store.jdbc.builder.WhereSql;

import java.util.List;

/**
* @author Robert HG ([email protected]) on 3/10/16.
*/
Expand All @@ -26,10 +32,39 @@ public void delete(JvmDataReq request) {
.doDelete();
}

@Override
public List<JVMGCDataPo> queryAvg(MDataPaginationReq request) {
return new SelectSql(getSqlTemplate())
.select()
.columns("timestamp",
"AVG(young_gc_collection_count) AS young_gc_collection_count",
"AVG(young_gc_collection_time) AS young_gc_collection_time",
"AVG(full_gc_collection_count) AS full_gc_collection_count",
"AVG(full_gc_collection_time) AS full_gc_collection_time",
"AVG(span_young_gc_collection_count) AS span_young_gc_collection_count",
"AVG(span_young_gc_collection_time) AS span_young_gc_collection_time",
"AVG(span_full_gc_collection_count) span_full_gc_collection_count",
"AVG(span_full_gc_collection_time) span_full_gc_collection_time")
.from()
.table(getTableName())
.whereSql(buildWhereSql(request))
.groupBy(" timestamp ASC ")
.limit(request.getStart(), request.getLimit())
.list(RshHandler.JVM_GC_SUM_M_DATA_RSH);
}

public WhereSql buildWhereSql(JvmDataReq req) {
return new WhereSql()
.andOnNotEmpty("identity = ?", req.getIdentity())
.andBetween("timestamp", req.getStartTime(), req.getEndTime());

}

public WhereSql buildWhereSql(MDataPaginationReq request) {
return new WhereSql()
.andOnNotNull("id = ?", request.getId())
.andOnNotEmpty("identity = ?", request.getIdentity())
.andOnNotEmpty("node_group = ?", request.getNodeGroup())
.andBetween("timestamp", request.getStartTime(), request.getEndTime());
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.lts.admin.access.mysql;

import com.lts.admin.access.RshHandler;
import com.lts.admin.access.face.BackendJVMMemoryAccess;
import com.lts.admin.request.JvmDataReq;
import com.lts.admin.request.MDataPaginationReq;
import com.lts.core.cluster.Config;
import com.lts.monitor.access.domain.JVMMemoryDataPo;
import com.lts.monitor.access.mysql.MysqlJVMMemoryAccess;
import com.lts.store.jdbc.builder.DeleteSql;
import com.lts.store.jdbc.builder.SelectSql;
import com.lts.store.jdbc.builder.WhereSql;

import java.util.List;

/**
* @author Robert HG ([email protected]) on 3/9/16.
*/
Expand All @@ -26,10 +32,55 @@ public void delete(JvmDataReq request) {
.doDelete();
}

@Override
public List<JVMMemoryDataPo> queryAvg(MDataPaginationReq request) {
return new SelectSql(getSqlTemplate())
.select()
.columns("timestamp",
"AVG(heap_memory_committed) AS heap_memory_committed",
"AVG(heap_memory_init) AS heap_memory_init",
"AVG(heap_memory_max) AS heap_memory_max",
"AVG(heap_memory_used) AS heap_memory_used",
"AVG(non_heap_memory_committed) AS non_heap_memory_committed",
"AVG(non_heap_memory_init) AS non_heap_memory_init",
"AVG(non_heap_memory_max) AS non_heap_memory_max",
"AVG(non_heap_memory_used) AS non_heap_memory_used",
"AVG(perm_gen_committed) AS perm_gen_committed",
"AVG(perm_gen_init) AS perm_gen_init",
"AVG(perm_gen_max) AS perm_gen_max",
"AVG(perm_gen_used) AS perm_gen_used",
"AVG(old_gen_committed) AS old_gen_committed",
"AVG(old_gen_init) AS old_gen_init",
"AVG(old_gen_max) AS old_gen_max",
"AVG(old_gen_used) AS old_gen_used",
"AVG(eden_space_committed) AS eden_space_committed",
"AVG(eden_space_init) AS eden_space_init",
"AVG(eden_space_max) AS eden_space_max",
"AVG(eden_space_used) AS eden_space_used",
"AVG(survivor_committed) AS survivor_committed",
"AVG(survivor_init) AS survivor_init",
"AVG(survivor_max) AS survivor_max",
"AVG(survivor_used) AS survivor_used")
.from()
.table(getTableName())
.whereSql(buildWhereSql(request))
.groupBy(" timestamp ASC ")
.limit(request.getStart(), request.getLimit())
.list(RshHandler.JVM_MEMORY_SUM_M_DATA_RSH);
}

public WhereSql buildWhereSql(JvmDataReq req) {
return new WhereSql()
.andOnNotEmpty("identity = ?", req.getIdentity())
.andBetween("timestamp", req.getStartTime(), req.getEndTime());

}

public WhereSql buildWhereSql(MDataPaginationReq request) {
return new WhereSql()
.andOnNotNull("id = ?", request.getId())
.andOnNotEmpty("identity = ?", request.getIdentity())
.andOnNotEmpty("node_group = ?", request.getNodeGroup())
.andBetween("timestamp", request.getStartTime(), request.getEndTime());
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package com.lts.admin.access.mysql;

import com.lts.admin.access.RshHandler;
import com.lts.admin.access.face.BackendJVMThreadAccess;
import com.lts.admin.request.JvmDataReq;
import com.lts.admin.request.MDataPaginationReq;
import com.lts.core.cluster.Config;
import com.lts.monitor.access.domain.JVMThreadDataPo;
import com.lts.monitor.access.mysql.MysqlJVMThreadAccess;
import com.lts.store.jdbc.builder.DeleteSql;
import com.lts.store.jdbc.builder.SelectSql;
import com.lts.store.jdbc.builder.WhereSql;

import java.util.List;

/**
* @author Robert HG ([email protected]) on 3/9/16.
*/
Expand All @@ -26,10 +32,36 @@ public void delete(JvmDataReq request) {
.doDelete();
}

@Override
public List<JVMThreadDataPo> queryAvg(MDataPaginationReq request) {
return new SelectSql(getSqlTemplate())
.select()
.columns("timestamp",
"AVG(daemon_thread_count) AS daemon_thread_count",
"AVG(thread_count) AS thread_count",
"AVG(total_started_thread_count) AS total_started_thread_count",
"AVG(dead_locked_thread_count) AS dead_locked_thread_count",
"AVG(process_cpu_time_rate) AS process_cpu_time_rate")
.from()
.table(getTableName())
.whereSql(buildWhereSql(request))
.groupBy(" timestamp ASC ")
.limit(request.getStart(), request.getLimit())
.list(RshHandler.JVM_THREAD_SUM_M_DATA_RSH);
}

public WhereSql buildWhereSql(JvmDataReq req) {
return new WhereSql()
.andOnNotEmpty("identity = ?", req.getIdentity())
.andBetween("timestamp", req.getStartTime(), req.getEndTime());

}

public WhereSql buildWhereSql(MDataPaginationReq request) {
return new WhereSql()
.andOnNotNull("id = ?", request.getId())
.andOnNotEmpty("identity = ?", request.getIdentity())
.andOnNotEmpty("node_group = ?", request.getNodeGroup())
.andBetween("timestamp", request.getStartTime(), request.getEndTime());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
/**
* Robert HG ([email protected]) on 6/5/15.
*/
public class BackendRegistryService implements InitializingBean {
public class BackendRegistrySrv implements InitializingBean {

private static final Logger LOGGER = LoggerFactory.getLogger(BackendRegistryService.class);
private static final Logger LOGGER = LoggerFactory.getLogger(BackendRegistrySrv.class);
@Autowired
private BackendAppContext appContext;
private Registry registry;
Expand Down
12 changes: 12 additions & 0 deletions lts-admin/src/main/java/com/lts/admin/request/JVMType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.lts.admin.request;

/**
* Created by hugui.hg on 3/13/16.
*/
public enum JVMType {

GC,
MEMORY,
THREAD

}
Loading

0 comments on commit bf24bc0

Please sign in to comment.