Package org.apache.ambari.server.controller

Examples of org.apache.ambari.server.controller.HostResponse


  @Override
  public HostResponse convertToResponse() {
    try {
      readLock.lock();
      HostResponse r = new HostResponse(getHostName());

      r.setAgentVersion(getAgentVersion());
      r.setAvailableMemBytes(getAvailableMemBytes());
      r.setPhCpuCount(getPhCpuCount());
      r.setCpuCount(getCpuCount());
      r.setDisksInfo(getDisksInfo());
      r.setHealthStatus(getHealthStatus());
      r.setHostAttributes(getHostAttributes());
      r.setIpv4(getIPv4());
      r.setIpv6(getIPv6());
      r.setLastHeartbeatTime(getLastHeartbeatTime());
      r.setLastAgentEnv(lastAgentEnv);
      r.setLastRegistrationTime(getLastRegistrationTime());
      r.setOsArch(getOsArch());
      r.setOsInfo(getOsInfo());
      r.setOsType(getOsType());
      r.setRackInfo(getRackInfo());
      r.setTotalMemBytes(getTotalMemBytes());
      r.setPublicHostName(getPublicHostName());
      r.setHostState(getState().toString());
      r.setStatus(getStatus());

      return r;
    }
    finally {
      readLock.unlock();
View Full Code Here


    if (clusterName == null) {
      return false;
    }

    HostResponse gangliaCollectorHost;

    try {

      final String gangliaCollectorHostName = getGangliaCollectorHostName(clusterName);

      HostRequest hostRequest = new HostRequest(gangliaCollectorHostName, clusterName, Collections.<String, String>emptyMap());
      Set<HostResponse> hosts = HostResourceProvider.getHosts(managementController, hostRequest);

      gangliaCollectorHost = hosts.size() == 1 ? hosts.iterator().next() : null;
    } catch (AmbariException e) {
      LOG.debug("Error checking of Ganglia server host live status: ", e);
      return false;
    }
   
    //Cluster without Ganglia
    return gangliaCollectorHost != null &&
        !gangliaCollectorHost.getHostState().equals(HostState.HEARTBEAT_LOST.name());
  }
View Full Code Here

    Resource.Type type = Resource.Type.Host;

    AmbariManagementController managementController = createMock(AmbariManagementController.class);

    Set<HostResponse> allResponse = new HashSet<HostResponse>();
    allResponse.add(new HostResponse("Host100", "Cluster100",
        "", "", 2, 1, "", "", "", 100000L, 200000L, null, 10L,
        0L, "rack info", null, null,
        new HostHealthStatus(HostHealthStatus.HealthStatus.HEALTHY, "HEALTHY"), "HEALTHY"));
    allResponse.add(new HostResponse("Host101", "Cluster100",
        "", "", 2, 1, "", "", "", 100000L, 200000L, null, 10L,
        0L, "rack info", null, null,
        new HostHealthStatus(HostHealthStatus.HealthStatus.HEALTHY, "HEALTHY"), "HEALTHY"));
    allResponse.add(new HostResponse("Host102", "Cluster100",
        "", "", 2, 1, "", "", "", 100000L, 200000L, null, 10L,
        0L, "rack info", null, null,
        new HostHealthStatus(HostHealthStatus.HealthStatus.HEALTHY, "HEALTHY"), "HEALTHY"));

    // set expectations
View Full Code Here

  public void testUpdateDesiredConfig() throws Exception {

    AmbariManagementController managementController = createMock(AmbariManagementController.class);
    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);

    HostResponse hr = new HostResponse("Host100", "Cluster100",
        "", "", 2, 1, "", "", "", 100000L, 200000L, null, 10L,
        0L, "rack info", null, null,
        new HostHealthStatus(HostHealthStatus.HealthStatus.HEALTHY, "HEALTHY"), "HEALTHY");
   
    Set<HostResponse> hostResponseSet = new HashSet<HostResponse>();
View Full Code Here

    AmbariManagementController managementController = createMock(AmbariManagementController.class);
    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);

    Set<HostResponse> hostResponseSet = new HashSet<HostResponse>();
    hostResponseSet.add(new HostResponse("Host100", "Cluster100",
        "", "", 2, 1, "", "", "", 100000L, 200000L, null, 10L,
        0L, "rack info", null, null,
        new HostHealthStatus(HostHealthStatus.HealthStatus.HEALTHY, "HEALTHY"), "HEALTHY"));

    // set expectations
