Package org.apache.ambari.server.state.configgroup

Examples of org.apache.ambari.server.state.configgroup.ConfigGroup


    Assert.assertNull(configGroup.getHosts().get("h1"));
  }

  @Test
  public void testGetConfigGroup() throws Exception {
    ConfigGroup configGroup = createConfigGroup();
    Assert.assertNotNull(configGroup);
    Assert.assertNotNull(cluster.getConfigGroups().get(configGroup.getId()));

    ConfigGroupEntity configGroupEntity = configGroupDAO.findById(configGroup
      .getId());
    Collection<ConfigGroupConfigMappingEntity> configMappingEntities =
      configGroupEntity.getConfigGroupConfigMappingEntities();
    Collection<ConfigGroupHostMappingEntity> hostMappingEntities =
      configGroupEntity.getConfigGroupHostMappingEntities();

    Assert.assertEquals(configGroup.getId(), configGroupEntity.getGroupId());
    Assert.assertEquals(configGroup.getTag(), configGroupEntity.getTag());
    Assert.assertNotNull(configMappingEntities);
    Assert.assertNotNull(hostMappingEntities);
    Assert.assertEquals("h1", hostMappingEntities.iterator().next()
      .getHostname());
    ConfigGroupConfigMappingEntity configMappingEntity =
View Full Code Here


    Map<String, Host> hosts = new HashMap<String, Host>();

    configs.put(config.getType(), config);
    hosts.put(host.getHostName(), host);

    ConfigGroup configGroup = configGroupFactory.createNew(cluster, "cg-test",
      "HDFS", "New HDFS configs for h1", configs, hosts);

    configGroup.persist();
    return configGroup;
  }
