Examples of ClusterEntity


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

  @Override
  @Transactional
  public synchronized Cluster getCluster(String clusterName)
      throws AmbariException {
    if (!clusters.containsKey(clusterName)) {
      ClusterEntity clusterEntity = clusterDAO.findByName(clusterName);
      if (clusterEntity != null) {
        Cluster cl = getClusterById(clusterEntity.getClusterId());
        clustersById.put(cl.getClusterId(), cl);
        clusters.put(cl.getClusterName(), cl);
        if (!clusterHostMap.containsKey(clusterEntity.getClusterName()))
          clusterHostMap.put(clusterEntity.getClusterName(), new HashSet<Host>());
      } else {
        throw new ClusterNotFoundException(clusterName);
      }
    }
    return clusters.get(clusterName);
View Full Code Here

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

  @Override
  @Transactional
  public synchronized Cluster getClusterById(long id) throws AmbariException {
    if (!clustersById.containsKey(id)) {
      ClusterEntity clusterEntity = clusterDAO.findById(id);
      if (clusterEntity != null) {
        Cluster cluster = clusterFactory.create(clusterEntity);
        clustersById.put(cluster.getClusterId(), cluster);
        clusters.put(clusterEntity.getClusterName(), cluster);
        if (!clusterHostMap.containsKey(clusterEntity.getClusterName()))
          clusterHostMap.put(clusterEntity.getClusterName(), new HashSet<Host>());
      } else {
        throw new ClusterNotFoundException("clusterID=" + id);
      }
    }
    return clustersById.get(id);
View Full Code Here

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

  }

  @Transactional
  void mapHostClusterEntities(String hostName, Long clusterId) {
    HostEntity hostEntity = hostDAO.findByName(hostName);
    ClusterEntity clusterEntity = clusterDAO.findById(clusterId);

    hostEntity.getClusterEntities().add(clusterEntity);
    clusterEntity.getHostEntities().add(hostEntity);

    clusterDAO.merge(clusterEntity);
    hostDAO.merge(hostEntity);
  }
View Full Code Here

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

      try {
        cluster = clusters.getCluster(stage.getClusterName());
      } catch (AmbariException e) {
        throw new RuntimeException(e);
      }
      ClusterEntity clusterEntity = clusterDAO.findById(cluster.getClusterId());

      stageEntity.setCluster(clusterEntity);
      stageDAO.create(stageEntity);

      for (HostRoleCommand hostRoleCommand : stage.getOrderedHostRoleCommands()) {
View Full Code Here

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

  private ConfigGroupEntity createConfigGroup(String clusterName,
         String groupName, String tag, String desc, List<HostEntity> hosts,
         List<ClusterConfigEntity> configs) throws Exception {
    ConfigGroupEntity configGroupEntity = new ConfigGroupEntity();

    ClusterEntity clusterEntity = new ClusterEntity();
    clusterEntity.setClusterName(clusterName);
    clusterDAO.create(clusterEntity);

    configGroupEntity.setClusterEntity(clusterEntity);
    configGroupEntity.setClusterId(clusterEntity.getClusterId());
    configGroupEntity.setGroupName(groupName);
    configGroupEntity.setDescription(desc);
    configGroupEntity.setTag(tag);

    configGroupDAO.create(configGroupEntity);

    if (hosts != null && !hosts.isEmpty()) {
      List<ConfigGroupHostMappingEntity> hostMappingEntities = new
        ArrayList<ConfigGroupHostMappingEntity>();

      for (HostEntity host : hosts) {
        hostDAO.create(host);

        ConfigGroupHostMappingEntity hostMappingEntity = new
          ConfigGroupHostMappingEntity();
        hostMappingEntity.setHostname(host.getHostName());
        hostMappingEntity.setHostEntity(host);
        hostMappingEntity.setConfigGroupEntity(configGroupEntity);
        hostMappingEntity.setConfigGroupId(configGroupEntity.getGroupId());
        hostMappingEntities.add(hostMappingEntity);
        configGroupHostMappingDAO.create(hostMappingEntity);
      }
      configGroupEntity.setConfigGroupHostMappingEntities(hostMappingEntities);
      configGroupDAO.merge(configGroupEntity);
    }

    if (configs != null && !configs.isEmpty()) {
      List<ConfigGroupConfigMappingEntity> configMappingEntities = new
        ArrayList<ConfigGroupConfigMappingEntity>();

      for (ClusterConfigEntity config : configs) {
        config.setClusterEntity(clusterEntity);
        config.setClusterId(clusterEntity.getClusterId());
        clusterDAO.createConfig(config);

        ConfigGroupConfigMappingEntity configMappingEntity = new
          ConfigGroupConfigMappingEntity();
        configMappingEntity.setClusterId(clusterEntity.getClusterId());
        configMappingEntity.setClusterConfigEntity(config);
        configMappingEntity.setConfigGroupEntity(configGroupEntity);
        configMappingEntity.setConfigGroupId(configGroupEntity.getGroupId());
        configMappingEntity.setVersionTag(config.getTag());
        configMappingEntity.setConfigType(config.getType());
View Full Code Here

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

        throw new DuplicateResourceException("Attempted to create a Cluster which already exists"
            + ", clusterName=" + clusterName);
      }
      // retrieve new cluster id
      // add cluster id -> cluster mapping into clustersById
      ClusterEntity clusterEntity = new ClusterEntity();
      clusterEntity.setClusterName(clusterName);
      clusterEntity.setDesiredStackVersion(gson.toJson(new StackId()));

      try {
        clusterDAO.create(clusterEntity);
        clusterEntity = clusterDAO.merge(clusterEntity);
      } catch (RollbackException e) {
View Full Code Here

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

  }
 
  @Transactional
  void mapHostClusterEntities(String hostName, Long clusterId) {
    HostEntity hostEntity = hostDAO.findByName(hostName);
    ClusterEntity clusterEntity = clusterDAO.findById(clusterId);

    hostEntity.getClusterEntities().add(clusterEntity);
    clusterEntity.getHostEntities().add(hostEntity);

    clusterDAO.merge(clusterEntity);
    hostDAO.merge(hostEntity);
  }
View Full Code Here

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

  }
 
  @Transactional
  private void unmapHostClusterEntities(String hostName, long clusterId) {
    HostEntity hostEntity = hostDAO.findByName(hostName);
    ClusterEntity clusterEntity = clusterDAO.findById(clusterId);

    hostEntity.getClusterEntities().remove(clusterEntity);
    clusterEntity.getHostEntities().remove(hostEntity);

    configGroupHostMappingDAO.removeAllByHost(hostName);
   
    hostDAO.merge(hostEntity);
    clusterDAO.merge(clusterEntity);
View Full Code Here

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

   *
   * @throws Exception
   */
  @Transactional
  private void persistEntities() {
    ClusterEntity clusterEntity = clusterDAO.findById(cluster.getClusterId());
    configGroupEntity.setClusterEntity(clusterEntity);
    configGroupEntity.setTimestamp(System.currentTimeMillis());
    configGroupDAO.create(configGroupEntity);

    persistConfigMapping(clusterEntity);
View Full Code Here

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

    }
  }

  @Transactional
  private void saveIfPersisted() {
    ClusterEntity clusterEntity = clusterDAO.findById(cluster.getClusterId());

    if (isPersisted) {
      configGroupDAO.merge(configGroupEntity);
      persistHostMapping();
      persistConfigMapping(clusterEntity);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.