use of com.hubspot.singularity.OrderDirection in project Singularity by HubSpot.
the class HistoryResource method getRecentCommandLineArgs.
@GET
@Path("/request/{requestId}/command-line-args")
@ApiOperation("Get a list of recently used command line args for an on-demand or scheduled request")
public Set<List<String>> getRecentCommandLineArgs(@Auth SingularityUser user, @ApiParam("Request ID to look up") @PathParam("requestId") String requestId, @ApiParam("Max number of recent args to return") @QueryParam("count") Optional<Integer> count) {
authorizationHelper.checkForAuthorizationByRequestId(requestId, user, SingularityAuthorizationScope.READ);
final int argCount = count.or(DEFAULT_ARGS_HISTORY_COUNT);
List<SingularityTaskIdHistory> historiesToCheck = taskHistoryHelper.getBlendedHistory(new SingularityTaskHistoryQuery(Optional.of(requestId), Optional.<String>absent(), Optional.<String>absent(), Optional.<String>absent(), Optional.<ExtendedTaskState>absent(), Optional.<Long>absent(), Optional.<Long>absent(), Optional.<Long>absent(), Optional.<Long>absent(), Optional.<OrderDirection>absent()), 0, argCount);
Collections.sort(historiesToCheck);
Set<List<String>> args = new HashSet<>();
for (SingularityTaskIdHistory taskIdHistory : historiesToCheck) {
Optional<SingularityTask> maybeTask = taskHistoryHelper.getTask(taskIdHistory.getTaskId());
if (maybeTask.isPresent() && maybeTask.get().getTaskRequest().getPendingTask().getCmdLineArgsList().isPresent()) {
List<String> taskArgs = maybeTask.get().getTaskRequest().getPendingTask().getCmdLineArgsList().get();
if (!taskArgs.isEmpty()) {
args.add(maybeTask.get().getTaskRequest().getPendingTask().getCmdLineArgsList().get());
}
}
}
return args;
}
Aggregations