public static ConfigAccessor createFromGlobalConfig(Config cfg) { Config localCfg = cfg.hasPath(CONFIG_PREFIX) ? cfg.getConfig(CONFIG_PREFIX) : ConfigFactory.empty(); return new ConfigAccessor(localCfg); } }
public DefaultGobblinInstanceDriverImpl(String instanceName, Configurable sysConfig, JobCatalog jobCatalog, JobSpecScheduler jobScheduler, JobExecutionLauncher jobLauncher, Optional<MetricContext> baseMetricContext, Optional<Logger> log, SharedResourcesBroker<GobblinScopeTypes> instanceBroker) { Preconditions.checkNotNull(jobCatalog); Preconditions.checkNotNull(jobScheduler); Preconditions.checkNotNull(jobLauncher); Preconditions.checkNotNull(sysConfig); _instanceName = instanceName; _log = log.or(LoggerFactory.getLogger(getClass())); _metricCtx = baseMetricContext.or(constructMetricContext(sysConfig, _log)); _instrumentationEnabled = null != _metricCtx && GobblinMetrics.isEnabled(sysConfig.getConfig()); _jobCatalog = jobCatalog; _jobScheduler = jobScheduler; _jobLauncher = jobLauncher; _sysConfig = sysConfig; _instanceCfg = ConfigAccessor.createFromGlobalConfig(_sysConfig.getConfig()); _callbacksDispatcher = new JobLifecycleListenersList(_jobCatalog, _jobScheduler, _log); _instanceBroker = instanceBroker; _metrics = new StandardMetrics(this); }
/** Config accessor from a no namespaced typesafe config. */ public ConfigAccessor(Config cfg) { Config effectiveCfg = cfg.withFallback(getDefaultConfig().getConfig(CONFIG_PREFIX)); this.startTimeoutMs = effectiveCfg.getLong(START_TIMEOUT_MS); this.shutdownTimeoutMs = effectiveCfg.getLong(SHUTDOWN_TIMEOUT_MS); }
@Override protected void startUp() throws Exception { getLog().info("Starting driver ..."); if (null != _subservices) { getLog().info("Starting subservices"); _subservices.startAsync(); _subservices.awaitHealthy(getInstanceCfg().getStartTimeoutMs(), TimeUnit.MILLISECONDS); getLog().info("All subservices have been started."); } else { getLog().info("No subservices found."); } super.startUp(); }
@Override protected void shutDown() throws Exception { getLog().info("Shutting down driver ..."); super.shutDown(); if (null != _subservices) { getLog().info("Shutting down subservices ..."); _subservices.stopAsync(); _subservices.awaitStopped(getInstanceCfg().getShutdownTimeoutMs(), TimeUnit.MILLISECONDS); getLog().info("All subservices have been shutdown."); } }