public ImmutableFSJobCatalog(Config sysConfig, PathAlterationObserver observer, Optional<MetricContext> parentMetricContext, boolean instrumentationEnabled) throws IOException { super(Optional.of(LOGGER), parentMetricContext, instrumentationEnabled, Optional.of(sysConfig)); this.sysConfig = sysConfig; ConfigAccessor cfgAccessor = new ConfigAccessor(this.sysConfig); this.jobConfDirPath = cfgAccessor.getJobConfDirPath(); this.fs = cfgAccessor.getJobConfDirFileSystem(); this.loader = new PullFileLoader(jobConfDirPath, jobConfDirPath.getFileSystem(new Configuration()), cfgAccessor.getJobConfigurationFileExtensions(), PullFileLoader.DEFAULT_HOCON_PULL_FILE_EXTENSIONS); this.converter = new ImmutableFSJobCatalog.JobSpecConverter(this.jobConfDirPath, getInjectedExtension()); long pollingInterval = cfgAccessor.getPollingInterval(); if (pollingInterval == ConfigurationKeys.DISABLED_JOB_CONFIG_FILE_MONITOR_POLLING_INTERVAL) { this.pathAlterationDetector = null; } else { this.pathAlterationDetector = new PathAlterationObserverScheduler(pollingInterval); // If absent, the Optional object will be created automatically by addPathAlterationObserver Optional<PathAlterationObserver> observerOptional = Optional.fromNullable(observer); FSPathAlterationListenerAdaptor configFilelistener = new FSPathAlterationListenerAdaptor(this.jobConfDirPath, this.loader, this.sysConfig, this.listeners, this.converter); this.pathAlterationDetector.addPathAlterationObserver(configFilelistener, observerOptional, this.jobConfDirPath); } }
detector.addPathAlterationObserver(listener, Optional.<PathAlterationObserver>absent(), new Path(this.jobConfigDir.getPath())); try {
public ImmutableFSJobCatalog(Config sysConfig, PathAlterationObserver observer, Optional<MetricContext> parentMetricContext, boolean instrumentationEnabled) throws IOException { super(Optional.of(LOGGER), parentMetricContext, instrumentationEnabled, Optional.of(sysConfig)); this.sysConfig = sysConfig; ConfigAccessor cfgAccessor = new ConfigAccessor(this.sysConfig); this.jobConfDirPath = cfgAccessor.getJobConfDirPath(); this.fs = cfgAccessor.getJobConfDirFileSystem(); this.loader = new PullFileLoader(jobConfDirPath, jobConfDirPath.getFileSystem(new Configuration()), cfgAccessor.getJobConfigurationFileExtensions(), PullFileLoader.DEFAULT_HOCON_PULL_FILE_EXTENSIONS); this.converter = new ImmutableFSJobCatalog.JobSpecConverter(this.jobConfDirPath, getInjectedExtension()); long pollingInterval = cfgAccessor.getPollingInterval(); if (pollingInterval == ConfigurationKeys.DISABLED_JOB_CONFIG_FILE_MONITOR_POLLING_INTERVAL) { this.pathAlterationDetector = null; } else { this.pathAlterationDetector = new PathAlterationObserverScheduler(pollingInterval); // If absent, the Optional object will be created automatically by addPathAlterationObserver Optional<PathAlterationObserver> observerOptional = Optional.fromNullable(observer); FSPathAlterationListenerAdaptor configFilelistener = new FSPathAlterationListenerAdaptor(this.jobConfDirPath, this.loader, this.sysConfig, this.listeners, this.converter); this.pathAlterationDetector.addPathAlterationObserver(configFilelistener, observerOptional, this.jobConfDirPath); } }