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.

Appended diagnostic debug info about Numanodes

bugzilla.redhat.com/1177154

Change-Id: I71a4b71348127aa479b13cb8ad5e39685252b518
Signed-off-by: Dudi Maroshi <d...@redhat.com>
---
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NumaUtils.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
2 files changed, 59 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/37819/1

diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NumaUtils.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NumaUtils.java
index b83ddcb..5dbe340 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NumaUtils.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/NumaUtils.java
@@ -7,8 +7,22 @@
 import org.ovirt.engine.core.common.businessentities.VdsNumaNode;
 import org.ovirt.engine.core.common.utils.Pair;
 import org.ovirt.engine.core.compat.Guid;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class NumaUtils {
+    private static final Logger log = LoggerFactory.getLogger(NumaUtils.class);
+
+    public static void traceNumaNode(VdsNumaNode numaNode) {
+        log.debug("--------------------------------------------------------");
+        log.debug("---------------traceNumaNode()--------------------------");
+        log.debug("numaNode.getId() = {}", numaNode.getId());
+        log.debug("numaNode.getIndex() = {}", numaNode.getIndex());
+        log.debug("numaNode.getCpuIds() = {}", numaNode.getCpuIds());
+        log.debug("numaNode.getMemTotal() = {}", numaNode.getMemTotal());
+        log.debug("numaNode.getNumaNodeDistances() = {}", 
numaNode.getNumaNodeDistances());
+        log.debug("numaNode.getNumaNodeStatistics() = {}", 
numaNode.getNumaNodeStatistics());
+    }
 
     public static VdsNumaNode getVdsNumaNodeByIndex(List<VdsNumaNode> 
numaNodes, int index) {
         for (VdsNumaNode numaNode : numaNodes) {
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 aacf584..362aa5d 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
@@ -975,6 +975,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>>)
@@ -991,8 +994,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)) {
@@ -1000,7 +1019,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(),
@@ -1012,6 +1031,29 @@
         vds.getNumaNodeList().addAll(vdsNumaNodes);
         vds.getStatisticsData().getCpuCoreStatistics().clear();
         vds.getStatisticsData().getCpuCoreStatistics().addAll(cpuStatsData);
+        traceOn_updateNumaStatisticsData(vds, xmlRpcStruct);
+    }
+
+    private static void traceOn_updateNumaStatisticsData(VDS vds, Map<String, 
Object> xmlRpcStruct) {
+        log.debug("--------------------------------------------------------");
+        log.debug("--------- updateNumaStatisticsData() trace -------------");
+        StackTraceElement[] stacktrace = 
Thread.currentThread().getStackTrace();
+        log.debug("--- Running in:\n", new Throwable());
+        log.debug("--- Parameters in:");
+        log.debug("xmlRpcStruct.get(VdsProperties.CPU_STATS)={}", 
xmlRpcStruct.get(VdsProperties.CPU_STATS));
+        log.debug("xmlRpcStruct.get(VdsProperties.NUMA_NODE_FREE_MEM_STAT)={}",
+                xmlRpcStruct.get(VdsProperties.NUMA_NODE_FREE_MEM_STAT));
+        log.debug("xmlRpcStruct.get(VdsProperties.CPU_STATS)={}",
+                xmlRpcStruct.get(VdsProperties.CPU_STATS));
+        log.debug("xmlRpcStruct.get(VdsProperties.NUMA_NODE_FREE_MEM)={}",
+                xmlRpcStruct.get(VdsProperties.NUMA_NODE_FREE_MEM));
+        log.debug("xmlRpcStruct.get(VdsProperties.NUMA_NODE_MEM_PERCENT)={}",
+                xmlRpcStruct.get(VdsProperties.NUMA_NODE_MEM_PERCENT));
+        log.debug("--------- NumaNodeList({}) after update -------------", 
vds.getNumaNodeList().size());
+        for (VdsNumaNode numaNode : vds.getNumaNodeList()) {
+            NumaUtils.traceNumaNode(numaNode);
+        }
+        log.debug("--------------------------------------------------------");
     }
 
     private static VdsNumaNode buildVdsNumaNodeStatistics(DecimalFormat 
percentageFormatter,


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I71a4b71348127aa479b13cb8ad5e39685252b518
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Dudi Maroshi <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to