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

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


    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

    Assert.assertNotNull(cluster.getConfig("test-site", "version100"));
  }

  @Test
  public void testDeleteConfigGroup() throws Exception {
    ConfigGroup configGroup = createConfigGroup();
    Assert.assertNotNull(configGroup);
    Long id = configGroup.getId();

    configGroup.delete();

    Assert.assertNull(configGroupDAO.findById(id));
    Assert.assertNull(cluster.getConfigGroups().get(id));
  }
View Full Code Here

    Assert.assertNull(cluster.getConfigGroups().get(id));
  }

  @Test
  public void testRemoveHost() throws Exception {
    ConfigGroup configGroup = createConfigGroup();
    Assert.assertNotNull(configGroup);
    Long id = configGroup.getId();

    configGroup = cluster.getConfigGroups().get(id);
    Assert.assertNotNull(configGroup);

    clusters.unmapHostFromCluster("h1", clusterName);

    Assert.assertNull(clusters.getHostsForCluster(clusterName).get("h1"));
    Assert.assertTrue(configGroupHostMappingDAO.findByHost("h1").isEmpty());
    Assert.assertNull(configGroup.getHosts().get("h1"));
  }
View Full Code Here

    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

      try {
        Set<ConfigGroupHostMapping> hostMappingEntities = configGroupHostMappingDAO.findByHost(hostname);

        if (hostMappingEntities != null && !hostMappingEntities.isEmpty()) {
          for (ConfigGroupHostMapping entity : hostMappingEntities) {
            ConfigGroup configGroup = configGroupMap.get(entity.getConfigGroupId());
            if (configGroup != null && !configGroups.containsKey(configGroup.getId())) {
              configGroups.put(configGroup.getId(), configGroup);
            }
          }
        }
        return configGroups;
View Full Code Here

    loadConfigGroups();
    clusterGlobalLock.writeLock().lock();
    try {
      readWriteLock.writeLock().lock();
      try {
        ConfigGroup configGroup = clusterConfigGroups.get(id);
        if (configGroup == null) {
          throw new AmbariException("Config group does not exist, id = " + id);
        }
        LOG.debug("Deleting Config group"
          + ", clusterName = " + getClusterName()
          + ", groupName = " + configGroup.getName()
          + ", groupId = " + configGroup.getId()
          + ", tag = " + configGroup.getTag());

        configGroup.delete();
        clusterConfigGroups.remove(id);
        configHelper.invalidateStaleConfigsCache();
      } finally {
        readWriteLock.writeLock().unlock();
      }
View Full Code Here

  }

  private ConfigGroup buildConfigGroup(ConfigGroupEntity configGroupEntity) {
   
    Cluster cluster = clusterFactory.create(configGroupEntity.getClusterEntity());
    ConfigGroup configGroup = configGroupFactory.createExisting(cluster, configGroupEntity);
   
    return configGroup;
  }
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

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.