Skip to content

Commit 96b36c4

Browse files
committed
add a new status SKIPPED for skipped jobs and flows
fix merge conflicts
1 parent 45ad13e commit 96b36c4

19 files changed

Lines changed: 246 additions & 29 deletions

File tree

gobblin-cluster/src/main/java/org/apache/gobblin/cluster/HelixRetriggeringJobCallable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ private void runJobExecutionLauncher() throws JobException {
279279

280280
try {
281281
if (planningJobIdFromStore.isPresent() && !canRun(planningJobIdFromStore.get(), planningJobHelixManager)) {
282+
// todo it should emit SKIPPED_JOB event that sets the job status SKIPPED rather than CANCELLED
282283
TimingEvent timer = new TimingEvent(eventSubmitter, TimingEvent.JOB_SKIPPED_TIME);
283284
HashMap<String, String> metadata = new HashMap<>(Tag.toMap(Tag.tagValuesToString(
284285
HelixUtils.initBaseEventTags(jobProps, Lists.newArrayList()))));

gobblin-metrics-libs/gobblin-metrics-base/src/main/java/org/apache/gobblin/metrics/event/TimingEvent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public static class LauncherTimings {
4343
public static final String JOB_PENDING_RESUME = "JobPendingResume";
4444
public static final String JOB_ORCHESTRATED = "JobOrchestrated";
4545
public static final String JOB_PREPARE = "JobPrepareTimer";
46+
public static final String JOB_SKIPPED = "JobSkipped";
4647
public static final String JOB_START = "JobStartTimer";
4748
public static final String JOB_RUN = "JobRunTimer";
4849
public static final String JOB_COMMIT = "JobCommitTimer";

gobblin-modules/gobblin-kafka-09/src/test/java/org/apache/gobblin/runtime/KafkaAvroJobStatusMonitorTest.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public void testProcessMessageForSkippedFlow() throws IOException, ReflectiveOpe
308308
ImmutableList.of(
309309
createFlowCompiledEvent(),
310310
createJobOrchestratedEvent(1, 2),
311-
createJobSkippedEvent()
311+
createJobSkippedTimeEvent()
312312
).forEach(event -> {
313313
context.submitEvent(event);
314314
kafkaReporter.report();
@@ -836,6 +836,40 @@ public void testObservabilityEventFlowFailed() throws IOException, ReflectiveOpe
836836
jobStatusMonitor.shutDown();
837837
}
838838

839+
@Test// (dependsOnMethods = "testObservabilityEventFlowFailed")
840+
public void testProcessMessageForSkippedEvent() throws IOException, ReflectiveOperationException {
841+
DagManagementStateStore dagManagementStateStore = mock(DagManagementStateStore.class);
842+
KafkaEventReporter kafkaReporter = builder.build("localhost:0000", "topic8");
843+
844+
//Submit GobblinTrackingEvents to Kafka
845+
ImmutableList.of(
846+
createJobSkippedEvent()
847+
).forEach(event -> {
848+
context.submitEvent(event);
849+
kafkaReporter.report();
850+
});
851+
852+
try {
853+
Thread.sleep(1000);
854+
} catch(InterruptedException ex) {
855+
Thread.currentThread().interrupt();
856+
}
857+
858+
MockKafkaAvroJobStatusMonitor jobStatusMonitor = createMockKafkaAvroJobStatusMonitor(new AtomicBoolean(false),
859+
ConfigFactory.empty(), new NoopGaaSJobObservabilityEventProducer(), dagManagementStateStore);
860+
jobStatusMonitor.buildMetricsContextAndMetrics();
861+
Iterator<DecodeableKafkaRecord<byte[], byte[]>> recordIterator = Iterators.transform(
862+
this.kafkaTestHelper.getIteratorForTopic(TOPIC),
863+
this::convertMessageAndMetadataToDecodableKafkaRecord);
864+
865+
State state = getNextJobStatusState(jobStatusMonitor, recordIterator, this.jobGroup, this.jobName);
866+
Assert.assertEquals(state.getProp(JobStatusRetriever.EVENT_NAME_FIELD), ExecutionStatus.SKIPPED.name());
867+
Mockito.verify(dagManagementStateStore, Mockito.times(1)).addJobDagAction(
868+
any(), any(), anyLong(), any(), eq(DagActionStore.DagActionType.REEVALUATE));
869+
870+
jobStatusMonitor.shutDown();
871+
}
872+
839873
private State getNextJobStatusState(MockKafkaAvroJobStatusMonitor jobStatusMonitor, Iterator<DecodeableKafkaRecord<byte[], byte[]>> recordIterator,
840874
String jobGroup, String jobName) throws IOException {
841875
jobStatusMonitor.processMessage(recordIterator.next());
@@ -871,11 +905,15 @@ private GobblinTrackingEvent createJobOrchestratedEvent(int currentAttempt, int
871905
return createGTE(TimingEvent.LauncherTimings.JOB_ORCHESTRATED, metadata);
872906
}
873907

908+
private GobblinTrackingEvent createJobSkippedEvent() {
909+
return createGTE(TimingEvent.LauncherTimings.JOB_SKIPPED, Maps.newHashMap());
910+
}
911+
874912
private GobblinTrackingEvent createJobStartEvent() {
875913
return createGTE(TimingEvent.LauncherTimings.JOB_START, Maps.newHashMap());
876914
}
877915

878-
private GobblinTrackingEvent createJobSkippedEvent() {
916+
private GobblinTrackingEvent createJobSkippedTimeEvent() {
879917
return createGTE(TimingEvent.JOB_SKIPPED_TIME, Maps.newHashMap());
880918
}
881919

gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-api/src/main/pegasus/org/apache/gobblin/service/ExecutionStatus.pdl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,9 @@ enum ExecutionStatus {
4949
* Flow cancelled.
5050
*/
5151
CANCELLED
52+
53+
/**
54+
* Flow or job is skipped
55+
*/
56+
SKIPPED
5257
}

gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-api/src/main/snapshot/org.apache.gobblin.service.flowexecutions.snapshot.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"name" : "ExecutionStatus",
1414
"namespace" : "org.apache.gobblin.service",
1515
"doc" : "Execution status for a flow or job",
16-
"symbols" : [ "COMPILED", "PENDING", "PENDING_RETRY", "PENDING_RESUME", "ORCHESTRATED", "RUNNING", "COMPLETE", "FAILED", "CANCELLED" ],
16+
"symbols" : [ "COMPILED", "PENDING", "PENDING_RETRY", "PENDING_RESUME", "ORCHESTRATED", "RUNNING", "COMPLETE", "FAILED", "CANCELLED", "SKIPPED" ],
1717
"symbolDocs" : {
1818
"CANCELLED" : "Flow cancelled.",
1919
"COMPILED" : "Flow compiled to jobs.",
@@ -23,7 +23,8 @@
2323
"PENDING" : "Flow or job is in pending state.",
2424
"PENDING_RESUME" : "Flow or job is currently resuming.",
2525
"PENDING_RETRY" : "Flow or job is pending retry.",
26-
"RUNNING" : "Flow or job is currently executing"
26+
"RUNNING" : "Flow or job is currently executing.",
27+
"SKIPPED" : "Flow or job is skipped."
2728
}
2829
}, {
2930
"type" : "record",

gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-api/src/main/snapshot/org.apache.gobblin.service.flowstatuses.snapshot.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"name" : "ExecutionStatus",
1414
"namespace" : "org.apache.gobblin.service",
1515
"doc" : "Execution status for a flow or job",
16-
"symbols" : [ "COMPILED", "PENDING", "PENDING_RETRY", "PENDING_RESUME", "ORCHESTRATED", "RUNNING", "COMPLETE", "FAILED", "CANCELLED" ],
16+
"symbols" : [ "COMPILED", "PENDING", "PENDING_RETRY", "PENDING_RESUME", "ORCHESTRATED", "RUNNING", "COMPLETE", "FAILED", "CANCELLED", "SKIPPED" ],
1717
"symbolDocs" : {
1818
"CANCELLED" : "Flow cancelled.",
1919
"COMPILED" : "Flow compiled to jobs.",
@@ -23,7 +23,8 @@
2323
"PENDING" : "Flow or job is in pending state.",
2424
"PENDING_RESUME" : "Flow or job is currently resuming.",
2525
"PENDING_RETRY" : "Flow or job is pending retry.",
26-
"RUNNING" : "Flow or job is currently executing"
26+
"RUNNING" : "Flow or job is currently executing.",
27+
"SKIPPED" : "Flow or job is skipped."
2728
}
2829
}, {
2930
"type" : "record",

gobblin-runtime/src/main/java/org/apache/gobblin/service/monitoring/FlowStatusGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
@Slf4j
4242
public class FlowStatusGenerator {
4343
public static final List<String> FINISHED_STATUSES = Lists.newArrayList(ExecutionStatus.FAILED.name(),
44-
ExecutionStatus.COMPLETE.name(), ExecutionStatus.CANCELLED.name());
44+
ExecutionStatus.COMPLETE.name(), ExecutionStatus.CANCELLED.name(), ExecutionStatus.SKIPPED.name());
4545
public static final int MAX_LOOKBACK = 100;
4646

4747
private final JobStatusRetriever jobStatusRetriever;

gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagManagementStateStore.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public interface DagManagementStateStore {
9999
* {@link DagManagementStateStore#addDag}. This call is just an additional identifier which may be used
100100
* for DagNode level operations. In the future, it may be merged with checkpointDag.
101101
* @param dagNode dag node to be added
102-
* @param dagId dag id of the dag this dag node belongs to
103102
*/
104103
void updateDagNode(Dag.DagNode<JobExecutionPlan> dagNode) throws IOException;
105104

gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/DagUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ public static Set<DagNode<JobExecutionPlan>> getNext(Dag<JobExecutionPlan> dag)
164164
DagNode<JobExecutionPlan> node = nodesToExpand.poll();
165165
ExecutionStatus executionStatus = getExecutionStatus(node);
166166
boolean addFlag = true;
167-
if (executionStatus == PENDING || executionStatus == PENDING_RETRY || executionStatus == PENDING_RESUME) {
167+
if (executionStatus == PENDING || executionStatus == PENDING_RETRY || executionStatus == PENDING_RESUME ||
168+
executionStatus == SKIPPED) {
168169
//Add a node to be executed next, only if all of its parent nodes are COMPLETE.
169170
List<DagNode<JobExecutionPlan>> parentNodes = dag.getParents(node);
170171
for (DagNode<JobExecutionPlan> parentNode : parentNodes) {

gobblin-service/src/main/java/org/apache/gobblin/service/modules/orchestration/MySqlDagManagementStateStore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.apache.gobblin.service.modules.flowgraph.Dag;
4444
import org.apache.gobblin.service.modules.flowgraph.DagNodeId;
4545
import org.apache.gobblin.service.modules.spec.JobExecutionPlan;
46+
import org.apache.gobblin.service.monitoring.FlowStatusGenerator;
4647
import org.apache.gobblin.service.monitoring.JobStatus;
4748
import org.apache.gobblin.service.monitoring.JobStatusRetriever;
4849
import org.apache.gobblin.util.ConfigUtils;

0 commit comments

Comments
 (0)