Search in sources :

Example 1 with VDSExceptionBase

use of org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase in project ovirt-engine by oVirt.

the class RemoveVMVDSCommand method proceedProxyReturnValue.

@Override
protected void proceedProxyReturnValue() {
    EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
    switch(returnStatus) {
        case Done:
            return;
        default:
            VDSExceptionBase outEx = createDefaultConcreteException(getReturnStatus().message);
            initializeVdsError(returnStatus);
            outEx.setVdsError(getVDSReturnValue().getVdsError());
            throw outEx;
    }
}
Also used : EngineError(org.ovirt.engine.core.common.errors.EngineError) VDSExceptionBase(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase)

Example 2 with VDSExceptionBase

use of org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase in project ovirt-engine by oVirt.

the class UpdateVMVDSCommand method proceedProxyReturnValue.

@Override
protected void proceedProxyReturnValue() {
    EngineError returnStatus = getReturnValueFromStatus(getReturnStatus());
    switch(returnStatus) {
        case Done:
            return;
        default:
            VDSExceptionBase outEx = createDefaultConcreteException(getReturnStatus().message);
            initializeVdsError(returnStatus);
            outEx.setVdsError(getVDSReturnValue().getVdsError());
            throw outEx;
    }
}
Also used : EngineError(org.ovirt.engine.core.common.errors.EngineError) VDSExceptionBase(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase)

Example 3 with VDSExceptionBase

use of org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase in project ovirt-engine by oVirt.

the class VDSCommandBase method setVdsRuntimeError.

protected void setVdsRuntimeError(RuntimeException ex) {
    getVDSReturnValue().setSucceeded(false);
    getVDSReturnValue().setExceptionString(ex.toString());
    getVDSReturnValue().setExceptionObject(ex);
    VDSExceptionBase vdsExp = (VDSExceptionBase) ((ex instanceof VDSExceptionBase) ? ex : null);
    // VDSExceptionBase exception
    if (vdsExp != null) {
        if (vdsExp.getVdsError() != null) {
            getVDSReturnValue().setVdsError(((VDSExceptionBase) ex).getVdsError());
        } else if (vdsExp.getCause() instanceof VDSExceptionBase) {
            getVDSReturnValue().setVdsError(((VDSExceptionBase) vdsExp.getCause()).getVdsError());
        }
    }
}
Also used : VDSExceptionBase(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase)

Example 4 with VDSExceptionBase

use of org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase in project ovirt-engine by oVirt.

the class IrsBrokerCommand method executeVDSCommand.

@Override
protected void executeVDSCommand() {
    AtomicBoolean isStartReconstruct = new AtomicBoolean(false);
    getCurrentIrsProxy().runInControlledConcurrency(() -> {
        try {
            if (getIrsProxy() != null) {
                executeIrsBrokerCommand();
            } else {
                if (getVDSReturnValue().getVdsError() == null) {
                    getVDSReturnValue().setExceptionString("Cannot allocate IRS server");
                    VDSError tempVar = new VDSError();
                    tempVar.setCode(EngineError.IRS_REPOSITORY_NOT_FOUND);
                    tempVar.setMessage("Cannot allocate IRS server");
                    getVDSReturnValue().setVdsError(tempVar);
                }
                getVDSReturnValue().setSucceeded(false);
            }
        } catch (UndeclaredThrowableException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            getVDSReturnValue().setVdsError(new VDSError(EngineError.VDS_NETWORK_ERROR, ex.getMessage()));
            if (ExceptionUtils.getRootCause(ex) != null) {
                logException(ExceptionUtils.getRootCause(ex));
            } else {
                LoggedUtils.logError(log, LoggedUtils.getObjectId(this), this, ex);
            }
            failover();
        } catch (TransportRunTimeException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            if (ex.isNetworkError()) {
                log.error("IrsBroker::Failed::{} - network exception.", getCommandName());
                getVDSReturnValue().setSucceeded(false);
            } else {
                log.error("IrsBroker::Failed::{}", getCommandName());
                log.debug(LoggedUtils.getObjectId(this), this, ex);
                throw new IRSProtocolException(ex);
            }
        } catch (IRSNoMasterDomainException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            getVDSReturnValue().setVdsError(ex.getVdsError());
            log.error("IrsBroker::Failed::{}: {}", getCommandName(), ex.getMessage());
            log.debug("Exception", ex);
            if ((ex.getVdsError() == null || ex.getVdsError().getCode() != EngineError.StoragePoolWrongMaster) && getCurrentIrsProxy().getHasVdssForSpmSelection()) {
                failover();
            } else {
                isStartReconstruct.set(true);
            }
        } catch (IRSUnicodeArgumentException ex) {
            throw new IRSGenericException("UNICODE characters are not supported.", ex);
        } catch (IRSStoragePoolStatusException | IrsOperationFailedNoFailoverException ex) {
            throw ex;
        } catch (IRSNonOperationalException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            getVDSReturnValue().setVdsError(ex.getVdsError());
            logException(ex);
            if (ex.getVdsError() != null && EngineError.SpmStatusError == ex.getVdsError().getCode()) {
                getCurrentIrsProxy().setCurrentVdsId(Guid.Empty);
            }
            failover();
        } catch (IRSErrorException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            getVDSReturnValue().setVdsError(ex.getVdsError());
            logException(ex);
            if (log.isDebugEnabled()) {
                LoggedUtils.logError(log, LoggedUtils.getObjectId(this), this, ex);
            }
            failover();
        } catch (RuntimeException ex) {
            getVDSReturnValue().setExceptionString(ex.toString());
            getVDSReturnValue().setExceptionObject(ex);
            if (ex instanceof VDSExceptionBase) {
                getVDSReturnValue().setVdsError(((VDSExceptionBase) ex).getVdsError());
            }
            if (ExceptionUtils.getRootCause(ex) != null && ExceptionUtils.getRootCause(ex) instanceof SocketException) {
                logException(ExceptionUtils.getRootCause(ex));
            } else {
                LoggedUtils.logError(log, LoggedUtils.getObjectId(this), this, ex);
            }
            // always failover because of changes in vdsm error, until we
            // realize what to do in each case:
            failover();
        } finally {
            getCurrentIrsProxy().getTriedVdssList().clear();
        }
    });
    if (isStartReconstruct.get()) {
        startReconstruct();
    }
}
Also used : SocketException(java.net.SocketException) TransportRunTimeException(org.ovirt.engine.core.vdsbroker.TransportRunTimeException) VDSExceptionBase(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) VDSError(org.ovirt.engine.core.common.errors.VDSError) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Aggregations

VDSExceptionBase (org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase)4 EngineError (org.ovirt.engine.core.common.errors.EngineError)2 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 SocketException (java.net.SocketException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 VDSError (org.ovirt.engine.core.common.errors.VDSError)1 TransportRunTimeException (org.ovirt.engine.core.vdsbroker.TransportRunTimeException)1