test_class.declarator: hostDao
test_class.modifier: @Mock
test_class.original_string: @Mock
      HostDao hostDao;
test_class.type: HostDao
test_class.var_name: hostDao
test_class.declarator: agentManager
test_class.modifier: @Mock
test_class.original_string: @Mock
      AgentManager agentManager;
test_class.type: AgentManager
test_class.var_name: agentManager
test_class.declarator: alertMgr
test_class.modifier: @Mock
test_class.original_string: @Mock
      AlertManager alertMgr;
test_class.type: AlertManager
test_class.var_name: alertMgr
test_class.declarator: resourceManager
test_class.modifier: @Mock
test_class.original_string: @Mock
      ResourceManager resourceManager;
test_class.type: ResourceManager
test_class.var_name: resourceManager
test_class.declarator: fencer
test_class.original_string: KVMFencer fencer;
test_class.type: KVMFencer
test_class.var_name: fencer
test_class.file: cosmic-core/server/src/test/java/com/cloud/ha/KVMFencerTest.java
test_class.identifier: KVMFencerTest
test_case.body: @Test
      public void testWithTimeoutingFence() throws AgentUnavailableException, OperationTimedoutException {
          final HostVO host = Mockito.mock(HostVO.class);
          Mockito.when(host.getClusterId()).thenReturn(1l);
          Mockito.when(host.getHypervisorType()).thenReturn(HypervisorType.KVM);
          Mockito.when(host.getStatus()).thenReturn(HostStatus.Up);
          Mockito.when(host.getDataCenterId()).thenReturn(1l);
          Mockito.when(host.getPodId()).thenReturn(1l);
          Mockito.when(host.getId()).thenReturn(1l);
  
          final HostVO secondHost = Mockito.mock(HostVO.class);
          Mockito.when(secondHost.getClusterId()).thenReturn(1l);
          Mockito.when(secondHost.getHypervisorType()).thenReturn(HypervisorType.KVM);
          Mockito.when(secondHost.getStatus()).thenReturn(HostStatus.Up);
          Mockito.when(secondHost.getDataCenterId()).thenReturn(1l);
          Mockito.when(secondHost.getPodId()).thenReturn(1l);
          Mockito.when(host.getId()).thenReturn(2l);
  
          final VirtualMachine virtualMachine = Mockito.mock(VirtualMachine.class);
  
          Mockito.when(resourceManager.listAllHostsInCluster(1l)).thenReturn(Arrays.asList(host, secondHost));
  
          Mockito.when(agentManager.send(Matchers.anyLong(), Matchers.any(FenceCommand.class))).thenThrow(new OperationTimedoutException(null, 2l, 0l, 0, false));
  
          Assert.assertFalse(fencer.fenceOff(virtualMachine, host));
      }
