use of co.cask.cdap.file.dropzone.polling.PollingListener 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