use of co.cask.cdap.file.dropzone.polling.PollingServiceManager in project cdap-ingest by caskdata.
the class FileDropZoneMain method main.
public static void main(String[] args) throws Exception {
File configurationFile;
if (args.length == 0) {
LOG.info("Application started using default file: \"file-drop-zone.properties\"");
configurationFile = new File(FileDropZoneMain.class.getClassLoader().getResource("file-drop-zone.properties").getPath());
} else {
LOG.info("Application started using file: {}", args[0]);
configurationFile = new File(args[0]);
}
PollingServiceManager pollingServiceManager = new PollingServiceManager(configurationFile);
try {
pollingServiceManager.initManager();
pollingServiceManager.initObservers();
} catch (IOException e) {
LOG.error("Error during manager setup: {}", e);
return;
}
LOG.info("Starting monitor");
pollingServiceManager.startMonitor();
Runtime.getRuntime().addShutdownHook(new Thread(new FileDropZoneShutdownTask(pollingServiceManager)));
}
use of co.cask.cdap.file.dropzone.polling.PollingServiceManager in project cdap-ingest by caskdata.
the class FileDropZoneIT method fileDropZoneBasicIT.
@Test
public void fileDropZoneBasicIT() throws Exception {
final File configurationFile = getConfigFile();
PollingServiceManager pollingServiceManager = new PollingServiceManager(configurationFile);
pollingServiceManager.initManager();
Field monitor = pollingServiceManager.getClass().getDeclaredField("monitor");
monitor.setAccessible(true);
PollingService myMonitor = (PollingService) monitor.get(pollingServiceManager);
ObserverConfiguration observerConf = loadConfig(configurationFile);
PollingListener myPollingListener = new PollingListenerImpl(myMonitor, observerConf);
FileTailerMetricsProcessor metricsProcessor = getMetricsProcessor(observerConf);
Field metricsProcessorField = myPollingListener.getClass().getDeclaredField("metricsProcessor");
metricsProcessorField.setAccessible(true);
metricsProcessorField.set(myPollingListener, metricsProcessor);
myMonitor.registerDirMonitor(observerConf.getPipeConf().getSourceConfiguration().getWorkDir(), myPollingListener);
createFile(observerConf.getPipeConf().getSourceConfiguration().getWorkDir().getAbsolutePath());
long start = System.currentTimeMillis();
pollingServiceManager.startMonitor();
Thread.sleep(SLEEP_TIME);
pollingServiceManager.stopMonitor();
checkDeliveredEvents(start, System.currentTimeMillis());
Assert.assertEquals(read.get(), ingest.get());
}
Aggregations