Search in sources :

Example 1 with JobTypeStatistics

use of com.dangdang.ddframe.job.statistics.type.job.JobTypeStatistics in project elastic-job by dangdangdotcom.

the class StatisticManager method getJobTypeStatistics.

/**
     * 获取作业类型统计数据.
     * 
     * @return 作业类型统计数据对象
     */
public JobTypeStatistics getJobTypeStatistics() {
    int scriptJobCnt = 0;
    int simpleJobCnt = 0;
    int dataflowJobCnt = 0;
    for (CloudJobConfiguration each : configurationService.loadAll()) {
        if (JobType.SCRIPT.equals(each.getTypeConfig().getJobType())) {
            scriptJobCnt++;
        } else if (JobType.SIMPLE.equals(each.getTypeConfig().getJobType())) {
            simpleJobCnt++;
        } else if (JobType.DATAFLOW.equals(each.getTypeConfig().getJobType())) {
            dataflowJobCnt++;
        }
    }
    return new JobTypeStatistics(scriptJobCnt, simpleJobCnt, dataflowJobCnt);
}
Also used : CloudJobConfiguration(com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration) JobTypeStatistics(com.dangdang.ddframe.job.statistics.type.job.JobTypeStatistics)

Example 2 with JobTypeStatistics

use of com.dangdang.ddframe.job.statistics.type.job.JobTypeStatistics in project elastic-job by dangdangdotcom.

the class CloudJobRestfulApiTest method assertGetJobTypeStatistics.

@Test
public void assertGetJobTypeStatistics() throws Exception {
    String result = sentGetRequest("http://127.0.0.1:19000/job/statistics/jobs/type");
    JobTypeStatistics jobTypeStatistics = GsonFactory.getGson().fromJson(result, JobTypeStatistics.class);
    assertThat(jobTypeStatistics.getSimpleJobCount(), is(0));
    assertThat(jobTypeStatistics.getDataflowJobCount(), is(0));
    assertThat(jobTypeStatistics.getScriptJobCount(), is(0));
}
Also used : JobTypeStatistics(com.dangdang.ddframe.job.statistics.type.job.JobTypeStatistics) Test(org.junit.Test)

Aggregations

JobTypeStatistics (com.dangdang.ddframe.job.statistics.type.job.JobTypeStatistics)2 CloudJobConfiguration (com.dangdang.ddframe.job.cloud.scheduler.config.job.CloudJobConfiguration)1 Test (org.junit.Test)1