Search in sources :

Example 1 with ImportConfiguration

use of org.voltdb.utils.CatalogUtil.ImportConfiguration in project voltdb by VoltDB.

the class ImportProcessor method setProcessorConfig.

@Override
public void setProcessorConfig(Map<String, ImportConfiguration> config, final Map<String, AbstractImporterFactory> importerModules) {
    for (String configName : config.keySet()) {
        ImportConfiguration importConfig = config.get(configName);
        addProcessorConfig(importConfig, importerModules);
    }
}
Also used : ImportConfiguration(org.voltdb.utils.CatalogUtil.ImportConfiguration)

Example 2 with ImportConfiguration

use of org.voltdb.utils.CatalogUtil.ImportConfiguration in project voltdb by VoltDB.

the class ImportManager method discoverConfigsAndLoadBundles.

/**
     * Parses importer configs and loads the bundle needed for importer into memory. Updates
     * mapping of active importer bundle to the bundle jar needed by the impoter
     * @param catalogContext
     */
private void discoverConfigsAndLoadBundles(CatalogContext catalogContext) {
    m_configsForProcessor.clear();
    for (String configName : m_processorConfig.keySet()) {
        ImportConfiguration importConfig = m_processorConfig.get(configName);
        Properties properties = importConfig.getmoduleProperties();
        String importBundleJar = properties.getProperty(ImportDataProcessor.IMPORT_MODULE);
        Preconditions.checkNotNull(importBundleJar, "Import source is undefined or custom import plugin class missing.");
        String procedure = properties.getProperty(ImportDataProcessor.IMPORT_PROCEDURE);
        //TODO: If processors is a list dont start till all procedures exists.
        Procedure catProc = catalogContext.procedures.get(procedure);
        if (catProc == null) {
            catProc = catalogContext.m_defaultProcs.checkForDefaultProcedure(procedure);
        }
        if (catProc == null) {
            importLog.info("Importer " + configName + " Procedure " + procedure + " is missing will disable this importer until the procedure becomes available.");
            continue;
        }
        if (loadImporterBundle(properties)) {
            m_configsForProcessor.put(configName, importConfig);
        }
    }
    if (!m_configsForProcessor.isEmpty()) {
        importLog.info("Loaded importer modules: " + m_loadedBundles.keySet() + ", types: " + m_importersByType.keySet());
    }
}
Also used : Procedure(org.voltdb.catalog.Procedure) ImportConfiguration(org.voltdb.utils.CatalogUtil.ImportConfiguration) Properties(java.util.Properties)

Example 3 with ImportConfiguration

use of org.voltdb.utils.CatalogUtil.ImportConfiguration in project voltdb by VoltDB.

the class ImportManager method create.

/**
     * This creates a import connector from configuration provided.
     * @param myHostId
     * @param catalogContext
     */
private synchronized void create(int myHostId, CatalogContext catalogContext) {
    try {
        ImportType importElement = catalogContext.getDeployment().getImport();
        if (importElement == null || importElement.getConfiguration().isEmpty()) {
            return;
        }
        initializeChannelDistributer();
        final String clusterTag = m_distributer.getClusterTag();
        ImportDataProcessor newProcessor = new ImportProcessor(myHostId, m_distributer, m_statsCollector, clusterTag);
        m_processorConfig = CatalogUtil.getImportProcessorConfig(catalogContext.getDeployment().getImport());
        m_formatterFactories.clear();
        for (ImportConfiguration config : m_processorConfig.values()) {
            Properties prop = config.getformatterProperties();
            String module = prop.getProperty(ImportDataProcessor.IMPORT_FORMATTER);
            try {
                AbstractFormatterFactory formatterFactory = m_formatterFactories.get(module);
                if (formatterFactory == null) {
                    URI moduleURI = URI.create(module);
                    formatterFactory = m_moduleManager.getService(moduleURI, AbstractFormatterFactory.class);
                    if (formatterFactory == null) {
                        VoltDB.crashLocalVoltDB("Failed to initialize formatter from: " + module);
                    }
                    m_formatterFactories.put(module, formatterFactory);
                }
                config.setFormatterFactory(formatterFactory);
            } catch (Throwable t) {
                VoltDB.crashLocalVoltDB("Failed to configure import handler for " + module);
            }
        }
        discoverConfigsAndLoadBundles(catalogContext);
        if (!m_configsForProcessor.isEmpty()) {
            newProcessor.setProcessorConfig(m_configsForProcessor, m_loadedBundles);
            m_processor.set(newProcessor);
        } else {
            m_processor.set(null);
        }
    } catch (final Exception e) {
        VoltDB.crashLocalVoltDB("Error creating import processor", true, e);
    }
}
Also used : ImportType(org.voltdb.compiler.deploymentfile.ImportType) ImportConfiguration(org.voltdb.utils.CatalogUtil.ImportConfiguration) Properties(java.util.Properties) URI(java.net.URI) AbstractFormatterFactory(org.voltdb.importer.formatter.AbstractFormatterFactory) IOException(java.io.IOException) BundleException(org.osgi.framework.BundleException)

Aggregations

ImportConfiguration (org.voltdb.utils.CatalogUtil.ImportConfiguration)3 Properties (java.util.Properties)2 IOException (java.io.IOException)1 URI (java.net.URI)1 BundleException (org.osgi.framework.BundleException)1 Procedure (org.voltdb.catalog.Procedure)1 ImportType (org.voltdb.compiler.deploymentfile.ImportType)1 AbstractFormatterFactory (org.voltdb.importer.formatter.AbstractFormatterFactory)1