Michael Kublin has uploaded a new change for review. Change subject: engine: Exception handling - VDSCommandBase ......................................................................
engine: Exception handling - VDSCommandBase The following patch will simplify exception handling in case of failure in xml rpc call. All XmlRpcRunTimeException will be translated to network exception with error code VdcBllErrors.VDS_NETWORK_ERROR. The XmlRpcRunTimeException - means that we failed in call , failed to parse xml and we did not get appropriate response that we can parse, this is by definition VdcBllErrors.VDS_NETWORK_ERROR. Now, VdcBllErrors.VDS_PROTOCOL error was removed as unused. Change-Id: I0bd38cd75706ff7669c1ff055b951aeb864b2736 Signed-off-by: Michael Kublin <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VDSCommandBase.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FutureVDSCommand.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java 5 files changed, 7 insertions(+), 49 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/14312/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java index fa4e1ea..2964c3c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java @@ -212,7 +212,7 @@ switch (errorCode) { case Done: // should never get here with errorCode = 'Done' though case exist: - case PROTOCOL_ERROR: // probably wrong xml format sent. + case VDS_NETWORK_ERROR: // probably wrong xml format sent. throw e; default: } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java index a05ddd6..3c3bda0 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllErrors.java @@ -381,7 +381,6 @@ // oVirt errors ENGINE(5001), DB(5002), - PROTOCOL_ERROR(5003), // The VDS does not exist in memory RESOURCE_MANAGER_VDS_NOT_FOUND(5004), IRS_IMAGE_STATUS_ILLEGAL(5006), diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VDSCommandBase.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VDSCommandBase.java index f71ab7f..afffcbe 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VDSCommandBase.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VDSCommandBase.java @@ -2,14 +2,10 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.exception.ExceptionUtils; -import org.ovirt.engine.core.common.errors.VDSError; -import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.vdscommands.VDSParametersBase; import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; import org.ovirt.engine.core.dal.VdcCommandBase; -import org.ovirt.engine.core.vdsbroker.irsbroker.IRSErrorException; import org.ovirt.engine.core.vdsbroker.vdsbroker.VDSExceptionBase; -import org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException; public abstract class VDSCommandBase<P extends VDSParametersBase> extends VdcCommandBase { private P _parameters; @@ -58,18 +54,9 @@ _returnValue = new VDSReturnValue(); getVDSReturnValue().setSucceeded(true); executeVDSCommand(); - } catch (VDSNetworkException ex) { - setVdsNetworkError(ex); - } catch (IRSErrorException ex) { - getVDSReturnValue().setSucceeded(false); - getVDSReturnValue().setExceptionString(ex.toString()); - getVDSReturnValue().setExceptionObject(ex); - getVDSReturnValue().setVdsError(ex.getVdsError()); - logException(ex); } catch (RuntimeException ex) { setVdsRuntimeError(ex); } - } protected void setVdsRuntimeError(RuntimeException ex) { @@ -88,18 +75,6 @@ } } - logException(ex); - } - - protected void setVdsNetworkError(VDSNetworkException ex) { - getVDSReturnValue().setSucceeded(false); - getVDSReturnValue().setExceptionString(ex.toString()); - getVDSReturnValue().setExceptionObject(ex); - VDSError tempVar = ex.getVdsError(); - VDSError tempVar2 = new VDSError(); - tempVar2.setCode(VdcBllErrors.VDS_NETWORK_ERROR); - tempVar2.setMessage(ex.getMessage()); - getVDSReturnValue().setVdsError((tempVar != null) ? tempVar : tempVar2); logException(ex); } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FutureVDSCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FutureVDSCommand.java index b86e26d..08410f5 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FutureVDSCommand.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/FutureVDSCommand.java @@ -7,11 +7,11 @@ import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; +import org.ovirt.engine.core.common.errors.VDSError; +import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.interfaces.FutureVDSCall; import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; -import org.ovirt.engine.core.utils.log.Log; -import org.ovirt.engine.core.utils.log.LogFactory; /** * This class is used for the non-blocking VDSM API. It uses Future API to fetch the response from the actual http @@ -19,8 +19,6 @@ * */ public abstract class FutureVDSCommand<P extends VdsIdVDSCommandParametersBase> extends VdsBrokerCommand<P> implements FutureVDSCall<VDSReturnValue> { - - private static Log log = LogFactory.getLog(BrokerCommandBase.class); public FutureVDSCommand(P parameters) { super(parameters); @@ -75,7 +73,9 @@ ProceedProxyReturnValue(); } catch (TimeoutException e) { httpTask.cancel(true); - setVdsNetworkError(new VDSNetworkException(new RuntimeException(e.getCause()))); + VDSNetworkException ex = new VDSNetworkException("Timeout during xml-rpc call"); + ex.setVdsError(new VDSError(VdcBllErrors.VDS_NETWORK_ERROR, "Timeout during xml-rpc call")); + setVdsRuntimeError(ex); log.error("Timeout waiting for VDSM response. " + e); throw e; } catch (Exception e) { diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java index 263668a..cb564ac 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerCommand.java @@ -1,6 +1,5 @@ package org.ovirt.engine.core.vdsbroker.vdsbroker; -import java.io.IOException; import org.apache.commons.lang.exception.ExceptionUtils; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.errors.VDSError; @@ -16,8 +15,6 @@ public abstract class VdsBrokerCommand<P extends VdsIdVDSCommandParametersBase> extends BrokerCommandBase<P> { private final IVdsServer mVdsBroker; private VDS mVds; - private static final String msgFormat = "XML RPC error in command {0} ( {1} ), the error was: {2}, {3} "; - /** * Construct the command using the parameters and the {@link VDS} which is loaded from the DB. * @@ -93,20 +90,7 @@ } catch (XmlRpcRunTimeException ex) { Throwable rootCause = ExceptionUtils.getRootCause(ex); VDSNetworkException networkException = new VDSNetworkException(rootCause); - if ((ex.isNetworkError() || rootCause instanceof IOException)) { - log.debugFormat(msgFormat, - getCommandName(), - getAdditionalInformation(), - ex.getMessage(), - rootCause.getMessage()); - } else { - log.errorFormat(msgFormat, - getCommandName(), - getAdditionalInformation(), - ex.getMessage(), - rootCause.getMessage()); - networkException.setVdsError(new VDSError(VdcBllErrors.PROTOCOL_ERROR, rootCause.toString())); - } + networkException.setVdsError(new VDSError(VdcBllErrors.VDS_NETWORK_ERROR, rootCause.toString())); PrintReturnValue(); throw networkException; } -- To view, visit http://gerrit.ovirt.org/14312 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0bd38cd75706ff7669c1ff055b951aeb864b2736 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Michael Kublin <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
