Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.PropertiesConfiguration


    assertThat(t2.getMinNumberOfInstances(), is(2));
  }

  @Test
  public void testNumberOfInstancesPerTemplate() throws Exception {
    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker,3 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.instance-templates-max-percent-failures", "100 hadoop-namenode+hadoop-jobtracker,60 hadoop-datanode+hadoop-tasktracker");
    ClusterSpec expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    List<InstanceTemplate> templates = expectedClusterSpec.getInstanceTemplates();
    InstanceTemplate t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    InstanceTemplate t2 = templates.get(1);
    assertThat(t2.getMinNumberOfInstances(), is(2));

    conf.setProperty("whirr.instance-templates-max-percent-failures", "60 hadoop-datanode+hadoop-tasktracker");
    expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    templates = expectedClusterSpec.getInstanceTemplates();
    t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    t2 = templates.get(1);
    assertThat(t2.getMinNumberOfInstances(), is(2));

    conf.addProperty("whirr.instance-templates-minumum-number-of-instances", "1 hadoop-datanode+hadoop-tasktracker");
    expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    templates = expectedClusterSpec.getInstanceTemplates();
    t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    t2 = templates.get(1);
    assertThat(t2.getMinNumberOfInstances(), is(2));

    conf.setProperty("whirr.instance-templates-minimum-number-of-instances", "3 hadoop-datanode+hadoop-tasktracker");
    expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    templates = expectedClusterSpec.getInstanceTemplates();
    t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    t2 = templates.get(1);
View Full Code Here


      "cloudservers-us:cloudfiles-us",
      "cloudservers-uk:cloudfiles-uk"
    }) {
      String[] parts = pair.split(":");

      Configuration config = new PropertiesConfiguration();
      config.addProperty("whirr.provider", parts[0]);

      ClusterSpec spec = ClusterSpec.withTemporaryKeys(config);
      assertThat(spec.getBlobStoreProvider(), is(parts[1]));
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testAutoHostnameForProvider() throws Exception {
      Configuration cloudServersConfig = new PropertiesConfiguration();
      cloudServersConfig.addProperty("whirr.provider", "cloudservers-us");

      ClusterSpec cloudServersSpec = ClusterSpec.withTemporaryKeys(cloudServersConfig);
      assertEquals(cloudServersSpec.getAutoHostnamePrefix(), null);
      assertEquals(cloudServersSpec.getAutoHostnameSuffix(), ".static.cloud-ips.com");

      Configuration cloudServersUkConfig = new PropertiesConfiguration();
      cloudServersUkConfig.addProperty("whirr.provider", "cloudservers-uk");

      ClusterSpec cloudServersUkSpec = ClusterSpec.withTemporaryKeys(cloudServersUkConfig);
      assertEquals(cloudServersUkSpec.getAutoHostnamePrefix(), null);
      assertEquals(cloudServersUkSpec.getAutoHostnameSuffix(), ".static.cloud-ips.co.uk");

      Configuration ec2Config = new PropertiesConfiguration();
      ec2Config.addProperty("whirr.provider", "aws-ec2");

      ClusterSpec ec2Spec = ClusterSpec.withTemporaryKeys(ec2Config);
      assertEquals(null, ec2Spec.getAutoHostnamePrefix());
      assertEquals(null, ec2Spec.getAutoHostnameSuffix());
  }
View Full Code Here

      assertEquals(null, ec2Spec.getAutoHostnameSuffix());
  }

  @Test
  public void testJdkInstallUrl() throws Exception {
      Configuration cloudServersConfig = new PropertiesConfiguration();

      ClusterSpec cloudServersSpec = ClusterSpec.withTemporaryKeys(cloudServersConfig);
      assertEquals(null, cloudServersSpec.getJdkInstallUrl());

      cloudServersConfig = new PropertiesConfiguration();
      cloudServersConfig.addProperty("whirr.jdk-install-url", "http://whirr-third-party.s3.amazonaws.com/jdk-6u21-linux-i586-rpm.bin");

      cloudServersSpec = ClusterSpec.withTemporaryKeys(cloudServersConfig);
      assertEquals("http://whirr-third-party.s3.amazonaws.com/jdk-6u21-linux-i586-rpm.bin", cloudServersSpec.getJdkInstallUrl());
 
View Full Code Here

      assertEquals("http://whirr-third-party.s3.amazonaws.com/jdk-6u21-linux-i586-rpm.bin", cloudServersSpec.getJdkInstallUrl());
 
 
  @Test
  public void testKerberosRealm() throws Exception {
      Configuration cloudServersConfig = new PropertiesConfiguration();

      ClusterSpec cloudServersSpec = ClusterSpec.withTemporaryKeys(cloudServersConfig);
      assertEquals(null, cloudServersSpec.getKerberosRealm());

      cloudServersConfig = new PropertiesConfiguration();
      cloudServersConfig.addProperty("whirr.kerberos-realm", "CDHCLUSTER.COM");

      cloudServersSpec = ClusterSpec.withTemporaryKeys(cloudServersConfig);
      assertEquals("CDHCLUSTER.COM", cloudServersSpec.getKerberosRealm());
  }
View Full Code Here

  }
 
  @Test
  public void testApplySubroleAliases() throws ConfigurationException {
    CompositeConfiguration c = new CompositeConfiguration();
    Configuration config = new PropertiesConfiguration();
    config.addProperty("whirr.instance-templates",
      "1 puppet:somepup::pet+something-else, 1 something-else-only");
    c.addConfiguration(config);
    InstanceTemplate template = InstanceTemplate.parse(c).get(0);
    Set<String> expected = Sets.newLinkedHashSet(Arrays.asList(new String[]{
      "puppet:somepup::pet", "something-else"}));
View Full Code Here

  }

  @Test
  public void testCopySpec() throws Exception {
    ClusterSpec spec = ClusterSpec.withTemporaryKeys(
      new PropertiesConfiguration("whirr-core-test.properties"));
    spec.setTemplate(TemplateBuilderSpec.parse("locationId=random-location"));

    /* check the copy is the same as the original */
    assertThat(spec.copy(), is(spec));
    assertThat(spec.copy().hashCode(), is(spec.hashCode()));
View Full Code Here

    assertThat(spec.copy().hashCode(), is(spec.hashCode()));
  }

  @Test
  public void testFirewallRules() throws Exception {
    PropertiesConfiguration conf = new PropertiesConfiguration("whirr-core-test.properties");
    conf.setProperty("whirr.firewall-rules", "8000,8001");
    conf.setProperty("whirr.firewall-rules.serviceA", "9000,9001");
    ClusterSpec spec = ClusterSpec.withTemporaryKeys(conf);

    Map<String, List<String>> firewallRules = spec.getFirewallRules();
    assertThat(firewallRules.get(null).equals(Lists.<String>newArrayList("8000", "8001")), is(true));
    assertThat(firewallRules.get("serviceA").equals(Lists.<String>newArrayList("9000", "9001")), is(true));
View Full Code Here

  protected Configuration getConfiguration(ClusterSpec clusterSpec,
                                           String defaultsPropertiesFile) throws IOException {
    try {
      return getConfiguration(clusterSpec,
                              new PropertiesConfiguration(getClass().getClassLoader().getResource(defaultsPropertiesFile)));
    } catch(ConfigurationException e) {
      throw new IOException("Error loading " + defaultsPropertiesFile, e);
    }
  }
View Full Code Here

    assertThat(firewallRules.get("serviceA").equals(Lists.<String>newArrayList("9000", "9001")), is(true));
  }

  @Test
  public void testHardwareIdPerInstanceTemplate() throws Exception {
    PropertiesConfiguration conf = new PropertiesConfiguration("whirr-core-test.properties");
    conf.setProperty("whirr.instance-templates", "2 noop, 1 role1+role2, 1 role1, 3 spots, 1 spec");
    conf.setProperty("whirr.hardware-id", "c1.xlarge");

    conf.setProperty("whirr.templates.noop.hardware-id", "m1.large");
    conf.setProperty("whirr.templates.role1+role2.hardware-id", "t1.micro");
    conf.setProperty("whirr.templates.role1+role2.image-id", "us-east-1/ami-123324");
    conf.setProperty("whirr.templates.spots.aws-ec2-spot-price", 0.5f);
    conf.setProperty("whirr.templates.spec.template", "osFamily=UBUNTU,os64Bit=true,minRam=2048");

    ClusterSpec spec = ClusterSpec.withTemporaryKeys(conf);
    List<InstanceTemplate> templates = spec.getInstanceTemplates();

    InstanceTemplate noops = get(templates, 0);
View Full Code Here

TOP

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

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.