Search in sources :

Example 1 with PollingService

use of co.cask.cdap.file.dropzone.polling.PollingService 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());
}
Also used : PollingListenerImpl(co.cask.cdap.file.dropzone.polling.PollingListenerImpl) Field(java.lang.reflect.Field) ObserverConfiguration(co.cask.cdap.file.dropzone.config.ObserverConfiguration) PollingListener(co.cask.cdap.file.dropzone.polling.PollingListener) PollingService(co.cask.cdap.file.dropzone.polling.PollingService) File(java.io.File) PollingServiceManager(co.cask.cdap.file.dropzone.polling.PollingServiceManager) FileTailerMetricsProcessor(co.cask.cdap.filetailer.metrics.FileTailerMetricsProcessor) Test(org.junit.Test)

Aggregations

ObserverConfiguration (co.cask.cdap.file.dropzone.config.ObserverConfiguration)1 PollingListener (co.cask.cdap.file.dropzone.polling.PollingListener)1 PollingListenerImpl (co.cask.cdap.file.dropzone.polling.PollingListenerImpl)1 PollingService (co.cask.cdap.file.dropzone.polling.PollingService)1 PollingServiceManager (co.cask.cdap.file.dropzone.polling.PollingServiceManager)1 FileTailerMetricsProcessor (co.cask.cdap.filetailer.metrics.FileTailerMetricsProcessor)1 File (java.io.File)1 Field (java.lang.reflect.Field)1 Test (org.junit.Test)1