Search in sources :

Example 1 with JobServiceSummary

use of alluxio.job.wire.JobServiceSummary in project alluxio by Alluxio.

the class JobServiceMetricsCommandTest method testBasic.

@Test
public void testBasic() throws IOException, ParseException {
    JobWorkerHealth jobWorkerHealth = new JobWorkerHealth(1, Lists.newArrayList(1.2, 0.9, 0.7), 10, 2, 2, "testHost");
    Mockito.when(mJobMasterClient.getAllWorkerHealth()).thenReturn(Lists.newArrayList(jobWorkerHealth));
    List<JobInfo> jobInfos = new ArrayList<>();
    jobInfos.add(createJobInfo(1, "Test1", Status.RUNNING, "2019-10-17 12:00:00"));
    jobInfos.add(createJobInfo(2, "Test2", Status.FAILED, "2019-10-17 12:30:15"));
    Mockito.when(mJobMasterClient.getJobServiceSummary()).thenReturn(new JobServiceSummary(jobInfos));
    new JobServiceMetricsCommand(mJobMasterClient, mPrintStream, "MM-dd-yyyy HH:mm:ss:SSS").run();
    String output = new String(mOutputStream.toByteArray(), StandardCharsets.UTF_8);
    String[] lineByLine = output.split("\n");
    // Worker Health Section
    assertEquals("Worker: testHost    Task Pool Size: 10     Unfinished Tasks: 2" + "      Active Tasks: 2      Load Avg: 1.2, 0.9, 0.7", lineByLine[0]);
    assertEquals("", lineByLine[1]);
    // Group By Status
    lineByLine = ArrayUtils.subarray(lineByLine, 2, lineByLine.length);
    assertEquals("Status: CREATED   Count: 0", lineByLine[0]);
    assertEquals("Status: CANCELED  Count: 0", lineByLine[1]);
    assertEquals("Status: FAILED    Count: 1", lineByLine[2]);
    assertEquals("Status: RUNNING   Count: 1", lineByLine[3]);
    assertEquals("Status: COMPLETED Count: 0", lineByLine[4]);
    assertEquals("", lineByLine[5]);
    // Top 10
    lineByLine = ArrayUtils.subarray(lineByLine, 6, lineByLine.length);
    assertEquals("10 Most Recently Modified Jobs:", lineByLine[0]);
    assertEquals("Timestamp: 01-17-2019 12:30:15:000       Id: 2                   Name: Test2" + "               Status: FAILED", lineByLine[1]);
    assertEquals("Timestamp: 01-17-2019 12:00:00:000       Id: 1                   Name: Test1" + "               Status: RUNNING", lineByLine[2]);
    assertEquals("", lineByLine[3]);
    assertEquals("10 Most Recently Failed Jobs:", lineByLine[4]);
    assertEquals("Timestamp: 01-17-2019 12:30:15:000       Id: 2                   Name: Test2" + "               Status: FAILED", lineByLine[5]);
    assertEquals("", lineByLine[6]);
    assertEquals("10 Longest Running Jobs:", lineByLine[7]);
    assertEquals("Timestamp: 01-17-2019 12:00:00:000       Id: 1                   Name: Test1" + "               Status: RUNNING", lineByLine[8]);
}
Also used : JobInfo(alluxio.job.wire.JobInfo) ArrayList(java.util.ArrayList) JobWorkerHealth(alluxio.job.wire.JobWorkerHealth) JobServiceSummary(alluxio.job.wire.JobServiceSummary) Test(org.junit.Test)

Example 2 with JobServiceSummary

use of alluxio.job.wire.JobServiceSummary in project alluxio by Alluxio.

the class JobServiceMetricsCommand method run.

/**
 * Runs a job services report metrics command.
 *
 * @return 0 on success, 1 otherwise
 */
public int run() throws IOException {
    List<JobWorkerHealth> allWorkerHealth = mJobMasterClient.getAllWorkerHealth();
    for (JobWorkerHealth workerHealth : allWorkerHealth) {
        mPrintStream.print(String.format("Worker: %-10s  ", workerHealth.getHostname()));
        mPrintStream.print(String.format("Task Pool Size: %-7s", workerHealth.getTaskPoolSize()));
        mPrintStream.print(String.format("Unfinished Tasks: %-7s", workerHealth.getUnfinishedTasks()));
        mPrintStream.print(String.format("Active Tasks: %-7s", workerHealth.getNumActiveTasks()));
        mPrintStream.println(String.format("Load Avg: %s", StringUtils.join(workerHealth.getLoadAverage(), ", ")));
    }
    mPrintStream.println();
    JobServiceSummary jobServiceSummary = mJobMasterClient.getJobServiceSummary();
    Collection<StatusSummary> jobStatusSummaries = jobServiceSummary.getSummaryPerStatus();
    for (StatusSummary statusSummary : jobStatusSummaries) {
        mPrintStream.print(String.format("Status: %-10s", statusSummary.getStatus()));
        mPrintStream.println(String.format("Count: %s", statusSummary.getCount()));
    }
    mPrintStream.println();
    mPrintStream.println(String.format("%s Most Recently Modified Jobs:", JobServiceSummary.RECENT_LENGTH));
    List<JobInfo> lastActivities = jobServiceSummary.getRecentActivities();
    printJobInfos(lastActivities);
    mPrintStream.println(String.format("%s Most Recently Failed Jobs:", JobServiceSummary.RECENT_LENGTH));
    List<JobInfo> lastFailures = jobServiceSummary.getRecentFailures();
    printJobInfos(lastFailures);
    mPrintStream.println(String.format("%s Longest Running Jobs:", JobServiceSummary.RECENT_LENGTH));
    List<JobInfo> longestRunning = jobServiceSummary.getLongestRunning();
    printJobInfos(longestRunning);
    return 0;
}
Also used : StatusSummary(alluxio.job.wire.StatusSummary) JobInfo(alluxio.job.wire.JobInfo) JobWorkerHealth(alluxio.job.wire.JobWorkerHealth) JobServiceSummary(alluxio.job.wire.JobServiceSummary)

Aggregations

JobInfo (alluxio.job.wire.JobInfo)2 JobServiceSummary (alluxio.job.wire.JobServiceSummary)2 JobWorkerHealth (alluxio.job.wire.JobWorkerHealth)2 StatusSummary (alluxio.job.wire.StatusSummary)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1