Search in sources :

Example 1 with ThreadAnalyser

use of com.creditease.uav.threadanalysis.server.ThreadAnalyser in project uavstack by uavorg.

the class ThreadAnalysisQueryHandler method queryMultiDumpInfo.

private void queryMultiDumpInfo(UAVHttpMessage data) {
    String ipport = data.getRequest("ipport");
    String timesStr = data.getRequest("times");
    List<String> times = JSONHelper.toObjectArray(timesStr, String.class);
    List<List<Map<String, Object>>> records = new ArrayList<>();
    for (String time : times) {
        long timestamp = DataConvertHelper.toLong(time, -1L);
        // build query builder
        BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
        queryBuilder.must(QueryBuilders.rangeQuery("time").gte(timestamp).lte(timestamp));
        queryBuilder.must(QueryBuilders.termQuery("ipport", ipport));
        SearchResponse sr = query(data, queryBuilder, null, buildSorts(data));
        List<Map<String, Object>> record = getRecords(sr);
        records.add(record);
    }
    ThreadAnalyser ta = (ThreadAnalyser) getConfigManager().getComponent(feature, "ThreadAnalyser");
    List<Map<String, String>> rs = ta.queryMutilDumpInfo(times, records);
    data.putResponse("rs", JSONHelper.toString(rs));
}
Also used : ArrayList(java.util.ArrayList) SearchResponse(org.elasticsearch.action.search.SearchResponse) BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) ThreadAnalyser(com.creditease.uav.threadanalysis.server.ThreadAnalyser) ArrayList(java.util.ArrayList) List(java.util.List) ThreadObject(com.creditease.uav.threadanalysis.server.da.ThreadObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ThreadAnalyser

use of com.creditease.uav.threadanalysis.server.ThreadAnalyser in project uavstack by uavorg.

the class ThreadAnalysisQueryHandler method queryMultiDumpGraph.

private void queryMultiDumpGraph(UAVHttpMessage data) {
    String ipport = data.getRequest("ipport");
    String timesStr = data.getRequest("times");
    String threadIdsStr = data.getRequest("threadIds");
    List<String> times = JSONHelper.toObjectArray(timesStr, String.class);
    List<String> threadIds = JSONHelper.toObjectArray(threadIdsStr, String.class);
    List<List<Map<String, Object>>> records = new ArrayList<>();
    for (String time : times) {
        long timestamp = DataConvertHelper.toLong(time, -1L);
        // build query builder
        BoolQueryBuilder queryBuilder = QueryBuilders.boolQuery();
        queryBuilder.must(QueryBuilders.rangeQuery("time").gte(timestamp).lte(timestamp));
        queryBuilder.must(QueryBuilders.termQuery("ipport", ipport));
        SearchResponse sr = query(data, queryBuilder, null, buildSorts(data));
        List<Map<String, Object>> record = getRecords(sr);
        records.add(record);
    }
    ThreadAnalyser ta = (ThreadAnalyser) getConfigManager().getComponent(feature, "ThreadAnalyser");
    Map<String, Object> rs = ta.queryMutilDumpGraph(threadIds, records);
    data.putResponse("rs", JSONHelper.toString(rs));
}
Also used : ArrayList(java.util.ArrayList) SearchResponse(org.elasticsearch.action.search.SearchResponse) BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) ThreadAnalyser(com.creditease.uav.threadanalysis.server.ThreadAnalyser) ArrayList(java.util.ArrayList) List(java.util.List) ThreadObject(com.creditease.uav.threadanalysis.server.da.ThreadObject) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ThreadAnalyser

use of com.creditease.uav.threadanalysis.server.ThreadAnalyser in project uavstack by uavorg.

the class ThreadAnalysisQueryHandler method queryThreadDigraph.

/**
 * @param data
 * @return {nodes: [{id:0, name:'', type: '', state: ''}], edges: [{from:0, to:1}]}
 */
