Search in sources :

Example 6 with PropertyType

use of org.voltdb.compiler.deploymentfile.PropertyType in project voltdb by VoltDB.

the class CatalogUtil method checkImportProcessorConfiguration.

private static ImportConfiguration checkImportProcessorConfiguration(ImportConfigurationType importConfiguration) {
    String importBundleUrl = importConfiguration.getModule();
    if (!importConfiguration.isEnabled()) {
        return null;
    }
    switch(importConfiguration.getType()) {
        case CUSTOM:
            break;
        case KAFKA:
            importBundleUrl = "kafkastream.jar";
            break;
        case KINESIS:
            importBundleUrl = "kinesisstream.jar";
            break;
        default:
            throw new DeploymentCheckException("Import Configuration type must be specified.");
    }
    Properties moduleProps = new Properties();
    Properties formatterProps = new Properties();
    String formatBundle = importConfiguration.getFormat();
    String formatName = null;
    if (formatBundle != null && formatBundle.trim().length() > 0) {
        if ("csv".equalsIgnoreCase(formatBundle) || "tsv".equalsIgnoreCase(formatBundle)) {
            formatName = formatBundle;
            formatBundle = "voltcsvformatter.jar";
        } else if (JAR_EXTENSION_RE.matcher(formatBundle).matches()) {
            int typeIndex = formatBundle.lastIndexOf("/");
            formatName = formatBundle.substring(typeIndex + 1);
            formatBundle = formatBundle.substring(0, typeIndex);
        } else {
            throw new DeploymentCheckException("Import format " + formatBundle + " not valid.");
        }
        formatterProps.setProperty(ImportDataProcessor.IMPORT_FORMATTER, buildBundleURL(formatBundle, true));
    }
    if (importBundleUrl != null && importBundleUrl.trim().length() > 0) {
        moduleProps.setProperty(ImportDataProcessor.IMPORT_MODULE, buildBundleURL(importBundleUrl, false));
    }
    List<PropertyType> importProperties = importConfiguration.getProperty();
    if (importProperties != null && !importProperties.isEmpty()) {
        for (PropertyType prop : importProperties) {
            String key = prop.getName();
            String value = prop.getValue();
            if (!key.toLowerCase().contains("passw")) {
                moduleProps.setProperty(key, value.trim());
            } else {
                //Don't trim passwords
                moduleProps.setProperty(key, value);
            }
        }
    }
    List<PropertyType> formatProperties = importConfiguration.getFormatProperty();
    if (formatProperties != null && !formatProperties.isEmpty()) {
        for (PropertyType prop : formatProperties) {
            formatterProps.setProperty(prop.getName(), prop.getValue());
        }
    }
    return new ImportConfiguration(formatName, moduleProps, formatterProps);
}
Also used : PropertyType(org.voltdb.compiler.deploymentfile.PropertyType) Properties(java.util.Properties)

Aggregations

PropertyType (org.voltdb.compiler.deploymentfile.PropertyType)6 Properties (java.util.Properties)5 ExportConfigurationType (org.voltdb.compiler.deploymentfile.ExportConfigurationType)3 ExportType (org.voltdb.compiler.deploymentfile.ExportType)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)1 JSONException (org.json_voltpatches.JSONException)1 VoltTable (org.voltdb.VoltTable)1 Cluster (org.voltdb.catalog.Cluster)1 Column (org.voltdb.catalog.Column)1 Connector (org.voltdb.catalog.Connector)1