use of com.google.gerrit.server.config.ListTasks.TaskInfo in project gerrit by GerritCodeReview.
the class ListTasksIT method listTasksWithoutViewQueueCapability.
@Test
public void listTasksWithoutViewQueueCapability() throws Exception {
RestResponse r = userRestSession.get("/config/server/tasks/");
r.assertOK();
List<TaskInfo> result = newGson().fromJson(r.getReader(), new TypeToken<List<TaskInfo>>() {
}.getType());
assertThat(result).isEmpty();
}
use of com.google.gerrit.server.config.ListTasks.TaskInfo in project gerrit by GerritCodeReview.
the class ShowQueue method print.
private void print(List<TaskInfo> tasks, long now, boolean viewAll, int threadPoolSize) {
for (TaskInfo task : tasks) {
String start;
switch(task.state) {
case DONE:
case CANCELLED:
case RUNNING:
case READY:
start = format(task.state);
break;
case OTHER:
case SLEEPING:
default:
start = time(now, task.delay);
break;
}
// Shows information about tasks depending on the user rights
if (viewAll || task.projectName == null) {
String command = task.command.length() < maxCommandWidth ? task.command : task.command.substring(0, maxCommandWidth);
stdout.print(String.format("%8s %-12s %-12s %-4s %s\n", task.id, start, startTime(task.startTime), "", command));
} else {
String remoteName = task.remoteName != null ? task.remoteName + "/" + task.projectName : task.projectName;
stdout.print(String.format("%8s %-12s %-4s %s\n", task.id, start, startTime(task.startTime), MoreObjects.firstNonNull(remoteName, "n/a")));
}
}
stdout.print("------------------------------------------------------------------------------\n");
stdout.print(" " + tasks.size() + " tasks");
if (threadPoolSize > 0) {
stdout.print(", " + threadPoolSize + " worker threads");
}
stdout.print("\n\n");
}
Aggregations