@Override protected void executeCommand() { if (validatePermissions()) { if (validateInputs()) { try { returnValue.setSucceeded(true); executeQueryCommand(); } catch (RuntimeException ex) { returnValue.setSucceeded(false); Throwable th = ex instanceof EngineException ? ex : ex.getCause(); if (th instanceof EngineException) { EngineException vdcExc = (EngineException) th; if (vdcExc.getErrorCode() != null) { returnValue.setExceptionString(vdcExc.getErrorCode().toString()); } else { returnValue.setExceptionString(vdcExc.getMessage()); } log.error("Query '{}' failed: {}", getClass().getSimpleName(), vdcExc.getMessage()); log.error("Exception", vdcExc); } else { returnValue.setExceptionString(ex.getMessage()); log.error("Query '{}' failed: {}", getClass().getSimpleName(), ex.getMessage()); log.error("Exception", ex); } } } else { log.error( "Query execution failed due to invalid inputs: {}", returnValue.getExceptionString()); } } else { String errMessage = "Query execution failed due to insufficient permissions."; log.error(errMessage); returnValue.setExceptionString(errMessage); } }
private void connectAndRefreshAllUpHosts(final boolean commandSucceeded) { if (isLastMaster || !commandSucceeded) { log.warn( "skipping connect and refresh for all hosts, last master '{}', command status '{}'", isLastMaster, commandSucceeded); return; } List<Callable<Void>> tasks = new ArrayList<>(); for (final VDS vds : getAllRunningVdssInPool()) { tasks.add( () -> { try { if (!connectVdsToNewMaster(vds)) { log.warn( "failed to connect vds '{}' to the new master '{}'", vds.getId(), getNewMasterStorageDomainId()); return null; } List<StoragePoolIsoMap> storagePoolIsoMap = storagePoolIsoMapDao.getAllForStoragePool(getStoragePool().getId()); try { runVdsCommand( VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters( vds, getStoragePool(), getNewMasterStorageDomainId(), storagePoolIsoMap, true)); } catch (EngineException ex) { if (EngineError.StoragePoolUnknown == ex.getVdsError().getCode()) { VDSReturnValue returnVal = runVdsCommand( VDSCommandType.ConnectStoragePool, new ConnectStoragePoolVDSCommandParameters( vds, getStoragePool(), getNewMasterStorageDomainId(), storagePoolIsoMap)); if (!returnVal.getSucceeded()) { log.error( "Post reconstruct actions (connectPool) did not complete on host '{}' in the pool. error {}", vds.getId(), returnVal.getVdsError().getMessage()); } } else { log.error( "Post reconstruct actions (refreshPool)" + " did not complete on host '{}' in the pool. error {}", vds.getId(), ex.getMessage()); } } } catch (Exception e) { log.error( "Post reconstruct actions (connectPool,refreshPool,disconnect storage)" + " did not complete on host '{}' in the pool: {}", vds.getId(), e.getMessage()); log.debug("Exception", e); } return null; }); } ThreadPoolUtil.invokeAll(tasks); }