Search in sources :

Example 1 with ObserverConfiguration

use of co.cask.cdap.file.dropzone.config.ObserverConfiguration in project cdap-ingest by caskdata.

the class FileDropZoneIT method loadConfig.

private ObserverConfiguration loadConfig(File file) throws ConfigurationLoadingException {
    ConfigurationLoader loader = new ConfigurationLoaderImpl();
    Configuration configuration = loader.load(file);
    List<ObserverConfiguration> observerConfig = new FileDropZoneConfigurationImpl(configuration.getProperties()).getObserverConfiguration();
    return observerConfig.get(0);
}
Also used : Configuration(co.cask.cdap.filetailer.config.Configuration) ObserverConfiguration(co.cask.cdap.file.dropzone.config.ObserverConfiguration) ObserverConfiguration(co.cask.cdap.file.dropzone.config.ObserverConfiguration) ConfigurationLoaderImpl(co.cask.cdap.filetailer.config.ConfigurationLoaderImpl) ConfigurationLoader(co.cask.cdap.filetailer.config.ConfigurationLoader) FileDropZoneConfigurationImpl(co.cask.cdap.file.dropzone.config.FileDropZoneConfigurationImpl)

Example 2 with ObserverConfiguration

use of co.cask.cdap.file.dropzone.config.ObserverConfiguration in project cdap-ingest by caskdata.

the class FileDropZoneIT method deleteTestDir.

private void deleteTestDir() throws Exception {
    File configFile = getConfigFile();
    ObserverConfiguration observerConfiguration = loadConfig(configFile);
    File workDir = observerConfiguration.getPipeConf().getSourceConfiguration().getWorkDir();
    FileUtils.deleteDirectory(workDir);
    File daemonDir = observerConfiguration.getPipeConf().getDaemonDir();
    FileUtils.deleteDirectory(daemonDir);
}
Also used : ObserverConfiguration(co.cask.cdap.file.dropzone.config.ObserverConfiguration) File(java.io.File)

Example 3 with ObserverConfiguration

use of co.cask.cdap.file.dropzone.config.ObserverConfiguration 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)3 File (java.io.File)2 FileDropZoneConfigurationImpl (co.cask.cdap.file.dropzone.config.FileDropZoneConfigurationImpl)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 Configuration (co.cask.cdap.filetailer.config.Configuration)1 ConfigurationLoader (co.cask.cdap.filetailer.config.ConfigurationLoader)1 ConfigurationLoaderImpl (co.cask.cdap.filetailer.config.ConfigurationLoaderImpl)1 FileTailerMetricsProcessor (co.cask.cdap.filetailer.metrics.FileTailerMetricsProcessor)1 Field (java.lang.reflect.Field)1 Test (org.junit.Test)1