@Test(dependsOnMethods = {"testSetAndGet"}) public void testToJobExecutionInfo() { JobExecutionInfo jobExecutionInfo = this.jobState.toJobExecutionInfo(); Assert.assertEquals(jobExecutionInfo.getJobName(), "TestJob"); Assert.assertEquals(jobExecutionInfo.getJobId(), "TestJob-1"); Assert.assertEquals(jobExecutionInfo.getStartTime().longValue(), this.startTime); Assert.assertEquals(jobExecutionInfo.getEndTime().longValue(), this.startTime + 1000); Assert.assertEquals(jobExecutionInfo.getDuration().longValue(), 1000L); Assert.assertEquals(jobExecutionInfo.getState().name(), JobState.RunningState.COMMITTED.name()); Assert.assertEquals(jobExecutionInfo.getLaunchedTasks().intValue(), 3); Assert.assertEquals(jobExecutionInfo.getCompletedTasks().intValue(), 3); Assert.assertEquals(jobExecutionInfo.getJobProperties().get("foo"), "bar"); List<String> taskStateIds = Lists.newArrayList(); for (TaskExecutionInfo taskExecutionInfo : jobExecutionInfo.getTaskExecutions()) { Assert.assertEquals(taskExecutionInfo.getJobId(), "TestJob-1"); Assert.assertEquals(taskExecutionInfo.getStartTime().longValue(), this.startTime); Assert.assertEquals(taskExecutionInfo.getEndTime().longValue(), this.startTime + 1000); Assert.assertEquals(taskExecutionInfo.getDuration().longValue(), 1000); Assert.assertEquals(taskExecutionInfo.getState().name(), WorkUnitState.WorkingState.COMMITTED.name()); Assert.assertEquals(taskExecutionInfo.getTaskProperties().get("foo"), "bar"); taskStateIds.add(taskExecutionInfo.getTaskId()); } Collections.sort(taskStateIds); Assert.assertEquals(taskStateIds, Lists.newArrayList("TestTask-0", "TestTask-1", "TestTask-2")); }
public JobExecutionInfo toJobExecutionInfo() { JobExecutionInfo jobExecutionInfo = new JobExecutionInfo(); jobExecutionInfo.setJobName(this.jobName); jobExecutionInfo.setJobId(this.jobId); if (this.startTime > 0) { jobExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { jobExecutionInfo.setEndTime(this.endTime); } jobExecutionInfo.setDuration(this.duration); jobExecutionInfo.setState(JobStateEnum.valueOf(this.state.name())); jobExecutionInfo.setLaunchedTasks(this.taskCount); jobExecutionInfo.setCompletedTasks(this.getCompletedTasks()); jobExecutionInfo.setLauncherType(getLauncherType()); if (getTrackingURL().isPresent()) { jobExecutionInfo.setTrackingUrl(getTrackingURL().get()); } TaskExecutionInfoArray taskExecutionInfos = new TaskExecutionInfoArray(); for (TaskState taskState : this.getTaskStates()) { taskExecutionInfos.add(taskState.toTaskExecutionInfo()); } jobExecutionInfo.setTaskExecutions(taskExecutionInfos); JobMetrics jobMetrics = JobMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.JOB.name()); counter.setName(entry.getKey()); counter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.COUNTER.name())); counter.setValue(Long.toString(((Counter) entry.getValue()).getCount())); metricArray.add(counter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.JOB.name()); meter.setName(entry.getKey()); meter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.METER.name())); meter.setValue(Double.toString(((Meter) entry.getValue()).getMeanRate())); metricArray.add(meter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.JOB.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } jobExecutionInfo.setMetrics(metricArray); Map<String, String> jobProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) { jobProperties.put(name, value); } } jobExecutionInfo.setJobProperties(new StringMap(jobProperties)); return jobExecutionInfo; }
JobState extends SourceState implements JobProgress { public JobExecutionInfo toJobExecutionInfo() { JobExecutionInfo jobExecutionInfo = new JobExecutionInfo(); jobExecutionInfo.setJobName(this.jobName); jobExecutionInfo.setJobId(this.jobId); if (this.startTime > 0) { jobExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { jobExecutionInfo.setEndTime(this.endTime); } jobExecutionInfo.setDuration(this.duration); jobExecutionInfo.setState(JobStateEnum.valueOf(this.state.name())); jobExecutionInfo.setLaunchedTasks(this.taskCount); jobExecutionInfo.setCompletedTasks(this.getCompletedTasks()); jobExecutionInfo.setLauncherType(getLauncherType()); if (getTrackingURL().isPresent()) { jobExecutionInfo.setTrackingUrl(getTrackingURL().get()); } TaskExecutionInfoArray taskExecutionInfos = new TaskExecutionInfoArray(); for (TaskState taskState : this.getTaskStates()) { taskExecutionInfos.add(taskState.toTaskExecutionInfo()); } jobExecutionInfo.setTaskExecutions(taskExecutionInfos); JobMetrics jobMetrics = JobMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.JOB.name()); counter.setName(entry.getKey()); counter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.COUNTER.name())); counter.setValue(Long.toString(((Counter) entry.getValue()).getCount())); metricArray.add(counter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.JOB.name()); meter.setName(entry.getKey()); meter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.METER.name())); meter.setValue(Double.toString(((Meter) entry.getValue()).getMeanRate())); metricArray.add(meter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.JOB.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } jobExecutionInfo.setMetrics(metricArray); Map<String, String> jobProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) { jobProperties.put(name, value); } } jobExecutionInfo.setJobProperties(new StringMap(jobProperties)); return jobExecutionInfo; } }
JobState extends SourceState implements JobProgress { public JobExecutionInfo toJobExecutionInfo() { JobExecutionInfo jobExecutionInfo = new JobExecutionInfo(); jobExecutionInfo.setJobName(this.jobName); jobExecutionInfo.setJobId(this.jobId); if (this.startTime > 0) { jobExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { jobExecutionInfo.setEndTime(this.endTime); } jobExecutionInfo.setDuration(this.duration); jobExecutionInfo.setState(JobStateEnum.valueOf(this.state.name())); jobExecutionInfo.setLaunchedTasks(this.taskCount); jobExecutionInfo.setCompletedTasks(this.getCompletedTasks()); jobExecutionInfo.setLauncherType(getLauncherType()); if (getTrackingURL().isPresent()) { jobExecutionInfo.setTrackingUrl(getTrackingURL().get()); } TaskExecutionInfoArray taskExecutionInfos = new TaskExecutionInfoArray(); for (TaskState taskState : this.getTaskStates()) { taskExecutionInfos.add(taskState.toTaskExecutionInfo()); } jobExecutionInfo.setTaskExecutions(taskExecutionInfos); JobMetrics jobMetrics = JobMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.JOB.name()); counter.setName(entry.getKey()); counter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.COUNTER.name())); counter.setValue(Long.toString(((Counter) entry.getValue()).getCount())); metricArray.add(counter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.JOB.name()); meter.setName(entry.getKey()); meter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.METER.name())); meter.setValue(Double.toString(((Meter) entry.getValue()).getMeanRate())); metricArray.add(meter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.JOB.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } jobExecutionInfo.setMetrics(metricArray); Map<String, String> jobProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) { jobProperties.put(name, value); } } jobExecutionInfo.setJobProperties(new StringMap(jobProperties)); return jobExecutionInfo; } JobState();  JobState(String jobName, String jobId);  JobState(State properties,String jobName, String jobId);  JobState(State properties, Map<String, JobState.DatasetState> previousDatasetStates, String jobName,
      String jobId); }
