@Test(dependsOnMethods = {"testSetAndGet"}) public void testToTaskExecutionInfo() { TaskExecutionInfo taskExecutionInfo = this.taskState.toTaskExecutionInfo(); Assert.assertEquals(taskExecutionInfo.getJobId(), "Job-1"); Assert.assertEquals(taskExecutionInfo.getTaskId(), "Task-1"); Assert.assertEquals(taskExecutionInfo.getHighWatermark().longValue(), 2000L); Assert.assertEquals(taskExecutionInfo.getStartTime().longValue(), this.startTime); Assert.assertEquals(taskExecutionInfo.getEndTime().longValue(), this.startTime + 1000); Assert.assertEquals(taskExecutionInfo.getDuration().longValue(), 1000L); Assert.assertEquals(taskExecutionInfo.getState().name(), WorkUnitState.WorkingState.COMMITTED.name()); Assert.assertEquals(taskExecutionInfo.getTaskProperties().get("foo"), "bar"); }
public TaskExecutionInfo toTaskExecutionInfo() { TaskExecutionInfo taskExecutionInfo = new TaskExecutionInfo(); taskExecutionInfo.setJobId(this.jobId); taskExecutionInfo.setTaskId(this.taskId); if (this.startTime > 0) { taskExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { taskExecutionInfo.setEndTime(this.endTime); } taskExecutionInfo.setDuration(this.duration); taskExecutionInfo.setState(TaskStateEnum.valueOf(getWorkingState().name())); if (this.contains(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)) { taskExecutionInfo.setFailureException(this.getProp(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)); } taskExecutionInfo.setHighWatermark(this.getHighWaterMark()); Table table = new Table(); Extract extract = this.getExtract(); table.setNamespace(extract.getNamespace()); table.setName(extract.getTable()); if (extract.hasType()) { table.setType(TableTypeEnum.valueOf(extract.getType().name())); } taskExecutionInfo.setTable(table); TaskMetrics taskMetrics = TaskMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : taskMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.TASK.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } taskExecutionInfo.setMetrics(metricArray); Map<String, String> taskProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) taskProperties.put(name, value); } taskExecutionInfo.setTaskProperties(new StringMap(taskProperties)); return taskExecutionInfo; }
TaskState extends WorkUnitState implements TaskProgress { public TaskExecutionInfo toTaskExecutionInfo() { TaskExecutionInfo taskExecutionInfo = new TaskExecutionInfo(); taskExecutionInfo.setJobId(this.jobId); taskExecutionInfo.setTaskId(this.taskId); if (this.startTime > 0) { taskExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { taskExecutionInfo.setEndTime(this.endTime); } taskExecutionInfo.setDuration(this.duration); taskExecutionInfo.setState(TaskStateEnum.valueOf(getWorkingState().name())); if (this.contains(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)) { taskExecutionInfo.setFailureException(this.getProp(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)); } taskExecutionInfo.setHighWatermark(this.getHighWaterMark()); Table table = new Table(); Extract extract = this.getExtract(); table.setNamespace(extract.getNamespace()); table.setName(extract.getTable()); if (extract.hasType()) { table.setType(TableTypeEnum.valueOf(extract.getType().name())); } taskExecutionInfo.setTable(table); TaskMetrics taskMetrics = TaskMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : taskMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.TASK.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } taskExecutionInfo.setMetrics(metricArray); Map<String, String> taskProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) taskProperties.put(name, value); } taskExecutionInfo.setTaskProperties(new StringMap(taskProperties)); return taskExecutionInfo; } }
TaskState extends WorkUnitState implements TaskProgress { public TaskExecutionInfo toTaskExecutionInfo() { TaskExecutionInfo taskExecutionInfo = new TaskExecutionInfo(); taskExecutionInfo.setJobId(this.jobId); taskExecutionInfo.setTaskId(this.taskId); if (this.startTime > 0) { taskExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { taskExecutionInfo.setEndTime(this.endTime); } taskExecutionInfo.setDuration(this.duration); taskExecutionInfo.setState(TaskStateEnum.valueOf(getWorkingState().name())); if (this.contains(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)) { taskExecutionInfo.setFailureException(this.getProp(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)); } taskExecutionInfo.setHighWatermark(this.getHighWaterMark()); Table table = new Table(); Extract extract = this.getExtract(); table.setNamespace(extract.getNamespace()); table.setName(extract.getTable()); if (extract.hasType()) { table.setType(TableTypeEnum.valueOf(extract.getType().name())); } taskExecutionInfo.setTable(table); TaskMetrics taskMetrics = TaskMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : taskMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.TASK.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } taskExecutionInfo.setMetrics(metricArray); Map<String, String> taskProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) taskProperties.put(name, value); } taskExecutionInfo.setTaskProperties(new StringMap(taskProperties)); return taskExecutionInfo; } TaskState();  TaskState(WorkUnitState workUnitState);  TaskState(TaskState taskState); }
TaskState extends WorkUnitState implements TaskProgress { public TaskExecutionInfo toTaskExecutionInfo() { TaskExecutionInfo taskExecutionInfo = new TaskExecutionInfo(); taskExecutionInfo.setJobId(this.jobId); taskExecutionInfo.setTaskId(this.taskId); if (this.startTime > 0) { taskExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { taskExecutionInfo.setEndTime(this.endTime); } taskExecutionInfo.setDuration(this.duration); taskExecutionInfo.setState(TaskStateEnum.valueOf(getWorkingState().name())); if (this.contains(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)) { taskExecutionInfo.setFailureException(this.getProp(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)); } taskExecutionInfo.setHighWatermark(this.getHighWaterMark()); Table table = new Table(); Extract extract = this.getExtract(); table.setNamespace(extract.getNamespace()); table.setName(extract.getTable()); if (extract.hasType()) { table.setType(TableTypeEnum.valueOf(extract.getType().name())); } taskExecutionInfo.setTable(table); TaskMetrics taskMetrics = TaskMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : taskMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.TASK.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } taskExecutionInfo.setMetrics(metricArray); Map<String, String> taskProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) taskProperties.put(name, value); } taskExecutionInfo.setTaskProperties(new StringMap(taskProperties)); return taskExecutionInfo; } TaskState();  TaskState(WorkUnitState workUnitState);  TaskState(TaskState taskState); String getJobId(); void setJobId(String jobId); String getTaskKey(); String getTaskId(); void setTaskId(String taskId); long getStartTime(); void setStartTime(long startTime); long getEndTime(); void setEndTime(long endTime); long getTaskDuration(); void setTaskDuration(long duration); Optional<String> getTaskFailureException(); void setTaskFailureException(Throwable taskFailureException); boolean isCompleted(); synchronized void updateRecordMetrics(long recordsWritten, int branchIndex); synchronized void updateByteMetrics(long bytesWritten, int branchIndex); void adjustJobMetricsOnRetry(int branches); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override boolean equals(Object object); @Override int hashCode(); void toJson(JsonWriter jsonWriter, boolean keepConfig); TaskExecutionInfo toTaskExecutionInfo(); }
TaskState extends WorkUnitState implements TaskProgress { public TaskExecutionInfo toTaskExecutionInfo() { TaskExecutionInfo taskExecutionInfo = new TaskExecutionInfo(); taskExecutionInfo.setJobId(this.jobId); taskExecutionInfo.setTaskId(this.taskId); if (this.startTime > 0) { taskExecutionInfo.setStartTime(this.startTime); } if (this.endTime > 0) { taskExecutionInfo.setEndTime(this.endTime); } taskExecutionInfo.setDuration(this.duration); taskExecutionInfo.setState(TaskStateEnum.valueOf(getWorkingState().name())); if (this.contains(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)) { taskExecutionInfo.setFailureException(this.getProp(ConfigurationKeys.TASK_FAILURE_EXCEPTION_KEY)); } taskExecutionInfo.setHighWatermark(this.getHighWaterMark()); Table table = new Table(); Extract extract = this.getExtract(); table.setNamespace(extract.getNamespace()); table.setName(extract.getTable()); if (extract.hasType()) { table.setType(TableTypeEnum.valueOf(extract.getType().name())); } taskExecutionInfo.setTable(table); TaskMetrics taskMetrics = TaskMetrics.get(this); MetricArray metricArray = new MetricArray(); for (Map.Entry<String, ? extends com.codahale.metrics.Metric> entry : taskMetrics.getMetricContext().getCounters() .entrySet()) { Metric counter = new Metric(); counter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getMeters() .entrySet()) { Metric meter = new Metric(); meter.setGroup(MetricGroup.TASK.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 : taskMetrics.getMetricContext().getGauges() .entrySet()) { Metric gauge = new Metric(); gauge.setGroup(MetricGroup.TASK.name()); gauge.setName(entry.getKey()); gauge.setType(MetricTypeEnum.valueOf(GobblinMetrics.MetricType.GAUGE.name())); gauge.setValue(((Gauge<?>) entry.getValue()).getValue().toString()); metricArray.add(gauge); } taskExecutionInfo.setMetrics(metricArray); Map<String, String> taskProperties = Maps.newHashMap(); for (String name : this.getPropertyNames()) { String value = this.getProp(name); if (!Strings.isNullOrEmpty(value)) taskProperties.put(name, value); } taskExecutionInfo.setTaskProperties(new StringMap(taskProperties)); return taskExecutionInfo; } TaskState();  TaskState(WorkUnitState workUnitState);  TaskState(TaskState taskState); String getJobId(); void setJobId(String jobId); String getTaskKey(); String getTaskId(); void setTaskId(String taskId); long getStartTime(); void setStartTime(long startTime); long getEndTime(); void setEndTime(long endTime); long getTaskDuration(); void setTaskDuration(long duration); Optional<String> getTaskFailureException(); void setTaskFailureException(Throwable taskFailureException); boolean isCompleted(); synchronized void updateRecordMetrics(long recordsWritten, int branchIndex); synchronized void updateByteMetrics(long bytesWritten, int branchIndex); void adjustJobMetricsOnRetry(int branches); @Override void readFields(DataInput in); @Override void write(DataOutput out); @Override boolean equals(Object object); @Override int hashCode(); void toJson(JsonWriter jsonWriter, boolean keepConfig); TaskExecutionInfo toTaskExecutionInfo();  }