• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import {info} from "../../../log/Log.js";
17
18export const initTraceTaskStrategy = (metricData: Array<any>): ProcessListItem => {
19    info("Trace Task Strategy data length is:", metricData.length)
20    let statListItems = []
21    for (let sqlIndex = 0; sqlIndex < metricData.length; sqlIndex++) {
22        let pidList = metricData[sqlIndex].pid;
23        let processNameList = metricData[sqlIndex].process_name;
24        let threadNameList = metricData[sqlIndex].thread_name;
25        let threadNames = [];
26        let newArr = '';
27        if (threadNameList != null) {
28            threadNames = threadNameList.split(',');
29            newArr = threadNames.reduce((prev: any, item: any) => prev.includes(item) ? prev : prev.concat(item), []);
30        }
31
32        let statListItem = {
33            pid: pidList,
34            processName: processNameList,
35            threadName: newArr
36        }
37        statListItems?.push(statListItem)
38    }
39    return {
40        process: statListItems
41    }
42}
43
44export interface ProcessListItem {
45    process: Array<any>
46}
47
48export interface ProcessItem {
49    pid: string
50    processName: string
51    threadName: string
52}
53