Repository: incubator-gobblin Updated Branches: refs/heads/master 85202fab2 -> dcdf7cacd
[GOBBLIN-550] Fix the alwaysDelete issue when runtime exception is thrown Closes #2411 from yukuai518/chen Project: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/commit/dcdf7cac Tree: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/tree/dcdf7cac Diff: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/diff/dcdf7cac Branch: refs/heads/master Commit: dcdf7cacd678854951bc007656bc6bed5c29dc88 Parents: 85202fa Author: Kuai Yu <[email protected]> Authored: Wed Aug 1 13:21:36 2018 -0700 Committer: Hung Tran <[email protected]> Committed: Wed Aug 1 13:21:36 2018 -0700 ---------------------------------------------------------------------- .../cluster/GobblinHelixJobScheduler.java | 25 +++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/dcdf7cac/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobScheduler.java ---------------------------------------------------------------------- diff --git a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobScheduler.java b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobScheduler.java index 3f53c23..e29fe61 100644 --- a/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobScheduler.java +++ b/gobblin-cluster/src/main/java/org/apache/gobblin/cluster/GobblinHelixJobScheduler.java @@ -402,8 +402,20 @@ public class GobblinHelixJobScheduler extends JobScheduler implements StandardMe this.creationTimeInMillis = System.currentTimeMillis(); } + private void deleteJobSpec(boolean alwaysDelete, boolean isDeleted) { + if (alwaysDelete && !isDeleted) { + try { + GobblinHelixJobScheduler.this.jobCatalog.remove(new URI(jobUri)); + } catch (URISyntaxException e) { + LOGGER.error("Always delete " + jobUri + ". Failed to remove job with bad uri " + jobUri, e); + } + } + } + @Override public void run() { + boolean alwaysDelete = PropertiesUtils + .getPropAsBoolean(this.jobConfig, GobblinClusterConfigurationKeys.JOB_ALWAYS_DELETE, "false"); boolean isDeleted = false; try { ((MetricsTrackingListener)jobListener).metrics.updateTimeBeforeJobLaunching(this.jobConfig); @@ -420,16 +432,11 @@ public class GobblinHelixJobScheduler extends JobScheduler implements StandardMe } } } catch (JobException je) { - boolean alwaysDelete = PropertiesUtils - .getPropAsBoolean(this.jobConfig, GobblinClusterConfigurationKeys.JOB_ALWAYS_DELETE, "false"); - if (alwaysDelete && !isDeleted) { - try { - GobblinHelixJobScheduler.this.jobCatalog.remove(new URI(jobUri)); - } catch (URISyntaxException e) { - LOGGER.error("Always delete " + jobUri + ". Failed to remove job with bad uri " + jobUri, e); - } - } + deleteJobSpec(alwaysDelete, isDeleted); LOGGER.error("Failed to run job " + this.jobConfig.getProperty(ConfigurationKeys.JOB_NAME_KEY), je); + } catch (Exception e) { + deleteJobSpec(alwaysDelete, isDeleted); + throw e; } } }
