Skip to content

Commit 336e066

Browse files
committed
[#9641] Replace agent-stat api
1 parent 8eb1a4e commit 336e066

File tree

8 files changed

+41
-41
lines changed

8 files changed

+41
-41
lines changed

web/src/main/angular/src/app/core/components/agent-statistic-chart/agent-statistic-chart-container.component.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ export class AgentStatisticChartContainerComponent implements OnInit {
2727
ngOnInit() {
2828
this.emptyText$ = this.translateService.get('COMMON.NO_DATA');
2929
this.chartData$ = this.storeHelperService.getAgentList(this.unsubscribe).pipe(
30-
filter((data: IAgentList) => !!data),
31-
map((data: IAgentList) => this.makeChartData(data))
30+
filter((data: IServerAndAgentDataV2[]) => !!data),
31+
map((data: IServerAndAgentDataV2[]) => this.makeChartData(data))
3232
);
3333
}
3434

35-
private makeChartData(data: IAgentList): {[key: string]: PrimitiveArray[]} {
35+
private makeChartData(data: IServerAndAgentDataV2[]): {[key: string]: PrimitiveArray[]} {
3636
if (isEmpty(data)) {
3737
return {
3838
jvm: [],
@@ -55,11 +55,11 @@ export class AgentStatisticChartContainerComponent implements OnInit {
5555
* }
5656
*/
5757
let count = 0;
58-
const dataObj = Object.keys(data).reduce((acc1: {[key: string]: any}, appKey: string) => {
59-
const app = data[appKey];
6058

61-
return app.reduce((acc2: {[key: string]: any}, {agentVersion, jvmInfo}: IAgent) => {
59+
const dataObj = data.reduce((acc1: {[key: string]: any}, {instancesList}: IServerAndAgentDataV2) => {
60+
return instancesList.reduce((acc2: {[key: string]: any}, {agentVersion, jvmInfo}: IAgentDataV2) => {
6261
count++;
62+
6363
if (agentVersion) {
6464
acc2['agent'][agentVersion] = (acc2['agent'][agentVersion] || 0) + 1;
6565
}
@@ -71,7 +71,7 @@ export class AgentStatisticChartContainerComponent implements OnInit {
7171

7272
return acc2;
7373
}, acc1);
74-
}, {jvm: {}, agent: {}}) as {[key: string]: {[key: string]: number}};
74+
}, {jvm: {}, agent: {}})
7575

7676
const sortedDataObj = Object.entries(dataObj).reduce((acc1: {[key: string]: Map<string, number>}, [key, valueObj]: [string, {[key: string]: number}]) => {
7777
const sortedChildMap = new Map<string, number>(Object.entries(valueObj).sort(([k1], [k2]) => k1 < k2 ? -1 : 1));

web/src/main/angular/src/app/core/components/agent-statistic-list/agent-statistic-list-container.component.ts

+11-17
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class AgentStatisticListContainerComponent implements OnInit, OnDestroy {
2525

2626
ngOnInit() {
2727
this.agentListData$ = this.storeHelperService.getAgentList(this.unsubscribe).pipe(
28-
map((data: IAgentList) => this.makeGridData(data))
28+
map((data: IServerAndAgentDataV2[]) => this.makeGridData(data))
2929
);
3030
}
3131

@@ -34,33 +34,27 @@ export class AgentStatisticListContainerComponent implements OnInit, OnDestroy {
3434
this.unsubscribe.complete();
3535
}
3636

37-
private makeGridData(agentList: IAgentList): IGridData[] {
37+
private makeGridData(data: IServerAndAgentDataV2[]): IGridData[] {
3838
let index = 1;
3939
const resultData: IGridData[] = [];
40-
Object.keys(agentList).forEach((key: string, innerIndex: number) => {
41-
const list: IAgent[] = agentList[key];
40+
data.forEach(({instancesList}: IServerAndAgentDataV2) => {
4241
let row: IGridData;
4342

44-
if (list.length === 0) {
45-
row = this.makeRow(list[0], index, false, false);
43+
instancesList.forEach((agent: IAgentDataV2, agentIndex: number) => {
44+
if (agentIndex === 0) {
45+
row = this.makeRow(agent, index, true, false);
46+
} else {
47+
row.children.push(this.makeRow(agent, index, false, true));
48+
}
4649
index++;
47-
} else {
48-
list.forEach((agent: IAgent, agentIndex: number) => {
49-
if (agentIndex === 0) {
50-
row = this.makeRow(agent, index, true, false);
51-
} else {
52-
row.children.push(this.makeRow(agent, index, false, true));
53-
}
54-
index++;
55-
});
56-
}
50+
});
5751
resultData.push(row);
5852
});
5953

6054
return resultData;
6155
}
6256

63-
private makeRow(agent: IAgent, index: number, hasChild: boolean, isChild: boolean): any {
57+
private makeRow(agent: IAgentDataV2, index: number, hasChild: boolean, isChild: boolean): any {
6458
const oRow: IGridData = {
6559
index: index,
6660
application: agent.applicationName,

web/src/main/angular/src/app/core/components/configuration-agent-statistic/agent-statistic-data.service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import { tap } from 'rxjs/operators';
55

66
@Injectable()
77
export class AgentStatisticDataService {
8-
private url = 'getAgentList.pinpoint';
8+
private url = 'agents/statistics.pinpoint';
99
private lastRequestTime: number;
1010

1111
constructor(
1212
private http: HttpClient
1313
) {}
1414

15-
getData(): Observable<IAgentList> {
16-
return this.http.get<IAgentList>(this.url).pipe(
15+
getData(): Observable<IServerAndAgentDataV2[]> {
16+
return this.http.get<IServerAndAgentDataV2[]>(this.url).pipe(
1717
tap(() => {
1818
this.lastRequestTime = new Date().getTime();
1919
})

web/src/main/angular/src/app/core/components/configuration-agent-statistic/configuration-agent-statistic-container.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class ConfigurationAgentStatisticContainerComponent implements OnInit, On
4343
tap(() => {
4444
this.lastRequestTime = moment(this.agentStatisticDataService.getLastRequestTime()).tz(this.timezone).format(this.dateFormat);
4545
}),
46-
map((data: IAgentList) => !!data)
46+
map((data: IServerAndAgentDataV2[]) => !!data)
4747
);
4848
}
4949

@@ -80,7 +80,7 @@ export class ConfigurationAgentStatisticContainerComponent implements OnInit, On
8080
this.showProcessing();
8181
this.agentStatisticDataService.getData().pipe(
8282
takeUntil(this.unsubscribe)
83-
).subscribe((agentList: IAgentList) => {
83+
).subscribe((agentList: IServerAndAgentDataV2[]) => {
8484
this.storeHelperService.dispatch(new Actions.UpdateAdminAgentList(agentList));
8585
this.hideProcessing();
8686
}, (error: IServerError) => {

web/src/main/angular/src/app/shared/services/store-helper.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class StoreHelperService {
108108
})
109109
);
110110
}
111-
getAgentList(unsubscribe: Subject<void>): Observable<IAgentList> {
111+
getAgentList(unsubscribe: Subject<void>): Observable<IServerAndAgentDataV2[]> {
112112
return this.getObservable(STORE_KEY.ADMIN_AGENT_LIST, unsubscribe);
113113
}
114114
getAgentSelection(unsubscribe: Subject<void>): Observable<string> {

web/src/main/angular/src/app/shared/store/reducers/admin.reducer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { Action } from '@ngrx/store';
33
const UPDATE_ADMIN_AGENT_LIST = 'UPDATE_ADMIN_AGENT_LIST';
44
export class UpdateAdminAgentList implements Action {
55
readonly type = UPDATE_ADMIN_AGENT_LIST;
6-
constructor(public payload: IAgentList) {}
6+
constructor(public payload: IServerAndAgentDataV2[]) {}
77
}
88

9-
export function Reducer(state: IAgentList, action: UpdateAdminAgentList): IAgentList {
9+
export function Reducer(state: IServerAndAgentDataV2[], action: UpdateAdminAgentList): IServerAndAgentDataV2[] {
1010
switch (action.type) {
1111
case UPDATE_ADMIN_AGENT_LIST:
1212
return action.payload;

web/src/main/angular/src/globals.d.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -336,28 +336,33 @@ interface IServerAndAgentDataV2 {
336336
}
337337

338338
interface IAgentDataV2 {
339+
applicationName: string;
339340
agentId: string;
340341
agentName: string;
341-
agentVersion: string;
342-
applicationName: string;
343-
container: boolean;
342+
startTimestamp: number;
344343
hostName: string;
345344
ip: string;
346-
linkList: any[];
347-
pid: number;
348345
ports: string;
349346
serviceType: string;
347+
pid: number;
348+
vmVersion: string;
349+
agentVersion: string;
350+
container: boolean;
350351
serviceTypeCode: number;
351-
startTimestamp: number;
352-
status: {
352+
jvmInfo?: {
353+
version: number;
354+
jvmVersion: string;
355+
gcTypeName: string;
356+
};
357+
status?: {
353358
agentId: string;
354359
eventTimestamp: number;
355360
state: {
356361
code: number;
357362
desc: string;
358363
}
359364
};
360-
vmVersion: string;
365+
linkList?: any[];
361366
}
362367

363368
// @store

web/src/main/angular/src/proxy.conf.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ const PROXY_CONFIG = [
7171
"/uriStat/top50.pinpoint",
7272
"/uriStat/chart.pinpoint",
7373
"/agents/search-all",
74-
"/agents/search-application"
74+
"/agents/search-application",
75+
"/agents/statistics"
7576
],
7677
target: 'http://localhost:8080',
7778
secure: false

0 commit comments

Comments
 (0)