List of usage examples for org.apache.commons.configuration CompositeConfiguration addProperty
public void addProperty(String key, Object value)
From source file:org.apache.whirr.service.elasticsearch.ElasticSearchConfigurationBuilder.java
/** * Build a configuration by adding the expected defaults */// w w w.j a v a 2s. c o m public static Configuration buildConfig(ClusterSpec spec, Cluster cluster) { CompositeConfiguration config = new CompositeConfiguration(); config.addConfiguration(spec.getConfiguration()); try { config.addConfiguration(new PropertiesConfiguration("whirr-elasticsearch-default.properties")); } catch (ConfigurationException e) { LOG.error("Configuration error", e); // this should never happen } if ("aws-ec2".equals(spec.getProvider()) || "ec2".equals(spec.getProvider())) { addDefaultsForEC2(spec, config); } else { addDefaultsForUnicast(cluster, config); } if (!config.containsKey("es.cluster.name")) { config.addProperty("es.cluster.name", spec.getClusterName()); } return config; }
From source file:org.apache.whirr.service.elasticsearch.ElasticSearchConfigurationBuilder.java
/** * Use the native EC2 discovery module on AWS *///from ww w . j a va2s .c o m private static void addDefaultsForEC2(ClusterSpec spec, CompositeConfiguration config) { config.addProperty("es.discovery.type", "ec2"); if (!config.containsKey("es.cloud.aws.access_key")) { config.addProperty("es.cloud.aws.access_key", spec.getIdentity()); } if (!config.containsKey("es.cloud.aws.secret_key")) { config.addProperty("es.cloud.aws.secret_key", spec.getCredential()); } if (!config.getList("es.plugins", Lists.newLinkedList()) .contains("elasticsearch/elasticsearch-cloud-aws/1.5.0")) { config.addProperty("es.plugins", "elasticsearch/elasticsearch-cloud-aws/1.5.0"); } }
From source file:org.apache.whirr.service.elasticsearch.ElasticSearchConfigurationBuilder.java
/** * Use unicast if not on AWS (most of the cloud providers deny multicast traffic). *///from w w w . j a v a2 s . com private static void addDefaultsForUnicast(Cluster cluster, CompositeConfiguration config) { List<String> hosts = Lists.newLinkedList(); for (Cluster.Instance instance : cluster.getInstancesMatching(role(ElasticSearchHandler.ROLE))) { hosts.add(String.format("\"%s:9300\"", instance.getPrivateIp())); } config.addProperty("es.discovery.zen.ping.multicast.enabled", "false"); config.addProperty("es.discovery.zen.ping.unicast.hosts", StringUtils.join(hosts, ",")); }