Package org.apache.ambari.server.orm.entities

Examples of org.apache.ambari.server.orm.entities.ClusterConfigEntity


          Long clusterId = clusterEntity.getClusterId();
          ClusterConfigEntityPK configEntityPK = new ClusterConfigEntityPK();
          configEntityPK.setClusterId(clusterId);
          configEntityPK.setType("hdfs-exclude-file");
          configEntityPK.setTag(value.trim());
          ClusterConfigEntity configEntity = clusterDAO.findConfig(configEntityPK);
          if (configEntity != null) {
            String configData = configEntity.getData();
            if (configData != null) {
              Map<String, String> properties = gson.<Map<String, String>>fromJson(configData, Map.class);
              if (properties != null && !properties.isEmpty()) {
                String decommissionedNodes = properties.get("datanodes");
                if (decommissionedNodes != null) {
View Full Code Here


    keyValueEntity.setKey("decommissionDataNodesTag");
    keyValueEntity.setValue("1394147791230");
    keyValueDAO.create(keyValueEntity);

    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
    ClusterConfigEntity configEntity = new ClusterConfigEntity();
    configEntity.setClusterEntity(clusterEntity);
    configEntity.setClusterId(clusterEntity.getClusterId());
    configEntity.setType("hdfs-exclude-file");
    configEntity.setTag("1394147791230");
    configEntity.setData("{\"datanodes\":\"" + HOST_NAME + "\"}");
    configEntity.setTimestamp(System.currentTimeMillis());
    clusterDAO.createConfig(configEntity);

    UpgradeCatalog150 upgradeCatalog150 = injector.getInstance(UpgradeCatalog150.class);

    upgradeCatalog150.processDecommissionedDatanodes();
View Full Code Here

    ClusterConfigEntityPK configEntityPK = new ClusterConfigEntityPK();
    configEntityPK.setClusterId(clusterId);
    configEntityPK.setType("hdfs-log4j");
    configEntityPK.setTag("version1");
    ClusterConfigEntity configEntity = clusterDAO.findConfig(configEntityPK);
    Assert.assertNull(configEntity);

    for (ClusterConfigMappingEntity ccme : clusterEntity.getConfigMappingEntities()) {
      if ("hdfs-log4j".equals(ccme.getType())) {
        Assert.fail();
View Full Code Here

      for (Config config : configurations.values()) {
        ClusterConfigEntityPK clusterConfigEntityPK = new ClusterConfigEntityPK();
        clusterConfigEntityPK.setClusterId(cluster.getClusterId());
        clusterConfigEntityPK.setTag(config.getVersionTag());
        clusterConfigEntityPK.setType(config.getType());
        ClusterConfigEntity clusterConfigEntity = clusterDAO.findConfig
          (clusterConfigEntityPK);

        if (clusterConfigEntity == null) {
          // Create configuration
          clusterConfigEntity = new ClusterConfigEntity();
          clusterConfigEntity.setClusterId(clusterEntity.getClusterId());
          clusterConfigEntity.setClusterEntity(clusterEntity);
          clusterConfigEntity.setType(config.getType());
          clusterConfigEntity.setTag(config.getVersionTag());
          clusterConfigEntity.setData(gson.toJson(config.getProperties()));
          clusterConfigEntity.setTimestamp(System.currentTimeMillis());

          // TODO: Is locking necessary and functional ?
          cluster.getClusterGlobalLock().writeLock().lock();
          try {
            clusterDAO.createConfig(clusterConfigEntity);
            clusterEntity.getClusterConfigEntities().add(clusterConfigEntity);
            cluster.addConfig(config);
            clusterDAO.merge(clusterEntity);
            cluster.refresh();
          } finally {
            cluster.getClusterGlobalLock().writeLock().unlock();
          }
        }

        ConfigGroupConfigMappingEntity configMappingEntity =
          new ConfigGroupConfigMappingEntity();
        configMappingEntity.setTimestamp(System.currentTimeMillis());
        configMappingEntity.setClusterId(clusterEntity.getClusterId());
        configMappingEntity.setClusterConfigEntity(clusterConfigEntity);
        configMappingEntity.setConfigGroupEntity(configGroupEntity);
        configMappingEntity.setConfigGroupId(configGroupEntity.getGroupId());
        configMappingEntity.setConfigType(clusterConfigEntity.getType());
        configMappingEntity.setVersionTag(clusterConfigEntity.getTag());
        configGroupConfigMappingDAO.create(configMappingEntity);
        configGroupEntity.getConfigGroupConfigMappingEntities().add
          (configMappingEntity);

        configGroupDAO.merge(configGroupEntity);
View Full Code Here

    }
  }

  @Test
  public void testFindConfigsByGroup() throws Exception {
    ClusterConfigEntity configEntity = new ClusterConfigEntity();
    configEntity.setType("core-site");
    configEntity.setTag("version1");
    configEntity.setData("someData");

    List<ClusterConfigEntity> configEntities = new
      ArrayList<ClusterConfigEntity>();
    configEntities.add(configEntity);
View Full Code Here

      for (Config config : configurations.values()) {
        ClusterConfigEntityPK clusterConfigEntityPK = new ClusterConfigEntityPK();
        clusterConfigEntityPK.setClusterId(cluster.getClusterId());
        clusterConfigEntityPK.setTag(config.getVersionTag());
        clusterConfigEntityPK.setType(config.getType());
        ClusterConfigEntity clusterConfigEntity = clusterDAO.findConfig
          (clusterConfigEntityPK);

        if (clusterConfigEntity == null) {
          // Create configuration
          clusterConfigEntity = new ClusterConfigEntity();
          clusterConfigEntity.setClusterId(clusterEntity.getClusterId());
          clusterConfigEntity.setClusterEntity(clusterEntity);
          clusterConfigEntity.setType(config.getType());
          clusterConfigEntity.setTag(config.getVersionTag());
          clusterConfigEntity.setData(gson.toJson(config.getProperties()));
          clusterConfigEntity.setTimestamp(System.currentTimeMillis());

          // TODO: Is locking necessary and functional ?
          cluster.getClusterGlobalLock().writeLock().lock();
          try {
            clusterDAO.createConfig(clusterConfigEntity);
            clusterEntity.getClusterConfigEntities().add(clusterConfigEntity);
            cluster.addConfig(config);
            clusterDAO.merge(clusterEntity);
            cluster.refresh();
          } finally {
            cluster.getClusterGlobalLock().writeLock().unlock();
          }
        }

        ConfigGroupConfigMappingEntity configMappingEntity =
          new ConfigGroupConfigMappingEntity();
        configMappingEntity.setTimestamp(System.currentTimeMillis());
        configMappingEntity.setClusterId(clusterEntity.getClusterId());
        configMappingEntity.setClusterConfigEntity(clusterConfigEntity);
        configMappingEntity.setConfigGroupEntity(configGroupEntity);
        configMappingEntity.setConfigGroupId(configGroupEntity.getGroupId());
        configMappingEntity.setConfigType(clusterConfigEntity.getType());
        configMappingEntity.setVersionTag(clusterConfigEntity.getTag());
        configGroupConfigMappingDAO.create(configMappingEntity);
        configGroupEntity.getConfigGroupConfigMappingEntities().add
          (configMappingEntity);

        configGroupDAO.merge(configGroupEntity);
View Full Code Here

  @Override
  public synchronized void persist() {
   
    ClusterEntity clusterEntity = clusterDAO.findById(cluster.getClusterId());
   
    ClusterConfigEntity entity = new ClusterConfigEntity();
    entity.setClusterEntity(clusterEntity);
    entity.setClusterId(Long.valueOf(cluster.getClusterId()));
    entity.setType(type);
    entity.setTag(getVersionTag());
    entity.setTimestamp(new Date().getTime());
   
    entity.setData(gson.toJson(getProperties()));
    clusterDAO.createConfig(entity);

    clusterEntity.getClusterConfigEntities().add(entity);
    clusterDAO.merge(clusterEntity);
    cluster.refresh();
View Full Code Here

            if (configType.contains(log4jConfigTypeContains)) {
              ClusterConfigEntityPK configEntityPK = new ClusterConfigEntityPK();
              configEntityPK.setClusterId(clusterId);
              configEntityPK.setType(configType);
              configEntityPK.setTag(defaultVersionTag);
              ClusterConfigEntity configEntity = clusterDAO.findConfig(configEntityPK);

              if (configEntity == null) {
                String filename = configType + ".xml";
                Map<String, String> properties = new HashMap<String, String>();
                for (PropertyInfo propertyInfo : serviceInfo.getProperties()) {
                  if (filename.equals(propertyInfo.getFilename())) {
                    properties.put(propertyInfo.getName(), propertyInfo.getValue());
                  }
                }
                if (!properties.isEmpty()) {
                  String configData = gson.toJson(properties);
                  configEntity = new ClusterConfigEntity();
                  configEntity.setClusterId(clusterId);
                  configEntity.setType(configType);
                  configEntity.setTag(defaultVersionTag);
                  configEntity.setData(configData);
                  configEntity.setTimestamp(System.currentTimeMillis());
                  configEntity.setClusterEntity(clusterEntity);
                  LOG.debug("Creating new " + configType + " config...");
                  clusterDAO.createConfig(configEntity);

                  Collection<ClusterConfigMappingEntity> entities =
                    clusterEntity.getConfigMappingEntities();

                  ClusterConfigMappingEntity clusterConfigMappingEntity =
                    new ClusterConfigMappingEntity();
                  clusterConfigMappingEntity.setClusterEntity(clusterEntity);
                  clusterConfigMappingEntity.setClusterId(clusterId);
                  clusterConfigMappingEntity.setType(configType);
                  clusterConfigMappingEntity.setCreateTimestamp(
                    Long.valueOf(System.currentTimeMillis()));
                  clusterConfigMappingEntity.setSelected(1);
                  clusterConfigMappingEntity.setUser(defaultUser);
                  clusterConfigMappingEntity.setVersion(configEntity.getTag());
                  entities.add(clusterConfigMappingEntity);
                  clusterDAO.merge(clusterEntity);
                }
              }
            }
View Full Code Here

          Long clusterId = clusterEntity.getClusterId();
          ClusterConfigEntityPK configEntityPK = new ClusterConfigEntityPK();
          configEntityPK.setClusterId(clusterId);
          configEntityPK.setType("hdfs-exclude-file");
          configEntityPK.setTag(value.trim());
          ClusterConfigEntity configEntity = clusterDAO.findConfig(configEntityPK);
          if (configEntity != null) {
            String configData = configEntity.getData();
            if (configData != null) {
              Map<String, String> properties = gson.<Map<String, String>>fromJson(configData, Map.class);
              if (properties != null && !properties.isEmpty()) {
                String decommissionedNodes = properties.get("datanodes");
                if (decommissionedNodes != null) {
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.orm.entities.ClusterConfigEntity

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.