Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
deprecated /queue/sizes endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindanr committed May 10, 2022
1 parent 2b7fc9e commit 67f39ba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -354,13 +355,43 @@ public void removeTaskFromQueue(String taskType, String taskId) {
public int getQueueSizeForTask(String taskType) {
Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank");

Map<String, Integer> taskTypeToQueueSizeMap =
Integer queueSize =
getForEntity(
"tasks/queue/sizes", new Object[] {"taskType", taskType}, queueSizeMap);
if (taskTypeToQueueSizeMap.containsKey(taskType)) {
return taskTypeToQueueSizeMap.get(taskType);
"tasks/queue/size",
new Object[] {"taskType", taskType},
new GenericType<Integer>() {});
return queueSize != null ? queueSize : 0;
}

public int getQueueSizeForTask(
String taskType, String domain, String isolationGroupId, String executionNamespace) {
Preconditions.checkArgument(StringUtils.isNotBlank(taskType), "Task type cannot be blank");

List<Object> params = new LinkedList<>();
params.add("taskType");
params.add(taskType);

if (StringUtils.isNotBlank(domain)) {
params.add("domain");
params.add(domain);
}
return 0;

if (StringUtils.isNotBlank(isolationGroupId)) {
params.add("isolationGroupId");
params.add(isolationGroupId);
}

if (StringUtils.isNotBlank(executionNamespace)) {
params.add("executionNamespace");
params.add(executionNamespace);
}

Integer queueSize =
getForEntity(
"tasks/queue/size",
params.toArray(new Object[0]),
new GenericType<Integer>() {});
return queueSize != null ? queueSize : 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public ResponseEntity<Task> getTask(@PathVariable("taskId") String taskId) {
}

@GetMapping("/queue/sizes")
@Operation(summary = "Get Task type queue sizes")
@Operation(summary = "Deprecated. Please use /tasks/queue/size endpoint")
@Deprecated
public Map<String, Integer> size(
@RequestParam(value = "taskType", required = false) List<String> taskTypes) {
return taskService.getTaskQueueSizes(taskTypes);
Expand Down

0 comments on commit 67f39ba

Please sign in to comment.