增强线程池监控功能.

pull/39/head
chen.ma 3 years ago
parent a302e5a2ac
commit 4cd8db3eaa

@ -34,6 +34,23 @@ public interface HisRunDataMapper extends BaseMapper<HisRunDataInfo> {
"limit 8")
List<ThreadPoolTaskRanking> queryThreadPoolTaskSumRanking(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
/**
* Query thread pool task sum ranking.
*
* @param startTime
* @param endTime
* @return
*/
@Select("SELECT " +
"tenant_id, item_id, tp_id, max(queue_size) as max_queue_size, max(reject_count) as max_reject_count, max(completed_task_count) as max_completed_task_count " +
"FROM his_run_data " +
"where timestamp between #{startTime} and #{endTime} " +
"group by tenant_id, item_id, tp_id " +
"order by max_completed_task_count desc " +
"limit 4")
List<ThreadPoolTaskRanking> queryThreadPoolMaxRanking(@Param("startTime") Long startTime, @Param("endTime") Long endTime);
@Data
class ThreadPoolTaskRanking {
@ -57,5 +74,15 @@ public interface HisRunDataMapper extends BaseMapper<HisRunDataInfo> {
*/
private Long maxCompletedTaskCount;
/**
*
*/
private Long maxQueueSize;
/**
*
*/
private Long maxRejectCount;
}
}

@ -28,4 +28,9 @@ public class ChartInfo {
*/
private Integer threadPoolCount;
/**
* 线
*/
private Integer threadPoolInstanceCount;
}

@ -18,13 +18,23 @@ import java.util.List;
public class LineChartInfo {
/**
* completedTaskCounts
* oneList
*/
private List<Long> completedTaskCounts;
private List<Object> oneList;
/**
* rejectCounts
* twoList
*/
private List<Long> rejectCounts;
private List<Object> twoList;
/**
* threeList
*/
private List<Object> threeList;
/**
* fourList
*/
private List<Object> fourList;
}

@ -24,6 +24,7 @@ import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -62,19 +63,34 @@ public class DashboardServiceImpl implements DashboardService {
ChartInfo chartInfo = new ChartInfo();
chartInfo.setTenantCount(tenantCount)
.setItemCount(itemCount)
.setThreadPoolCount(threadPoolCount);
.setThreadPoolCount(threadPoolCount)
.setThreadPoolInstanceCount(ConfigCacheService.getTotal());
return chartInfo;
}
@Override
public LineChartInfo getLineChatInfo() {
Date currentDate = new Date();
DateTime sixtyTime = DateUtil.offsetMinute(currentDate, -60);
List<Long> completedTaskCounts = Lists.newArrayList(2000L, 2345L, 5676L, 2357L, 1111L, 11193L);
List<Long> rejectCounts = Lists.newArrayList(1000L, 1345L, 2676L, 1357L, 111L, 11193L);
DateTime startTime = DateUtil.offsetMinute(currentDate, -10);
List<HisRunDataMapper.ThreadPoolTaskRanking> threadPoolTaskRankings = hisRunDataMapper.queryThreadPoolMaxRanking(startTime.getTime(), currentDate.getTime());
List<Object> oneList = Lists.newArrayList();
List<Object> twoList = Lists.newArrayList();
List<Object> threeList = Lists.newArrayList();
List<Object> fourList = Lists.newArrayList();
ArrayList<List<Object>> lists = Lists.newArrayList(oneList, twoList, threeList, fourList);
for (int i = 0; i < threadPoolTaskRankings.size(); i++) {
List<Object> eachList = lists.get(i);
HisRunDataMapper.ThreadPoolTaskRanking taskRanking = threadPoolTaskRankings.get(i);
eachList.add(taskRanking.getTpId());
eachList.add(taskRanking.getMaxQueueSize());
eachList.add(taskRanking.getMaxRejectCount());
eachList.add(taskRanking.getMaxCompletedTaskCount());
}
return new LineChartInfo(completedTaskCounts, rejectCounts);
return new LineChartInfo(oneList, twoList, threeList, fourList);
}
@Override
@ -150,14 +166,14 @@ public class DashboardServiceImpl implements DashboardService {
Lease<InstanceInfo> first = CollUtil.getFirst(leases);
if (first == null) {
rankingChartInfo.setInst(0);
} else {
InstanceInfo holder = first.getHolder();
String itemTenantKey = holder.getGroupKey();
String groupKey = getGroupKey(each.getTpId(), itemTenantKey);
Map<String, CacheItem> content = ConfigCacheService.getContent(groupKey);
rankingChartInfo.setInst(content.keySet().size());
}
InstanceInfo holder = first.getHolder();
String itemTenantKey = holder.getGroupKey();
String groupKey = getGroupKey(each.getTpId(), itemTenantKey);
Map<String, CacheItem> content = ConfigCacheService.getContent(groupKey);
rankingChartInfo.setInst(content.keySet().size());
String keyTenant = GroupKey.getKeyTenant(each.getTenantId(), each.getItemId(), each.getTpId());
rankingChartInfo.setGroupKey(keyTenant);

Loading…
Cancel
Save