View Full Code Here

    return configGroup;
  }

  @Test
  public void testCreateNewConfigGroup() throws Exception {
    ConfigGroup configGroup = createConfigGroup();
    Assert.assertNotNull(configGroup);

    ConfigGroupEntity configGroupEntity = configGroupDAO.findByName("cg-test");
    Assert.assertNotNull(configGroupEntity);
    Assert.assertEquals("HDFS", configGroupEntity.getTag());
View Full Code Here

  }

  @Test
  @Transactional
  public void testUpdateConfigGroup() throws Exception {
    ConfigGroup configGroup = createConfigGroup();
    Assert.assertNotNull(configGroup);
    ConfigGroupEntity configGroupEntity = configGroupDAO.findById(configGroup.getId());
    Assert.assertNotNull(configGroupEntity);

    configGroup = configGroupFactory.createExisting(cluster, configGroupEntity);

    // Add new host
    Host host = clusters.getHost("h2");
    configGroup.addHost(host);
    Assert.assertEquals(2, configGroup.getHosts().values().size());

    // Create a new config
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("key1", "value1");
    Config config = new ConfigImpl("test-site");
    config.setProperties(properties);
    config.setVersionTag("version100");

    configGroup.addConfiguration(config);
    Assert.assertEquals(2, configGroup.getConfigurations().values().size());

    configGroup.setName("NewName");
    configGroup.setDescription("NewDesc");
    configGroup.setTag("NewTag");

    // Save
    configGroup.persist();

    configGroupEntity = configGroupDAO.findByName("NewName");

    Assert.assertNotNull(configGroupEntity);
    Assert.assertEquals(2, configGroupEntity
View Full Code Here

    sch.setStackVersion(new StackId("HDP-1.0.0"));
    sch.setDesiredStackVersion(new StackId("HDP-1.1.0"));

    Cluster cluster = clusters.getCluster("C1");

    final ConfigGroup configGroup = configGroupFactory.createNew(cluster,
      "cg1", "t1", "", new HashMap<String, Config>(), new HashMap<String, Host>());

    configGroup.persist();
    cluster.addConfigGroup(configGroup);
   
    Map<String, Map<String,String>> actual =
        new HashMap<String, Map<String, String>>() {{
          put("global", new HashMap<String,String>() {{ put("tag", "version1"); }});
          put("core-site", new HashMap<String,String>() {{ put("tag", "version1");
            put(configGroup.getId().toString(), "version2"); }});
        }};
       
    sch.updateActualConfigs(actual);
   
    Map<String, HostConfig> confirm = sch.getActualConfigs();
View Full Code Here

        new HashMap<String, String>() {{ put("dfs.journalnode.http-address", "http://goo"); }});
    c.setVersionTag("version3");
    c.persist();
    cluster.addConfig(c);
    //host.addDesiredConfig(cluster.getClusterId(), true, "user", c);
    ConfigGroup configGroup = configGroupFactory.createNew(cluster, "g1",
      "t1", "", new HashMap<String, Config>() {{ put("hdfs-site", c); }},
      new HashMap<String, Host>() {{ put("h3", host); }});
    configGroup.persist();
    cluster.addConfigGroup(configGroup);
   
    // HDP-x/HDFS/hdfs-site updated host to changed property
    Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
    Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
   
    actual.get("hdfs-site").put(configGroup.getId().toString(), "version3");
    sch2.updateActualConfigs(actual);
    // HDP-x/HDFS/hdfs-site updated host to changed property
    Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
    Assert.assertFalse(sch2.convertToResponse().isStaleConfig());
   
    sch1.updateActualConfigs(actual);
    // HDP-x/HDFS/hdfs-site updated host to changed property
    Assert.assertFalse(sch1.convertToResponse().isStaleConfig());
    Assert.assertFalse(sch2.convertToResponse().isStaleConfig());
   
    // change 'global' property only affecting global/HDFS
    makeConfig(cluster, "global", "version2",
      new HashMap<String,String>() {{
        put("a", "b");
        put("dfs_namenode_name_dir", "/foo3"); // HDFS only
        put("mapred_log_dir_prefix", "/foo2"); // MR2 only
      }});
   
    Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
    Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
    Assert.assertFalse(sch3.convertToResponse().isStaleConfig());

    // Change core-site property, only HDFS property
    makeConfig(cluster, "core-site", "version1",
      new HashMap<String,String>() {{
        put("a", "b");
        put("fs.trash.interval", "360"); // HDFS only
      }});

    Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
    Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
    Assert.assertTrue(sch3.convertToResponse().isStaleConfig());

    actual.put("core-site", new HashMap<String, String>() {{
      put("tag", "version1");
    }});

    sch1.updateActualConfigs(actual);

    final Config c1 = configFactory.createNew(cluster, "core-site",
      new HashMap<String, String>() {{ put("fs.trash.interval", "400"); }});
    c1.setVersionTag("version2");
    c1.persist();
    cluster.addConfig(c1);
    configGroup = configGroupFactory.createNew(cluster, "g2",
      "t2", "", new HashMap<String, Config>() {{ put("core-site", c1); }},
      new HashMap<String, Host>() {{ put("h3", host); }});
    configGroup.persist();
    cluster.addConfigGroup(configGroup);

    Assert.assertTrue(sch1.convertToResponse().isStaleConfig());
    Assert.assertTrue(sch2.convertToResponse().isStaleConfig());
    Assert.assertTrue(sch3.convertToResponse().isStaleConfig());
View Full Code Here

    for (Config config : configs) {
      configMap.put(config.getType(), config);
    }

    ConfigGroup configGroup = configGroupFactory.createNew(cluster, name,
      tag, "", configMap, hostMap);

    configGroup.persist();
    cluster.addConfigGroup(configGroup);

    return configGroup.getId();
  }
View Full Code Here

    for (Config config : configs) {
      configMap.put(config.getType(), config);
    }

    ConfigGroup configGroup = configGroupFactory.createNew(cluster, name,
      tag, "", configMap, hostMap);

    configGroup.persist();
    cluster.addConfigGroup(configGroup);

    return configGroup.getId();
  }
View Full Code Here

    // Config group not associated with host
    Assert.assertEquals("b", mapredInstall.getExecutionCommandWrapper()
      .getExecutionCommand().getConfigurations().get("mapred-site").get("a"));

    // Associate the right host
    ConfigGroup configGroup = cluster.getConfigGroups().get(groupId);
    configGroup.setHosts(new HashMap<String, Host>() {{ put("h3",
      clusters.getHost("h3")); }});
    configGroup.persist();

    requestId = startService(clusterName, serviceName2, false, false);
    mapredInstall = null;
    for (Stage stage : actionDB.getAllStages(requestId)) {
      for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
View Full Code Here

    // Config group not associated with host
    Assert.assertEquals("b", mapredInstall.getExecutionCommandWrapper()
      .getExecutionCommand().getConfigurations().get("mapred-site").get("a"));

    // Associate the right host
    ConfigGroup configGroup = cluster.getConfigGroups().get(groupId);
    configGroup.setHosts(new HashMap<String, Host>() {{ put("h3",
      clusters.getHost("h3")); }});
    configGroup.persist();

    requestId = startService(clusterName, serviceName2, false, false);
    mapredInstall = null;
    for (Stage stage : actionDB.getAllStages(requestId)) {
      for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.state.configgroup.ConfigGroup

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.