From ecd99ad379b713fd52da18cd42427a2f6e91eccd Mon Sep 17 00:00:00 2001 From: alena Date: Fri, 2 Sep 2011 12:07:14 -0700 Subject: [PATCH] bug 11332: don't try to log vm's information when the vm is already Expunged status 11332: resolved fixed Conflicts: server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java --- .../com/cloud/vm/dao/VMInstanceDaoImpl.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java index ef721783433..d2b6322790b 100644 --- a/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java +++ b/server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java @@ -26,18 +26,15 @@ import javax.ejb.Local; import org.apache.log4j.Logger; -import com.cloud.cluster.agentlb.HostTransferMapVO; -import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl; import com.cloud.host.HostVO; import com.cloud.host.dao.HostDaoImpl; -import com.cloud.org.Managed; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.db.Attribute; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.GenericSearchBuilder; +import com.cloud.utils.db.JoinBuilder.JoinType; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.db.JoinBuilder.JoinType; import com.cloud.utils.db.SearchCriteria.Func; import com.cloud.utils.db.SearchCriteria.Op; import com.cloud.utils.db.UpdateBuilder; @@ -303,12 +300,19 @@ public class VMInstanceDaoImpl extends GenericDaoBase implem int result = update(vmi, sc); if (result == 0 && s_logger.isDebugEnabled()) { + VMInstanceVO vo = findByIdIncludingRemoved(vm.getId()); - StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); - str.append(": DB Data={Host=").append(vo.getHostId()).append("; State=").append(vo.getState().toString()).append("; updated=").append(vo.getUpdated()).append("; time=").append(vo.getUpdateTime()); - str.append("} New Data: {Host=").append(vm.getHostId()).append("; State=").append(vm.getState().toString()).append("; updated=").append(vmi.getUpdated()).append("; time=").append(vo.getUpdateTime()); - str.append("} Stale Data: {Host=").append(oldHostId).append("; State=").append(oldState).append("; updated=").append(oldUpdated).append("; time=").append(oldUpdateDate).append("}"); - s_logger.debug(str.toString()); + + if (vo != null) { + StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); + str.append(": DB Data={Host=").append(vo.getHostId()).append("; State=").append(vo.getState().toString()).append("; updated=").append(vo.getUpdated()).append("; time=").append(vo.getUpdateTime()); + str.append("} New Data: {Host=").append(vm.getHostId()).append("; State=").append(vm.getState().toString()).append("; updated=").append(vmi.getUpdated()).append("; time=").append(vo.getUpdateTime()); + str.append("} Stale Data: {Host=").append(oldHostId).append("; State=").append(oldState).append("; updated=").append(oldUpdated).append("; time=").append(oldUpdateDate).append("}"); + s_logger.debug(str.toString()); + + } else { + s_logger.debug("Unable to update the vm id=" + vm.getId() + "; the vm either doesn't exist or already removed"); + } } return result > 0; }