Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.CompositeConfiguration


      } else {
        optionsConfig.setProperty(property.getConfigName(),
            optionSet.valueOf(option));
      }
    }
    CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(optionsConfig);
    if (optionSet.has(configOption)) {
      Configuration defaults = new PropertiesConfiguration(optionSet.valueOf(configOption));
      config.addConfiguration(defaults);
    }

    for (Property required : EnumSet.of(SERVICE_NAME, CLUSTER_NAME, IDENTITY)) {
      if (config.getString(required.getConfigName()) == null) {
        throw new IllegalArgumentException(String.format("Option '%s' not set.",
            required.getSimpleName()));
      }
    }
    return new ClusterSpec(config);
View Full Code Here


  private ZooKeeperCluster cluster;
 
  @Before
  public void setUp() throws ConfigurationException, IOException,
      JSchException {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
      config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    config.addConfiguration(new PropertiesConfiguration("whirr-zookeeper-test.properties"));
    clusterSpec = new ClusterSpec(config);
    if (clusterSpec.getPrivateKey() == null) {
      Map<String, String> pair = KeyPair.generate();
      clusterSpec.setPublicKey(pair.get("public"));
      clusterSpec.setPrivateKey(pair.get("private"));
View Full Code Here

  /**
   * Build a configuration by adding the expected defaults
   */
  public static Configuration buildConfig(ClusterSpec spec, Cluster cluster) {
    CompositeConfiguration config = new CompositeConfiguration();

    config.addConfiguration(spec.getConfiguration());
    try {
      config.addConfiguration(
        new PropertiesConfiguration(ElasticSearchConfigurationBuilder.class.getResource("/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;
  }
View Full Code Here

    LoggerFactory.getLogger(BootstrapClusterActionTest.class);

  @SuppressWarnings("unchecked")
  @Test
  public void testDoActionRetriesSucceed() throws Exception {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
      config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.service-name", "test-service");
    conf.addProperty("whirr.cluster-name", "test-cluster");
    conf.addProperty("whirr.instance-templates",
      "1 hadoop-namenode+hadoop-jobtracker,4 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.instance-templates-max-percent-failures", "60 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.provider", "ec2");
    config.addConfiguration(conf);
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(conf);

    Set<String> jtnn = new HashSet<String>();
    jtnn.add("hadoop-jobtracker");
    jtnn.add("hadoop-namenode");    
View Full Code Here

  }

  @SuppressWarnings("unchecked")
  @Test(expected = IOException.class)
  public void testDoActionRetriesExceeds() throws Exception {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
      config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.service-name", "test-service");
    conf.addProperty("whirr.cluster-name", "test-cluster");
    conf.addProperty("whirr.instance-templates",
      "1 hadoop-namenode+hadoop-jobtracker,4 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.instance-templates-max-percent-failures", "60 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.provider", "ec2");
    config.addConfiguration(conf);
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(conf);

    Set<String> jtnn = new HashSet<String>();
    jtnn.add("hadoop-jobtracker");
    jtnn.add("hadoop-namenode");    
View Full Code Here

  }
 
  @Test
  @SuppressWarnings("unchecked")
  public void testSubroleInvoked() throws Exception {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
      config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.service-name", "test-service");
    conf.addProperty("whirr.cluster-name", "test-cluster");
    conf.addProperty("whirr.instance-templates", "1 puppet:module::manifest+something-else");
    conf.addProperty("whirr.provider", "ec2");
    config.addConfiguration(conf);
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(conf);

    Set<String> nn = new HashSet<String>();
    nn.add("puppet:module::manifest");
    nn.add("something-else");    
View Full Code Here

  /** test is the same as previous (SubroleInvoked) except it knows puppet, not puppet:, as the role;
   * the colon in the role def'n is the indication it accepts subroles,
   * so this should throw IllegalArgument when we refer to puppet:module...
   */
  public void testSubroleNotSupported() throws Exception {
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
      config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.service-name", "test-service");
    conf.addProperty("whirr.cluster-name", "test-cluster");
    conf.addProperty("whirr.instance-templates", "1 puppet:module::manifest+something-else");
    conf.addProperty("whirr.provider", "ec2");
    config.addConfiguration(conf);
    ClusterSpec clusterSpec = ClusterSpec.withTemporaryKeys(conf);

    Set<String> nn = new HashSet<String>();
    nn.add("puppet:module::manifest");
    nn.add("something-else");    
View Full Code Here

    return config;
  }

  private static Configuration build(ClusterSpec clusterSpec, Cluster cluster, Configuration defaults, String prefix)
      throws ConfigurationException {
    CompositeConfiguration config = new CompositeConfiguration();
    Configuration sub = clusterSpec.getConfigurationForKeysWithPrefix(prefix);
    config.addConfiguration(sub.subset(prefix)); // remove prefix
    config.addConfiguration(defaults.subset(prefix));
    return config;
  }
View Full Code Here

    }
  }

  public synchronized void startup() throws Exception {
    LOG.info("Starting up cluster...");
    CompositeConfiguration config = new CompositeConfiguration();
    if (System.getProperty("config") != null) {
      config.addConfiguration(new PropertiesConfiguration(System.getProperty("config")));
    }
    config.addConfiguration(new PropertiesConfiguration(HamaServiceController.class.getResource("/whirr-hama-test.properties")));
    clusterSpec = ClusterSpec.withTemporaryKeys(config);
    controller = new ClusterController();
   
    cluster = controller.launchCluster(clusterSpec);
    proxy = new HadoopProxy(clusterSpec, cluster);
View Full Code Here

    "whirr-yarn-default.properties";

  private static Configuration build(ClusterSpec clusterSpec, Cluster cluster,
      Configuration defaults, String prefix)
      throws ConfigurationException {
    CompositeConfiguration config = new CompositeConfiguration();
    Configuration sub = clusterSpec.getConfigurationForKeysWithPrefix(prefix);
    config.setDelimiterParsingDisabled(true);
    config.addConfiguration(sub.subset(prefix)); // remove prefix
    config.addConfiguration(defaults.subset(prefix));
    return config;
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.CompositeConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.