test_case.class_method_signature: KVMFencerTest.testWithTimeoutingFence()
test_case.full_signature: @Test public void testWithTimeoutingFence()
test_case.identifier: testWithTimeoutingFence
test_case.invocations: mock thenReturn when getClusterId thenReturn when getHypervisorType thenReturn when getStatus thenReturn when getDataCenterId thenReturn when getPodId thenReturn when getId mock thenReturn when getClusterId thenReturn when getHypervisorType thenReturn when getStatus thenReturn when getDataCenterId thenReturn when getPodId thenReturn when getId mock thenReturn when listAllHostsInCluster asList thenThrow when send anyLong any assertFalse fenceOff
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testWithTimeoutingFence()
focal_class.declarator: s_logger = LoggerFactory.getLogger(KVMFencer.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger s_logger = LoggerFactory.getLogger(KVMFencer.class);
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.declarator: _hostDao
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      HostDao _hostDao;
focal_class.type: HostDao
focal_class.var_name: _hostDao
focal_class.declarator: _agentMgr
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      AgentManager _agentMgr;
focal_class.type: AgentManager
focal_class.var_name: _agentMgr
focal_class.declarator: _alertMgr
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      AlertManager _alertMgr;
focal_class.type: AlertManager
focal_class.var_name: _alertMgr
focal_class.declarator: _resourceMgr
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      ResourceManager _resourceMgr;
focal_class.type: ResourceManager
focal_class.var_name: _resourceMgr
focal_class.file: cosmic-core/server/src/main/java/com/cloud/ha/KVMFencer.java
focal_class.identifier: KVMFencer
focal_class.interfaces: implements FenceBuilder
focal_class.class_method_signature: KVMFencer.KVMFencer()
focal_class.full_signature: public  KVMFencer()
focal_class.identifier: KVMFencer
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  KVMFencer()
focal_class.class_method_signature: KVMFencer.configure(final String name, final Map<String, Object> params)
focal_class.full_signature: @Override public boolean configure(final String name, final Map<String, Object> params)
focal_class.identifier: configure
focal_class.modifiers: @Override public
focal_class.parameters: (final String name, final Map<String, Object> params)
focal_class.return: boolean
focal_class.signature: boolean configure(final String name, final Map<String, Object> params)
focal_class.class_method_signature: KVMFencer.start()
focal_class.full_signature: @Override public boolean start()
focal_class.identifier: start
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean start()
focal_class.class_method_signature: KVMFencer.stop()
focal_class.full_signature: @Override public boolean stop()
focal_class.identifier: stop
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean stop()
focal_class.class_method_signature: KVMFencer.fenceOff(final VirtualMachine vm, final Host host)
focal_class.full_signature: @Override public Boolean fenceOff(final VirtualMachine vm, final Host host)
focal_class.identifier: fenceOff
focal_class.modifiers: @Override public
focal_class.parameters: (final VirtualMachine vm, final Host host)
focal_class.return: Boolean
focal_class.signature: Boolean fenceOff(final VirtualMachine vm, final Host host)
focal_class.superclass: extends AdapterBase
focal_method.body: @Override
      public Boolean fenceOff(final VirtualMachine vm, final Host host) {
          if (host.getHypervisorType() != HypervisorType.KVM) {
              s_logger.warn("Don't know how to fence non kvm hosts " + host.getHypervisorType());
              return null;
          }
  
          final List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(host.getClusterId());
          final FenceCommand fence = new FenceCommand(vm, host);
  
          int i = 0;
          for (final HostVO h : hosts) {
              if (h.getHypervisorType() == HypervisorType.KVM) {
                  if (h.getStatus() != HostStatus.Up) {
                      continue;
                  }
  
                  i++;
  
                  if (h.getId() == host.getId()) {
                      continue;
                  }
                  final FenceAnswer answer;
                  try {
                      answer = (FenceAnswer) _agentMgr.send(h.getId(), fence);
                  } catch (final AgentUnavailableException e) {
                      s_logger.info("Moving on to the next host because " + h.toString() + " is unavailable");
                      continue;
                  } catch (final OperationTimedoutException e) {
                      s_logger.info("Moving on to the next host because " + h.toString() + " is unavailable");
                      continue;
                  }
                  if (answer != null && answer.getResult()) {
                      return true;
                  }
              }
          }
  
          _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(),
                  "Unable to fence off host: " + host.getId(),
                  "Fencing off host " + host.getId() + " did not succeed after asking " + i + " hosts. " +
                          "Check Agent logs for more information.");
  
          s_logger.error("Unable to fence off " + vm.toString() + " on " + host.toString());
  
          return false;
      }
focal_method.class_method_signature: KVMFencer.fenceOff(final VirtualMachine vm, final Host host)
focal_method.full_signature: @Override public Boolean fenceOff(final VirtualMachine vm, final Host host)
focal_method.identifier: fenceOff
focal_method.invocations: getHypervisorType warn getHypervisorType listAllHostsInCluster getClusterId getHypervisorType getStatus getId getId send getId info toString info toString getResult sendAlert getDataCenterId getPodId getId getId error toString toString
focal_method.modifiers: @Override public
focal_method.parameters: (final VirtualMachine vm, final Host host)
focal_method.return: Boolean
focal_method.signature: Boolean fenceOff(final VirtualMachine vm, final Host host)