@Override public void run() { while (fileWatcher.processEvents()) { } } });
private void watchFiles(StreamCatalogService catalogService) { String customProcessorWatchPath = (String) config.get(com.hortonworks.streamline.streams.common.Constants.CONFIG_CP_WATCH_PATH); String customProcessorUploadFailPath = (String) config.get(com.hortonworks.streamline.streams.common.Constants.CONFIG_CP_UPLOAD_FAIL_PATH); String customProcessorUploadSuccessPath = (String) config.get(com.hortonworks.streamline.streams.common.Constants.CONFIG_CP_UPLOAD_SUCCESS_PATH); if (customProcessorWatchPath == null || customProcessorUploadFailPath == null || customProcessorUploadSuccessPath == null) { return; } FileEventHandler customProcessorUploadHandler = new CustomProcessorUploadHandler(customProcessorWatchPath, customProcessorUploadFailPath, customProcessorUploadSuccessPath, catalogService); List<FileEventHandler> fileEventHandlers = new ArrayList<>(); fileEventHandlers.add(customProcessorUploadHandler); final FileWatcher fileWatcher = new FileWatcher(fileEventHandlers); fileWatcher.register(); Thread thread = new Thread(new Runnable() { @Override public void run() { while (fileWatcher.processEvents()) { } } }); thread.start(); }