Fix auto-merge caused issues

This commit is contained in:
Kelven Yang 2014-01-09 11:33:47 -08:00
parent 0587382265
commit ac0faeb091
2 changed files with 25 additions and 12 deletions

View File

@ -16,6 +16,7 @@
// under the License.
package com.cloud.vm;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
@ -98,24 +99,35 @@ public class VmWorkJobHandlerProxy implements VmWorkJobHandler {
Method method = getHandlerMethod(work.getClass());
if (method != null) {
if (s_logger.isDebugEnabled())
s_logger.debug("Execute VM work job: " + work.getClass().getName() + _gsonLogger.toJson(work));
Object obj = method.invoke(_target, work);
try {
if (s_logger.isDebugEnabled())
s_logger.debug("Execute VM work job: " + work.getClass().getName() + _gsonLogger.toJson(work));
if (s_logger.isDebugEnabled())
s_logger.debug("Done executing VM work job: " + work.getClass().getName() + _gsonLogger.toJson(work));
Object obj = method.invoke(_target, work);
assert (obj instanceof Pair);
return (Pair<JobInfo.Status, String>)obj;
if (s_logger.isDebugEnabled())
s_logger.debug("Done executing VM work job: " + work.getClass().getName() + _gsonLogger.toJson(work));
assert (obj instanceof Pair);
return (Pair<JobInfo.Status, String>)obj;
} catch (InvocationTargetException e) {
s_logger.error("Invocation exception, caused by: " + e.getCause());
// legacy CloudStack code relies on checked exception for error handling
// we need to re-throw the real exception here
if (e.getCause() != null && e.getCause() instanceof Exception) {
s_logger.info("Rethrow exception " + e.getCause());
throw (Exception)e.getCause();
}
throw e;
}
} else {
s_logger.error("Unable to find handler for VM work job: " + work.getClass().getName() + _gsonLogger.toJson(work));
RuntimeException e = new RuntimeException("Unsupported VM work job: " + work.getClass().getName() + _gsonLogger.toJson(work));
String exceptionJson = JobSerializerHelper.toSerializedString(e);
s_logger.error("Serialize exception object into json: " + exceptionJson);
return new Pair<JobInfo.Status, String>(JobInfo.Status.FAILED, exceptionJson);
RuntimeException ex = new RuntimeException("Unable to find handler for VM work job: " + work.getClass().getName());
return new Pair<JobInfo.Status, String>(JobInfo.Status.FAILED, JobSerializerHelper.toObjectSerializedString(ex));
}
}
}

View File

@ -165,6 +165,7 @@ import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.VmWork;
import com.cloud.vm.VmWorkConstants;
import com.cloud.vm.VmWorkJobHandler;
import com.cloud.vm.VmWorkJobHandlerProxy;
import com.cloud.vm.VmWorkSerializer;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.DomainRouterDao;