Search in sources :

Example 6 with TaskInfo

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();
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo) RestResponse(com.google.gerrit.acceptance.RestResponse) TypeToken(com.google.gson.reflect.TypeToken) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 7 with TaskInfo

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");
}
Also used : TaskInfo(com.google.gerrit.server.config.ListTasks.TaskInfo)

Aggregations

TaskInfo (com.google.gerrit.server.config.ListTasks.TaskInfo)7 RestResponse (com.google.gerrit.acceptance.RestResponse)6 TypeToken (com.google.gson.reflect.TypeToken)6 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 Test (org.junit.Test)4 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Truth8.assertThat (com.google.common.truth.Truth8.assertThat)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1