JobState extends SourceState implements JobProgress { public JobExecutionInfo toJobExecutionInfo() { JobExecutionInfo jobExecutionInfo = new JobExecutionInfo(); jobExecutionInfo.setJobName(this.jobName); jobExecutionInfo.setJobId(this.jobId); if (this.startTime > 0) { jobExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { jobExecutionInfo.setEndTime(this.endTime); } jobExecutionInfo.setDuration(this.duration); jobExecutionInfo.setState(JobStateEnum.valueOf(this.state.name())); jobExecutionInfo.setLaunchedTasks(this.taskCount); jobExecutionInfo.setCompletedTasks(this.getCompletedTasks()); jobExecutionInfo.setLauncherType(getLauncherType()); if (getTrackingURL().isPresent()) { jobExecutionInfo.setTrackingUrl(getTrackingURL().get()); } TaskExecutionInfoArray taskExecutionInfos = new TaskExecutionInfoArray(); for (TaskState taskState : this.getTaskStates()) { taskExecutionInfos.add(taskState.toTaskExecutionInfo()); } jobExecutionInfo.setTaskExecutions(taskExecutionInfos); JobMetrics jobMetrics = JobMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.JOB.name()); counter.setName(entry.getKey()); counter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.COUNTER.name())); counter.setValue(Long.toString(((Counter) entry.getValue()).getCount())); metricArray.add(counter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.JOB.name()); meter.setName(entry.getKey()); meter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.METER.name())); meter.setValue(Double.toString(((Meter) entry.getValue()).getMeanRate())); metricArray.add(meter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.JOB.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } jobExecutionInfo.setMetrics(metricArray); Map<String, String> jobProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) { jobProperties.put(name, value); } } jobExecutionInfo.setJobProperties(new StringMap(jobProperties)); return jobExecutionInfo; } JobState();  JobState(String jobName, String jobId);  JobState(State properties,String jobName, String jobId);  JobState(State properties, Map<String, JobState.DatasetState> previousDatasetStates, String jobName,
      String jobId); static String getJobNameFromState(State state); static String getJobNameFromProps(Properties props); static String getJobGroupFromState(State state); static String getJobGroupFromProps(Properties props); static String getJobDescriptionFromProps(State state); static String getJobDescriptionFromProps(Properties props); String getJobName(); void setJobName(String jobName); String getJobId(); void setJobId(String jobId); long getStartTime(); void setStartTime(long startTime); long getEndTime(); long getElapsedTime(); void setEndTime(long endTime); long getDuration(); void setDuration(long duration); synchronized RunningState getState(); synchronized void setState(RunningState state); int getTaskCount(); void setTaskCount(int taskCount); void setJobFailureException(Throwable jobFailureException); void setJobFailureMessage(String jobFailureMessage); void incrementTaskCount(); void addTaskState(TaskState taskState); void addSkippedTaskState(TaskState taskState); void removeTaskState(TaskState taskState); void filterSkippedTaskStates(); void addTaskStates(Collection<TaskState> taskStates); void addSkippedTaskStates(Collection<TaskState> taskStates); int getCompletedTasks(); List<TaskState> getTaskStates(); @Override List<TaskState> getTaskProgress(); Map<String, DatasetState> createDatasetStatesByUrns(); List<WorkUnitState> getTaskStatesAsWorkUnitStates(); LauncherTypeEnum getLauncherType(); void setJobLauncherType(LauncherTypeEnum jobLauncherType); Optional<String> getTrackingURL(); @Override void readFields(DataInput in); @Override void write(DataOutput out); void write(DataOutput out, boolean writeTasks, boolean writePreviousWorkUnitStates); void toJson(JsonWriter jsonWriter, boolean keepConfig); @Override boolean equals(Object object); @Override int hashCode(); @Override String toString(); JobExecutionInfo toJobExecutionInfo(); DatasetState newDatasetState(boolean fullCopy); static List<WorkUnitState> workUnitStatesFromDatasetStates(Iterable<JobState.DatasetState> datasetStates); }
