Repository: incubator-gobblin Updated Branches: refs/heads/master 7af61741c -> a66205a7e
[GOBBLIN-497] GobblinHelixJobScheduler should wait until service is fully up before any job scheduling Closes #2368 from yukuai518/npe Project: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/commit/a66205a7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/tree/a66205a7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/diff/a66205a7 Branch: refs/heads/master Commit: a66205a7e169c6a031ea5d006af6330e0839918d Parents: 7af6174 Author: Kuai Yu <[email protected]> Authored: Mon May 21 16:35:00 2018 -0700 Committer: Abhishek Tiwari <[email protected]> Committed: Mon May 21 16:35:00 2018 -0700 ---------------------------------------------------------------------- .../org/apache/gobblin/cluster/GobblinHelixJobScheduler.java | 7 +++++++ 1 file changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/a66205a7/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 e539273..fac7242 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 @@ -88,6 +88,7 @@ public class GobblinHelixJobScheduler extends JobScheduler implements StandardMe private final MutableJobCatalog jobCatalog; private final MetricContext metricContext; private final Metrics metrics; + private boolean startServicesCompleted; public GobblinHelixJobScheduler(Properties properties, HelixManager helixManager, EventBus eventBus, Path appWorkDir, List<? extends Tag<?>> metadataTags, SchedulerService schedulerService, @@ -102,6 +103,7 @@ public class GobblinHelixJobScheduler extends JobScheduler implements StandardMe this.jobCatalog = jobCatalog; this.metricContext = Instrumented.getMetricContext(new org.apache.gobblin.configuration.State(properties), this.getClass()); this.metrics = new Metrics(this.metricContext); + this.startServicesCompleted = false; } @Nonnull @@ -253,11 +255,16 @@ public class GobblinHelixJobScheduler extends JobScheduler implements StandardMe protected void startUp() throws Exception { this.eventBus.register(this); super.startUp(); + this.startServicesCompleted = true; } @Override public void scheduleJob(Properties jobProps, JobListener jobListener) throws JobException { try { + while (!startServicesCompleted) { + LOGGER.info("{} service is not fully up, waiting here...", this.getClass().getName()); + Thread.sleep(1000); + } scheduleJob(jobProps, jobListener, Maps.newHashMap(), GobblinHelixJob.class); } catch (Exception e) { throw new JobException("Failed to schedule job " + jobProps.getProperty(ConfigurationKeys.JOB_NAME_KEY), e);
