JobInfoConverter { public static JobInstance parseToJobInstance(CubingJob job, Map<String, Output> outputs) { if (job == null) { logger.warn("job is null."); return null; } Output output = outputs.get(job.getId()); if (output == null) { logger.warn("job output is null."); return null; } CubingJob cubeJob = (CubingJob) job; CubeInstance cube = CubeManager.getInstance(KylinConfig.getInstanceFromEnv()) .getCube(CubingExecutableUtil.getCubeName(cubeJob.getParams())); final JobInstance result = new JobInstance(); result.setName(job.getName()); result.setProjectName(cubeJob.getProjectName()); result.setRelatedCube(cube != null ? cube.getName() : CubingExecutableUtil.getCubeName(cubeJob.getParams())); result.setDisplayCubeName(cube != null ? cube.getDisplayName() : CubingExecutableUtil.getCubeName(cubeJob.getParams())); result.setRelatedSegment(CubingExecutableUtil.getSegmentId(cubeJob.getParams())); result.setRelatedSegmentName(CubingExecutableUtil.getSegmentName(cubeJob.getParams())); result.setLastModified(output.getLastModified()); result.setSubmitter(job.getSubmitter()); result.setUuid(job.getId()); result.setType(CubeBuildTypeEnum.BUILD); result.setStatus(parseToJobStatus(output.getState())); result.setBuildInstance(AbstractExecutable.getBuildInstance(output)); result.setMrWaiting(AbstractExecutable.getExtraInfoAsLong(output, CubingJob.MAP_REDUCE_WAIT_TIME, 0L) / 1000); result.setExecStartTime(AbstractExecutable.getStartTime(output)); result.setExecEndTime(AbstractExecutable.getEndTime(output)); result.setExecInterruptTime(AbstractExecutable.getInterruptTime(output)); result.setDuration(AbstractExecutable.getDuration(result.getExecStartTime(), result.getExecEndTime(), result.getExecInterruptTime()) / 1000); for (int i = 0; i < job.getTasks().size(); ++i) { AbstractExecutable task = job.getTasks().get(i); result.addStep(parseToJobStep(task, i, outputs.get(task.getId()))); } return result; }  static JobInstance parseToJobInstanceQuietly(CubingJob job, Map<String, Output> outputs); static JobInstance parseToJobInstanceQuietly(CheckpointExecutable job, Map<String, Output> outputs); static JobInstance parseToJobInstance(CubingJob job, Map<String, Output> outputs); static JobInstance parseToJobInstance(CheckpointExecutable job, Map<String, Output> outputs); static JobInstance.JobStep parseToJobStep(AbstractExecutable task, int i, Output stepOutput); static JobStatusEnum parseToJobStatus(ExecutableState state); static JobStepStatusEnum parseToJobStepStatus(ExecutableState state); static JobSearchResult parseToJobSearchResult(DefaultChainedExecutable job, Map<String, ExecutableOutputPO> outputs);  }
@Test public void testParseToJobInstance() { TestJob task = new TestJob(); JobInstance instance = JobInfoConverter.parseToJobInstanceQuietly(task, Maps.newHashMap()); assertTrue(instance == null); }