Dudi Maroshi has uploaded a new change for review.

Change subject: engine: Append Numa dynamic data to static data
......................................................................

engine: Append Numa dynamic data to static data

Numa statistics were created into an empty VdsNumaNode and written to the DB.
The correction append Numa statistics into existing VdsNumaNode static 
information.

This is relevant only while doing capabilities refresh. Othewise it is OK to 
store
VdsNumaNode with only statistical data.

Bug-URl: bugzilla.redhat.com/1177154
Change-Id: I71a4b71348127aa479b13cb8ad5e39685252b518
Signed-off-by: Dudi Maroshi <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
2 files changed, 26 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/52/38052/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
index c8a3f6b..9674a47 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java
@@ -337,10 +337,11 @@
                 nodesMap.put(node.getIndex(), node);
             }
             for (VdsNumaNode node : updateNumaNodes) {
-                if (nodesMap.containsKey(node.getIndex())) {
-                    node.setId(nodesMap.get(node.getIndex()).getId());
+                VdsNumaNode dbNode = nodesMap.get(node.getIndex());
+                if (dbNode != null) {
                     if (node.getNumaNodeStatistics() != null) {
-                        vdsNumaNodesToSave.add(node);
+                        
dbNode.setNumaNodeStatistics(node.getNumaNodeStatistics());
+                        vdsNumaNodesToSave.add(dbNode);
                     }
                 }
             }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
index 4d24960..62466e5 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
@@ -818,6 +818,9 @@
 
     public static void updateNumaStatisticsData(VDS vds, Map<String, Object> 
xmlRpcStruct) {
         List<VdsNumaNode> vdsNumaNodes = new ArrayList<>();
+        if (vds.getNumaNodeList() != null && !vds.getNumaNodeList().isEmpty()) 
{
+            vdsNumaNodes.addAll(vds.getNumaNodeList());
+        }
         List<CpuStatistics> cpuStatsData = new ArrayList<>();
         if (xmlRpcStruct.containsKey(VdsProperties.CPU_STATS)) {
             Map<String, Map<String, Object>> cpuStats = (Map<String, 
Map<String, Object>>)
@@ -834,8 +837,24 @@
             }
             DecimalFormat percentageFormatter = new DecimalFormat("#.##");
             for (Map.Entry<Integer, List<CpuStatistics>> item : 
numaNodeCpuStats.entrySet()) {
-                VdsNumaNode node = 
buildVdsNumaNodeStatistics(percentageFormatter, item);
-                vdsNumaNodes.add(node);
+                VdsNumaNode nodeWithStatistics = 
buildVdsNumaNodeStatistics(percentageFormatter, item);
+                if (vdsNumaNodes.isEmpty()) {
+                    vdsNumaNodes.add(nodeWithStatistics);
+                } else {
+                    boolean foundNumaNode = false;
+                    // append the statistics to the correct numaNode (search 
by its Index.)
+                    for (VdsNumaNode currNumaNode : vdsNumaNodes) {
+                        if (currNumaNode.getIndex() == 
nodeWithStatistics.getIndex()) {
+                            
currNumaNode.setNumaNodeStatistics(nodeWithStatistics.getNumaNodeStatistics());
+                            foundNumaNode = true;
+                            break;
+                        }
+                    }
+                    // append new numaNode (contains only statistics) if not 
found existing
+                    if (!foundNumaNode) {
+                        vdsNumaNodes.add(nodeWithStatistics);
+                    }
+                }
             }
         }
         if (xmlRpcStruct.containsKey(VdsProperties.NUMA_NODE_FREE_MEM_STAT)) {
@@ -843,7 +862,7 @@
                     xmlRpcStruct.get(VdsProperties.NUMA_NODE_FREE_MEM_STAT);
             for (Map.Entry<String, Map<String, Object>> item : 
memStats.entrySet()) {
                 VdsNumaNode node = 
NumaUtils.getVdsNumaNodeByIndex(vdsNumaNodes, Integer.valueOf(item.getKey()));
-                if (node != null) {
+                if (node != null && node.getNumaNodeStatistics() != null) {
                     
node.getNumaNodeStatistics().setMemFree(AssignLongValue(item.getValue(),
                             VdsProperties.NUMA_NODE_FREE_MEM));
                     
node.getNumaNodeStatistics().setMemUsagePercent(AssignIntValue(item.getValue(),


-- 
To view, visit http://gerrit.ovirt.org/38052
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I71a4b71348127aa479b13cb8ad5e39685252b518
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Dudi Maroshi <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to