Java Code Examples for org.elasticsearch.common.settings.Settings#names()

The following examples show how to use org.elasticsearch.common.settings.Settings#names() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnalyzedColumnDefinition.java    From crate with Apache License 2.0 6 votes vote down vote up
private static void applyAndValidateStorageSettings(Map<String, Object> mapping,
                                                    AnalyzedColumnDefinition<Object> definition) {
    if (definition.storageProperties == null) {
        return;
    }
    Settings storageSettings = GenericPropertiesConverter.genericPropertiesToSettings(definition.storageProperties);
    for (String property : storageSettings.names()) {
        if (property.equals(COLUMN_STORE_PROPERTY)) {
            DataType<?> dataType = definition.dataType();
            boolean val = storageSettings.getAsBoolean(property, true);
            if (val == false) {
                if (!DataTypes.isSameType(dataType, DataTypes.STRING)) {
                    throw new IllegalArgumentException(
                        String.format(Locale.ENGLISH, "Invalid storage option \"columnstore\" for data type \"%s\"",
                                      dataType.getName()));
                }

                mapping.put(DOC_VALUES, "false");
            }
        } else {
            throw new IllegalArgumentException(
                String.format(Locale.ENGLISH, "Invalid storage option \"%s\"", storageSettings.get(property)));
        }
    }
}
 
Example 2
Source File: GeoSettingsApplier.java    From crate with Apache License 2.0 5 votes vote down vote up
private static void validate(Settings geoSettings) {
    for (String setting : geoSettings.names()) {
        if (!SUPPORTED_OPTIONS.contains(setting)) {
            throw new IllegalArgumentException(
                String.format(Locale.ENGLISH, "Setting \"%s\" ist not supported on geo_shape index", setting));
        }
    }
}
 
Example 3
Source File: KafkaSink.java    From deprecated-security-advanced-modules with Apache License 2.0 4 votes vote down vote up
public KafkaSink(final String name, final Settings settings, final String settingsPrefix, AuditLogSink fallbackSink) {
	super(name, settings, settingsPrefix, fallbackSink);

	Settings sinkSettings = settings.getAsSettings(settingsPrefix);
	checkMandatorySinkSettings(sinkSettings);

	if (!valid) {
		log.error("Failed to configure Kafka producer, please check the logfile.");
		return;
	}

       final Properties producerProps = new Properties();

       for(String key: sinkSettings.names()) {
           if(!key.equals("topic_name")) {
               producerProps.put(key.replace('_', '.'), sinkSettings.get(key));
           }
       }

	producerProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, LongSerializer.class.getName());
	producerProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
	topicName = sinkSettings.get("topic_name");

	//map path of
	//ssl.keystore.location
	//ssl.truststore.location
	//sasl.kerberos.kinit.cmd

	final SecurityManager sm = System.getSecurityManager();

       if (sm != null) {
           sm.checkPermission(new SpecialPermission());
       }

       try {
           this.producer = AccessController.doPrivileged(new PrivilegedExceptionAction<KafkaProducer<Long, String>>() {
               @Override
               public KafkaProducer<Long, String> run() throws Exception {
                   return new KafkaProducer<Long, String>(producerProps);
               }
           });
       } catch (PrivilegedActionException e) {
           log.error("Failed to configure Kafka producer due to {}", e.getException(), e.getException());
           this.valid = false;
       }

}