Skip to content

Commit

Permalink
[pinpoint-apm#11328] remove ping event check
Browse files Browse the repository at this point in the history
  • Loading branch information
donghun-cho committed Sep 10, 2024
1 parent 15af83a commit d946fd5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public ApplicationController(AgentInfoService agentInfoService, ApplicationServi
this.cacheService = Objects.requireNonNull(cacheService, "cacheService");
}

@GetMapping(value = "/getApplicationHostInfo")
public ApplicationAgentHostList getApplicationHostInfo(
@GetMapping(value = "/getApplicationHostInfoV1")
public ApplicationAgentHostList getApplicationHostInfoV1(
@RequestParam(value = "offset", required = false, defaultValue = "1") @Positive int offset,
@RequestParam(value = "limit", required = false, defaultValue = "100") @Positive int limit,
@RequestParam(value = "durationDays", required = false) @PositiveOrZero Integer durationDays
Expand All @@ -85,7 +85,7 @@ public ApplicationAgentHostList getApplicationHostInfo(
return agentInfoService.getApplicationAgentHostList(offset, maxLimit, durationDaysPeriod);
}

@GetMapping(value = "/getApplicationHostInfoV2", params = "durationHours")
@GetMapping(value = "/getApplicationHostInfo", params = "durationHours")
public ApplicationAgentHostList getApplicationHostInfoV2(
@RequestParam(value = "offset", required = false, defaultValue = "1") @Positive int offset,
@RequestParam(value = "limit", required = false, defaultValue = "100") @Positive int limit,
Expand All @@ -102,7 +102,7 @@ public ApplicationAgentHostList getApplicationHostInfoV2(
return agentInfoService.getApplicationAgentHostList(offset, maxLimit, durationHours, applicationList, agentInfoFilter);
}

@GetMapping(value = "/getApplicationHostInfoV2")
@GetMapping(value = "/getApplicationHostInfo")
public ApplicationAgentHostList getApplicationHostInfoDaysV2(
@RequestParam(value = "offset", required = false, defaultValue = "1") @Positive int offset,
@RequestParam(value = "limit", required = false, defaultValue = "100") @Positive int limit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public interface AgentInfoService {
AgentsMapByHost getAgentsListByApplicationName(AgentStatusFilter agentStatusFilter, AgentInfoFilter agentInfoPredicate, String applicationName, Range range, SortByAgentInfo.Rules sortBy);
AgentsMapByHost getAgentsListByApplicationName(AgentStatusFilter agentStatusFilter, String applicationName, Range range, SortByAgentInfo.Rules sortBy);

@Deprecated
ApplicationAgentHostList getApplicationAgentHostList(int offset, int limit, Period durationDays);

ApplicationAgentHostList getApplicationAgentHostList(int offset, int limit, int durationDays, List<Application> applicationList, AgentInfoFilter agentInfoFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.navercorp.pinpoint.web.filter.agent.AgentEventFilter;
import com.navercorp.pinpoint.web.hyperlink.HyperLinkFactory;
import com.navercorp.pinpoint.web.service.component.ActiveAgentValidator;
import com.navercorp.pinpoint.web.service.component.LegacyAgentCompatibility;
import com.navercorp.pinpoint.web.service.stat.AgentWarningStatService;
import com.navercorp.pinpoint.web.vo.AgentEvent;
import com.navercorp.pinpoint.web.vo.Application;
Expand Down Expand Up @@ -91,22 +92,24 @@ public class AgentInfoServiceImpl implements AgentInfoService {

private final HyperLinkFactory hyperLinkFactory;
private final ActiveAgentValidator activeAgentValidator;

private final LegacyAgentCompatibility legacyAgentCompatibility;

public AgentInfoServiceImpl(AgentEventService agentEventService,
AgentWarningStatService agentWarningStatService,
ApplicationIndexDao applicationIndexDao,
AgentInfoDao agentInfoDao,
AgentLifeCycleDao agentLifeCycleDao,
ActiveAgentValidator activeAgentValidator,
HyperLinkFactory hyperLinkFactory) {
HyperLinkFactory hyperLinkFactory,
LegacyAgentCompatibility legacyAgentCompatibility) {
this.agentEventService = Objects.requireNonNull(agentEventService, "agentEventService");
this.agentWarningStatService = Objects.requireNonNull(agentWarningStatService, "agentWarningStatService");
this.applicationIndexDao = Objects.requireNonNull(applicationIndexDao, "applicationIndexDao");
this.agentInfoDao = Objects.requireNonNull(agentInfoDao, "agentInfoDao");
this.agentLifeCycleDao = Objects.requireNonNull(agentLifeCycleDao, "agentLifeCycleDao");
this.activeAgentValidator = Objects.requireNonNull(activeAgentValidator, "activeAgentValidator");
this.hyperLinkFactory = Objects.requireNonNull(hyperLinkFactory, "hyperLinkFactory");
this.legacyAgentCompatibility = Objects.requireNonNull(legacyAgentCompatibility, "legacyAgentCompatibility");
}

@Override
Expand Down Expand Up @@ -204,6 +207,7 @@ private boolean isActiveAgentPredicate(AgentAndStatus agentAndStatus,
}


@Deprecated
@Override
public ApplicationAgentHostList getApplicationAgentHostList(int offset, int limit, Period durationDays) {
if (offset <= 0) {
Expand All @@ -217,6 +221,7 @@ public ApplicationAgentHostList getApplicationAgentHostList(int offset, int limi
return getApplicationAgentHostList0(offset, limit, durationDays);
}

@Deprecated
private ApplicationAgentHostList getApplicationAgentHostList0(int offset, int limit, Period durationDays) {
List<String> applicationNameList = getApplicationNameList(applicationIndexDao.selectAllApplicationNames());
if (offset > applicationNameList.size()) {
Expand Down Expand Up @@ -279,16 +284,32 @@ private List<AgentInfo> getAgentInfoList(String applicationName, long timestamp,
Range range = Range.between(timestamp - TimeUnit.HOURS.toMillis(durationHours), timestamp);
List<AgentAndStatus> agentAndStatusList = getAgentAndStatuses(filteredAgentInfoList, timestamp);
List<AgentInfo> filteredActiveAgentInfoList = agentAndStatusList.stream()
.filter(agentAndStatus -> isActiveAgentPredicate(agentAndStatus, AgentInfoFilters.acceptAll(), AgentStatusFilters.recentRunning(range.getFrom()), range))
.filter(agentAndStatus -> isActiveAgentSimplePredicate(agentAndStatus, AgentStatusFilters.recentRunning(range.getFrom()), range))
.map(AgentAndStatus::getAgentInfo)
.collect(Collectors.toList());
return filteredActiveAgentInfoList;
}

private boolean isActiveAgentSimplePredicate(AgentAndStatus agentAndStatus, AgentStatusFilter agentStatusFilter, Range range) {
if (agentStatusFilter.test(agentAndStatus.getStatus())) {
return true;
}

AgentInfo agentInfo = agentAndStatus.getAgentInfo();
if (legacyAgentCompatibility.isLegacyAgent(agentInfo.getServiceTypeCode(), agentInfo.getAgentVersion())) {
if (legacyAgentCompatibility.isActiveAgent(agentInfo.getAgentId(), range)) {
return true;
}
}

return false;
}

private ApplicationAgentHostList.Builder newBuilder(int offset, int endIndex, int totalApplications) {
return ApplicationAgentHostList.newBuilder(offset, endIndex, totalApplications);
}

@Deprecated
private List<String> getAgentIdList(String applicationName, Period durationDays) {
List<String> agentIds = this.applicationIndexDao.selectAgentIds(applicationName);
if (CollectionUtils.isEmpty(agentIds)) {
Expand Down

0 comments on commit d946fd5

Please sign in to comment.