http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/capacity/CapacityManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java index b81180d..541c847 100644 --- a/server/src/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java @@ -29,6 +29,7 @@ import javax.naming.ConfigurationException; import com.cloud.resource.ResourceState; import com.cloud.utils.fsm.StateMachine2; +import org.apache.log4j.Logger; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; @@ -103,6 +104,7 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDao; @Local(value = CapacityManager.class) public class CapacityManagerImpl extends ManagerBase implements CapacityManager, StateListener<State, VirtualMachine.Event, VirtualMachine>, Listener, ResourceListener, Configurable { + private static final Logger s_logger = Logger.getLogger(CapacityManagerImpl.class); @Inject CapacityDao _capacityDao; @Inject @@ -190,7 +192,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, if (hostId != null) { HostVO host = _hostDao.findById(hostId); if (host == null) { - logger.warn("Host " + hostId + " no long exist anymore!"); + s_logger.warn("Host " + hostId + " no long exist anymore!"); return true; } @@ -222,9 +224,9 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long actualTotalMem = capacityMemory.getTotalCapacity(); long totalMem = (long)(actualTotalMem * memoryOvercommitRatio); long totalCpu = (long)(actualTotalCpu * cpuOvercommitRatio); - if (logger.isDebugEnabled()) { - logger.debug("Hosts's actual total CPU: " + actualTotalCpu + " and CPU after applying overprovisioning: " + totalCpu); - logger.debug("Hosts's actual total RAM: " + actualTotalMem + " and RAM after applying overprovisioning: " + totalMem); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Hosts's actual total CPU: " + actualTotalCpu + " and CPU after applying overprovisioning: " + totalCpu); + s_logger.debug("Hosts's actual total RAM: " + actualTotalMem + " and RAM after applying overprovisioning: " + totalMem); } if (!moveFromReserved) { @@ -253,11 +255,11 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, } } - logger.debug("release cpu from host: " + hostId + ", old used: " + usedCpu + ",reserved: " + reservedCpu + ", actual total: " + actualTotalCpu + + s_logger.debug("release cpu from host: " + hostId + ", old used: " + usedCpu + ",reserved: " + reservedCpu + ", actual total: " + actualTotalCpu + ", total with overprovisioning: " + totalCpu + "; new used: " + capacityCpu.getUsedCapacity() + ",reserved:" + capacityCpu.getReservedCapacity() + "; movedfromreserved: " + moveFromReserved + ",moveToReservered" + moveToReservered); - logger.debug("release mem from host: " + hostId + ", old used: " + usedMem + ",reserved: " + reservedMem + ", total: " + totalMem + "; new used: " + + s_logger.debug("release mem from host: " + hostId + ", old used: " + usedMem + ",reserved: " + reservedMem + ", total: " + totalMem + "; new used: " + capacityMemory.getUsedCapacity() + ",reserved:" + capacityMemory.getReservedCapacity() + "; movedfromreserved: " + moveFromReserved + ",moveToReservered" + moveToReservered); @@ -268,7 +270,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, return true; } catch (Exception e) { - logger.debug("Failed to transit vm's state, due to " + e.getMessage()); + s_logger.debug("Failed to transit vm's state, due to " + e.getMessage()); return false; } } @@ -313,27 +315,27 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long actualTotalMem = capacityMem.getTotalCapacity(); long totalCpu = (long)(actualTotalCpu * cpuOvercommitRatio); long totalMem = (long)(actualTotalMem * memoryOvercommitRatio); - if (logger.isDebugEnabled()) { - logger.debug("Hosts's actual total CPU: " + actualTotalCpu + " and CPU after applying overprovisioning: " + totalCpu); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Hosts's actual total CPU: " + actualTotalCpu + " and CPU after applying overprovisioning: " + totalCpu); } long freeCpu = totalCpu - (reservedCpu + usedCpu); long freeMem = totalMem - (reservedMem + usedMem); - if (logger.isDebugEnabled()) { - logger.debug("We are allocating VM, increasing the used capacity of this host:" + hostId); - logger.debug("Current Used CPU: " + usedCpu + " , Free CPU:" + freeCpu + " ,Requested CPU: " + cpu); - logger.debug("Current Used RAM: " + usedMem + " , Free RAM:" + freeMem + " ,Requested RAM: " + ram); + if (s_logger.isDebugEnabled()) { + s_logger.debug("We are allocating VM, increasing the used capacity of this host:" + hostId); + s_logger.debug("Current Used CPU: " + usedCpu + " , Free CPU:" + freeCpu + " ,Requested CPU: " + cpu); + s_logger.debug("Current Used RAM: " + usedMem + " , Free RAM:" + freeMem + " ,Requested RAM: " + ram); } capacityCpu.setUsedCapacity(usedCpu + cpu); capacityMem.setUsedCapacity(usedMem + ram); if (fromLastHost) { /* alloc from reserved */ - if (logger.isDebugEnabled()) { - logger.debug("We are allocating VM to the last host again, so adjusting the reserved capacity if it is not less than required"); - logger.debug("Reserved CPU: " + reservedCpu + " , Requested CPU: " + cpu); - logger.debug("Reserved RAM: " + reservedMem + " , Requested RAM: " + ram); + if (s_logger.isDebugEnabled()) { + s_logger.debug("We are allocating VM to the last host again, so adjusting the reserved capacity if it is not less than required"); + s_logger.debug("Reserved CPU: " + reservedCpu + " , Requested CPU: " + cpu); + s_logger.debug("Reserved RAM: " + reservedMem + " , Requested RAM: " + ram); } if (reservedCpu >= cpu && reservedMem >= ram) { capacityCpu.setReservedCapacity(reservedCpu - cpu); @@ -342,18 +344,18 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, } else { /* alloc from free resource */ if (!((reservedCpu + usedCpu + cpu <= totalCpu) && (reservedMem + usedMem + ram <= totalMem))) { - if (logger.isDebugEnabled()) { - logger.debug("Host doesnt seem to have enough free capacity, but increasing the used capacity anyways, " + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host doesnt seem to have enough free capacity, but increasing the used capacity anyways, " + "since the VM is already starting on this host "); } } } - logger.debug("CPU STATS after allocation: for host: " + hostId + ", old used: " + usedCpu + ", old reserved: " + reservedCpu + ", actual total: " + + s_logger.debug("CPU STATS after allocation: for host: " + hostId + ", old used: " + usedCpu + ", old reserved: " + reservedCpu + ", actual total: " + actualTotalCpu + ", total with overprovisioning: " + totalCpu + "; new used:" + capacityCpu.getUsedCapacity() + ", reserved:" + capacityCpu.getReservedCapacity() + "; requested cpu:" + cpu + ",alloc_from_last:" + fromLastHost); - logger.debug("RAM STATS after allocation: for host: " + hostId + ", old used: " + usedMem + ", old reserved: " + reservedMem + ", total: " + + s_logger.debug("RAM STATS after allocation: for host: " + hostId + ", old used: " + usedMem + ", old reserved: " + reservedMem + ", total: " + totalMem + "; new used: " + capacityMem.getUsedCapacity() + ", reserved: " + capacityMem.getReservedCapacity() + "; requested mem: " + ram + ",alloc_from_last:" + fromLastHost); @@ -362,7 +364,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, } }); } catch (Exception e) { - logger.error("Exception allocating VM capacity", e); + s_logger.error("Exception allocating VM capacity", e); return; } } @@ -375,14 +377,14 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, boolean isCpuNumGood = host.getCpus().intValue() >= cpuNum; boolean isCpuSpeedGood = host.getSpeed().intValue() >= cpuSpeed; if (isCpuNumGood && isCpuSpeedGood) { - if (logger.isDebugEnabled()) { - logger.debug("Host: " + hostId + " has cpu capability (cpu:" + host.getCpus() + ", speed:" + host.getSpeed() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host: " + hostId + " has cpu capability (cpu:" + host.getCpus() + ", speed:" + host.getSpeed() + ") to support requested CPU: " + cpuNum + " and requested speed: " + cpuSpeed); } return true; } else { - if (logger.isDebugEnabled()) { - logger.debug("Host: " + hostId + " doesn't have cpu capability (cpu:" + host.getCpus() + ", speed:" + host.getSpeed() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host: " + hostId + " doesn't have cpu capability (cpu:" + host.getCpus() + ", speed:" + host.getSpeed() + ") to support requested CPU: " + cpuNum + " and requested speed: " + cpuSpeed); } return false; @@ -394,8 +396,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, boolean considerReservedCapacity) { boolean hasCapacity = false; - if (logger.isDebugEnabled()) { - logger.debug("Checking if host: " + hostId + " has enough capacity for requested CPU: " + cpu + " and requested RAM: " + ram + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Checking if host: " + hostId + " has enough capacity for requested CPU: " + cpu + " and requested RAM: " + ram + " , cpuOverprovisioningFactor: " + cpuOvercommitRatio); } @@ -404,13 +406,13 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, if (capacityCpu == null || capacityMem == null) { if (capacityCpu == null) { - if (logger.isDebugEnabled()) { - logger.debug("Cannot checkIfHostHasCapacity, Capacity entry for CPU not found in Db, for hostId: " + hostId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Cannot checkIfHostHasCapacity, Capacity entry for CPU not found in Db, for hostId: " + hostId); } } if (capacityMem == null) { - if (logger.isDebugEnabled()) { - logger.debug("Cannot checkIfHostHasCapacity, Capacity entry for RAM not found in Db, for hostId: " + hostId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Cannot checkIfHostHasCapacity, Capacity entry for RAM not found in Db, for hostId: " + hostId); } } @@ -425,8 +427,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long actualTotalMem = capacityMem.getTotalCapacity(); long totalCpu = (long)(actualTotalCpu * cpuOvercommitRatio); long totalMem = (long)(actualTotalMem * memoryOvercommitRatio); - if (logger.isDebugEnabled()) { - logger.debug("Hosts's actual total CPU: " + actualTotalCpu + " and CPU after applying overprovisioning: " + totalCpu); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Hosts's actual total CPU: " + actualTotalCpu + " and CPU after applying overprovisioning: " + totalCpu); } String failureReason = ""; @@ -434,10 +436,10 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long freeCpu = reservedCpu; long freeMem = reservedMem; - if (logger.isDebugEnabled()) { - logger.debug("We need to allocate to the last host again, so checking if there is enough reserved capacity"); - logger.debug("Reserved CPU: " + freeCpu + " , Requested CPU: " + cpu); - logger.debug("Reserved RAM: " + freeMem + " , Requested RAM: " + ram); + if (s_logger.isDebugEnabled()) { + s_logger.debug("We need to allocate to the last host again, so checking if there is enough reserved capacity"); + s_logger.debug("Reserved CPU: " + freeCpu + " , Requested CPU: " + cpu); + s_logger.debug("Reserved RAM: " + freeMem + " , Requested RAM: " + ram); } /* alloc from reserved */ if (reservedCpu >= cpu) { @@ -455,8 +457,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long reservedMemValueToUse = reservedMem; if (!considerReservedCapacity) { - if (logger.isDebugEnabled()) { - logger.debug("considerReservedCapacity is" + considerReservedCapacity + " , not considering reserved capacity for calculating free capacity"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("considerReservedCapacity is" + considerReservedCapacity + " , not considering reserved capacity for calculating free capacity"); } reservedCpuValueToUse = 0; reservedMemValueToUse = 0; @@ -464,9 +466,9 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long freeCpu = totalCpu - (reservedCpuValueToUse + usedCpu); long freeMem = totalMem - (reservedMemValueToUse + usedMem); - if (logger.isDebugEnabled()) { - logger.debug("Free CPU: " + freeCpu + " , Requested CPU: " + cpu); - logger.debug("Free RAM: " + freeMem + " , Requested RAM: " + ram); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Free CPU: " + freeCpu + " , Requested CPU: " + cpu); + s_logger.debug("Free RAM: " + freeMem + " , Requested RAM: " + ram); } /* alloc from free resource */ if ((reservedCpuValueToUse + usedCpu + cpu <= totalCpu)) { @@ -481,29 +483,29 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, } if (hasCapacity) { - if (logger.isDebugEnabled()) { - logger.debug("Host has enough CPU and RAM available"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host has enough CPU and RAM available"); } - logger.debug("STATS: Can alloc CPU from host: " + hostId + ", used: " + usedCpu + ", reserved: " + reservedCpu + ", actual total: " + actualTotalCpu + + s_logger.debug("STATS: Can alloc CPU from host: " + hostId + ", used: " + usedCpu + ", reserved: " + reservedCpu + ", actual total: " + actualTotalCpu + ", total with overprovisioning: " + totalCpu + "; requested cpu:" + cpu + ",alloc_from_last_host?:" + checkFromReservedCapacity + " ,considerReservedCapacity?: " + considerReservedCapacity); - logger.debug("STATS: Can alloc MEM from host: " + hostId + ", used: " + usedMem + ", reserved: " + reservedMem + ", total: " + totalMem + + s_logger.debug("STATS: Can alloc MEM from host: " + hostId + ", used: " + usedMem + ", reserved: " + reservedMem + ", total: " + totalMem + "; requested mem: " + ram + ",alloc_from_last_host?:" + checkFromReservedCapacity + " ,considerReservedCapacity?: " + considerReservedCapacity); } else { if (checkFromReservedCapacity) { - logger.debug("STATS: Failed to alloc resource from host: " + hostId + " reservedCpu: " + reservedCpu + ", requested cpu: " + cpu + ", reservedMem: " + + s_logger.debug("STATS: Failed to alloc resource from host: " + hostId + " reservedCpu: " + reservedCpu + ", requested cpu: " + cpu + ", reservedMem: " + reservedMem + ", requested mem: " + ram); } else { - logger.debug("STATS: Failed to alloc resource from host: " + hostId + " reservedCpu: " + reservedCpu + ", used cpu: " + usedCpu + ", requested cpu: " + + s_logger.debug("STATS: Failed to alloc resource from host: " + hostId + " reservedCpu: " + reservedCpu + ", used cpu: " + usedCpu + ", requested cpu: " + cpu + ", actual total cpu: " + actualTotalCpu + ", total cpu with overprovisioning: " + totalCpu + ", reservedMem: " + reservedMem + ", used Mem: " + usedMem + ", requested mem: " + ram + ", total Mem:" + totalMem + " ,considerReservedCapacity?: " + considerReservedCapacity); } - if (logger.isDebugEnabled()) { - logger.debug(failureReason + ", cannot allocate to this host."); + if (s_logger.isDebugEnabled()) { + s_logger.debug(failureReason + ", cannot allocate to this host."); } } @@ -591,8 +593,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, final CapacityState capacityState = (host.getResourceState() == ResourceState.Enabled) ? CapacityState.Enabled : CapacityState.Disabled; List<VMInstanceVO> vms = _vmDao.listUpByHostId(host.getId()); - if (logger.isDebugEnabled()) { - logger.debug("Found " + vms.size() + " VMs on host " + host.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found " + vms.size() + " VMs on host " + host.getId()); } ClusterVO cluster = _clusterDao.findById(host.getClusterId()); @@ -626,8 +628,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, } List<VMInstanceVO> vmsByLastHostId = _vmDao.listByLastHostId(host.getId()); - if (logger.isDebugEnabled()) { - logger.debug("Found " + vmsByLastHostId.size() + " VM, not running on host " + host.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found " + vmsByLastHostId.size() + " VM, not running on host " + host.getId()); } for (VMInstanceVO vm : vmsByLastHostId) { long secondsSinceLastUpdate = (DateUtil.currentGMTTime().getTime() - vm.getUpdateTime().getTime()) / 1000; @@ -678,50 +680,50 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, long hostTotalCpu = host.getCpus().longValue() * host.getSpeed().longValue(); if (cpuCap.getTotalCapacity() != hostTotalCpu) { - logger.debug("Calibrate total cpu for host: " + host.getId() + " old total CPU:" + cpuCap.getTotalCapacity() + " new total CPU:" + hostTotalCpu); + s_logger.debug("Calibrate total cpu for host: " + host.getId() + " old total CPU:" + cpuCap.getTotalCapacity() + " new total CPU:" + hostTotalCpu); cpuCap.setTotalCapacity(hostTotalCpu); } // Set the capacity state as per the host allocation state. if(capacityState != cpuCap.getCapacityState()){ - logger.debug("Calibrate cpu capacity state for host: " + host.getId() + " old capacity state:" + cpuCap.getTotalCapacity() + " new capacity state:" + hostTotalCpu); + s_logger.debug("Calibrate cpu capacity state for host: " + host.getId() + " old capacity state:" + cpuCap.getTotalCapacity() + " new capacity state:" + hostTotalCpu); cpuCap.setCapacityState(capacityState); } memCap.setCapacityState(capacityState); if (cpuCap.getUsedCapacity() == usedCpu && cpuCap.getReservedCapacity() == reservedCpu) { - logger.debug("No need to calibrate cpu capacity, host:" + host.getId() + " usedCpu: " + cpuCap.getUsedCapacity() + " reservedCpu: " + + s_logger.debug("No need to calibrate cpu capacity, host:" + host.getId() + " usedCpu: " + cpuCap.getUsedCapacity() + " reservedCpu: " + cpuCap.getReservedCapacity()); } else { if (cpuCap.getReservedCapacity() != reservedCpu) { - logger.debug("Calibrate reserved cpu for host: " + host.getId() + " old reservedCpu:" + cpuCap.getReservedCapacity() + " new reservedCpu:" + + s_logger.debug("Calibrate reserved cpu for host: " + host.getId() + " old reservedCpu:" + cpuCap.getReservedCapacity() + " new reservedCpu:" + reservedCpu); cpuCap.setReservedCapacity(reservedCpu); } if (cpuCap.getUsedCapacity() != usedCpu) { - logger.debug("Calibrate used cpu for host: " + host.getId() + " old usedCpu:" + cpuCap.getUsedCapacity() + " new usedCpu:" + usedCpu); + s_logger.debug("Calibrate used cpu for host: " + host.getId() + " old usedCpu:" + cpuCap.getUsedCapacity() + " new usedCpu:" + usedCpu); cpuCap.setUsedCapacity(usedCpu); } } if (memCap.getTotalCapacity() != host.getTotalMemory()) { - logger.debug("Calibrate total memory for host: " + host.getId() + " old total memory:" + memCap.getTotalCapacity() + " new total memory:" + + s_logger.debug("Calibrate total memory for host: " + host.getId() + " old total memory:" + memCap.getTotalCapacity() + " new total memory:" + host.getTotalMemory()); memCap.setTotalCapacity(host.getTotalMemory()); } // Set the capacity state as per the host allocation state. if(capacityState != memCap.getCapacityState()){ - logger.debug("Calibrate memory capacity state for host: " + host.getId() + " old capacity state:" + memCap.getTotalCapacity() + " new capacity state:" + hostTotalCpu); + s_logger.debug("Calibrate memory capacity state for host: " + host.getId() + " old capacity state:" + memCap.getTotalCapacity() + " new capacity state:" + hostTotalCpu); memCap.setCapacityState(capacityState); } if (memCap.getUsedCapacity() == usedMemory && memCap.getReservedCapacity() == reservedMemory) { - logger.debug("No need to calibrate memory capacity, host:" + host.getId() + " usedMem: " + memCap.getUsedCapacity() + " reservedMem: " + + s_logger.debug("No need to calibrate memory capacity, host:" + host.getId() + " usedMem: " + memCap.getUsedCapacity() + " reservedMem: " + memCap.getReservedCapacity()); } else { if (memCap.getReservedCapacity() != reservedMemory) { - logger.debug("Calibrate reserved memory for host: " + host.getId() + " old reservedMem:" + memCap.getReservedCapacity() + " new reservedMem:" + + s_logger.debug("Calibrate reserved memory for host: " + host.getId() + " old reservedMem:" + memCap.getReservedCapacity() + " new reservedMem:" + reservedMemory); memCap.setReservedCapacity(reservedMemory); } @@ -731,7 +733,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, * state(starting/migrating) that I don't know on which host * they are allocated */ - logger.debug("Calibrate used memory for host: " + host.getId() + " old usedMem: " + memCap.getUsedCapacity() + " new usedMem: " + usedMemory); + s_logger.debug("Calibrate used memory for host: " + host.getId() + " old usedMem: " + memCap.getUsedCapacity() + " new usedMem: " + usedMemory); memCap.setUsedCapacity(usedMemory); } } @@ -740,7 +742,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, _capacityDao.update(cpuCap.getId(), cpuCap); _capacityDao.update(memCap.getId(), memCap); } catch (Exception e) { - logger.error("Caught exception while updating cpu/memory capacity for the host " + host.getId(), e); + s_logger.error("Caught exception while updating cpu/memory capacity for the host " + host.getId(), e); } } else { final long usedMemoryFinal = usedMemory; @@ -787,7 +789,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, State oldState = transition.getCurrentState(); State newState = transition.getToState(); Event event = transition.getEvent(); - logger.debug("VM state transitted from :" + oldState + " to " + newState + " with event: " + event + "vm's original host id: " + vm.getLastHostId() + + s_logger.debug("VM state transitted from :" + oldState + " to " + newState + " with event: " + event + "vm's original host id: " + vm.getLastHostId() + " new host id: " + vm.getHostId() + " host id before state transition: " + oldHostId); if (oldState == State.Starting) { @@ -830,7 +832,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, if ((newState == State.Starting || newState == State.Migrating || event == Event.AgentReportMigrated) && vm.getHostId() != null) { boolean fromLastHost = false; if (vm.getHostId().equals(vm.getLastHostId())) { - logger.debug("VM starting again on the last host it was stopped on"); + s_logger.debug("VM starting again on the last host it was stopped on"); fromLastHost = true; } allocateVmCapacity(vm, fromLastHost); @@ -878,7 +880,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, CapacityVOCpu.setReservedCapacity(0); CapacityVOCpu.setTotalCapacity(newTotalCpu); } else { - logger.debug("What? new cpu is :" + newTotalCpu + ", old one is " + CapacityVOCpu.getUsedCapacity() + "," + CapacityVOCpu.getReservedCapacity() + + s_logger.debug("What? new cpu is :" + newTotalCpu + ", old one is " + CapacityVOCpu.getUsedCapacity() + "," + CapacityVOCpu.getReservedCapacity() + "," + CapacityVOCpu.getTotalCapacity()); } _capacityDao.update(CapacityVOCpu.getId(), CapacityVOCpu); @@ -905,7 +907,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, CapacityVOMem.setReservedCapacity(0); CapacityVOMem.setTotalCapacity(newTotalMem); } else { - logger.debug("What? new cpu is :" + newTotalMem + ", old one is " + CapacityVOMem.getUsedCapacity() + "," + CapacityVOMem.getReservedCapacity() + + s_logger.debug("What? new cpu is :" + newTotalMem + ", old one is " + CapacityVOMem.getUsedCapacity() + "," + CapacityVOMem.getReservedCapacity() + "," + CapacityVOMem.getTotalCapacity()); } _capacityDao.update(CapacityVOMem.getId(), CapacityVOMem); @@ -947,14 +949,14 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, float cpuConsumption = _capacityDao.findClusterConsumption(clusterId, Capacity.CAPACITY_TYPE_CPU, cpuRequested); if (cpuConsumption / clusterCpuOverProvisioning > clusterCpuCapacityDisableThreshold) { - logger.debug("Cluster: " + clusterId + " cpu consumption " + cpuConsumption / clusterCpuOverProvisioning + s_logger.debug("Cluster: " + clusterId + " cpu consumption " + cpuConsumption / clusterCpuOverProvisioning + " crosses disable threshold " + clusterCpuCapacityDisableThreshold); return true; } float memoryConsumption = _capacityDao.findClusterConsumption(clusterId, Capacity.CAPACITY_TYPE_MEMORY, ramRequested); if (memoryConsumption / clusterMemoryOverProvisioning > clusterMemoryCapacityDisableThreshold) { - logger.debug("Cluster: " + clusterId + " memory consumption " + memoryConsumption / clusterMemoryOverProvisioning + s_logger.debug("Cluster: " + clusterId + " memory consumption " + memoryConsumption / clusterMemoryOverProvisioning + " crosses disable threshold " + clusterMemoryCapacityDisableThreshold); return true; } @@ -1065,8 +1067,8 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, String hypervisorVersion = host.getHypervisorVersion(); Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion); if (vmCount.longValue() >= maxGuestLimit.longValue()) { - if (logger.isDebugEnabled()) { - logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + " already reached max Running VMs(count includes system VMs), limit is: " + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + " already reached max Running VMs(count includes system VMs), limit is: " + maxGuestLimit + ",Running VM counts is: " + vmCount.longValue()); } return true;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/configuration/ConfigurationManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index ee3d7a2..fc7bff9 100644 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -37,6 +37,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.acl.SecurityChecker; import org.apache.cloudstack.affinity.AffinityGroup; @@ -216,6 +217,7 @@ import com.cloud.vm.dao.NicSecondaryIpDao; @Local(value = {ConfigurationManager.class, ConfigurationService.class}) public class ConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService, Configurable { + public static final Logger s_logger = Logger.getLogger(ConfigurationManagerImpl.class); @Inject EntityManager _entityMgr; @@ -419,13 +421,13 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati if (mgtCidr == null || mgtCidr.trim().isEmpty()) { final String[] localCidrs = NetUtils.getLocalCidrs(); if (localCidrs != null && localCidrs.length > 0) { - logger.warn("Management network CIDR is not configured originally. Set it default to " + localCidrs[0]); + s_logger.warn("Management network CIDR is not configured originally. Set it default to " + localCidrs[0]); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management network CIDR is not configured originally. Set it default to " + localCidrs[0], ""); _configDao.update(Config.ManagementNetwork.key(), Config.ManagementNetwork.getCategory(), localCidrs[0]); } else { - logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting"); + s_logger.warn("Management network CIDR is not properly configured and we are not able to find a default setting"); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management network CIDR is not properly configured and we are not able to find a default setting", ""); } @@ -445,7 +447,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati final String validationMsg = validateConfigurationValue(name, value, scope); if (validationMsg != null) { - logger.error("Invalid configuration option, name: " + name + ", value:" + value); + s_logger.error("Invalid configuration option, name: " + name + ", value:" + value); throw new InvalidParameterValueException(validationMsg); } @@ -517,7 +519,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati txn.start(); if (!_configDao.update(name, category, value)) { - logger.error("Failed to update configuration option, name: " + name + ", value:" + value); + s_logger.error("Failed to update configuration option, name: " + name + ", value:" + value); throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support."); } @@ -620,7 +622,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati // FIX ME - All configuration parameters are not moved from config.java to configKey if (config == null) { if (_configDepot.get(name) == null) { - logger.warn("Probably the component manager where configuration variable " + name + " is defined needs to implement Configurable interface"); + s_logger.warn("Probably the component manager where configuration variable " + name + " is defined needs to implement Configurable interface"); throw new InvalidParameterValueException("Config parameter with name " + name + " doesn't exist"); } catergory = _configDepot.get(name).category(); @@ -679,24 +681,24 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati final ConfigurationVO cfg = _configDao.findByName(name); if (cfg == null) { - logger.error("Missing configuration variable " + name + " in configuration table"); + s_logger.error("Missing configuration variable " + name + " in configuration table"); return "Invalid configuration variable."; } final String configScope = cfg.getScope(); if (scope != null) { if (!configScope.contains(scope)) { - logger.error("Invalid scope id provided for the parameter " + name); + s_logger.error("Invalid scope id provided for the parameter " + name); return "Invalid scope id provided for the parameter " + name; } } Class<?> type = null; final Config c = Config.getConfig(name); if (c == null) { - logger.warn("Did not find configuration " + name + " in Config.java. Perhaps moved to ConfigDepot"); + s_logger.warn("Did not find configuration " + name + " in Config.java. Perhaps moved to ConfigDepot"); final ConfigKey<?> configKey = _configDepot.get(name); if(configKey == null) { - logger.warn("Did not find configuration " + name + " in ConfigDepot too."); + s_logger.warn("Did not find configuration " + name + " in ConfigDepot too."); return null; } type = configKey.type(); @@ -715,7 +717,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } catch (final Exception e) { // catching generic exception as some throws NullPointerException and some throws NumberFormatExcpeion - logger.error(errMsg); + s_logger.error(errMsg); return errMsg; } @@ -725,7 +727,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } if (overprovisioningFactorsForValidation.contains(name)) { final String msg = "value cannot be null for the parameter " + name; - logger.error(msg); + s_logger.error(msg); return msg; } return null; @@ -735,18 +737,18 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati try { if (overprovisioningFactorsForValidation.contains(name) && Float.parseFloat(value) < 1f) { final String msg = name + " should be greater than or equal to 1"; - logger.error(msg); + s_logger.error(msg); throw new InvalidParameterValueException(msg); } } catch (final NumberFormatException e) { final String msg = "There was an error trying to parse the float value for: " + name; - logger.error(msg); + s_logger.error(msg); throw new InvalidParameterValueException(msg); } if (type.equals(Boolean.class)) { if (!(value.equals("true") || value.equals("false"))) { - logger.error("Configuration variable " + name + " is expecting true or false instead of " + value); + s_logger.error("Configuration variable " + name + " is expecting true or false instead of " + value); return "Please enter either 'true' or 'false'."; } return null; @@ -763,7 +765,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new InvalidParameterValueException("Please enter a value greater than 6 for the configuration parameter:" + name); } } catch (final NumberFormatException e) { - logger.error("There was an error trying to parse the integer value for:" + name); + s_logger.error("There was an error trying to parse the integer value for:" + name); throw new InvalidParameterValueException("There was an error trying to parse the integer value for:" + name); } } @@ -775,7 +777,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new InvalidParameterValueException("Please enter a value between 0 and 1 for the configuration parameter: " + name); } } catch (final NumberFormatException e) { - logger.error("There was an error trying to parse the float value for:" + name); + s_logger.error("There was an error trying to parse the float value for:" + name); throw new InvalidParameterValueException("There was an error trying to parse the float value for:" + name); } } @@ -795,16 +797,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati if (range.equals("privateip")) { try { if (!NetUtils.isSiteLocalAddress(value)) { - logger.error("privateip range " + value + " is not a site local address for configuration variable " + name); + s_logger.error("privateip range " + value + " is not a site local address for configuration variable " + name); return "Please enter a site local IP address."; } } catch (final NullPointerException e) { - logger.error("Error parsing ip address for " + name); + s_logger.error("Error parsing ip address for " + name); throw new InvalidParameterValueException("Error parsing ip address"); } } else if (range.equals("netmask")) { if (!NetUtils.isValidNetmask(value)) { - logger.error("netmask " + value + " is not a valid net mask for configuration variable " + name); + s_logger.error("netmask " + value + " is not a valid net mask for configuration variable " + name); return "Please enter a valid netmask."; } } else if (range.equals("hypervisorList")) { @@ -848,7 +850,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati return null; } } - logger.error("configuration value for " + name + " is invalid"); + s_logger.error("configuration value for " + name + " is invalid"); return "Please enter : " + range; } @@ -856,14 +858,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati final String[] options = range.split("-"); if (options.length != 2) { final String msg = "configuration range " + range + " for " + name + " is invalid"; - logger.error(msg); + s_logger.error(msg); return msg; } final int min = Integer.parseInt(options[0]); final int max = Integer.parseInt(options[1]); final int val = Integer.parseInt(value); if (val < min || val > max) { - logger.error("configuration value for " + name + " is invalid"); + s_logger.error("configuration value for " + name + " is invalid"); return "Please enter : " + range; } } @@ -1233,7 +1235,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } }); } catch (final Exception e) { - logger.error("Unable to edit pod due to " + e.getMessage(), e); + s_logger.error("Unable to edit pod due to " + e.getMessage(), e); throw new CloudRuntimeException("Failed to edit pod. Please contact Cloud Support."); } @@ -1761,7 +1763,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati _networkSvc.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), "vlan", mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(), mgmtTraffic.getVmwareNetworkLabel(), mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan(), mgmtTraffic.getHypervNetworkLabel(), mgmtTraffic.getOvm3NetworkLabel()); - logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network " + mgmtPhyNetwork.getId() + s_logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network " + mgmtPhyNetwork.getId() + " with same configure of management traffic type"); } } catch (final InvalidParameterValueException ex) { @@ -2893,7 +2895,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati if (supportsMultipleSubnets == null || !Boolean.valueOf(supportsMultipleSubnets)) { throw new InvalidParameterValueException("The Dhcp serivice provider for this network dose not support the dhcp across multiple subnets"); } - logger.info("adding a new subnet to the network " + network.getId()); + s_logger.info("adding a new subnet to the network " + network.getId()); } else if (sameSubnet != null) { // if it is same subnet the user might not send the vlan and the // netmask details. so we are @@ -3254,7 +3256,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati @Override public VlanVO doInTransaction(final TransactionStatus status) { VlanVO vlan = new VlanVO(vlanType, vlanId, vlanGateway, vlanNetmask, zone.getId(), ipRange, networkId, physicalNetworkId, vlanIp6Gateway, vlanIp6Cidr, ipv6Range); - logger.debug("Saving vlan range " + vlan); + s_logger.debug("Saving vlan range " + vlan); vlan = _vlanDao.persist(vlan); // IPv6 use a used ip map, is different from ipv4, no need to save @@ -3317,8 +3319,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new CloudRuntimeException("Unable to acquire vlan configuration: " + vlanDbId); } - if (logger.isDebugEnabled()) { - logger.debug("lock vlan " + vlanDbId + " is acquired"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("lock vlan " + vlanDbId + " is acquired"); } for (final IPAddressVO ip : ips) { boolean success = true; @@ -3342,7 +3344,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati success = _ipAddrMgr.disassociatePublicIpAddress(ip.getId(), userId, caller); } if (!success) { - logger.warn("Some ip addresses failed to be released as a part of vlan " + vlanDbId + " removal"); + s_logger.warn("Some ip addresses failed to be released as a part of vlan " + vlanDbId + " removal"); } else { resourceCountToBeDecrement++; UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NET_IP_RELEASE, acctVln.get(0).getAccountId(), ip.getDataCenterId(), ip.getId(), @@ -3499,14 +3501,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati if (vlan == null) { throw new CloudRuntimeException("Unable to acquire vlan configuration: " + vlanDbId); } - if (logger.isDebugEnabled()) { - logger.debug("lock vlan " + vlanDbId + " is acquired"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("lock vlan " + vlanDbId + " is acquired"); } for (final IPAddressVO ip : ips) { // Disassociate allocated IP's that are not in use if (!ip.isOneToOneNat() && !ip.isSourceNat() && !(_firewallDao.countRulesByIpId(ip.getId()) > 0)) { - if (logger.isDebugEnabled()) { - logger.debug("Releasing Public IP addresses" + ip + " of vlan " + vlanDbId + " as part of Public IP" + " range release to the system pool"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing Public IP addresses" + ip + " of vlan " + vlanDbId + " as part of Public IP" + " range release to the system pool"); } success = success && _ipAddrMgr.disassociatePublicIpAddress(ip.getId(), userId, caller); } else { @@ -3514,7 +3516,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } } if (!success) { - logger.warn("Some Public IP addresses that were not in use failed to be released as a part of" + " vlan " + vlanDbId + "release to the system pool"); + s_logger.warn("Some Public IP addresses that were not in use failed to be released as a part of" + " vlan " + vlanDbId + "release to the system pool"); } } finally { _vlanDao.releaseFromLockTable(vlanDbId); @@ -3797,8 +3799,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati public void checkDiskOfferingAccess(final Account caller, final DiskOffering dof) { for (final SecurityChecker checker : _secChecker) { if (checker.checkAccess(caller, dof)) { - if (logger.isDebugEnabled()) { - logger.debug("Access granted to " + caller + " to disk offering:" + dof.getId() + " by " + checker.getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Access granted to " + caller + " to disk offering:" + dof.getId() + " by " + checker.getName()); } return; } else { @@ -3814,8 +3816,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati public void checkZoneAccess(final Account caller, final DataCenter zone) { for (final SecurityChecker checker : _secChecker) { if (checker.checkAccess(caller, zone)) { - if (logger.isDebugEnabled()) { - logger.debug("Access granted to " + caller + " to zone:" + zone.getId() + " by " + checker.getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Access granted to " + caller + " to zone:" + zone.getId() + " by " + checker.getName()); } return; } else { @@ -3998,7 +4000,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati // dhcp provider and userdata provider should be same because vm will be contacting dhcp server for user data. if (dhcpProvider == null && IsVrUserdataProvider) { - logger.debug("User data provider VR can't be selected without VR as dhcp provider. In this case VM fails to contact the DHCP server for userdata"); + s_logger.debug("User data provider VR can't be selected without VR as dhcp provider. In this case VM fails to contact the DHCP server for userdata"); throw new InvalidParameterValueException("Without VR as dhcp provider, User data can't selected for VR. Please select VR as DHCP provider "); } @@ -4058,7 +4060,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati // if Firewall service is missing, add Firewall service/provider // combination if (firewallProvider != null) { - logger.debug("Adding Firewall service with provider " + firewallProvider.getName()); + s_logger.debug("Adding Firewall service with provider " + firewallProvider.getName()); final Set<Provider> firewallProviderSet = new HashSet<Provider>(); firewallProviderSet.add(firewallProvider); serviceProviderMap.put(Service.Firewall, firewallProviderSet); @@ -4384,7 +4386,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati NetworkOfferingVO offering = offeringFinal; // 1) create network offering object - logger.debug("Adding network offering " + offering); + s_logger.debug("Adding network offering " + offering); offering.setConcurrentConnections(maxconn); offering.setKeepAliveEnabled(enableKeepAlive); offering = _networkOfferingDao.persist(offering, details); @@ -4400,7 +4402,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } final NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service, provider); _ntwkOffServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService + " with provider " + provider.getName()); + s_logger.trace("Added service for the network offering: " + offService + " with provider " + provider.getName()); } if (vpcOff) { @@ -4411,7 +4413,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } else { final NetworkOfferingServiceMapVO offService = new NetworkOfferingServiceMapVO(offering.getId(), service, null); _ntwkOffServiceMapDao.persist(offService); - logger.trace("Added service for the network offering: " + offService + " with null provider"); + s_logger.trace("Added service for the network offering: " + offService + " with null provider"); } } } @@ -4833,7 +4835,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati // Check if the account exists final Account account = _accountDao.findEnabledAccount(accountName, domainId); if (account == null) { - logger.error("Unable to find account by name: " + accountName + " in domain " + domainId); + s_logger.error("Unable to find account by name: " + accountName + " in domain " + domainId); throw new InvalidParameterValueException("Account by name: " + accountName + " doesn't exist in domain " + domainId); } @@ -4953,11 +4955,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati } }); } catch (final CloudRuntimeException e) { - logger.error(e); + s_logger.error(e); return false; } } else { - logger.trace("Account id=" + accountId + " has no account specific virtual ip ranges, nothing to release"); + s_logger.trace("Account id=" + accountId + " has no account specific virtual ip ranges, nothing to release"); } return true; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java b/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java index 7fd3f4c..6824b9c 100644 --- a/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java +++ b/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java @@ -22,6 +22,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.security.keys.KeysManager; @@ -47,6 +48,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Local(value = {ConsoleProxyManager.class}) public class AgentBasedConsoleProxyManager extends ManagerBase implements ConsoleProxyManager { + private static final Logger s_logger = Logger.getLogger(AgentBasedConsoleProxyManager.class); @Inject protected HostDao _hostDao; @@ -99,8 +101,8 @@ public class AgentBasedConsoleProxyManager extends ManagerBase implements Consol @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { - if (logger.isInfoEnabled()) { - logger.info("Start configuring AgentBasedConsoleProxyManager"); + if (s_logger.isInfoEnabled()) { + s_logger.info("Start configuring AgentBasedConsoleProxyManager"); } Map<String, String> configs = _configDao.getConfiguration("management-server", params); @@ -124,8 +126,8 @@ public class AgentBasedConsoleProxyManager extends ManagerBase implements Consol _listener = new ConsoleProxyListener(new AgentBasedAgentHook(_instanceDao, _hostDao, _configDao, _ksMgr, _agentMgr, _keysMgr)); _agentMgr.registerForHostEvents(_listener, true, true, false); - if (logger.isInfoEnabled()) { - logger.info("AgentBasedConsoleProxyManager has been configured. SSL enabled: " + _sslEnabled); + if (s_logger.isInfoEnabled()) { + s_logger.info("AgentBasedConsoleProxyManager has been configured. SSL enabled: " + _sslEnabled); } return true; } @@ -138,22 +140,22 @@ public class AgentBasedConsoleProxyManager extends ManagerBase implements Consol public ConsoleProxyInfo assignProxy(long dataCenterId, long userVmId) { UserVmVO userVm = _userVmDao.findById(userVmId); if (userVm == null) { - logger.warn("User VM " + userVmId + " no longer exists, return a null proxy for user vm:" + userVmId); + s_logger.warn("User VM " + userVmId + " no longer exists, return a null proxy for user vm:" + userVmId); return null; } HostVO host = findHost(userVm); if (host != null) { - if (logger.isDebugEnabled()) { - logger.debug("Assign embedded console proxy running at " + host.getName() + " to user vm " + userVmId + " with public IP " + host.getPublicIpAddress()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Assign embedded console proxy running at " + host.getName() + " to user vm " + userVmId + " with public IP " + host.getPublicIpAddress()); } // only private IP, public IP, host id have meaningful values, rest // of all are place-holder values String publicIp = host.getPublicIpAddress(); if (publicIp == null) { - if (logger.isDebugEnabled()) { - logger.debug("Host " + host.getName() + "/" + host.getPrivateIpAddress() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host " + host.getName() + "/" + host.getPrivateIpAddress() + " does not have public interface, we will return its private IP for cosole proxy."); } publicIp = host.getPrivateIpAddress(); @@ -167,7 +169,7 @@ public class AgentBasedConsoleProxyManager extends ManagerBase implements Consol return new ConsoleProxyInfo(_sslEnabled, publicIp, _consoleProxyPort, urlPort, _consoleProxyUrlDomain); } else { - logger.warn("Host that VM is running is no longer available, console access to VM " + userVmId + " will be temporarily unavailable."); + s_logger.warn("Host that VM is running is no longer available, console access to VM " + userVmId + " will be temporarily unavailable."); } return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/consoleproxy/AgentBasedStandaloneConsoleProxyManager.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/consoleproxy/AgentBasedStandaloneConsoleProxyManager.java b/server/src/com/cloud/consoleproxy/AgentBasedStandaloneConsoleProxyManager.java index 3cf606b..869af13 100644 --- a/server/src/com/cloud/consoleproxy/AgentBasedStandaloneConsoleProxyManager.java +++ b/server/src/com/cloud/consoleproxy/AgentBasedStandaloneConsoleProxyManager.java @@ -20,6 +20,7 @@ import java.util.List; import javax.ejb.Local; +import org.apache.log4j.Logger; import com.cloud.host.Host; import com.cloud.host.HostVO; @@ -28,12 +29,13 @@ import com.cloud.vm.UserVmVO; @Local(value = {ConsoleProxyManager.class}) public class AgentBasedStandaloneConsoleProxyManager extends AgentBasedConsoleProxyManager { + private static final Logger s_logger = Logger.getLogger(AgentBasedStandaloneConsoleProxyManager.class); @Override public ConsoleProxyInfo assignProxy(long dataCenterId, long userVmId) { UserVmVO userVm = _userVmDao.findById(userVmId); if (userVm == null) { - logger.warn("User VM " + userVmId + " no longer exists, return a null proxy for user vm:" + userVmId); + s_logger.warn("User VM " + userVmId + " no longer exists, return a null proxy for user vm:" + userVmId); return null; } @@ -58,19 +60,19 @@ public class AgentBasedStandaloneConsoleProxyManager extends AgentBasedConsolePr } } if (allocatedHost == null) { - if (logger.isDebugEnabled()) - logger.debug("Failed to find a console proxy at host: " + host.getName() + " and in the pod: " + host.getPodId() + " to user vm " + userVmId); + if (s_logger.isDebugEnabled()) + s_logger.debug("Failed to find a console proxy at host: " + host.getName() + " and in the pod: " + host.getPodId() + " to user vm " + userVmId); return null; } - if (logger.isDebugEnabled()) - logger.debug("Assign standalone console proxy running at " + allocatedHost.getName() + " to user vm " + userVmId + " with public IP " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Assign standalone console proxy running at " + allocatedHost.getName() + " to user vm " + userVmId + " with public IP " + allocatedHost.getPublicIpAddress()); // only private IP, public IP, host id have meaningful values, rest of all are place-holder values String publicIp = allocatedHost.getPublicIpAddress(); if (publicIp == null) { - if (logger.isDebugEnabled()) - logger.debug("Host " + allocatedHost.getName() + "/" + allocatedHost.getPrivateIpAddress() + + if (s_logger.isDebugEnabled()) + s_logger.debug("Host " + allocatedHost.getName() + "/" + allocatedHost.getPrivateIpAddress() + " does not have public interface, we will return its private IP for cosole proxy."); publicIp = allocatedHost.getPrivateIpAddress(); } @@ -81,7 +83,7 @@ public class AgentBasedStandaloneConsoleProxyManager extends AgentBasedConsolePr return new ConsoleProxyInfo(_sslEnabled, publicIp, _consoleProxyPort, urlPort, _consoleProxyUrlDomain); } else { - logger.warn("Host that VM is running is no longer available, console access to VM " + userVmId + " will be temporarily unavailable."); + s_logger.warn("Host that VM is running is no longer available, console access to VM " + userVmId + " will be temporarily unavailable."); } return null; }
