gobblin-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (GOBBLIN-795) Make JobCatalog optional for FsJobConfigurationManager
Date Wed, 05 Jun 2019 18:10:01 GMT

     [ https://issues.apache.org/jira/browse/GOBBLIN-795?focusedWorklogId=254533&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-254533
]

ASF GitHub Bot logged work on GOBBLIN-795:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Jun/19 18:09
            Start Date: 05/Jun/19 18:09
    Worklog Time Spent: 10m 
      Work Description: htran1 commented on pull request #2662: GOBBLIN-795: Make JobCatalog
optional for FsJobConfigurationManager
URL: https://github.com/apache/incubator-gobblin/pull/2662#discussion_r290866472
 
 

 ##########
 File path: gobblin-cluster/src/main/java/org/apache/gobblin/cluster/FsJobConfigurationManager.java
 ##########
 @@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.gobblin.cluster;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang3.reflect.ConstructorUtils;
+import org.apache.commons.lang3.tuple.Pair;
+
+import com.google.common.base.Optional;
+import com.google.common.eventbus.EventBus;
+import com.typesafe.config.Config;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.apache.gobblin.runtime.api.FsSpecConsumer;
+import org.apache.gobblin.runtime.api.JobSpec;
+import org.apache.gobblin.runtime.api.MutableJobCatalog;
+import org.apache.gobblin.runtime.api.SpecConsumer;
+import org.apache.gobblin.runtime.api.SpecExecutor;
+import org.apache.gobblin.util.ClassAliasResolver;
+import org.apache.gobblin.util.ConfigUtils;
+import org.apache.gobblin.util.ExecutorsUtils;
+
+
+/**
+ * A {@link JobConfigurationManager} that reads {@link JobSpec}s from a source path on a
+ * {@link org.apache.hadoop.fs.FileSystem} and posts them to an {@link EventBus}.
+ * The {@link FsJobConfigurationManager} has an underlying {@link FsSpecConsumer} that periodically
reads the
+ * {@link JobSpec}s from the filesystem and posts an appropriate JobConfigArrivalEvent with
the job configuration to
+ * the EventBus for consumption by the listeners.
+ */
+@Slf4j
+public class FsJobConfigurationManager extends JobConfigurationManager {
+  private static final long DEFAULT_JOB_SPEC_REFRESH_INTERVAL = 60;
+
+  private final long refreshIntervalInSeconds;
+
+  private final ScheduledExecutorService fetchJobSpecExecutor;
+
+  protected final SpecConsumer _specConsumer;
+
+  private final ClassAliasResolver<SpecConsumer> aliasResolver;
+
+  private final Optional<MutableJobCatalog> _jobCatalogOptional;
+
+  public FsJobConfigurationManager(EventBus eventBus, Config config) {
+    this(eventBus, config, null);
+  }
+
+  public FsJobConfigurationManager(EventBus eventBus, Config config, MutableJobCatalog jobCatalog)
{
+    super(eventBus, config);
+    this._jobCatalogOptional = jobCatalog != null ? Optional.of(jobCatalog) : Optional.absent();
+    this.refreshIntervalInSeconds = ConfigUtils.getLong(config, GobblinClusterConfigurationKeys.JOB_SPEC_REFRESH_INTERVAL,
+        DEFAULT_JOB_SPEC_REFRESH_INTERVAL);
+
+    this.fetchJobSpecExecutor = Executors.newSingleThreadScheduledExecutor(
+        ExecutorsUtils.newThreadFactory(Optional.of(log), Optional.of("FetchJobSpecExecutor")));
+
+    this.aliasResolver = new ClassAliasResolver<>(SpecConsumer.class);
+    try {
+      String specConsumerClassName = GobblinClusterConfigurationKeys.DEFAULT_SPEC_CONSUMER_CLASS;
+      if (config.hasPath(GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY)) {
+        specConsumerClassName = config.getString(GobblinClusterConfigurationKeys.SPEC_CONSUMER_CLASS_KEY);
+      }
+      log.info("Using SpecConsumer ClassNameclass name/alias " + specConsumerClassName);
+      this._specConsumer = (SpecConsumer) ConstructorUtils
+          .invokeConstructor(Class.forName(this.aliasResolver.resolve(specConsumerClassName)),
config);
+    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException |
InstantiationException
+        | ClassNotFoundException e) {
+      throw new RuntimeException(e);
+    }
+  }
+
+  protected void startUp() throws Exception{
+    super.startUp();
+    // Schedule the job config fetch task
+    this.fetchJobSpecExecutor.scheduleAtFixedRate(new Runnable() {
+      @Override
+      public void run() {
+        try {
+          fetchJobSpecs();
+        } catch (InterruptedException | ExecutionException e) {
+          log.error("Failed to fetch job specs", e);
 
 Review comment:
   Can you try a test with error to make sure  the exception is detected and we don't just
lose the scheduled execution silently?
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 254533)
    Time Spent: 0.5h  (was: 20m)

> Make JobCatalog optional for FsJobConfigurationManager
> ------------------------------------------------------
>
>                 Key: GOBBLIN-795
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-795
>             Project: Apache Gobblin
>          Issue Type: Improvement
>          Components: gobblin-cluster
>    Affects Versions: 0.15.0
>            Reporter: Sudarshan Vasudevan
>            Assignee: Hung Tran
>            Priority: Major
>             Fix For: 0.15.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Existing behavior enforces the need to provide a JobCatalog. We relax this requirement
and allow the JobConfigurationManager to bootstrap the gobblin cluster with job configs from
a configured location (as opposed to bootstrapping from a JobCatalog). 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message