30
30
import com .navercorp .pinpoint .web .service .stat .AgentWarningStatService ;
31
31
import com .navercorp .pinpoint .web .vo .AgentEvent ;
32
32
import com .navercorp .pinpoint .web .vo .AgentInfo ;
33
+ import com .navercorp .pinpoint .web .vo .AgentAndStatus ;
33
34
import com .navercorp .pinpoint .web .vo .AgentInfoFilter ;
34
35
import com .navercorp .pinpoint .web .vo .AgentStatus ;
35
36
import com .navercorp .pinpoint .web .vo .AgentStatusQuery ;
@@ -117,12 +118,12 @@ public ApplicationAgentsList getApplicationAgentsList(ApplicationAgentsList.Grou
117
118
Objects .requireNonNull (applicationName , "applicationName" );
118
119
119
120
ApplicationAgentsList applicationAgentsList = new ApplicationAgentsList (groupBy , filter , hyperLinkFactory );
120
- Set <AgentInfo > agentInfos = getAgentsByApplicationName (applicationName , timestamp );
121
- if (agentInfos .isEmpty ()) {
121
+ Set <AgentAndStatus > agentInfoAnsStatuss = getAgentsByApplicationName (applicationName , timestamp );
122
+ if (agentInfoAnsStatuss .isEmpty ()) {
122
123
logger .warn ("agent list is empty for application:{}" , applicationName );
123
124
return applicationAgentsList ;
124
125
}
125
- applicationAgentsList .addAll (agentInfos );
126
+ applicationAgentsList .addAll (agentInfoAnsStatuss );
126
127
if (logger .isDebugEnabled ()) {
127
128
logger .debug ("getApplicationAgentsList={}" , applicationAgentsList );
128
129
}
@@ -218,20 +219,20 @@ private List<String> getApplicationNameList(List<Application> applications) {
218
219
}
219
220
220
221
@ Override
221
- public Set <AgentInfo > getAgentsByApplicationName (String applicationName , long timestamp ) {
222
+ public Set <AgentAndStatus > getAgentsByApplicationName (String applicationName , long timestamp ) {
222
223
List <AgentInfo > agentInfos = this .getAgentsByApplicationNameWithoutStatus0 (applicationName , timestamp );
223
224
225
+ List <AgentAndStatus > result = new ArrayList <>(agentInfos .size ());
224
226
225
227
AgentStatusQuery query = AgentStatusQuery .buildQuery (agentInfos , Instant .ofEpochMilli (timestamp ));
226
228
List <Optional <AgentStatus >> agentStatus = this .agentLifeCycleDao .getAgentStatus (query );
227
229
for (int i = 0 ; i < agentStatus .size (); i ++) {
228
230
Optional <AgentStatus > status = agentStatus .get (i );
229
- if (status .isPresent ()) {
230
- AgentInfo agentInfo = agentInfos .get (i );
231
- agentInfo .setStatus (status .get ());
232
- }
231
+ AgentInfo agentInfo = agentInfos .get (i );
232
+ result .add (new AgentAndStatus (agentInfo , status .orElse (null )));
233
233
}
234
- return new HashSet <>(agentInfos );
234
+
235
+ return new HashSet <>(result );
235
236
}
236
237
237
238
@@ -257,33 +258,35 @@ public List<AgentInfo> getAgentsByApplicationNameWithoutStatus0(String applicati
257
258
}
258
259
259
260
@ Override
260
- public Set <AgentInfo > getRecentAgentsByApplicationName (String applicationName , long timestamp , long timeDiff ) {
261
+ public Set <AgentAndStatus > getRecentAgentsByApplicationName (String applicationName , long timestamp , long timeDiff ) {
261
262
if (timeDiff > timestamp ) {
262
263
throw new IllegalArgumentException ("timeDiff must not be greater than timestamp" );
263
264
}
264
265
265
- Set <AgentInfo > unfilteredAgentInfos = this .getAgentsByApplicationName (applicationName , timestamp );
266
+ Set <AgentAndStatus > unfilteredAgentInfos = this .getAgentsByApplicationName (applicationName , timestamp );
266
267
267
268
final long eventTimestampFloor = timestamp - timeDiff ;
268
269
269
- Set <AgentInfo > filteredAgentInfos = new HashSet <>();
270
- for (AgentInfo agentInfo : unfilteredAgentInfos ) {
271
- AgentStatus agentStatus = agentInfo .getStatus ();
270
+ Set <AgentAndStatus > filteredAgentInfos = new HashSet <>();
271
+ for (AgentAndStatus agentInfoAndStatus : unfilteredAgentInfos ) {
272
+ AgentStatus agentStatus = agentInfoAndStatus .getStatus ();
272
273
if (AgentLifeCycleState .UNKNOWN == agentStatus .getState () || eventTimestampFloor <= agentStatus .getEventTimestamp ()) {
273
- filteredAgentInfos .add (agentInfo );
274
+ filteredAgentInfos .add (agentInfoAndStatus );
274
275
}
275
276
}
276
277
return filteredAgentInfos ;
277
278
}
278
279
279
280
@ Override
280
- public AgentInfo getAgentInfo (String agentId , long timestamp ) {
281
+ public AgentAndStatus getAgentInfo (String agentId , long timestamp ) {
282
+
281
283
AgentInfo agentInfo = getAgentInfoWithoutStatus (agentId , timestamp );
282
- if (agentInfo != null ) {
283
- Optional <AgentStatus > agentStatus = this .agentLifeCycleDao .getAgentStatus (agentInfo .getAgentId (), agentInfo .getStartTimestamp (), timestamp );
284
- agentInfo .setStatus (agentStatus .orElse (null ));
284
+ if (agentInfo == null ) {
285
+ return null ;
285
286
}
286
- return agentInfo ;
287
+
288
+ Optional <AgentStatus > agentStatus = this .agentLifeCycleDao .getAgentStatus (agentInfo .getAgentId (), agentInfo .getStartTimestamp (), timestamp );
289
+ return new AgentAndStatus (agentInfo , agentStatus .orElse (null ));
287
290
}
288
291
289
292
@ Override
0 commit comments