Roy Golan has uploaded a new change for review.

Change subject: core: monitoring: adhere to fields naming convention
......................................................................

core: monitoring: adhere to fields naming convention

Change-Id: I18d520d3b7a61c2e02bb43ca73334b8c0ecc1c23
Signed-off-by: Roy Golan <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/HostMonitoring.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VmsMonitoring.java
2 files changed, 164 insertions(+), 164 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/27941/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/HostMonitoring.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/HostMonitoring.java
index eea6dd9..62a9cd2 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/HostMonitoring.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/HostMonitoring.java
@@ -49,24 +49,23 @@
 
 @SuppressWarnings({ "synthetic-access", "unchecked", "rawtypes" })
 public class HostMonitoring {
-    private boolean _saveVdsDynamic;
-    private VDSStatus _firstStatus = VDSStatus.forValue(0);
-    private boolean _saveVdsStatistics;
-    private final VdsManager _vdsManager;
+    private final VDS vds;
+    private final VdsManager vdsManager;
+    private VDSStatus firstStatus = VDSStatus.forValue(0);
     private final MonitoringStrategy monitoringStrategy;
-    private final VDS _vds;
-
+    private boolean saveVdsDynamic;
+    private boolean saveVdsStatistics;
     private boolean processHardwareCapsNeeded;
     private boolean refreshedCapabilities = false;
-    VmsMonitoring vmsMonitoring;
+    private VmsMonitoring vmsMonitoring;
     private static Map<Guid, Long> hostDownTimes = new HashMap<>();
 
     private static final Log log = LogFactory.getLog(HostMonitoring.class);
 
     public HostMonitoring(VdsManager vdsManager, VDS vds, MonitoringStrategy 
monitoringStrategy) {
-        _vdsManager = vdsManager;
-        _vds = vds;
-        _firstStatus = _vds.getStatus();
+        this.vdsManager = vdsManager;
+        this.vds = vds;
+        firstStatus = vds.getStatus();
         this.monitoringStrategy = monitoringStrategy;
         vmsMonitoring = new VmsMonitoring(vdsManager, vds);
     }
@@ -76,16 +75,16 @@
             refreshVdsRunTimeInfo();
         } finally {
             try {
-                if (_firstStatus != _vds.getStatus() && _vds.getStatus() == 
VDSStatus.Up) {
+                if (firstStatus != vds.getStatus() && vds.getStatus() == 
VDSStatus.Up) {
                     // use this lock in order to allow only one host updating 
DB and
                     // calling UpEvent in a time
-                    VdsManager.cancelRecoveryJob(_vds.getId());
+                    VdsManager.cancelRecoveryJob(vds.getId());
                     if (log.isDebugEnabled()) {
-                        log.debugFormat("vds {0}-{1} firing up event.", 
_vds.getId(), _vds.getName());
+                        log.debugFormat("vds {0}-{1} firing up event.", 
vds.getId(), vds.getName());
                     }
-                    
_vdsManager.setIsSetNonOperationalExecuted(!ResourceManager.getInstance()
+                    
vdsManager.setIsSetNonOperationalExecuted(!ResourceManager.getInstance()
                             .getEventListener()
-                            .vdsUpEvent(_vds));
+                            .vdsUpEvent(vds));
                 }
                 // save all data to db
                 saveDataToDb();
@@ -102,43 +101,43 @@
     }
 
     public void refreshVdsRunTimeInfo() {
-        boolean isVdsUpOrGoingToMaintenance = _vds.getStatus() == VDSStatus.Up
-                || _vds.getStatus() == VDSStatus.PreparingForMaintenance || 
_vds.getStatus() == VDSStatus.Error
-                || _vds.getStatus() == VDSStatus.NonOperational;
+        boolean isVdsUpOrGoingToMaintenance = vds.getStatus() == VDSStatus.Up
+                || vds.getStatus() == VDSStatus.PreparingForMaintenance || 
vds.getStatus() == VDSStatus.Error
+                || vds.getStatus() == VDSStatus.NonOperational;
         try {
             if (isVdsUpOrGoingToMaintenance) {
                 // check if its time for statistics refresh
-                if (_vdsManager.getRefreshStatistics() || _vds.getStatus() == 
VDSStatus.PreparingForMaintenance) {
+                if (vdsManager.getRefreshStatistics() || vds.getStatus() == 
VDSStatus.PreparingForMaintenance) {
                     refreshVdsStats();
                 }
             } else {
                 // refresh dynamic data
                 final AtomicBoolean processHardwareNeededAtomic = new 
AtomicBoolean();
                 VDSStatus refreshReturnStatus =
-                        
_vdsManager.refreshCapabilities(processHardwareNeededAtomic, _vds);
+                        
vdsManager.refreshCapabilities(processHardwareNeededAtomic, vds);
                 processHardwareCapsNeeded = processHardwareNeededAtomic.get();
                 refreshedCapabilities = true;
                 if (refreshReturnStatus != VDSStatus.NonOperational) {
-                    _vdsManager.setStatus(VDSStatus.Up, _vds);
+                    vdsManager.setStatus(VDSStatus.Up, vds);
                 }
-                _saveVdsDynamic = true;
+                saveVdsDynamic = true;
             }
             beforeFirstRefreshTreatment(isVdsUpOrGoingToMaintenance);
             vmsMonitoring.refreshVmStats();
         } catch (VDSRecoveringException e) {
             // if PreparingForMaintenance and vds is in install failed keep to
             // move vds to maintenance
-            if (_vds.getStatus() != VDSStatus.PreparingForMaintenance) {
+            if (vds.getStatus() != VDSStatus.PreparingForMaintenance) {
                 throw e;
             }
         } catch (ClassCastException cce) {
             // This should occur only if the vdsm API is not the same as the 
cluster API (version mismatch)
             log.error(String.format("Failure to refresh Vds %s runtime info. 
Incorrect vdsm version for cluster %s",
-                    _vds.getName(),
-                    _vds.getVdsGroupName()), cce);
-            if (_vds.getStatus() != VDSStatus.PreparingForMaintenance && 
_vds.getStatus() != VDSStatus.Maintenance) {
+                    vds.getName(),
+                    vds.getVdsGroupName()), cce);
+            if (vds.getStatus() != VDSStatus.PreparingForMaintenance && 
vds.getStatus() != VDSStatus.Maintenance) {
                 
ResourceManager.getInstance().runVdsCommand(VDSCommandType.SetVdsStatus,
-                        new SetVdsStatusVDSCommandParameters(_vds.getId(), 
VDSStatus.Error));
+                        new SetVdsStatusVDSCommandParameters(vds.getId(), 
VDSStatus.Error));
             }
         } catch (Throwable t) {
             log.error("Failure to refresh Vds runtime info", t);
@@ -148,23 +147,23 @@
     }
 
     private void saveDataToDb() {
-        if (_saveVdsDynamic) {
-            _vdsManager.updateDynamicData(_vds.getDynamicData());
+        if (saveVdsDynamic) {
+            vdsManager.updateDynamicData(vds.getDynamicData());
             if (refreshedCapabilities) {
-                _vdsManager.updateNumaData(_vds);
+                vdsManager.updateNumaData(vds);
             }
         }
 
-        if (_saveVdsStatistics) {
-            VdsStatistics stat = _vds.getStatisticsData();
-            _vdsManager.updateStatisticsData(stat);
+        if (saveVdsStatistics) {
+            VdsStatistics stat = vds.getStatisticsData();
+            vdsManager.updateStatisticsData(stat);
             checkVdsMemoryThreshold(stat);
             checkVdsCpuThreshold(stat);
             checkVdsNetworkThreshold(stat);
             checkVdsSwapThreshold(stat);
 
             final List<VdsNetworkStatistics> statistics = new 
LinkedList<VdsNetworkStatistics>();
-            for (VdsNetworkInterface iface : _vds.getInterfaces()) {
+            for (VdsNetworkInterface iface : vds.getInterfaces()) {
                 statistics.add(iface.getStatistics());
             }
             if (!statistics.isEmpty()) {
@@ -188,17 +187,17 @@
     private void saveCpuStatisticsDataToDb() {
         final List<CpuStatistics> cpuStatisticsToSave = new ArrayList<>();
 
-        
cpuStatisticsToSave.addAll(_vds.getStatisticsData().getCpuCoreStatistics());
+        
cpuStatisticsToSave.addAll(vds.getStatisticsData().getCpuCoreStatistics());
         if (!cpuStatisticsToSave.isEmpty()) {
             List<CpuStatistics> dbCpuStats = 
getDbFacade().getVdsCpuStatisticsDAO()
-                    .getAllCpuStatisticsByVdsId(_vds.getId());
+                    .getAllCpuStatisticsByVdsId(vds.getId());
             if (dbCpuStats.isEmpty()) {
                 
TransactionSupport.executeInScope(TransactionScopeOption.Required,
                         new TransactionMethod<Void>() {
                             @Override
                             public Void runInTransaction() {
                                 
getDbFacade().getVdsCpuStatisticsDAO().massSaveCpuStatistics(
-                                        cpuStatisticsToSave, _vds.getId());
+                                        cpuStatisticsToSave, vds.getId());
                                 return null;
                             }
                         });
@@ -210,9 +209,9 @@
                             new TransactionMethod<Void>() {
                                 @Override
                                 public Void runInTransaction() {
-                                    
getDbFacade().getVdsCpuStatisticsDAO().removeAllCpuStatisticsByVdsId(_vds.getId());
+                                    
getDbFacade().getVdsCpuStatisticsDAO().removeAllCpuStatisticsByVdsId(vds.getId());
                                     
getDbFacade().getVdsCpuStatisticsDAO().massSaveCpuStatistics(
-                                            cpuStatisticsToSave, _vds.getId());
+                                            cpuStatisticsToSave, vds.getId());
                                     return null;
                                 }
                             });
@@ -223,7 +222,7 @@
                                 @Override
                                 public Void runInTransaction() {
                                     
getDbFacade().getVdsCpuStatisticsDAO().massUpdateCpuStatistics(
-                                            cpuStatisticsToSave, _vds.getId());
+                                            cpuStatisticsToSave, vds.getId());
                                     return null;
                                 }
                             });
@@ -255,10 +254,10 @@
 
     private void saveNumaStatisticsDataToDb() {
         final List<VdsNumaNode> vdsNumaNodesToSave = new ArrayList<>();
-        List<VdsNumaNode> updateNumaNodes = _vds.getNumaNodeList();
+        List<VdsNumaNode> updateNumaNodes = vds.getNumaNodeList();
         if (!updateNumaNodes.isEmpty()) {
             List<VdsNumaNode> dbVdsNumaNodes = 
getDbFacade().getVdsNumaNodeDAO()
-                    .getAllVdsNumaNodeByVdsId(_vds.getId());
+                    .getAllVdsNumaNodeByVdsId(vds.getId());
             Map<Integer, VdsNumaNode> nodesMap = new HashMap<>();
             for (VdsNumaNode node : dbVdsNumaNodes) {
                 nodesMap.put(node.getIndex(), node);
@@ -280,7 +279,8 @@
                             
getDbFacade().getVdsNumaNodeDAO().massUpdateNumaNodeStatistics(vdsNumaNodesToSave);
                             return null;
                         }
-                    });
+                    }
+            );
         }
     }
 
@@ -303,10 +303,10 @@
                 AuditLogType.VDS_LOW_MEM :
                 AuditLogType.VDS_HIGH_MEM_USE;
 
-        if ((stat.getMemFree() < minAvailableThreshold && 
Version.v3_2.compareTo(_vds.getVersion()) <= 0)
+        if ((stat.getMemFree() < minAvailableThreshold && 
Version.v3_2.compareTo(vds.getVersion()) <= 0)
                 || stat.getusage_mem_percent() > maxUsedPercentageThreshold) {
             AuditLogableBase logable = new AuditLogableBase(stat.getId());
-            logable.addCustomValue("HostName", _vds.getName());
+            logable.addCustomValue("HostName", vds.getName());
             logable.addCustomValue("AvailableMemory", 
stat.getMemFree().toString());
             logable.addCustomValue("UsedMemory", 
stat.getusage_mem_percent().toString());
             logable.addCustomValue("Threshold", stat.getMemFree() < 
minAvailableThreshold ?
@@ -327,7 +327,7 @@
         if (stat.getusage_cpu_percent() != null
                 && stat.getusage_cpu_percent() > maxUsedPercentageThreshold) {
             AuditLogableBase logable = new AuditLogableBase(stat.getId());
-            logable.addCustomValue("HostName", _vds.getName());
+            logable.addCustomValue("HostName", vds.getName());
             logable.addCustomValue("UsedCpu", 
stat.getusage_cpu_percent().toString());
             logable.addCustomValue("Threshold", 
maxUsedPercentageThreshold.toString());
             auditLog(logable, AuditLogType.VDS_HIGH_CPU_USE);
@@ -341,14 +341,14 @@
      */
     private void checkVdsNetworkThreshold(VdsStatistics stat) {
         Integer maxUsedPercentageThreshold = 
Config.getValue(ConfigValues.LogMaxNetworkUsedThresholdInPercentage);
-        for (VdsNetworkInterface iface : _vds.getInterfaces()) {
+        for (VdsNetworkInterface iface : vds.getInterfaces()) {
             Double transmitRate = iface.getStatistics().getTransmitRate();
             Double receiveRate = iface.getStatistics().getReceiveRate();
             if ((transmitRate != null && 
iface.getStatistics().getTransmitRate().intValue() > maxUsedPercentageThreshold)
                     || (receiveRate != null && 
iface.getStatistics().getReceiveRate().intValue() > 
maxUsedPercentageThreshold)) {
-                AuditLogableBase logable = new AuditLogableBase(_vds.getId());
+                AuditLogableBase logable = new AuditLogableBase(vds.getId());
                 logable.setCustomId(iface.getName());
-                logable.addCustomValue("HostName", _vds.getName());
+                logable.addCustomValue("HostName", vds.getName());
                 logable.addCustomValue("InterfaceName", iface.getName());
                 logable.addCustomValue("Threshold", 
maxUsedPercentageThreshold.toString());
                 logable.addCustomValue("TransmitRate", 
String.valueOf(transmitRate.intValue()));
@@ -381,7 +381,7 @@
 
         if (stat.getswap_free() < minAvailableThreshold || swapUsedPercent > 
maxUsedPercentageThreshold) {
             AuditLogableBase logable = new AuditLogableBase(stat.getId());
-            logable.addCustomValue("HostName", _vds.getName());
+            logable.addCustomValue("HostName", vds.getName());
             logable.addCustomValue("UsedSwap", swapUsedPercent.toString());
             logable.addCustomValue("AvailableSwapMemory", 
stat.getswap_free().toString());
             logable.addCustomValue("Threshold", stat.getswap_free() < 
minAvailableThreshold ?
@@ -394,8 +394,8 @@
         log.errorFormat("{0} Error: {1}, vds = {2} : {3}",
                 messagePrefix,
                 ExceptionUtils.getMessage(ex),
-                _vds.getId(),
-                _vds.getName());
+                vds.getId(),
+                vds.getName());
     }
 
     protected IVdsEventListener getVdsEventListener() {
@@ -405,35 +405,35 @@
     public void afterRefreshTreatment() {
         try {
             if (processHardwareCapsNeeded) {
-                monitoringStrategy.processHardwareCapabilities(_vds);
+                monitoringStrategy.processHardwareCapabilities(vds);
                 markIsSetNonOperationalExecuted();
             }
 
             if (refreshedCapabilities) {
-                getVdsEventListener().handleVdsVersion(_vds.getId());
+                getVdsEventListener().handleVdsVersion(vds.getId());
                 markIsSetNonOperationalExecuted();
             }
 
-            if (_vds.getStatus() == VDSStatus.Maintenance) {
+            if (vds.getStatus() == VDSStatus.Maintenance) {
                 try {
-                    getVdsEventListener().vdsMovedToMaintenance(_vds);
+                    getVdsEventListener().vdsMovedToMaintenance(vds);
                 } catch (RuntimeException ex) {
                     log.errorFormat("Host encounter a problem moving to 
maintenance mode, probably error during disconnecting it from pool {0}. The 
Host will stay in Maintenance",
                             ex.getMessage());
                 }
-            } else if (_vds.getStatus() == VDSStatus.NonOperational && 
_firstStatus != VDSStatus.NonOperational) {
+            } else if (vds.getStatus() == VDSStatus.NonOperational && 
firstStatus != VDSStatus.NonOperational) {
 
-                if (!_vdsManager.isSetNonOperationalExecuted()) {
+                if (!vdsManager.isSetNonOperationalExecuted()) {
                     ResourceManager
                             .getInstance()
                             .getEventListener()
-                            .vdsNonOperational(_vds.getId(), 
_vds.getNonOperationalReason(), true, Guid.Empty);
+                            .vdsNonOperational(vds.getId(), 
vds.getNonOperationalReason(), true, Guid.Empty);
                 } else {
 
                     log.infoFormat("Host {0} : {1} is already in 
NonOperational status for reason {2}. SetNonOperationalVds command is skipped.",
-                            _vds.getId(),
-                            _vds.getName(),
-                            (_vds.getNonOperationalReason() != null) ? 
_vds.getNonOperationalReason().name()
+                            vds.getId(),
+                            vds.getName(),
+                            (vds.getNonOperationalReason() != null) ? 
vds.getNonOperationalReason().name()
                                     : "unknown");
                 }
             }
@@ -451,24 +451,24 @@
     }
 
     private void markIsSetNonOperationalExecuted() {
-        if (!_vdsManager.isSetNonOperationalExecuted()) {
-            VdsDynamic vdsDynamic = 
getDbFacade().getVdsDynamicDao().get(_vds.getId());
+        if (!vdsManager.isSetNonOperationalExecuted()) {
+            VdsDynamic vdsDynamic = 
getDbFacade().getVdsDynamicDao().get(vds.getId());
             if (vdsDynamic.getStatus() == VDSStatus.NonOperational) {
-                _vdsManager.setIsSetNonOperationalExecuted(true);
+                vdsManager.setIsSetNonOperationalExecuted(true);
             }
         }
     }
 
     public void refreshVdsStats() {
         if (Config.<Boolean> getValue(ConfigValues.DebugTimerLogging)) {
-            log.debugFormat("vdsManager::refreshVdsStats entered, vds = {0} : 
{1}", _vds.getId(),
-                    _vds.getName());
+            log.debugFormat("vdsManager::refreshVdsStats entered, vds = {0} : 
{1}", vds.getId(),
+                    vds.getName());
         }
         // get statistics data, images checks and vm_count data (dynamic)
         GetStatsVDSCommand<VdsIdAndVdsVDSCommandParametersBase> 
vdsBrokerCommand =
-                new 
GetStatsVDSCommand<VdsIdAndVdsVDSCommandParametersBase>(new 
VdsIdAndVdsVDSCommandParametersBase(_vds));
+                new 
GetStatsVDSCommand<VdsIdAndVdsVDSCommandParametersBase>(new 
VdsIdAndVdsVDSCommandParametersBase(vds));
         vdsBrokerCommand.execute();
-        
ResourceManager.getInstance().getEventListener().updateSchedulingStats(_vds);
+        
ResourceManager.getInstance().getEventListener().updateSchedulingStats(vds);
         if (!vdsBrokerCommand.getVDSReturnValue().getSucceeded()
                 && vdsBrokerCommand.getVDSReturnValue().getExceptionObject() 
!= null) {
             VDSNetworkException ex =
@@ -476,22 +476,22 @@
                             .getVDSReturnValue().getExceptionObject()
                             : null);
             if (ex != null) {
-                if (_vdsManager.handleNetworkException(ex, _vds)) {
-                    _saveVdsDynamic = true;
+                if (vdsManager.handleNetworkException(ex, vds)) {
+                    saveVdsDynamic = true;
                 }
                 log.errorFormat("vds::refreshVdsStats Failed getVdsStats,  vds 
= {0} : {1}, error = {2}",
-                        _vds.getId(), _vds.getName(), 
ExceptionUtils.getMessage(ex));
+                        vds.getId(), vds.getName(), 
ExceptionUtils.getMessage(ex));
             } else {
                 log.errorFormat("vds::refreshVdsStats Failed getVdsStats,  vds 
= {0} : {1}, error = {2}",
-                        _vds.getId(), _vds.getName(), 
vdsBrokerCommand.getVDSReturnValue().getExceptionString());
+                        vds.getId(), vds.getName(), 
vdsBrokerCommand.getVDSReturnValue().getExceptionString());
             }
             throw vdsBrokerCommand.getVDSReturnValue().getExceptionObject();
         }
         // save also dynamic because vm_count data and image_check getting with
         // statistics data
         // TODO: omer- one day remove dynamic save when possible please check 
if vdsDynamic changed before save
-        _saveVdsDynamic = true;
-        _saveVdsStatistics = true;
+        saveVdsDynamic = true;
+        saveVdsStatistics = true;
 
         alertIfLowDiskSpaceOnHost();
         checkVdsInterfaces();
@@ -505,7 +505,7 @@
      * Log to the audit log in case one/some of the paths monitored by VDSM 
are low on disk space.
      */
     private void alertIfLowDiskSpaceOnHost() {
-        Map<String, Long> disksUsage = _vds.getLocalDisksUsage();
+        Map<String, Long> disksUsage = vds.getLocalDisksUsage();
         if (disksUsage == null || disksUsage.isEmpty()) {
             return;
         }
@@ -547,7 +547,7 @@
             final Integer lowSpaceThreshold,
             AuditLogType logType) {
         if (!disksWithLowSpace.isEmpty()) {
-            AuditLogableBase logable = new AuditLogableBase(_vds.getId());
+            AuditLogableBase logable = new AuditLogableBase(vds.getId());
             logable.addCustomValue("DiskSpace", lowSpaceThreshold.toString());
             logable.addCustomValue("Disks", 
StringUtils.join(disksWithLowSpace, ", "));
             auditLog(logable, logType);
@@ -557,7 +557,7 @@
     // Check if one of the Host interfaces is down, we set the host to 
non-operational
     // We cannot have Host that don't have all networks in cluster in status Up
     private void checkVdsInterfaces() {
-        if (_vds.getStatus() != VDSStatus.Up) {
+        if (vds.getStatus() != VDSStatus.Up) {
             return;
         }
 
@@ -566,30 +566,30 @@
 
         try {
             reportNicStatusChanges();
-            Pair<List<String>, List<String>> problematicNics = 
NetworkMonitoringHelper.determineProblematicNics(_vds.getInterfaces(),
-                    
getDbFacade().getNetworkDao().getAllForCluster(_vds.getVdsGroupId()));
+            Pair<List<String>, List<String>> problematicNics = 
NetworkMonitoringHelper.determineProblematicNics(vds.getInterfaces(),
+                    
getDbFacade().getNetworkDao().getAllForCluster(vds.getVdsGroupId()));
             brokenNics.addAll(problematicNics.getFirst());
             networks.addAll(problematicNics.getSecond());
         } catch (Exception e) {
-            log.error(String.format("Failure on checkInterfaces on update 
runtimeinfo for vds: %s", _vds.getName()),
+            log.error(String.format("Failure on checkInterfaces on update 
runtimeinfo for vds: %s", vds.getName()),
                     e);
         } finally {
             if (!brokenNics.isEmpty()) {
                 // we give 1 minutes to a nic to get up in case the nic get 
the ip from DHCP server
-                if (!hostDownTimes.containsKey(_vds.getId())) {
-                    hostDownTimes.put(_vds.getId(), 
System.currentTimeMillis());
+                if (!hostDownTimes.containsKey(vds.getId())) {
+                    hostDownTimes.put(vds.getId(), System.currentTimeMillis());
                     return;
                 }
 
                 // if less then 1 minutes, still waiting for DHCP
                 int delay = Config.<Integer> 
getValue(ConfigValues.NicDHCPDelayGraceInMS) * 1000;
-                if (System.currentTimeMillis() < 
hostDownTimes.get(_vds.getId()) + delay) {
+                if (System.currentTimeMillis() < 
hostDownTimes.get(vds.getId()) + delay) {
                     return;
                 }
 
                 // if we could retrieve it within the timeout, remove from map 
(for future checks) and set the host to
                 // non-operational
-                hostDownTimes.remove(_vds.getId());
+                hostDownTimes.remove(vds.getId());
 
                 try {
                     String networkNames = StringUtils.join(networks, ", ");
@@ -598,33 +598,33 @@
                     String message =
                             String.format(
                                     "Host '%s' moved to Non-Operational state 
because interface/s '%s' are down which needed by network/s '%s' in the current 
cluster",
-                                    _vds.getName(),
+                                    vds.getName(),
                                     nicNames,
                                     networkNames);
 
-                    
_vds.setNonOperationalReason(NonOperationalReason.NETWORK_INTERFACE_IS_DOWN);
-                    _vdsManager.setStatus(VDSStatus.NonOperational, _vds);
+                    
vds.setNonOperationalReason(NonOperationalReason.NETWORK_INTERFACE_IS_DOWN);
+                    vdsManager.setStatus(VDSStatus.NonOperational, vds);
                     log.info(message);
 
-                    AuditLogableBase logable = new 
AuditLogableBase(_vds.getId());
+                    AuditLogableBase logable = new 
AuditLogableBase(vds.getId());
                     logable.addCustomValue("Networks", networkNames);
                     logable.addCustomValue("Interfaces", nicNames);
                     logable.setCustomId(nicNames + networkNames);
                     auditLog(logable, 
AuditLogType.VDS_SET_NONOPERATIONAL_IFACE_DOWN);
                 } catch (Exception e) {
                     log.error(String.format("checkInterface: Failure on moving 
host: %s to non-operational.",
-                            _vds.getName()),
+                            vds.getName()),
                             e);
                 }
             } else {
                 // no nics are down, remove from list if exists
-                hostDownTimes.remove(_vds.getId());
+                hostDownTimes.remove(vds.getId());
             }
         }
     }
 
     private void reportNicStatusChanges() {
-        List<VdsNetworkInterface> interfaces = _vds.getInterfaces();
+        List<VdsNetworkInterface> interfaces = vds.getInterfaces();
         Set<VdsNetworkInterface> slaves = new HashSet<>();
         Map<String, VdsNetworkInterface> monitoredInterfaces = new 
HashMap<String, VdsNetworkInterface>();
         Map<String, VdsNetworkInterface> interfaceByName = 
Entities.entitiesByName(interfaces);
@@ -660,14 +660,14 @@
             }
         }
 
-        for (VdsNetworkInterface oldIface : 
getDbFacade().getInterfaceDao().getAllInterfacesForVds(_vds.getId())) {
+        for (VdsNetworkInterface oldIface : 
getDbFacade().getInterfaceDao().getAllInterfacesForVds(vds.getId())) {
             VdsNetworkInterface iface = 
monitoredInterfaces.get(oldIface.getName());
             InterfaceStatus status;
             if (iface != null) {
                 status = iface.getStatistics().getStatus();
                 if (oldIface.getStatistics().getStatus() != 
InterfaceStatus.NONE
                         && oldIface.getStatistics().getStatus() != status) {
-                    AuditLogableBase logable = new 
AuditLogableBase(_vds.getId());
+                    AuditLogableBase logable = new 
AuditLogableBase(vds.getId());
                     logable.setCustomId(iface.getName());
                     if (iface.getBondName() != null) {
                         logable.addCustomValue("SlaveName", iface.getName());
@@ -685,43 +685,43 @@
     }
 
     private void beforeFirstRefreshTreatment(boolean 
isVdsUpOrGoingToMaintenance) {
-        if (_vdsManager.getbeforeFirstRefresh()) {
+        if (vdsManager.getbeforeFirstRefresh()) {
             boolean flagsChanged = false;
             final AtomicBoolean processHardwareCapsNeededTemp = new 
AtomicBoolean();
-            _vdsManager.refreshCapabilities(processHardwareCapsNeededTemp, 
_vds);
+            vdsManager.refreshCapabilities(processHardwareCapsNeededTemp, vds);
             flagsChanged = processHardwareCapsNeededTemp.get();
-            _vdsManager.setbeforeFirstRefresh(false);
+            vdsManager.setbeforeFirstRefresh(false);
             refreshedCapabilities = true;
-            _saveVdsDynamic = true;
+            saveVdsDynamic = true;
             // change the _cpuFlagsChanged flag only if it was false,
             // because get capabilities is called twice on a new server in same
             // loop!
             processHardwareCapsNeeded = (processHardwareCapsNeeded) ? 
processHardwareCapsNeeded : flagsChanged;
-        } else if (isVdsUpOrGoingToMaintenance || _vds.getStatus() == 
VDSStatus.Error) {
+        } else if (isVdsUpOrGoingToMaintenance || vds.getStatus() == 
VDSStatus.Error) {
             return;
         }
         // show status UP in audit only when InitVdsOnUpCommand finished 
successfully
-        if (_vds.getStatus() != VDSStatus.Up) {
-            AuditLogableBase logable = new AuditLogableBase(_vds.getId());
-            logable.addCustomValue("HostStatus", _vds.getStatus().toString());
+        if (vds.getStatus() != VDSStatus.Up) {
+            AuditLogableBase logable = new AuditLogableBase(vds.getId());
+            logable.addCustomValue("HostStatus", vds.getStatus().toString());
             auditLog(logable, AuditLogType.VDS_DETECTED);
         }
     }
 
     private void moveVDSToMaintenanceIfNeeded() {
-        if (_vds.getStatus() == VDSStatus.PreparingForMaintenance) {
-            if (monitoringStrategy.canMoveToMaintenance(_vds)) {
-                _vdsManager.setStatus(VDSStatus.Maintenance, _vds);
-                _saveVdsDynamic = true;
-                _saveVdsStatistics = true;
+        if (vds.getStatus() == VDSStatus.PreparingForMaintenance) {
+            if (monitoringStrategy.canMoveToMaintenance(vds)) {
+                vdsManager.setStatus(VDSStatus.Maintenance, vds);
+                saveVdsDynamic = true;
+                saveVdsStatistics = true;
                 log.infoFormat(
                         "Updated vds status from 'Preparing for Maintenance' 
to 'Maintenance' in database,  vds = {0} : {1}",
-                        _vds.getId(),
-                        _vds.getName());
+                        vds.getId(),
+                        vds.getName());
             } else {
-                if (_vdsManager.isTimeToRetryMaintenance()) {
-                    
ResourceManager.getInstance().getEventListener().handleVdsMaintenanceTimeout(_vds);
-                    _vdsManager.calculateNextMaintenanceAttemptTime();
+                if (vdsManager.isTimeToRetryMaintenance()) {
+                    
ResourceManager.getInstance().getEventListener().handleVdsMaintenanceTimeout(vds);
+                    vdsManager.calculateNextMaintenanceAttemptTime();
                 }
             }
         }
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VmsMonitoring.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VmsMonitoring.java
index d0eee50..f765df8 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VmsMonitoring.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VmsMonitoring.java
@@ -78,23 +78,23 @@
     private final Map<Guid, VM> vmDict;
     private Map<Guid, VmInternalData> runningVms;
 
-    private final Map<Guid, VmDynamic> _vmDynamicToSave = new HashMap<>();
-    private final Map<Guid, VmStatistics> _vmStatisticsToSave = new 
HashMap<>();
-    private final Map<Guid, List<VmNetworkInterface>> 
_vmInterfaceStatisticsToSave = new HashMap<>();
-    private final Map<Guid, DiskImageDynamic> _vmDiskImageDynamicToSave = new 
HashMap<>();
+    private final Map<Guid, VmDynamic> vmDynamicToSave = new HashMap<>();
+    private final Map<Guid, VmStatistics> vmStatisticsToSave = new HashMap<>();
+    private final Map<Guid, List<VmNetworkInterface>> 
vmInterfaceStatisticsToSave = new HashMap<>();
+    private final Map<Guid, DiskImageDynamic> vmDiskImageDynamicToSave = new 
HashMap<>();
     private final Map<VmDeviceId, VmDevice> vmDeviceToSave = new HashMap<>();
-    private final Map<VM, VmDynamic> _vmsClientIpChanged = new HashMap<>();
+    private final Map<VM, VmDynamic> vmsClientIpChanged = new HashMap<>();
     private final Map<Guid, List<VmGuestAgentInterface>> vmGuestAgentNics = 
new HashMap<>();
-    private final List<VmDynamic> _poweringUpVms = new ArrayList<>();
-    private final List<Guid> _vmsMovedToDown = new ArrayList<>();
-    private final List<Guid> _vmsToRemoveFromAsync = new ArrayList<>();
-    private final List<Guid> _succededToRunVms = new ArrayList<>();
+    private final List<VmDynamic> poweringUpVms = new ArrayList<>();
+    private final List<Guid> vmsMovedToDown = new ArrayList<>();
+    private final List<Guid> vmsToRemoveFromAsync = new ArrayList<>();
+    private final List<Guid> succededToRunVms = new ArrayList<>();
     private final List<VmDevice> newVmDevices = new ArrayList<>();
     private final List<VmDeviceId> removedDeviceIds = new ArrayList<>();
     private final List<LUNs> vmLunDisksToSave = new ArrayList<>();
-    private final List<Guid> _vmsToRerun = new ArrayList<>();
-    private final List<Guid> _autoVmsToRun = new ArrayList<>();
-    private final List<VmStatic> _externalVmsToAdd = new ArrayList<>();
+    private final List<Guid> vmsToRerun = new ArrayList<>();
+    private final List<Guid> autoVmsToRun = new ArrayList<>();
+    private final List<VmStatic> externalVmsToAdd = new ArrayList<>();
 
     private static final Map<Guid, Integer> vmsWithBalloonDriverProblem = new 
HashMap<>();
     private static final Map<Guid, Integer> vmsWithUncontrolledBalloon = new 
HashMap<>();
@@ -411,7 +411,7 @@
                 
vmStatic.setMemSizeMb(parseIntVdsProperty(vmInfo.get(VdsProperties.mem_size_mb)));
                 vmStatic.setSingleQxlPci(false);
 
-                _externalVmsToAdd.add(vmStatic);
+                externalVmsToAdd.add(vmStatic);
                 log.infoFormat("Importing VM {0} as {1}, as it is running on 
the on Host, but does not exist in the engine.", vmNameOnHost, 
vmStatic.getName());
             }
         }
@@ -427,7 +427,7 @@
                 if (vmToUpdate != null) {
                     if (vmDict.containsKey(vmToUpdate.getId())
                             && !StringUtils.equals(runningVm.getClientIp(), 
vmToUpdate.getClientIp())) {
-                        _vmsClientIpChanged.put(vmToUpdate, runningVm);
+                        vmsClientIpChanged.put(vmToUpdate, runningVm);
                     }
                 }
                 if (vmToUpdate != null) {
@@ -439,7 +439,7 @@
                         // Vm moved to powering Up or up status - launch spice
                         // if no current client ip already connected.
                         if (runningVm.getDisplay() != null) {
-                            _poweringUpVms.add(runningVm);
+                            poweringUpVms.add(runningVm);
                         } else {
                             log.error("UpdateRepository - runningVm.display is 
null, cannot start spice for it");
                         }
@@ -459,8 +459,8 @@
                         if (log.isDebugEnabled()) {
                             log.debugFormat("removing VM {0} from successful 
run VMs list", vmToUpdate.getId());
                         }
-                        if (!_succededToRunVms.contains(vmToUpdate.getId())) {
-                            _succededToRunVms.add(vmToUpdate.getId());
+                        if (!succededToRunVms.contains(vmToUpdate.getId())) {
+                            succededToRunVms.add(vmToUpdate.getId());
                         }
                     }
                     afterMigrationFrom(runningVm, vmToUpdate);
@@ -472,7 +472,7 @@
                     }
                     // check if vm is suspended and remove it from async list
                     else if (runningVm.getStatus() == VMStatus.Paused) {
-                        _vmsToRemoveFromAsync.add(vmToUpdate.getId());
+                        vmsToRemoveFromAsync.add(vmToUpdate.getId());
                         if (vmToUpdate.getStatus() != VMStatus.Paused) {
                             // check exit message to determine why the VM is 
paused
                             AuditLogType logType = 
vmPauseStatusToAuditLogType(runningVm.getPauseStatus());
@@ -508,7 +508,7 @@
 
                 VmDynamic vmDynamic = 
getDbFacade().getVmDynamicDao().get(runningVm.getId());
                 if (vmDynamic == null || vmDynamic.getStatus() != 
VMStatus.Unknown) {
-                    _vmDynamicToSave.remove(runningVm.getId());
+                    vmDynamicToSave.remove(runningVm.getId());
                 }
             }
         }
@@ -530,8 +530,8 @@
 
                 vmDict.put(vmToUpdate.argvalue.getId(), vmToUpdate.argvalue);
                 if (vmNewDynamicData.getStatus() == VMStatus.Up) {
-                    if 
(!_succededToRunVms.contains(vmToUpdate.argvalue.getId())) {
-                        _succededToRunVms.add(vmToUpdate.argvalue.getId());
+                    if 
(!succededToRunVms.contains(vmToUpdate.argvalue.getId())) {
+                        succededToRunVms.add(vmToUpdate.argvalue.getId());
                     }
                 }
             }
@@ -584,7 +584,7 @@
                     DiskImage diskImage = (DiskImage) disk;
                     Guid activeImageId = diskImage.getImageId();
                     imageDynamic.setId(activeImageId);
-                    _vmDiskImageDynamicToSave.put(activeImageId, imageDynamic);
+                    vmDiskImageDynamicToSave.put(activeImageId, imageDynamic);
                 }
             }
         }
@@ -676,8 +676,8 @@
                             && !dbHash.equals(vmDynamic.getHash())) {
                         vmsToUpdateFromVds.add(vmDynamic.getId().toString());
                         // update new hash value
-                        if (_vmDynamicToSave.containsKey(vm.getId())) {
-                            
_vmDynamicToSave.get(vm.getId()).setHash(vmDynamic.getHash());
+                        if (vmDynamicToSave.containsKey(vm.getId())) {
+                            
vmDynamicToSave.get(vm.getId()).setHash(vmDynamic.getHash());
                         } else {
                             addVmDynamicToList(vmDynamic);
                         }
@@ -710,8 +710,8 @@
                         vmGuestAgentNics.put(vmDynamic.getId(), 
vmGuestAgentInterfaces);
 
                         // update new hash value
-                        if (_vmDynamicToSave.containsKey(vm.getId())) {
-                            
updateGuestAgentInterfacesChanges(_vmDynamicToSave.get(vm.getId()),
+                        if (vmDynamicToSave.containsKey(vm.getId())) {
+                            
updateGuestAgentInterfacesChanges(vmDynamicToSave.get(vm.getId()),
                                     vmGuestAgentInterfaces,
                                     guestAgentNicHash);
                         } else {
@@ -761,11 +761,11 @@
     }
 
     void saveVmsToDb() {
-        
getDbFacade().getVmDynamicDao().updateAllInBatch(_vmDynamicToSave.values());
-        
getDbFacade().getVmStatisticsDao().updateAllInBatch(_vmStatisticsToSave.values());
+        
getDbFacade().getVmDynamicDao().updateAllInBatch(vmDynamicToSave.values());
+        
getDbFacade().getVmStatisticsDao().updateAllInBatch(vmStatisticsToSave.values());
 
         final List<VmNetworkStatistics> allVmInterfaceStatistics = new 
LinkedList<VmNetworkStatistics>();
-        for (List<VmNetworkInterface> list : 
_vmInterfaceStatisticsToSave.values()) {
+        for (List<VmNetworkInterface> list : 
vmInterfaceStatisticsToSave.values()) {
             for (VmNetworkInterface iface : list) {
                 allVmInterfaceStatistics.add(iface.getStatistics());
             }
@@ -773,36 +773,36 @@
 
         
getDbFacade().getVmNetworkStatisticsDao().updateAllInBatch(allVmInterfaceStatistics);
 
-        
getDbFacade().getDiskImageDynamicDao().updateAllInBatch(_vmDiskImageDynamicToSave.values());
+        
getDbFacade().getDiskImageDynamicDao().updateAllInBatch(vmDiskImageDynamicToSave.values());
         getDbFacade().getLunDao().updateAllInBatch(vmLunDisksToSave);
         saveVmDevicesToDb();
         saveVmGuestAgentNetworkDevices();
-        getVdsEventListener().addExternallyManagedVms(_externalVmsToAdd);
+        getVdsEventListener().addExternallyManagedVms(externalVmsToAdd);
     }
 
     void afterVMsRefreshTreatment() {
         // rerun all vms from rerun list
-        for (Guid vm_guid : _vmsToRerun) {
+        for (Guid vm_guid : vmsToRerun) {
             log.errorFormat("Rerun vm {0}. Called from vds {1}", vm_guid, 
vds.getName());
             ResourceManager.getInstance().RerunFailedCommand(vm_guid, 
vds.getId());
 
         }
-        for (Guid vm_guid : _succededToRunVms) {
+        for (Guid vm_guid : succededToRunVms) {
             vdsManager.succededToRunVm(vm_guid);
         }
 
         // Refrain from auto-start HA VM during its re-run attempts.
-        _autoVmsToRun.removeAll(_vmsToRerun);
+        autoVmsToRun.removeAll(vmsToRerun);
         // run all vms that crushed that marked with auto startup
-        getVdsEventListener().runFailedAutoStartVMs(_autoVmsToRun);
+        getVdsEventListener().runFailedAutoStartVMs(autoVmsToRun);
 
         // process all vms that their ip changed.
-        for (Map.Entry<VM, VmDynamic> pair : _vmsClientIpChanged.entrySet()) {
+        for (Map.Entry<VM, VmDynamic> pair : vmsClientIpChanged.entrySet()) {
             getVdsEventListener().processOnClientIpChange(vds, 
pair.getValue().getId());
         }
 
         // process all vms that powering up.
-        for (VmDynamic runningVm : _poweringUpVms) {
+        for (VmDynamic runningVm : poweringUpVms) {
             ResourceManager
                     .getInstance()
                     .getEventListener()
@@ -811,10 +811,10 @@
         }
 
         // process all vms that went down
-        for (Guid vm_guid : _vmsMovedToDown) {
+        for (Guid vm_guid : vmsMovedToDown) {
             getVdsEventListener().processOnVmStop(vm_guid);
         }
-        for (Guid vm_guid : _vmsToRemoveFromAsync) {
+        for (Guid vm_guid : vmsToRemoveFromAsync) {
             ResourceManager.getInstance().RemoveAsyncRunningVm(vm_guid);
         }
     }
@@ -945,9 +945,9 @@
             if (cacheVm != null) {
                 if 
(ResourceManager.getInstance().IsVmInAsyncRunningList(vmDynamic.getId())) {
                     log.infoFormat("Running on vds during rerun failed vm: 
{0}", vmDynamic.getRunOnVds());
-                    _vmsToRerun.add(vmDynamic.getId());
+                    vmsToRerun.add(vmDynamic.getId());
                 } else if (cacheVm.isAutoStartup()) {
-                    _autoVmsToRun.add(vmDynamic.getId());
+                    autoVmsToRun.add(vmDynamic.getId());
                 }
             }
             // if failed in destination right after migration
@@ -992,7 +992,7 @@
         if (vm.getStatus() != VMStatus.MigratingFrom) {
             // we must check that vm.getStatus() != VMStatus.Down because if 
it was set to down
             // the exit status and message were set, and we don't want to 
override them here.
-            // we will add it to _vmDynamicToSave though because it might been 
removed from it in #updateRepository
+            // we will add it to vmDynamicToSave though because it might been 
removed from it in #updateRepository
             if (vm.getStatus() != VMStatus.Suspended && vm.getStatus() != 
VMStatus.Down) {
                 ResourceManager.getInstance().InternalSetVmStatus(vm, 
VMStatus.Down, exitStatus, exitMessage, exitReason);
             }
@@ -1000,7 +1000,7 @@
             addVmStatisticsToList(vm.getStatisticsData());
             addVmInterfaceStatisticsToList(vm.getInterfaces());
             if 
(!ResourceManager.getInstance().IsVmInAsyncRunningList(vm.getId())) {
-                _vmsMovedToDown.add(vm.getId());
+                vmsMovedToDown.add(vm.getId());
             }
         }
     }
@@ -1251,9 +1251,9 @@
                     vmToRemove.getName(), vmToRemove.getId(), vds.getName());
 
             vmGuid = vmToRemove.getId();
-            if (!isInMigration && !_vmsToRerun.contains(vmGuid)
+            if (!isInMigration && !vmsToRerun.contains(vmGuid)
                     && 
ResourceManager.getInstance().IsVmInAsyncRunningList(vmGuid)) {
-                _vmsToRerun.add(vmGuid);
+                vmsToRerun.add(vmGuid);
                 log.infoFormat("add VM {0} to rerun treatment", 
vmToRemove.getName());
             }
             // vm should be auto startup
@@ -1261,11 +1261,11 @@
             // not in reported from vdsm at all
             // or reported from vdsm with error code
             else if (vmToRemove.isAutoStartup()
-                    && !_autoVmsToRun.contains(vmGuid)
+                    && !autoVmsToRun.contains(vmGuid)
                     && (!runningVms.containsKey(vmGuid) || 
(runningVms.containsKey(vmGuid) && runningVms.get(vmGuid)
                     .getVmDynamic()
                     .getExitStatus() != VmExitStatus.Normal))) {
-                _autoVmsToRun.add(vmGuid);
+                autoVmsToRun.add(vmGuid);
                 log.infoFormat("add VM {0} to HA rerun treatment", 
vmToRemove.getName());
             }
         }
@@ -1331,7 +1331,7 @@
         // is not MigratingFrom, it means the migration failed
         if (oldVmStatus == VMStatus.MigratingFrom && currentVmStatus != 
VMStatus.MigratingFrom
                 && currentVmStatus.isRunning()) {
-            _vmsToRerun.add(runningVm.getId());
+            vmsToRerun.add(runningVm.getId());
             log.infoFormat("Adding VM {0} to re-run list", runningVm.getId());
             vmToUpdate.setMigratingToVds(null);
         }
@@ -1397,7 +1397,7 @@
      * @param vmDynamic
      */
     private void addVmDynamicToList(VmDynamic vmDynamic) {
-        _vmDynamicToSave.put(vmDynamic.getId(), vmDynamic);
+        vmDynamicToSave.put(vmDynamic.getId(), vmDynamic);
     }
 
     /**
@@ -1406,14 +1406,14 @@
      * @param vmStatistics
      */
     private void addVmStatisticsToList(VmStatistics vmStatistics) {
-        _vmStatisticsToSave.put(vmStatistics.getId(), vmStatistics);
+        vmStatisticsToSave.put(vmStatistics.getId(), vmStatistics);
     }
 
     private void addVmInterfaceStatisticsToList(List<VmNetworkInterface> list) 
{
         if (list.isEmpty()) {
             return;
         }
-        _vmInterfaceStatisticsToSave.put(list.get(0).getVmId(), list);
+        vmInterfaceStatisticsToSave.put(list.get(0).getVmId(), list);
     }
 
     /**
@@ -1460,7 +1460,7 @@
         return runningVms;
     }
     protected List<VmDynamic> getPoweringUpVms() {
-        return _poweringUpVms;
+        return poweringUpVms;
     }
 
     protected DbFacade getDbFacade() {


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

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

Reply via email to