private void queryThreadDigraph(UAVHttpMessage data) {
    QueryBuilder query = buildQuery(data);
    if (query == null) {
        return;
    }
    SearchResponse sr = query(data, query, null, buildSorts(data));
    List<Map<String, Object>> records = getRecords(sr);
    ThreadAnalyser ta = (ThreadAnalyser) getConfigManager().getComponent(feature, "ThreadAnalyser");
    Map<String, Object> rs = ta.buildThreadDigraph(records);
    data.putResponse("rs", JSONHelper.toString(rs));
}
Also used : ThreadAnalyser(com.creditease.uav.threadanalysis.server.ThreadAnalyser) ThreadObject(com.creditease.uav.threadanalysis.server.da.ThreadObject) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) RangeQueryBuilder(org.elasticsearch.index.query.RangeQueryBuilder) BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) HashMap(java.util.HashMap) Map(java.util.Map) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 4 with ThreadAnalyser

use of com.creditease.uav.threadanalysis.server.ThreadAnalyser in project uavstack by uavorg.

the class ThreadAnalysisQueryHandler method queryDumpInfo.

/**
 * @param data
 * @return josnString: {cpu: '50', threadCount: '123', runnableCount: '23', blockedCount: '34', waitingCount: '45',
 *         deadlock: []}
 */
private void queryDumpInfo(UAVHttpMessage data) {
    QueryBuilder query = buildQuery(data);
    if (query == null) {
        return;
    }
    SearchResponse sr = query(data, query, null, buildSorts(data));
    List<Map<String, Object>> records = getRecords(sr);
    ThreadAnalyser ta = (ThreadAnalyser) getConfigManager().getComponent(feature, "ThreadAnalyser");
    Map<String, Object> map = ta.queryDumpInfo(records);
    data.putResponse("rs", JSONHelper.toString(map));
}
Also used : ThreadAnalyser(com.creditease.uav.threadanalysis.server.ThreadAnalyser) ThreadObject(com.creditease.uav.threadanalysis.server.da.ThreadObject) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) RangeQueryBuilder(org.elasticsearch.index.query.RangeQueryBuilder) BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) HashMap(java.util.HashMap) Map(java.util.Map) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 5 with ThreadAnalyser

use of com.creditease.uav.threadanalysis.server.ThreadAnalyser in project uavstack by uavorg.

the class ThreadAnalysisQueryHandler method queryThreadChain.

/**
 * 查找线程依赖
 *
 * @param data
 */
private void queryThreadChain(UAVHttpMessage data) {
    QueryBuilder query = buildQuery(data);
    if (query == null) {
        return;
    }
    SearchResponse sr = query(data, query, null, buildSorts(data));
    List<Map<String, Object>> records = getRecords(sr);
    String threadId = data.getRequest("threadId");
    ThreadAnalyser ta = (ThreadAnalyser) getConfigManager().getComponent(feature, "ThreadAnalyser");
    List<ThreadObject> chain = ta.findThreadChain(records, threadId);
    List<String> infoChain = new ArrayList<>();
    for (ThreadObject to : chain) {
        infoChain.add(to.getInfo());
    }
    data.putResponse("rs", JSONHelper.toString(infoChain));
}
Also used : ThreadObject(com.creditease.uav.threadanalysis.server.da.ThreadObject) ArrayList(java.util.ArrayList) ThreadAnalyser(com.creditease.uav.threadanalysis.server.ThreadAnalyser) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) RangeQueryBuilder(org.elasticsearch.index.query.RangeQueryBuilder) BoolQueryBuilder(org.elasticsearch.index.query.BoolQueryBuilder) HashMap(java.util.HashMap) Map(java.util.Map) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Aggregations

ThreadAnalyser (com.creditease.uav.threadanalysis.server.ThreadAnalyser)5 ThreadObject (com.creditease.uav.threadanalysis.server.da.ThreadObject)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 SearchResponse (org.elasticsearch.action.search.SearchResponse)5 BoolQueryBuilder (org.elasticsearch.index.query.BoolQueryBuilder)5 ArrayList (java.util.ArrayList)3 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)3 RangeQueryBuilder (org.elasticsearch.index.query.RangeQueryBuilder)3 List (java.util.List)2