@Test public void testWatchMultipleDirectories() throws Exception { final File testDir = this.tempDir.newFolder(); final String filePrefix = "test"; final File testDir2 = this.tempDir.newFolder(); final String filePrefix2 = "2ndTest"; SingerLogConfig config = createSingerLogConfig(filePrefix, testDir.getAbsolutePath()); SingerLogConfig config2 = createSingerLogConfig(filePrefix2, testDir2.getAbsolutePath()); config.setLogStreamRegex("test.tmp"); config2.setLogStreamRegex("2ndTest.tmp"); LogStream toMonitor = new LogStream(new SingerLog(config), filePrefix); LogStream toMonitor2 = new LogStream(new SingerLog(config2), filePrefix2); FileSystemMonitor t = new FileSystemMonitor(Arrays.asList(toMonitor, toMonitor2), "testWatchMultipleDirectories"); t.start(); Thread.sleep(FILE_EVENT_WAIT_TIME_MS); verifyFiles(testDir.list(), toMonitor); verifyFiles(testDir2.list(), toMonitor2); int NUM_FILES = 10; File[] created = createTestLogStreamFiles(testDir, "test.tmp", NUM_FILES); Thread.sleep(FILE_EVENT_WAIT_TIME_MS); verifyFiles(testDir.list(), toMonitor); verifyFiles(testDir2.list(), toMonitor2); int NUM_FILES_2 = 20; File[] created2 = createTestLogStreamFiles(testDir2, "2ndTest.tmp", NUM_FILES_2); Thread.sleep(FILE_EVENT_WAIT_TIME_MS); verifyFiles(testDir.list(), toMonitor); verifyFiles(testDir2.list(), toMonitor2); for (int i = 0; i < NUM_FILES_2 / 2; i++) { created2[i].delete(); } Thread.sleep(FILE_EVENT_WAIT_TIME_MS); verifyFiles(testDir.list(), toMonitor); verifyFiles(testDir2.list(), toMonitor2); for (int i = 1; i < NUM_FILES; i++) { created[i].delete(); } Thread.sleep(FILE_EVENT_WAIT_TIME_MS); verifyFiles(testDir.list(), toMonitor); verifyFiles(testDir2.list(), toMonitor2); }
public void start() { if(thread == null) { thread = new Thread(this); thread.setName("FileSystemMonitor-" + name); thread.start(); } }
FileSystemMonitor implements Runnable { public void start() { if(thread == null) { thread = new Thread(this); thread.setName("FileSystemMonitor-" + name); thread.start(); } } }
FileSystemMonitor implements Runnable { public void start() { if(thread == null) { thread = new Thread(this); thread.setName("FileSystemMonitor-" + name); thread.start(); } } FileSystemMonitor(String name);  FileSystemMonitor(SingerConfig singerConfig, String name);  FileSystemMonitor(Collection<LogStream> streamsToWatch, String name); }
FileSystemMonitor implements Runnable { public void start() { if(thread == null) { thread = new Thread(this); thread.setName("FileSystemMonitor-" + name); thread.start(); } } FileSystemMonitor(String name);  FileSystemMonitor(SingerConfig singerConfig, String name);  FileSystemMonitor(Collection<LogStream> streamsToWatch, String name); void start(); void stop(); void join(); void registerPath(Path logDir); @VisibleForTesting void processFileSystemEvents(); void updateAllDirectories(); boolean isRunning(); @Override void run(); void destroy(); }
FileSystemMonitor implements Runnable { public void start() { if(thread == null) { thread = new Thread(this); thread.setName("FileSystemMonitor-" + name); thread.start(); } } FileSystemMonitor(String name);  FileSystemMonitor(SingerConfig singerConfig, String name);  FileSystemMonitor(Collection<LogStream> streamsToWatch, String name); void start(); void stop(); void join(); void registerPath(Path logDir); @VisibleForTesting void processFileSystemEvents(); void updateAllDirectories(); boolean isRunning(); @Override void run(); void destroy();  }