View Full Code Here

  @Override
  public HostResponse convertToResponse() {
    try {
      readLock.lock();
      HostResponse r = new HostResponse(getHostName());

      r.setAgentVersion(getAgentVersion());
      r.setAvailableMemBytes(getAvailableMemBytes());
      r.setPhCpuCount(getPhCpuCount());
      r.setCpuCount(getCpuCount());
      r.setDisksInfo(getDisksInfo());
      r.setHealthStatus(getHealthStatus());
      r.setHostAttributes(getHostAttributes());
      r.setIpv4(getIPv4());
      r.setIpv6(getIPv6());
      r.setLastHeartbeatTime(getLastHeartbeatTime());
      r.setLastAgentEnv(lastAgentEnv);
      r.setLastRegistrationTime(getLastRegistrationTime());
      r.setOsArch(getOsArch());
      r.setOsInfo(getOsInfo());
      r.setOsType(getOsType());
      r.setRackInfo(getRackInfo());
      r.setTotalMemBytes(getTotalMemBytes());
      r.setPublicHostName(getPublicHostName());
      r.setHostState(getState().toString());

      return r;
    }
    finally {
      readLock.unlock();
View Full Code Here

  @Override
  public HostResponse convertToResponse() {
    try {
      readLock.lock();
      HostResponse r = new HostResponse(getHostName());

      r.setAgentVersion(getAgentVersion());
      r.setAvailableMemBytes(getAvailableMemBytes());
      r.setCpuCount(getCpuCount());
      r.setDisksInfo(getDisksInfo());
      r.setHealthStatus(getHealthStatus());
      r.setHostAttributes(getHostAttributes());
      r.setIpv4(getIPv4());
      r.setIpv6(getIPv6());
      r.setLastHeartbeatTime(getLastHeartbeatTime());
      r.setLastAgentEnv(lastAgentEnv);
      r.setLastRegistrationTime(getLastRegistrationTime());
      r.setOsArch(getOsArch());
      r.setOsInfo(getOsInfo());
      r.setOsType(getOsType());
      r.setRackInfo(getRackInfo());
      r.setTotalMemBytes(getTotalMemBytes());
      r.setPublicHostName(getPublicHostName());
      r.setHostState(getState().toString());

      return r;
    }
    finally {
      readLock.unlock();
View Full Code Here

  @Override
  public HostResponse convertToResponse() {
    try {
      readLock.lock();
      HostResponse r = new HostResponse(getHostName());

      r.setAgentVersion(getAgentVersion());
      r.setAvailableMemBytes(getAvailableMemBytes());
      r.setCpuCount(getCpuCount());
      r.setDisksInfo(getDisksInfo());
      r.setHealthStatus(getHealthStatus());
      r.setHostAttributes(getHostAttributes());
      r.setIpv4(getIPv4());
      r.setIpv6(getIPv6());
      r.setLastHeartbeatTime(getLastHeartbeatTime());
      r.setLastRegistrationTime(getLastRegistrationTime());
      r.setOsArch(getOsArch());
      r.setOsInfo(getOsInfo());
      r.setOsType(getOsType());
      r.setRackInfo(getRackInfo());
      r.setTotalMemBytes(getTotalMemBytes());
      r.setPublicHostName(getPublicHostName());
      r.setHostState(getState().toString());

      return r;
    }
    finally {
      readLock.unlock();
View Full Code Here

    Host host2 = createNiceMock(Host.class);
    Host host3 = createNiceMock(Host.class);
    HostHealthStatus healthStatus = createNiceMock(HostHealthStatus.class);
    AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);

    HostResponse hostResponse1 = createNiceMock(HostResponse.class);
    HostResponse hostResponse2 = createNiceMock(HostResponse.class);
    HostResponse hostResponse3 = createNiceMock(HostResponse.class);

    List<Host> hosts = new LinkedList<Host>();
    hosts.add(host1);
    hosts.add(host2);
    hosts.add(host3);

    Set<Cluster> clusterSet = new HashSet<Cluster>();
    clusterSet.add(cluster);

    // set expectations
    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
    expect(managementController.getHostComponents((Set<ServiceComponentHostRequest>) anyObject())).andReturn(Collections.<ServiceComponentHostResponse>emptySet()).anyTimes();

    expect(clusters.getHosts()).andReturn(hosts).anyTimes();

    expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();

    expect(clusters.getClustersForHost("Host100")).andReturn(clusterSet).anyTimes();
    expect(clusters.getClustersForHost("Host101")).andReturn(clusterSet).anyTimes();
    expect(clusters.getClustersForHost("Host102")).andReturn(clusterSet).anyTimes();

    expect(host1.getHostName()).andReturn("Host100").anyTimes();
    expect(host2.getHostName()).andReturn("Host101").anyTimes();
    expect(host3.getHostName()).andReturn("Host102").anyTimes();

    expect(host1.convertToResponse()).andReturn(hostResponse1);
    expect(host2.convertToResponse()).andReturn(hostResponse2);
    expect(host3.convertToResponse()).andReturn(hostResponse3);

    expect(hostResponse1.getClusterName()).andReturn("Cluster100").anyTimes();
    expect(hostResponse2.getClusterName()).andReturn("Cluster100").anyTimes();
    expect(hostResponse3.getClusterName()).andReturn("Cluster100").anyTimes();
    expect(hostResponse1.getHostname()).andReturn("Host100").anyTimes();
    expect(hostResponse2.getHostname()).andReturn("Host101").anyTimes();
    expect(hostResponse3.getHostname()).andReturn("Host102").anyTimes();
    expect(hostResponse1.getHealthStatus()).andReturn(healthStatus).anyTimes();
    expect(hostResponse2.getHealthStatus()).andReturn(healthStatus).anyTimes();
    expect(hostResponse3.getHealthStatus()).andReturn(healthStatus).anyTimes();

    expect(healthStatus.getHealthStatus()).andReturn(HostHealthStatus.HealthStatus.HEALTHY).anyTimes();
    expect(healthStatus.getHealthReport()).andReturn("HEALTHY").anyTimes();

    // replay
View Full Code Here

    Host host1 = createNiceMock(Host.class);
    HostHealthStatus healthStatus = createNiceMock(HostHealthStatus.class);
    AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
    ComponentInfo componentInfo = createNiceMock(ComponentInfo.class);

    HostResponse hostResponse1 = createNiceMock(HostResponse.class);

    List<Host> hosts = new LinkedList<Host>();
    hosts.add(host1);

    Set<Cluster> clusterSet = new HashSet<Cluster>();
    clusterSet.add(cluster);

    ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component100", "Host100", "STARTED", "", null, null);
    ServiceComponentHostResponse shr2 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component102", "Host100", "STARTED", "", null, null);
    ServiceComponentHostResponse shr3 = new ServiceComponentHostResponse("Cluster100", "Service100", "Component103", "Host100", "STARTED", "", null, null);

    Set<ServiceComponentHostResponse> responses = new HashSet<ServiceComponentHostResponse>();
    responses.add(shr1);
    responses.add(shr2);
    responses.add(shr3);

    // set expectations
    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
    expect(managementController.getHostComponents((Set<ServiceComponentHostRequest>) anyObject())).andReturn(responses).anyTimes();

    expect(clusters.getHosts()).andReturn(hosts).anyTimes();

    expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();

    expect(clusters.getClustersForHost("Host100")).andReturn(clusterSet).anyTimes();

    expect(host1.getHostName()).andReturn("Host100").anyTimes();

    expect(host1.convertToResponse()).andReturn(hostResponse1);

    expect(hostResponse1.getClusterName()).andReturn("").anyTimes();
    expect(hostResponse1.getHostname()).andReturn("Host100").anyTimes();
    expect(hostResponse1.getHealthStatus()).andReturn(healthStatus).anyTimes();

    expect(healthStatus.getHealthStatus()).andReturn(HostHealthStatus.HealthStatus.HEALTHY).anyTimes();
    expect(healthStatus.getHealthReport()).andReturn("HEALTHY").anyTimes();

View Full Code Here

TOP

Related Classes of org.apache.ambari.server.controller.HostResponse

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.