Search in sources :

Example 1 with KVMHAVMActivityChecker

use of com.cloud.hypervisor.kvm.resource.KVMHAVMActivityChecker in project cloudstack by apache.

the class LibvirtCheckVMActivityOnStoragePoolCommandWrapper method execute.

@Override
public Answer execute(final CheckVMActivityOnStoragePoolCommand command, final LibvirtComputingResource libvirtComputingResource) {
    final ExecutorService executors = Executors.newSingleThreadExecutor();
    final KVMHAMonitor monitor = libvirtComputingResource.getMonitor();
    final StorageFilerTO pool = command.getPool();
    if (Storage.StoragePoolType.NetworkFilesystem == pool.getType()) {
        final NfsStoragePool nfspool = monitor.getStoragePool(pool.getUuid());
        final KVMHAVMActivityChecker ha = new KVMHAVMActivityChecker(nfspool, command.getHost().getPrivateNetwork().getIp(), command.getVolumeList(), libvirtComputingResource.getVmActivityCheckPath(), command.getSuspectTimeInSeconds());
        final Future<Boolean> future = executors.submit(ha);
        try {
            final Boolean result = future.get();
            if (result) {
                return new Answer(command, false, "VMHA disk activity detected ...");
            } else {
                return new Answer(command);
            }
        } catch (InterruptedException e) {
            return new Answer(command, false, "CheckVMActivityOnStoragePoolCommand: can't get status of host: InterruptedException");
        } catch (ExecutionException e) {
            return new Answer(command, false, "CheckVMActivityOnStoragePoolCommand: can't get status of host: ExecutionException");
        }
    }
    return new Answer(command, false, "Unsupported Storage");
}
Also used : Answer(com.cloud.agent.api.Answer) KVMHAMonitor(com.cloud.hypervisor.kvm.resource.KVMHAMonitor) NfsStoragePool(com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool) ExecutorService(java.util.concurrent.ExecutorService) KVMHAVMActivityChecker(com.cloud.hypervisor.kvm.resource.KVMHAVMActivityChecker) ExecutionException(java.util.concurrent.ExecutionException) StorageFilerTO(com.cloud.agent.api.to.StorageFilerTO)

Aggregations

Answer (com.cloud.agent.api.Answer)1 StorageFilerTO (com.cloud.agent.api.to.StorageFilerTO)1 NfsStoragePool (com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool)1 KVMHAMonitor (com.cloud.hypervisor.kvm.resource.KVMHAMonitor)1 KVMHAVMActivityChecker (com.cloud.hypervisor.kvm.resource.KVMHAVMActivityChecker)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1