JobState extends SourceState implements JobProgress { public JobExecutionInfo toJobExecutionInfo() { JobExecutionInfo jobExecutionInfo = new JobExecutionInfo(); jobExecutionInfo.setJobName(this.jobName); jobExecutionInfo.setJobId(this.jobId); if (this.startTime > 0) { jobExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { jobExecutionInfo.setEndTime(this.endTime); } jobExecutionInfo.setDuration(this.duration); jobExecutionInfo.setState(JobStateEnum.valueOf(this.state.name())); jobExecutionInfo.setLaunchedTasks(this.taskCount); jobExecutionInfo.setCompletedTasks(this.getCompletedTasks()); jobExecutionInfo.setLauncherType(getLauncherType()); if (getTrackingURL().isPresent()) { jobExecutionInfo.setTrackingUrl(getTrackingURL().get()); } TaskExecutionInfoArray taskExecutionInfos = new TaskExecutionInfoArray(); for (TaskState taskState : this.getTaskStates()) { taskExecutionInfos.add(taskState.toTaskExecutionInfo()); } jobExecutionInfo.setTaskExecutions(taskExecutionInfos); JobMetrics jobMetrics = JobMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.JOB.name()); counter.setName(entry.getKey()); counter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.COUNTER.name())); counter.setValue(Long.toString(((Counter) entry.getValue()).getCount())); metricArray.add(counter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.JOB.name()); meter.setName(entry.getKey()); meter.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.METER.name())); meter.setValue(Double.toString(((Meter) entry.getValue()).getMeanRate())); metricArray.add(meter); } for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : jobMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.JOB.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } jobExecutionInfo.setMetrics(metricArray); Map<String, String> jobProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) { jobProperties.put(name, value); } } jobExecutionInfo.setJobProperties(new StringMap(jobProperties)); return jobExecutionInfo; } JobState();  JobState(String jobName, String jobId);  JobState(State properties,String jobName, String jobId);  JobState(State properties, Map<String, JobState.DatasetState> previousDatasetStates, String jobName,
      String jobId); static String getJobNameFromState(State state); static String getJobNameFromProps(Properties props); static String getJobGroupFromState(State state); static String getJobGroupFromProps(Properties props); static String getJobDescriptionFromProps(State state); static String getJobDescriptionFromProps(Properties props); String getJobName(); void setJobName(String jobName); String getJobId(); void setJobId(String jobId); long getStartTime(); void setStartTime(long startTime); long getEndTime(); long getElapsedTime(); void setEndTime(long endTime); long getDuration(); void setDuration(long duration); synchronized RunningState getState(); synchronized void setState(RunningState state); int getTaskCount(); void setTaskCount(int taskCount); void setJobFailureException(Throwable jobFailureException); void setJobFailureMessage(String jobFailureMessage); void incrementTaskCount(); void addTaskState(TaskState taskState); void addSkippedTaskState(TaskState taskState); void removeTaskState(TaskState taskState); void filterSkippedTaskStates(); void addTaskStates(Collection<TaskState> taskStates); void addSkippedTaskStates(Collection<TaskState> taskStates); int getCompletedTasks(); List<TaskState> getTaskStates(); @Override List<TaskState> getTaskProgress(); Map<String, DatasetState> createDatasetStatesByUrns(); List<WorkUnitState> getTaskStatesAsWorkUnitStates(); LauncherTypeEnum getLauncherType(); void setJobLauncherType(LauncherTypeEnum jobLauncherType); Optional<String> getTrackingURL(); @Override void readFields(DataInput in); @Override void write(DataOutput out); void write(DataOutput out, boolean writeTasks, boolean writePreviousWorkUnitStates); void toJson(JsonWriter jsonWriter, boolean keepConfig); @Override boolean equals(Object object); @Override int hashCode(); @Override String toString(); JobExecutionInfo toJobExecutionInfo(); DatasetState newDatasetState(boolean fullCopy); static List<WorkUnitState> workUnitStatesFromDatasetStates(Iterable<JobState.DatasetState> datasetStates);  }