@Test public void testRemoveFiles() throws Exception { final File testDir = this.tempDir.newFolder(); final String filePrefix = "test.tmp"; SingerLogConfig config = createSingerLogConfig(filePrefix, testDir.getAbsolutePath()); config.setLogStreamRegex("test.tmp"); LogStream toMonitor = LogStreamManager.createNewLogStream(new SingerLog(config), filePrefix); FileSystemMonitor t = new FileSystemMonitor(Arrays.asList(toMonitor), "testRemoveFiles"); verifyFiles(testDir.list(), toMonitor); final int NUM_FILES = 10; File[] created = createTestLogStreamFiles(testDir, "test.tmp", NUM_FILES); t.start(); Thread.sleep(FILE_EVENT_WAIT_TIME_MS); verifyFiles(testDir.list(), toMonitor); int FIRST_HALF = NUM_FILES / 2; for (int i = 1; i < FIRST_HALF + 1; i++) { created[i].delete(); } Thread.sleep(FILE_EVENT_WAIT_TIME_MS); verifyFiles(testDir.list(), toMonitor); for (int i = 1; i < FIRST_HALF + 1; i++) { String s = created[i].getName(); assertFalse("deleted files shouldn't be in there", toMonitor.containsFile(s)); } }
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();  }