@Test(dependsOnMethods = {"testLoadJobConfigsForCommonPropsFile", "testloadGenericJobConfig"}) public void testPathAlterationObserver() throws Exception { PathAlterationObserverScheduler monitor = new PathAlterationObserverScheduler(1000); final Set<Path> fileAltered = Sets.newHashSet(); final Semaphore semaphore = new Semaphore(0); PathAlterationListener listener = new PathAlterationListenerAdaptor() { @Override public void onFileCreate(Path path) { fileAltered.add(path); semaphore.release(); } @Override public void onFileChange(Path path) { fileAltered.add(path); semaphore.release(); } }; SchedulerUtils.addPathAlterationObserver(monitor, listener, new Path(this.jobConfigDir.getPath())); try { monitor.start(); Thread.sleep(1000); File jobConfigFile = new File(this.subDir11, "test111.pull"); Files.touch(jobConfigFile); File commonPropsFile = new File(this.subDir1, "test.properties"); Files.touch(commonPropsFile); File newJobConfigFile = new File(this.subDir11, "test112.pull"); Files.append("k1=v1", newJobConfigFile, ConfigurationKeys.DEFAULT_CHARSET_ENCODING); semaphore.acquire(3); Assert.assertEquals(fileAltered.size(), 3); Assert.assertTrue(fileAltered.contains(new Path("file:" + jobConfigFile))); Assert.assertTrue(fileAltered.contains(new Path("file:" + commonPropsFile))); Assert.assertTrue(fileAltered.contains(new Path("file:" + newJobConfigFile))); } finally { monitor.stop(); } }
public static void addPathAlterationObserver(PathAlterationObserverScheduler monitor, PathAlterationListener listener, Path rootDirPath) throws IOException { PathAlterationObserver observer = new PathAlterationObserver(rootDirPath); observer.addListener(listener); monitor.addObserver(observer); }
SchedulerUtils { public static void addPathAlterationObserver(PathAlterationObserverScheduler monitor, PathAlterationListener listener, Path rootDirPath) throws IOException { PathAlterationObserver observer = new PathAlterationObserver(rootDirPath); observer.addListener(listener); monitor.addObserver(observer); } }
SchedulerUtils { public static void addPathAlterationObserver(PathAlterationObserverScheduler monitor, PathAlterationListener listener, Path rootDirPath) throws IOException { PathAlterationObserver observer = new PathAlterationObserver(rootDirPath); observer.addListener(listener); monitor.addObserver(observer); }  }
SchedulerUtils { public static void addPathAlterationObserver(PathAlterationObserverScheduler monitor, PathAlterationListener listener, Path rootDirPath) throws IOException { PathAlterationObserver observer = new PathAlterationObserver(rootDirPath); observer.addListener(listener); monitor.addObserver(observer); }  static List<Properties> loadGenericJobConfigs(Properties sysProps, JobSpecResolver resolver); static List<Properties> loadGenericJobConfigs(Properties sysProps, Path commonPropsPath,
      Path jobConfigPathDir, JobSpecResolver resolver); static Properties loadGenericJobConfig(Properties sysProps, Path jobConfigPath, Path jobConfigPathDir,
      JobSpecResolver resolver); static void addPathAlterationObserver(PathAlterationObserverScheduler monitor, PathAlterationListener listener,
      Path rootDirPath); }
SchedulerUtils { public static void addPathAlterationObserver(PathAlterationObserverScheduler monitor, PathAlterationListener listener, Path rootDirPath) throws IOException { PathAlterationObserver observer = new PathAlterationObserver(rootDirPath); observer.addListener(listener); monitor.addObserver(observer); }  static List<Properties> loadGenericJobConfigs(Properties sysProps, JobSpecResolver resolver); static List<Properties> loadGenericJobConfigs(Properties sysProps, Path commonPropsPath,
      Path jobConfigPathDir, JobSpecResolver resolver); static Properties loadGenericJobConfig(Properties sysProps, Path jobConfigPath, Path jobConfigPathDir,
      JobSpecResolver resolver); static void addPathAlterationObserver(PathAlterationObserverScheduler monitor, PathAlterationListener listener,
      Path rootDirPath); static final String JOB_PROPS_FILE_EXTENSION; }