@Override public void run() { if (!running) { return; } for (final PathAlterationObserver observer : observers) { try { observer.checkAndNotify(); } catch (IOException ioe) { LOGGER.error("Path alteration detector error.", ioe); } } }
/** * Check whether the file and its chlidren have been created, modified or deleted. */ public void checkAndNotify() throws IOException { /* fire onStart() */ for (final PathAlterationListener listener : listeners.values()) { listener.onStart(this); } /* fire directory/file events */ final Path rootPath = rootEntry.getPath(); if (fs.exists(rootPath)) { // Current existed. checkAndNotify(rootEntry, rootEntry.getChildren(), listPaths(rootPath)); } else if (rootEntry.isExists()) { // Existed before and not existed now. checkAndNotify(rootEntry, rootEntry.getChildren(), EMPTY_PATH_ARRAY); } else { // Didn't exist and still doesn't } /* fire onStop() */ for (final PathAlterationListener listener : listeners.values()) { listener.onStop(this); } }
checkAndNotify(previousEntry, previousEntry.getChildren(), listPaths(currentPaths[c])); current[c] = previousEntry; c++; } else { checkAndNotify(previousEntry, previousEntry.getChildren(), EMPTY_PATH_ARRAY); doDelete(previousEntry);
observer.checkAndNotify(); Assert.assertTrue(specs.containsKey(js1_1.getUri())); JobSpec js1_1_notified = specs.get(js1_1.getUri()); observer.checkAndNotify(); Assert.assertTrue(specs.containsKey(js1_2.getUri())); JobSpec js1_2_notified = specs.get(js1_2.getUri()); observer.checkAndNotify(); Assert.assertTrue(specs.containsKey(js2.getUri())); JobSpec js2_notified = specs.get(js2.getUri()); observer.checkAndNotify(); Assert.assertFalse(specs.containsKey(js2.getUri())); observer.checkAndNotify(); Assert.assertTrue(specs.containsKey(js3.getUri())); JobSpec js3_notified = specs.get(js3.getUri());
@Override public void run() { if (!running) { return; } for (final PathAlterationObserver observer : observers) { try { observer.checkAndNotify(); } catch (IOException ioe) { LOGGER.error("Path alteration detector error.", ioe); } } }
/** * Check whether the file and its chlidren have been created, modified or deleted. */ public void checkAndNotify() throws IOException { /* fire onStart() */ for (final PathAlterationListener listener : listeners.values()) { listener.onStart(this); } /* fire directory/file events */ final Path rootPath = rootEntry.getPath(); if (fs.exists(rootPath)) { // Current existed. checkAndNotify(rootEntry, rootEntry.getChildren(), listPaths(rootPath)); } else if (rootEntry.isExists()) { // Existed before and not existed now. checkAndNotify(rootEntry, rootEntry.getChildren(), EMPTY_PATH_ARRAY); } else { // Didn't exist and still doesn't } /* fire onStop() */ for (final PathAlterationListener listener : listeners.values()) { listener.onStop(this); } }
checkAndNotify(previousEntry, previousEntry.getChildren(), listPaths(currentPaths[c])); current[c] = previousEntry; c++; } else { checkAndNotify(previousEntry, previousEntry.getChildren(), EMPTY_PATH_ARRAY); doDelete(previousEntry);