Package org.apache.ambari.server.state.host

Examples of org.apache.ambari.server.state.host.HostImpl


  @Override
  public synchronized void mapHostToCluster(String hostname,
      String clusterName) throws AmbariException {
    Cluster cluster = getCluster(clusterName);
    HostImpl host = (HostImpl) getHost(hostname);

    if (!hostClusterMap.containsKey(hostname)) {
      throw new HostNotFoundException(hostname);
    }

    for (Cluster c : hostClusterMap.get(hostname)) {
      if (c.getClusterName().equals(clusterName)) {
        throw new DuplicateResourceException("Attempted to create a host which already exists: clusterName=" +
            clusterName + ", hostName=" + hostname);
      }
    }

    if (!isOsSupportedByClusterStack(cluster, host)) {
      String message = "Trying to map host to cluster where stack does not"
          + " support host's os type"
          + ", clusterName=" + clusterName
          + ", clusterStackId=" + cluster.getDesiredStackVersion().getStackId()
          + ", hostname=" + hostname
          + ", hostOsType=" + host.getOsType();
      LOG.warn(message);
      throw new AmbariException(message);
    }

    mapHostClusterEntities(hostname, cluster.getClusterId());

    hostClusterMap.get(hostname).add(cluster);
    clusterHostMap.get(clusterName).add(host);

    cluster.refresh();
    host.refresh();

    if (LOG.isDebugEnabled()) {
      LOG.debug("Mapping a host to a cluster"
          + ", clusterName=" + clusterName
          + ", clusterId=" + cluster.getClusterId()
View Full Code Here


  @Override
  public synchronized void mapHostToCluster(String hostname,
      String clusterName) throws AmbariException {
    Cluster cluster = getCluster(clusterName);
    HostImpl host = (HostImpl) getHost(hostname);

    if (!hostClusterMap.containsKey(hostname)) {
      throw new HostNotFoundException(hostname);
    }

    for (Cluster c : hostClusterMap.get(hostname)) {
      if (c.getClusterName().equals(clusterName)) {
        throw new DuplicateResourceException("Attempted to create a host which already exists: clusterName=" +
            clusterName + ", hostName=" + hostname);
      }
    }

    if (!isOsSupportedByClusterStack(cluster, host)) {
      String message = "Trying to map host to cluster where stack does not"
          + " support host's os type"
          + ", clusterName=" + clusterName
          + ", clusterStackId=" + cluster.getDesiredStackVersion().getStackId()
          + ", hostname=" + hostname
          + ", hostOsType=" + host.getOsType();
      LOG.warn(message);
      throw new AmbariException(message);
    }

    mapHostClusterEntities(hostname, cluster.getClusterId());

    hostClusterMap.get(hostname).add(cluster);
    clusterHostMap.get(clusterName).add(host);

    cluster.refresh();
    host.refresh();

    if (LOG.isDebugEnabled()) {
      LOG.debug("Mapping a host to a cluster"
          + ", clusterName=" + clusterName
          + ", clusterId=" + cluster.getClusterId()
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.state.host.HostImpl

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.