Examples of HostConfigMapping


Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

  @Transactional
  public boolean addDesiredConfig(long clusterId, boolean selected, String user, Config config) {
    if (null == user)
      throw new NullPointerException("User must be specified.");
   
    HostConfigMapping exist = getDesiredConfigEntity(clusterId, config.getType());
    if (null != exist && exist.getVersion().equals(config.getVersionTag())) {
      if (!selected) {
        exist.setSelected(0);
        hostConfigMappingDAO.merge(exist);
      }
      return false;
    }
   
    writeLock.lock();
   
    try {
      // set all old mappings for this type to empty
      for (HostConfigMapping e : hostConfigMappingDAO.findByType(clusterId,
          hostEntity.getHostName(), config.getType())) {
        e.setSelected(0);
        hostConfigMappingDAO.merge(e);
      }
     
      HostConfigMapping hostConfigMapping = new HostConfigMappingImpl();
      hostConfigMapping.setClusterId(Long.valueOf(clusterId));
      hostConfigMapping.setCreateTimestamp(Long.valueOf(System.currentTimeMillis()));
      hostConfigMapping.setHostName(hostEntity.getHostName());
      hostConfigMapping.setSelected(1);
      hostConfigMapping.setUser(user);
      hostConfigMapping.setType(config.getType());
      hostConfigMapping.setVersion(config.getVersionTag());
     
      hostConfigMappingDAO.create(hostConfigMapping);
    }
    finally {
      writeLock.unlock();
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

    }
    return hostConfigMap;
  }

  private HostConfigMapping getDesiredConfigEntity(long clusterId, String type) {
    HostConfigMapping findSelectedByType = hostConfigMappingDAO.findSelectedByType(clusterId,
        hostEntity.getHostName(), type);
   
   
    return findSelectedByType;
  }
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

  @Transactional
  public boolean addDesiredConfig(long clusterId, boolean selected, String user, Config config) {
    if (null == user)
      throw new NullPointerException("User must be specified.");
   
    HostConfigMapping exist = getDesiredConfigEntity(clusterId, config.getType());
    if (null != exist && exist.getVersion().equals(config.getVersionTag())) {
      if (!selected) {
        exist.setSelected(0);
        hostConfigMappingDAO.merge(exist);
      }
      return false;
    }
   
    writeLock.lock();
   
    try {
      // set all old mappings for this type to empty
      for (HostConfigMapping e : hostConfigMappingDAO.findByType(clusterId,
          hostEntity.getHostName(), config.getType())) {
        e.setSelected(0);
        hostConfigMappingDAO.merge(e);
      }
     
      HostConfigMapping hostConfigMapping = new HostConfigMappingImpl();
      hostConfigMapping.setClusterId(Long.valueOf(clusterId));
      hostConfigMapping.setCreateTimestamp(Long.valueOf(System.currentTimeMillis()));
      hostConfigMapping.setHostName(hostEntity.getHostName());
      hostConfigMapping.setSelected(1);
      hostConfigMapping.setUser(user);
      hostConfigMapping.setType(config.getType());
      hostConfigMapping.setVersion(config.getVersionTag());
     
      hostConfigMappingDAO.create(hostConfigMapping);
    }
    finally {
      writeLock.unlock();
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

    }
    return hostConfigMap;
  }

  private HostConfigMapping getDesiredConfigEntity(long clusterId, String type) {
    HostConfigMapping findSelectedByType = hostConfigMappingDAO.findSelectedByType(clusterId,
        hostEntity.getHostName(), type);
   
   
    return findSelectedByType;
  }
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

              if (setByHost == null) {
                setByHost = new HashSet<HostConfigMapping>();
                hostConfigMappingByHost.put(hostConfigMappingEntity.getHostName(), setByHost);
              }
      
              HostConfigMapping hostConfigMapping = buildHostConfigMapping(hostConfigMappingEntity);
              setByHost.add(hostConfigMapping);
            }
          }
        } finally {
          gl.writeLock().unlock();
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

    if (!hostConfigMappingByHost.containsKey(hostName))
      return null;
   
    Set<HostConfigMapping> set = new HashSet<HostConfigMapping>(hostConfigMappingByHost.get(hostName));
   
    HostConfigMapping result = (HostConfigMapping) CollectionUtils.find(set, new Predicate() {
     
      @Override
      public boolean evaluate(Object arg0) {
       
        return ((HostConfigMapping) arg0).getClusterId().equals(clusterId)
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

  }
 
  public HostConfigMapping buildHostConfigMapping(
      HostConfigMappingEntity hostConfigMappingEntity) {
   
    HostConfigMapping hostConfigMapping = new HostConfigMappingImpl();
   
    hostConfigMapping.setClusterId(hostConfigMappingEntity.getClusterId());
    hostConfigMapping.setCreateTimestamp(hostConfigMappingEntity.getCreateTimestamp());
    hostConfigMapping.setHostName(hostConfigMappingEntity.getHostName());
    hostConfigMapping.setServiceName(hostConfigMappingEntity.getServiceName());
    hostConfigMapping.setType(hostConfigMappingEntity.getType());
    hostConfigMapping.setUser(hostConfigMappingEntity.getUser());
    hostConfigMapping.setSelected(hostConfigMappingEntity.isSelected());
    hostConfigMapping.setVersion(hostConfigMappingEntity.getVersion());
   
    return hostConfigMapping;
  }
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

  public void teardown() throws AmbariException {
    injector.getInstance(PersistService.class).stop();
  }
 
  private HostConfigMapping createEntity(long clusterId, String host, String type, String version) throws Exception {
    HostConfigMapping entity = new HostConfigMappingImpl();
    entity.setClusterId(Long.valueOf(clusterId));
    entity.setCreateTimestamp(Long.valueOf(System.currentTimeMillis()));
    entity.setHostName(host);
    entity.setSelected(1);
    entity.setType(type);
    entity.setVersion(version);
    entity.setUser("_test");
   
    hostConfigMappingDAO.create(entity);
   
    return entity;
  }
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

  }
 

  @Test
  public void testFindByType() throws Exception {
    HostConfigMapping source = createEntity(1L, "h1", "global", "v1");
   
    Set<HostConfigMapping> target = hostConfigMappingDAO.findByType(1L, "h1", "global");

    Assert.assertEquals("Expected one result", 1, target.size());
   
    for (HostConfigMapping item : target)
      Assert.assertEquals("Expected version 'v1'", source.getVersion(), item.getVersion());
  }
View Full Code Here

Examples of org.apache.ambari.server.orm.cache.HostConfigMapping

      Assert.assertEquals("Expected version 'v1'", source.getVersion(), item.getVersion());
  }
 
  @Test
  public void testMerge() throws Exception {
    HostConfigMapping source = createEntity(1L, "h1", "global", "v1");
   
    Set<HostConfigMapping> target = hostConfigMappingDAO.findByType(1L, "h1", "global");

    Assert.assertEquals("Expected one result", 1, target.size());
   
    HostConfigMapping toChange = null;
   
    for (HostConfigMapping item: target) {
     
      Assert.assertEquals("Expected version 'v1'", source.getVersion(), item.getVersion());
      Assert.assertEquals("Expected selected flag 1", 1, (int)item.getSelected());
     
      toChange = item;
     
      toChange.setSelected(0);
     
    }
   

   
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.