Skip to content

Commit

Permalink
[pinpoint-apm#9017] Add max limit to getApplicationHostInfo for OOM p…
Browse files Browse the repository at this point in the history
…revent
  • Loading branch information
emeroad committed Jul 7, 2022
1 parent ecc44a4 commit 03ea05e
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.navercorp.pinpoint.web.service.ApplicationService;
import com.navercorp.pinpoint.web.vo.ApplicationAgentHostList;
import com.navercorp.pinpoint.web.response.CodeResult;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -36,6 +37,8 @@

@RestController
public class ApplicationController {
public static final int MAX_PAGING_LIMIT = 100;
private static final int NO_DURATION = -1;

private final AgentInfoService agentInfoService;

Expand All @@ -46,19 +49,15 @@ public ApplicationController(AgentInfoService agentInfoService, ApplicationServi
this.applicationService = Objects.requireNonNull(applicationService, "applicationService");
}

@GetMapping(value = "/getApplicationHostInfo", params = {"!durationDays"})
public ApplicationAgentHostList getApplicationHostInfo (
@RequestParam(value = "offset", required = false, defaultValue = "1") int offset,
@RequestParam(value = "limit", required = false, defaultValue = "100") int limit) {
return agentInfoService.getApplicationAgentHostList(offset, limit);
}

@GetMapping(value = "/getApplicationHostInfo", params = {"durationDays"})
@GetMapping(value = "/getApplicationHostInfo")
public ApplicationAgentHostList getApplicationHostInfo (
@RequestParam(value = "offset", required = false, defaultValue = "1") int offset,
@RequestParam(value = "limit", required = false, defaultValue = "100") int limit,
@RequestParam(value = "durationDays") int durationDays) {
return agentInfoService.getApplicationAgentHostList(offset, limit, durationDays);
@RequestParam(value = "durationDays", required = false) Integer durationDays) {
int maxLimit = Math.min(MAX_PAGING_LIMIT, limit);
durationDays = ObjectUtils.defaultIfNull(durationDays, NO_DURATION);

return agentInfoService.getApplicationAgentHostList(offset, maxLimit, durationDays);
}

@RequestMapping(value = "/isAvailableApplicationName")
Expand Down

0 comments on commit 03ea05e

Please sign in to comment.