Search in sources :

Example 1 with CheckHealthCommand

use of com.cloud.legacymodel.communication.command.CheckHealthCommand in project cosmic by MissionCriticalCloud.

the class AgentManagerImpl method investigate.

protected HostStatus investigate(final AgentAttache agent) {
    final Long hostId = agent.getId();
    final HostVO host = this._hostDao.findById(hostId);
    if (host != null && host.getType() != null && !host.getType().isVirtual()) {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("checking if agent (" + hostId + ") is alive");
        }
        final Answer answer = easySend(hostId, new CheckHealthCommand());
        if (answer != null && answer.getResult()) {
            final HostStatus status = HostStatus.Up;
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("agent (" + hostId + ") responded to checkHeathCommand, reporting that agent is " + status);
            }
            return status;
        }
        return this._haMgr.investigate(hostId);
    }
    return HostStatus.Alert;
}
Also used : AgentControlAnswer(com.cloud.legacymodel.communication.answer.AgentControlAnswer) StartupAnswer(com.cloud.legacymodel.communication.answer.StartupAnswer) PingAnswer(com.cloud.legacymodel.communication.answer.PingAnswer) ReadyAnswer(com.cloud.legacymodel.communication.answer.ReadyAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) UnsupportedAnswer(com.cloud.legacymodel.communication.answer.UnsupportedAnswer) HostStatus(com.cloud.legacymodel.dc.HostStatus) HostVO(com.cloud.host.HostVO) CheckHealthCommand(com.cloud.legacymodel.communication.command.CheckHealthCommand)

Example 2 with CheckHealthCommand

use of com.cloud.legacymodel.communication.command.CheckHealthCommand in project cosmic by MissionCriticalCloud.

the class NiciraCheckHealthCommandWrapperTest method tetsExecuteWhenClusterIsNotStable.

@Test
public void tetsExecuteWhenClusterIsNotStable() throws Exception {
    when(niciraApi.getControlClusterStatus()).thenReturn(new ControlClusterStatus());
    final NiciraCheckHealthCommandWrapper commandWrapper = new NiciraCheckHealthCommandWrapper();
    final Answer answer = commandWrapper.execute(new CheckHealthCommand(), niciraResource);
    assertThat(answer.getResult(), equalTo(false));
}
Also used : ControlClusterStatus(com.cloud.network.nicira.ControlClusterStatus) Answer(com.cloud.legacymodel.communication.answer.Answer) CheckHealthCommand(com.cloud.legacymodel.communication.command.CheckHealthCommand) Test(org.junit.Test)

Example 3 with CheckHealthCommand

use of com.cloud.legacymodel.communication.command.CheckHealthCommand in project cosmic by MissionCriticalCloud.

the class NiciraCheckHealthCommandWrapperTest method tetsExecuteWhenClusterIsStable.

@Test
public void tetsExecuteWhenClusterIsStable() throws Exception {
    final ControlClusterStatus statusValue = mock(ControlClusterStatus.class);
    when(statusValue.getClusterStatus()).thenReturn("stable");
    when(niciraApi.getControlClusterStatus()).thenReturn(statusValue);
    final NiciraCheckHealthCommandWrapper commandWrapper = new NiciraCheckHealthCommandWrapper();
    final Answer answer = commandWrapper.execute(new CheckHealthCommand(), niciraResource);
    assertThat(answer.getResult(), equalTo(true));
}
Also used : ControlClusterStatus(com.cloud.network.nicira.ControlClusterStatus) Answer(com.cloud.legacymodel.communication.answer.Answer) CheckHealthCommand(com.cloud.legacymodel.communication.command.CheckHealthCommand) Test(org.junit.Test)

Example 4 with CheckHealthCommand

use of com.cloud.legacymodel.communication.command.CheckHealthCommand in project cosmic by MissionCriticalCloud.

the class LibvirtComputingResourceTest method testCheckHealthCommand.

@Test
public void testCheckHealthCommand() {
    final CheckHealthCommand command = new CheckHealthCommand();
    final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
    assertTrue(answer.getResult());
}
Also used : Answer(com.cloud.legacymodel.communication.answer.Answer) CheckRouterAnswer(com.cloud.legacymodel.communication.answer.CheckRouterAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) LibvirtRequestWrapper(com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper) CheckHealthCommand(com.cloud.legacymodel.communication.command.CheckHealthCommand) Test(org.junit.Test)

Example 5 with CheckHealthCommand

use of com.cloud.legacymodel.communication.command.CheckHealthCommand in project cosmic by MissionCriticalCloud.

the class NotAValidCommand method testCheckHealthCommand.

@Test
public void testCheckHealthCommand() {
    final CheckHealthCommand checkHealthCommand = new CheckHealthCommand();
    final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
    assertNotNull(wrapper);
    final Answer answer = wrapper.execute(checkHealthCommand, this.citrixResourceBase);
    assertFalse(answer.getResult());
}
Also used : RebootAnswer(com.cloud.legacymodel.communication.answer.RebootAnswer) Answer(com.cloud.legacymodel.communication.answer.Answer) CreateAnswer(com.cloud.legacymodel.communication.answer.CreateAnswer) AttachAnswer(com.cloud.legacymodel.communication.answer.AttachAnswer) CheckHealthCommand(com.cloud.legacymodel.communication.command.CheckHealthCommand) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Answer (com.cloud.legacymodel.communication.answer.Answer)6 CheckHealthCommand (com.cloud.legacymodel.communication.command.CheckHealthCommand)6 Test (org.junit.Test)5 AttachAnswer (com.cloud.legacymodel.communication.answer.AttachAnswer)2 ControlClusterStatus (com.cloud.network.nicira.ControlClusterStatus)2 LibvirtRequestWrapper (com.cloud.agent.resource.kvm.wrapper.LibvirtRequestWrapper)1 HostVO (com.cloud.host.HostVO)1 AgentControlAnswer (com.cloud.legacymodel.communication.answer.AgentControlAnswer)1 CheckRouterAnswer (com.cloud.legacymodel.communication.answer.CheckRouterAnswer)1 CreateAnswer (com.cloud.legacymodel.communication.answer.CreateAnswer)1 PingAnswer (com.cloud.legacymodel.communication.answer.PingAnswer)1 ReadyAnswer (com.cloud.legacymodel.communication.answer.ReadyAnswer)1 RebootAnswer (com.cloud.legacymodel.communication.answer.RebootAnswer)1 StartupAnswer (com.cloud.legacymodel.communication.answer.StartupAnswer)1 UnsupportedAnswer (com.cloud.legacymodel.communication.answer.UnsupportedAnswer)1 HostStatus (com.cloud.legacymodel.dc.HostStatus)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1