public static void checkNotFound(boolean condition, String message, Object... args) { if (!condition) { notFound(message, args); } }
throw notFound("Slave @ %s was not found, it is probably offline", slaveHostname);
throw notFound("Slave @ %s was not found, it is probably offline", slaveHostname);
@GET @Path("/task/{taskId}/statistics") @Operation( summary = "Retrieve resource usage statistics about a specific active task", responses = { @ApiResponse(responseCode = "404", description = "A task with this id, or slave and executor with matching statistics was not found") } ) public MesosTaskStatisticsObject getTaskStatistics( @Parameter(hidden = true) @Auth SingularityUser user, @Parameter(description = "Id of the task") @PathParam("taskId") String taskId) { SingularityTask task = checkActiveTask(taskId, SingularityAuthorizationScope.READ, user); String executorIdToMatch = null; if (task.getMesosTask().hasExecutor()) { executorIdToMatch = task.getMesosTask().getExecutor().getExecutorId().getValue(); } else { executorIdToMatch = taskId; } for (MesosTaskMonitorObject taskMonitor : mesosClient.getSlaveResourceUsage(task.getHostname())) { if (taskMonitor.getExecutorId().equals(executorIdToMatch)) { return taskMonitor.getStatistics(); } } throw notFound("Couldn't find executor %s for %s on slave %s", executorIdToMatch, taskId, task.getHostname()); }
public static void checkNotFound(boolean condition, String message, Object... args) { if (!condition) { notFound(message, args); } }
throw notFound("Slave @ %s was not found, it is probably offline", slaveHostname);
throw notFound("Slave @ %s was not found, it is probably offline", slaveHostname);
@GET @Path("/task/{taskId}/statistics") @Operation( summary = "Retrieve resource usage statistics about a specific active task", responses = { @ApiResponse(responseCode = "404", description = "A task with this id, or slave and executor with matching statistics was not found") } ) public MesosTaskStatisticsObject getTaskStatistics( @Parameter(hidden = true) @Auth SingularityUser user, @Parameter(description = "Id of the task") @PathParam("taskId") String taskId) { SingularityTask task = checkActiveTask(taskId, SingularityAuthorizationScope.READ, user); String executorIdToMatch = null; if (task.getMesosTask().hasExecutor()) { executorIdToMatch = task.getMesosTask().getExecutor().getExecutorId().getValue(); } else { executorIdToMatch = taskId; } for (MesosTaskMonitorObject taskMonitor : mesosClient.getSlaveResourceUsage(task.getHostname())) { if (taskMonitor.getExecutorId().equals(executorIdToMatch)) { return taskMonitor.getStatistics(); } } throw notFound("Couldn't find executor %s for %s on slave %s", executorIdToMatch, taskId, task.getHostname()); }