cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject [2/7] git commit: updated refs/heads/sf-plugins-a to 49ca3b4
Date Wed, 14 Oct 2015 18:09:42 GMT
CLOUDSTACK-8848: added null pointer guard to new public method


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8cd8b6c8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8cd8b6c8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8cd8b6c8

Branch: refs/heads/sf-plugins-a
Commit: 8cd8b6c83c360777a3648be709424365bc121cae
Parents: 30c7049
Author: Daan Hoogland <daan@onecht.net>
Authored: Fri Oct 2 11:42:42 2015 +0200
Committer: Rene Moser <resmo@apache.org>
Committed: Mon Oct 12 13:03:02 2015 +0200

----------------------------------------------------------------------
 .../com/cloud/vm/VirtualMachinePowerStateSyncImpl.java | 13 +++++++++----
 .../schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java |  3 +++
 2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8cd8b6c8/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
index 19ed71c..3b9d6f5 100644
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
@@ -24,13 +24,13 @@ import java.util.Map;
 import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.messagebus.MessageBus;
 import org.apache.cloudstack.framework.messagebus.PublishScope;
 
 import com.cloud.agent.api.HostVmStateReportEntry;
 import com.cloud.utils.DateUtil;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.dao.VMInstanceDao;
 
 public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStateSync {
@@ -112,9 +112,14 @@ public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStat
             for (VMInstanceVO instance : vmsThatAreMissingReport) {
 
                 // Make sure powerState is up to date for missing VMs
-                if (!_instanceDao.isPowerStateUpToDate(instance.getId())) {
-                    s_logger.warn("Detected missing VM but power state is outdated, wait
for another process report run for VM id: " + instance.getId());
-                    _instanceDao.resetVmPowerStateTracking(instance.getId());
+                try {
+                    if (!_instanceDao.isPowerStateUpToDate(instance.getId())) {
+                        s_logger.warn("Detected missing VM but power state is outdated, wait
for another process report run for VM id: " + instance.getId());
+                        _instanceDao.resetVmPowerStateTracking(instance.getId());
+                        continue;
+                    }
+                } catch (CloudRuntimeException e) {
+                    s_logger.warn("Checked for missing powerstate of a none existing vm",
e);
                     continue;
                 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8cd8b6c8/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
index 48b56d1..aa940ce 100644
--- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
@@ -806,6 +806,9 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO,
Long> implem
     @Override
     public boolean isPowerStateUpToDate(final long instanceId) {
         VMInstanceVO instance = findById(instanceId);
+        if(instance == null) {
+            throw new CloudRuntimeException("checking power state update count on non existing
instance " + instanceId);
+        }
         return instance.getPowerStateUpdateCount() < MAX_CONSECUTIVE_SAME_STATE_UPDATE_COUNT;
     }
 


Mime
View raw message