Liran Zelkha has uploaded a new change for review.

Change subject: core: Print details on changes in VdsDynamic
......................................................................

core: Print details on changes in VdsDynamic

VdsDynamic updates are heavy on the database. This patch will print
why a VdsDynamic entity is updated in the database (which field in the
entity has changed).

Change-Id: I30711bc02adcc6ebbcac95d609da0fbc54f49cb2
Signed-off-by: [email protected] <[email protected]>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
2 files changed, 195 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/37/31437/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
index fa930b9..601fc10 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
@@ -6,8 +6,8 @@
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-
 import java.util.Set;
+
 import javax.validation.constraints.Size;
 
 import org.ovirt.engine.core.common.utils.ObjectUtils;
@@ -807,4 +807,196 @@
                 && liveMergeSupport == other.liveMergeSupport;
     }
 
+    public String whatChanged(VdsDynamic obj) {
+        StringBuilder sb = new StringBuilder();
+
+        if (this == obj) {
+            return "we are the same";
+        }
+        if (obj == null) {
+            return "the other is null";
+        }
+        VdsDynamic other = (VdsDynamic) obj;
+        if (ObjectUtils.objectsEqual(id, other.id)) {
+            sb.append("id,");
+        }
+        if (ObjectUtils.objectsEqual(_supportedClusterVersionsSet, 
other._supportedClusterVersionsSet)) {
+            sb.append("_supportedClusterVersionsSet,");
+        }
+        if (ObjectUtils.objectsEqual(_supportedENGINESVersionsSet, 
other._supportedENGINESVersionsSet)) {
+            sb.append("_supportedENGINESVersionsSet,");
+        }
+        if (ObjectUtils.objectsEqual(buildName, other.buildName)) {
+            sb.append("buildName,");
+        }
+        if (ObjectUtils.objectsEqual(cpu_cores, other.cpu_cores)) {
+            sb.append("cpu_cores,");
+        }
+        if (ObjectUtils.objectsEqual(cpuThreads, other.cpuThreads)) {
+            sb.append("cpuThreads,");
+        }
+        if (ObjectUtils.objectsEqual(cpu_flags, other.cpu_flags)) {
+            sb.append("cpu_flags,");
+        }
+        if (ObjectUtils.objectsEqual(cpu_model, other.cpu_model)) {
+            sb.append("cpu_model,");
+        }
+        if (ObjectUtils.objectsEqual(cpu_over_commit_time_stamp, 
other.cpu_over_commit_time_stamp)) {
+            sb.append("cpu_over_commit_time_stamp,");
+        }
+        if (ObjectUtils.objectsEqual(cpu_sockets, other.cpu_sockets)) {
+            sb.append("cpu_sockets,");
+        }
+        if (ObjectUtils.objectsEqual(cpu_speed_mh, other.cpu_speed_mh)) {
+            sb.append("cpu_speed_mh,");
+        }
+        if (ObjectUtils.objectsEqual(guest_overhead, other.guest_overhead)) {
+            sb.append("guest_overhead,");
+        }
+        if (ObjectUtils.objectsEqual(hooksStr, other.hooksStr)) {
+            sb.append("hooksStr,");
+        }
+        if (ObjectUtils.objectsEqual(host_os, other.host_os)) {
+            sb.append("host_os,");
+        }
+        if (ObjectUtils.objectsEqual(iScsiInitiatorName, 
other.iScsiInitiatorName)) {
+            sb.append("iScsiInitiatorName,");
+        }
+        if (ObjectUtils.objectsEqual(if_total_speed, other.if_total_speed)) {
+            sb.append("if_total_speed,");
+        }
+        if (ObjectUtils.objectsEqual(kernel_version, other.kernel_version)) {
+            sb.append("kernel_version,");
+        }
+        if (ObjectUtils.objectsEqual(kvm_enabled, other.kvm_enabled)) {
+            sb.append("kvm_enabled,");
+        }
+        if (ObjectUtils.objectsEqual(kvm_version, other.kvm_version)) {
+            sb.append("kvm_version,");
+        }
+        if (ObjectUtils.objectsEqual(libvirt_version, other.libvirt_version)) {
+            sb.append("libvirt_version,");
+        }
+        if (ObjectUtils.objectsEqual(rpmVersion, other.rpmVersion)) {
+            sb.append("rpmVersion");
+        }
+        if (ObjectUtils.objectsEqual(mem_commited, other.mem_commited)) {
+            sb.append("mem_commited,");
+        }
+        if (ObjectUtils.objectsEqual(net_config_dirty, 
other.net_config_dirty)) {
+            sb.append("net_config_dirty,");
+        }
+        if (nonOperationalReason == other.nonOperationalReason) {
+            sb.append("nonOperationalReason,");
+        }
+        if (ObjectUtils.objectsEqual(pending_vcpus_count, 
other.pending_vcpus_count)) {
+            sb.append("pending_vcpus_count,");
+        }
+        if (ObjectUtils.objectsEqual(pending_vmem_size, 
other.pending_vmem_size)) {
+            sb.append("pending_vmem_size,");
+        }
+        if (ObjectUtils.objectsEqual(physical_mem_mb, other.physical_mem_mb)) {
+            sb.append("physical_mem_mb");
+        }
+        if (previous_status == other.previous_status) {
+            sb.append("previous_status,");
+        }
+        if (ObjectUtils.objectsEqual(reserved_mem, other.reserved_mem)) {
+            sb.append("reserved_mem,");
+        }
+        if (ObjectUtils.objectsEqual(getsoftware_version(), 
other.getsoftware_version())) {
+            sb.append("getsoftware_version,");
+        }
+        if (ObjectUtils.objectsEqual(spice_version, other.spice_version)) {
+            sb.append("spice_version,");
+        }
+        if (ObjectUtils.objectsEqual(glusterVersion, other.glusterVersion)) {
+            sb.append("glusterVersion,");
+        }
+        if (status == other.status) {
+            sb.append("status,");
+        }
+        if (ObjectUtils.objectsEqual(supported_cluster_levels, 
other.supported_cluster_levels)) {
+            sb.append("supported_cluster_levels,");
+        }
+        if (ObjectUtils.objectsEqual(supported_engines, 
other.supported_engines)) {
+            sb.append("supported_engines,");
+        }
+        if (transparentHugePagesState == other.transparentHugePagesState) {
+            sb.append("transparentHugePagesState,");
+        }
+        if (ObjectUtils.objectsEqual(versionName, other.versionName)) {
+            sb.append("versionName");
+        }
+        if (ObjectUtils.objectsEqual(vm_active, other.vm_active)) {
+            sb.append("vm_active,");
+        }
+        if (vm_count == other.vm_count) {
+            sb.append("vm_count,");
+        }
+        if (ObjectUtils.objectsEqual(vm_migrating, other.vm_migrating)) {
+            sb.append("vm_migrating,");
+        }
+        if (ObjectUtils.objectsEqual(vms_cores_count, other.vms_cores_count)) {
+            sb.append("vms_cores_count,");
+        }
+        if (ObjectUtils.objectsEqual(hwManufacturer, other.hwManufacturer)) {
+            sb.append("hwManufacturer,");
+        }
+        if (ObjectUtils.objectsEqual(hwProductName, other.hwProductName)) {
+            sb.append("hwProductName,");
+        }
+        if (ObjectUtils.objectsEqual(hwVersion, other.hwVersion)) {
+            sb.append("hwVersion,");
+        }
+        if (ObjectUtils.objectsEqual(hwSerialNumber, other.hwSerialNumber)) {
+            sb.append("hwSerialNumber,");
+        }
+        if (ObjectUtils.objectsEqual(hwUUID, other.hwUUID)) {
+            sb.append("hwUUID,");
+        }
+        if (ObjectUtils.objectsEqual(hwFamily, other.hwFamily)) {
+            sb.append("hwFamily,");
+        }
+        if (ObjectUtils.objectsEqual(HBAs, other.HBAs)) {
+            sb.append("HBAs,");
+        }
+        if (ObjectUtils.objectsEqual(supportedEmulatedMachines, 
other.supportedEmulatedMachines)) {
+            sb.append("supportedEmulatedMachines,");
+        }
+        if (powerManagementControlledByPolicy == 
other.powerManagementControlledByPolicy) {
+            sb.append("powerManagementControlledByPolicy,");
+        }
+        if (kdumpStatus == other.kdumpStatus) {
+            sb.append("kdumpStatus,");
+        }
+        if (ObjectUtils.objectsEqual(selinuxEnforceMode, 
other.selinuxEnforceMode)) {
+            sb.append("selinuxEnforceMode,");
+        }
+        if (ObjectUtils.objectsEqual(numaNodeList, other.numaNodeList)) {
+            sb.append("numaNodeList");
+        }
+        if (autoNumaBalancing.getValue() == 
other.autoNumaBalancing.getValue()) {
+            sb.append("autoNumaBalancing");
+        }
+        if (numaSupport == other.numaSupport) {
+            sb.append("numaSupport");
+        }
+        if (ObjectUtils.objectsEqual(supportedEmulatedMachines, 
other.supportedEmulatedMachines)) {
+            sb.append("supportedEmulatedMachines,");
+        }
+        if (powerManagementControlledByPolicy == 
other.powerManagementControlledByPolicy) {
+            sb.append("powerManagementControlledByPolicy,");
+        }
+        if (ObjectUtils.objectsEqual(supportedRngSources, 
other.supportedRngSources)) {
+            sb.append("supportedRngSources,");
+        }
+        if (liveSnapshotSupport == other.liveSnapshotSupport) {
+            sb.append("liveSnapshotSupport,");
+        }
+        if (liveMergeSupport == other.liveMergeSupport) {
+            sb.append("liveMergeSupport,");
+        }
+        return sb.toString();
+    }
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
index 9bf9c53..8d53be1 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
@@ -277,6 +277,8 @@
     public void updateIfNeeded(VdsDynamic vdsDynamic) {
         VdsDynamic dbData = get(vdsDynamic.getId());
         if (!dbData.equals(vdsDynamic)) {
+            // log what is changed
+            log.warn(dbData.whatChanged(vdsDynamic));
             update(vdsDynamic);
         } else {
             log.debug("Ignored an unneeded update of VdsDynamic");


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

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

Reply via email to