Search in sources :

Example 16 with FormatterBuilder

use of org.voltdb.importer.formatter.FormatterBuilder in project voltdb by VoltDB.

the class ImportProcessor method addProcessorConfig.

private void addProcessorConfig(ImportConfiguration config, Map<String, AbstractImporterFactory> importerModules) {
    Properties properties = config.getmoduleProperties();
    String module = properties.getProperty(ImportDataProcessor.IMPORT_MODULE);
    assert (module != null);
    String[] attrs = module.split("\\|");
    String bundleJar = attrs[1];
    FormatterBuilder formatterBuilder = config.getFormatterBuilder();
    try {
        ImporterWrapper wrapper = m_importers.get(bundleJar);
        if (wrapper == null) {
            AbstractImporterFactory importFactory = importerModules.get(bundleJar);
            wrapper = new ImporterWrapper(importFactory);
            String name = wrapper.getImporterType();
            if (name == null || name.trim().isEmpty()) {
                throw new RuntimeException("Importer must implement and return a valid unique name.");
            }
            m_importers.put(bundleJar, wrapper);
        }
        wrapper.configure(properties, formatterBuilder);
    } catch (Throwable t) {
        m_logger.error("Failed to configure import handler for " + bundleJar, t);
        Throwables.propagate(t);
    }
}
Also used : Properties(java.util.Properties) FormatterBuilder(org.voltdb.importer.formatter.FormatterBuilder)

Aggregations

Properties (java.util.Properties)16 FormatterBuilder (org.voltdb.importer.formatter.FormatterBuilder)16 Test (org.junit.Test)14 ServiceReference (org.osgi.framework.ServiceReference)14 AbstractFormatterFactory (org.voltdb.importer.formatter.AbstractFormatterFactory)14 Formatter (org.voltdb.importer.formatter.Formatter)13 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ImporterConfig (org.voltdb.importer.ImporterConfig)1 VoltCSVFormatterFactory (org.voltdb.importer.formatter.builtin.VoltCSVFormatterFactory)1