http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java ---------------------------------------------------------------------- diff --git a/plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java b/plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java index d23679f..e35c29d 100644 --- a/plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java +++ b/plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java @@ -21,6 +21,7 @@ import com.cloud.user.dao.UserAccountDao; import com.cloud.utils.Pair; import com.cloud.utils.exception.CloudRuntimeException; import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import org.bouncycastle.util.encoders.Base64; import javax.ejb.Local; @@ -33,6 +34,7 @@ import java.util.Map; @Local(value = {UserAuthenticator.class}) public class SHA256SaltedUserAuthenticator extends DefaultUserAuthenticator { + public static final Logger s_logger = Logger.getLogger(SHA256SaltedUserAuthenticator.class); private static final String s_defaultPassword = "000000000000000000000000000="; private static final String s_defaultSalt = "0000000000000000000000000000000="; @Inject @@ -44,19 +46,19 @@ public class SHA256SaltedUserAuthenticator extends DefaultUserAuthenticator { */ @Override public Pair<Boolean, ActionOnFailedAuthentication> authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters) { - if (logger.isDebugEnabled()) { - logger.debug("Retrieving user: " + username); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Retrieving user: " + username); } if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) { - logger.debug("Username or Password cannot be empty"); + s_logger.debug("Username or Password cannot be empty"); return new Pair<Boolean, ActionOnFailedAuthentication>(false, null); } boolean realUser = true; UserAccount user = _userAccountDao.getUserAccount(username, domainId); if (user == null) { - logger.debug("Unable to find user with " + username + " in domain " + domainId); + s_logger.debug("Unable to find user with " + username + " in domain " + domainId); realUser = false; } /* Fake Data */ @@ -65,7 +67,7 @@ public class SHA256SaltedUserAuthenticator extends DefaultUserAuthenticator { if (realUser) { String storedPassword[] = user.getPassword().split(":"); if (storedPassword.length != 2) { - logger.warn("The stored password for " + username + " isn't in the right format for this authenticator"); + s_logger.warn("The stored password for " + username + " isn't in the right format for this authenticator"); realUser = false; } else { realPassword = storedPassword[1];
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java index 9fc0f16..3a2b280 100644 --- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java @@ -27,6 +27,7 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.agent.manager.allocator.HostAllocator; @@ -68,6 +69,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Component @Local(value = {HostAllocator.class}) public class FirstFitAllocator extends AdapterBase implements HostAllocator { + private static final Logger s_logger = Logger.getLogger(FirstFitAllocator.class); @Inject protected HostDao _hostDao = null; @Inject @@ -117,8 +119,8 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { return new ArrayList<Host>(); } - if (logger.isDebugEnabled()) { - logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId); } String hostTagOnOffering = offering.getHostTag(); @@ -139,29 +141,29 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { List<HostVO> hostsMatchingOfferingTag = new ArrayList<HostVO>(); List<HostVO> hostsMatchingTemplateTag = new ArrayList<HostVO>(); if (hasSvcOfferingTag) { - if (logger.isDebugEnabled()) { - logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering); } hostsMatchingOfferingTag = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnOffering); - if (logger.isDebugEnabled()) { - logger.debug("Hosts with tag '" + hostTagOnOffering + "' are:" + hostsMatchingOfferingTag); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Hosts with tag '" + hostTagOnOffering + "' are:" + hostsMatchingOfferingTag); } } if (hasTemplateTag) { - if (logger.isDebugEnabled()) { - logger.debug("Looking for hosts having tag specified on Template:" + hostTagOnTemplate); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Looking for hosts having tag specified on Template:" + hostTagOnTemplate); } hostsMatchingTemplateTag = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnTemplate); - if (logger.isDebugEnabled()) { - logger.debug("Hosts with tag '" + hostTagOnTemplate + "' are:" + hostsMatchingTemplateTag); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Hosts with tag '" + hostTagOnTemplate + "' are:" + hostsMatchingTemplateTag); } } if (hasSvcOfferingTag && hasTemplateTag) { hostsMatchingOfferingTag.retainAll(hostsMatchingTemplateTag); clusterHosts = _hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnTemplate); - if (logger.isDebugEnabled()) { - logger.debug("Found " + hostsMatchingOfferingTag.size() + " Hosts satisfying both tags, host ids are:" + hostsMatchingOfferingTag); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found " + hostsMatchingOfferingTag.size() + " Hosts satisfying both tags, host ids are:" + hostsMatchingOfferingTag); } clusterHosts = hostsMatchingOfferingTag; @@ -216,25 +218,25 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { hostsCopy.retainAll(_resourceMgr.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId)); } else { if (hasSvcOfferingTag) { - if (logger.isDebugEnabled()) { - logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Looking for hosts having tag specified on SvcOffering:" + hostTagOnOffering); } hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnOffering)); - if (logger.isDebugEnabled()) { - logger.debug("Hosts with tag '" + hostTagOnOffering + "' are:" + hostsCopy); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Hosts with tag '" + hostTagOnOffering + "' are:" + hostsCopy); } } if (hasTemplateTag) { - if (logger.isDebugEnabled()) { - logger.debug("Looking for hosts having tag specified on Template:" + hostTagOnTemplate); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Looking for hosts having tag specified on Template:" + hostTagOnTemplate); } hostsCopy.retainAll(_hostDao.listByHostTag(type, clusterId, podId, dcId, hostTagOnTemplate)); - if (logger.isDebugEnabled()) { - logger.debug("Hosts with tag '" + hostTagOnTemplate + "' are:" + hostsCopy); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Hosts with tag '" + hostTagOnTemplate + "' are:" + hostsCopy); } } } @@ -258,20 +260,20 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { hosts = reorderHostsByCapacity(plan, hosts); } - if (logger.isDebugEnabled()) { - logger.debug("FirstFitAllocator has " + hosts.size() + " hosts to check for allocation: " + hosts); + if (s_logger.isDebugEnabled()) { + s_logger.debug("FirstFitAllocator has " + hosts.size() + " hosts to check for allocation: " + hosts); } // We will try to reorder the host lists such that we give priority to hosts that have // the minimums to support a VM's requirements hosts = prioritizeHosts(template, offering, hosts); - if (logger.isDebugEnabled()) { - logger.debug("Found " + hosts.size() + " hosts for allocation after prioritization: " + hosts); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found " + hosts.size() + " hosts for allocation after prioritization: " + hosts); } - if (logger.isDebugEnabled()) { - logger.debug("Looking for speed=" + (offering.getCpu() * offering.getSpeed()) + "Mhz, Ram=" + offering.getRamSize()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Looking for speed=" + (offering.getCpu() * offering.getSpeed()) + "Mhz, Ram=" + offering.getRamSize()); } long serviceOfferingId = offering.getId(); @@ -283,16 +285,16 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { break; } if (avoid.shouldAvoid(host)) { - if (logger.isDebugEnabled()) { - logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + " is in avoid set, skipping this and trying other available hosts"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + " is in avoid set, skipping this and trying other available hosts"); } continue; } //find number of guest VMs occupying capacity on this host. if (_capacityMgr.checkIfHostReachMaxGuestLimit(host)) { - if (logger.isDebugEnabled()) { - logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host name: " + host.getName() + ", hostId: " + host.getId() + " already has max Running VMs(count includes system VMs), skipping this and trying other available hosts"); } continue; @@ -302,7 +304,7 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { if ((offeringDetails = _serviceOfferingDetailsDao.findDetail(serviceOfferingId, GPU.Keys.vgpuType.toString())) != null) { ServiceOfferingDetailsVO groupName = _serviceOfferingDetailsDao.findDetail(serviceOfferingId, GPU.Keys.pciDevice.toString()); if(!_resourceMgr.isGPUDeviceAvailable(host.getId(), groupName.getValue(), offeringDetails.getValue())){ - logger.info("Host name: " + host.getName() + ", hostId: "+ host.getId() +" does not have required GPU devices available"); + s_logger.info("Host name: " + host.getName() + ", hostId: "+ host.getId() +" does not have required GPU devices available"); continue; } } @@ -320,20 +322,20 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { considerReservedCapacity); if (hostHasCpuCapability && hostHasCapacity) { - if (logger.isDebugEnabled()) { - logger.debug("Found a suitable host, adding to list: " + host.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Found a suitable host, adding to list: " + host.getId()); } suitableHosts.add(host); } else { - if (logger.isDebugEnabled()) { - logger.debug("Not using host " + host.getId() + "; host has cpu capability? " + hostHasCpuCapability + ", host has capacity?" + hostHasCapacity); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Not using host " + host.getId() + "; host has cpu capability? " + hostHasCpuCapability + ", host has capacity?" + hostHasCapacity); } avoid.addHost(host.getId()); } } - if (logger.isDebugEnabled()) { - logger.debug("Host Allocator returning " + suitableHosts.size() + " suitable hosts"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Host Allocator returning " + suitableHosts.size() + " suitable hosts"); } return suitableHosts; @@ -349,8 +351,8 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { capacityType = CapacityVO.CAPACITY_TYPE_MEMORY; } List<Long> hostIdsByFreeCapacity = _capacityDao.orderHostsByFreeCapacity(clusterId, capacityType); - if (logger.isDebugEnabled()) { - logger.debug("List of hosts in descending order of free capacity in the cluster: "+ hostIdsByFreeCapacity); + if (s_logger.isDebugEnabled()) { + s_logger.debug("List of hosts in descending order of free capacity in the cluster: "+ hostIdsByFreeCapacity); } //now filter the given list of Hosts by this ordered list @@ -379,8 +381,8 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { Long clusterId = plan.getClusterId(); List<Long> hostIdsByVmCount = _vmInstanceDao.listHostIdsByVmCount(dcId, podId, clusterId, account.getAccountId()); - if (logger.isDebugEnabled()) { - logger.debug("List of hosts in ascending order of number of VMs: " + hostIdsByVmCount); + if (s_logger.isDebugEnabled()) { + s_logger.debug("List of hosts in ascending order of number of VMs: " + hostIdsByVmCount); } //now filter the given list of Hosts by this ordered list @@ -432,9 +434,9 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator { hostsToCheck.addAll(hosts); } - if (logger.isDebugEnabled()) { + if (s_logger.isDebugEnabled()) { if (noHvmHosts.size() > 0) { - logger.debug("Not considering hosts: " + noHvmHosts + " to deploy template: " + template + " as they are not HVM enabled"); + s_logger.debug("Not considering hosts: " + noHvmHosts + " to deploy template: " + template + " as they are not HVM enabled"); } } // If a host is tagged with the same guest OS category as the template, move it to a high priority list http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java index c2d1abd..161c965 100644 --- a/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/RecreateHostAllocator.java @@ -27,6 +27,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; @@ -57,6 +58,7 @@ import com.cloud.vm.VirtualMachineProfile; @Component @Local(value = HostAllocator.class) public class RecreateHostAllocator extends FirstFitRoutingAllocator { + private final static Logger s_logger = Logger.getLogger(RecreateHostAllocator.class); @Inject HostPodDao _podDao; @@ -81,10 +83,10 @@ public class RecreateHostAllocator extends FirstFitRoutingAllocator { return hosts; } - logger.debug("First fit was unable to find a host"); + s_logger.debug("First fit was unable to find a host"); VirtualMachine.Type vmType = vm.getType(); if (vmType == VirtualMachine.Type.User) { - logger.debug("vm is not a system vm so let's just return empty list"); + s_logger.debug("vm is not a system vm so let's just return empty list"); return new ArrayList<Host>(); } @@ -93,11 +95,11 @@ public class RecreateHostAllocator extends FirstFitRoutingAllocator { //getting rid of direct.attached.untagged.vlan.enabled config param: Bug 7204 //basic network type for zone maps to direct untagged case if (dc.getNetworkType().equals(NetworkType.Basic)) { - logger.debug("Direct Networking mode so we can only allow the host to be allocated in the same pod due to public ip address cannot change"); + s_logger.debug("Direct Networking mode so we can only allow the host to be allocated in the same pod due to public ip address cannot change"); List<VolumeVO> vols = _volsDao.findByInstance(vm.getId()); VolumeVO vol = vols.get(0); long podId = vol.getPodId(); - logger.debug("Pod id determined from volume " + vol.getId() + " is " + podId); + s_logger.debug("Pod id determined from volume " + vol.getId() + " is " + podId); Iterator<PodCluster> it = pcs.iterator(); while (it.hasNext()) { PodCluster pc = it.next(); @@ -118,22 +120,22 @@ public class RecreateHostAllocator extends FirstFitRoutingAllocator { } for (Pair<Long, Long> pcId : avoidPcs) { - logger.debug("Removing " + pcId + " from the list of available pods"); + s_logger.debug("Removing " + pcId + " from the list of available pods"); pcs.remove(new PodCluster(new HostPodVO(pcId.first()), pcId.second() != null ? new ClusterVO(pcId.second()) : null)); } for (PodCluster p : pcs) { if (p.getPod().getAllocationState() != Grouping.AllocationState.Enabled) { - if (logger.isDebugEnabled()) { - logger.debug("Pod name: " + p.getPod().getName() + ", podId: " + p.getPod().getId() + " is in " + p.getPod().getAllocationState().name() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Pod name: " + p.getPod().getName() + ", podId: " + p.getPod().getId() + " is in " + p.getPod().getAllocationState().name() + " state, skipping this and trying other pods"); } continue; } Long clusterId = p.getCluster() == null ? null : p.getCluster().getId(); if (p.getCluster() != null && p.getCluster().getAllocationState() != Grouping.AllocationState.Enabled) { - if (logger.isDebugEnabled()) { - logger.debug("Cluster name: " + p.getCluster().getName() + ", clusterId: " + clusterId + " is in " + p.getCluster().getAllocationState().name() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Cluster name: " + p.getCluster().getName() + ", clusterId: " + clusterId + " is in " + p.getCluster().getAllocationState().name() + " state, skipping this and trying other pod-clusters"); } continue; @@ -146,7 +148,7 @@ public class RecreateHostAllocator extends FirstFitRoutingAllocator { } - logger.debug("Unable to find any available pods at all!"); + s_logger.debug("Unable to find any available pods at all!"); return new ArrayList<Host>(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java index 0f4b470..885032e 100644 --- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java @@ -27,6 +27,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; @@ -59,6 +60,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Local(value = PodAllocator.class) public class UserConcentratedAllocator extends AdapterBase implements PodAllocator { + private final static Logger s_logger = Logger.getLogger(UserConcentratedAllocator.class); @Inject UserVmDao _vmDao; @@ -87,7 +89,7 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat List<HostPodVO> podsInZone = _podDao.listByDataCenterId(zoneId); if (podsInZone.size() == 0) { - logger.debug("No pods found in zone " + zone.getName()); + s_logger.debug("No pods found in zone " + zone.getName()); return null; } @@ -110,8 +112,8 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat dataCenterAndPodHasEnoughCapacity(zoneId, podId, (offering.getRamSize()) * 1024L * 1024L, Capacity.CAPACITY_TYPE_MEMORY, hostCandiates); if (!enoughCapacity) { - if (logger.isDebugEnabled()) { - logger.debug("Not enough RAM available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Not enough RAM available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")"); } continue; } @@ -120,8 +122,8 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat enoughCapacity = dataCenterAndPodHasEnoughCapacity(zoneId, podId, ((long)offering.getCpu() * offering.getSpeed()), Capacity.CAPACITY_TYPE_CPU, hostCandiates); if (!enoughCapacity) { - if (logger.isDebugEnabled()) { - logger.debug("Not enough cpu available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Not enough cpu available in zone/pod to allocate storage for user VM (zone: " + zoneId + ", pod: " + podId + ")"); } continue; } @@ -145,13 +147,13 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat } if (availablePods.size() == 0) { - logger.debug("There are no pods with enough memory/CPU capacity in zone " + zone.getName()); + s_logger.debug("There are no pods with enough memory/CPU capacity in zone " + zone.getName()); return null; } else { // Return a random pod int next = _rand.nextInt(availablePods.size()); HostPodVO selectedPod = availablePods.get(next); - logger.debug("Found pod " + selectedPod.getName() + " in zone " + zone.getName()); + s_logger.debug("Found pod " + selectedPod.getName() + " in zone " + zone.getName()); return new Pair<Pod, Long>(selectedPod, podHostCandidates.get(selectedPod.getId())); } } @@ -163,9 +165,9 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat sc.addAnd("capacityType", SearchCriteria.Op.EQ, capacityType); sc.addAnd("dataCenterId", SearchCriteria.Op.EQ, dataCenterId); sc.addAnd("podId", SearchCriteria.Op.EQ, podId); - logger.trace("Executing search"); + s_logger.trace("Executing search"); capacities = _capacityDao.search(sc, null); - logger.trace("Done with a search"); + s_logger.trace("Done with a search"); boolean enoughCapacity = false; if (capacities != null) { @@ -194,8 +196,8 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat private boolean skipCalculation(VMInstanceVO vm) { if (vm.getState() == State.Expunging) { - if (logger.isDebugEnabled()) { - logger.debug("Skip counting capacity for Expunging VM : " + vm.getInstanceName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Skip counting capacity for Expunging VM : " + vm.getInstanceName()); } return true; } @@ -215,8 +217,8 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat long millisecondsSinceLastUpdate = DateUtil.currentGMTTime().getTime() - vm.getUpdateTime().getTime(); if (millisecondsSinceLastUpdate > secondsToSkipVMs * 1000L) { - if (logger.isDebugEnabled()) { - logger.debug("Skip counting " + vm.getState().toString() + " vm " + vm.getInstanceName() + " in capacity allocation as it has been " + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Skip counting " + vm.getState().toString() + " vm " + vm.getInstanceName() + " in capacity allocation as it has been " + vm.getState().toString().toLowerCase() + " for " + millisecondsSinceLastUpdate / 60000 + " minutes"); } return true; @@ -260,15 +262,15 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat if (capacityType == Capacity.CAPACITY_TYPE_MEMORY) { usedCapacity += so.getRamSize() * 1024L * 1024L; - if (logger.isDebugEnabled()) { - logger.debug("Counting memory capacity used by vm: " + vm.getId() + ", size: " + so.getRamSize() + "MB, host: " + hostId + ", currently counted: " + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Counting memory capacity used by vm: " + vm.getId() + ", size: " + so.getRamSize() + "MB, host: " + hostId + ", currently counted: " + usedCapacity + " Bytes"); } } else if (capacityType == Capacity.CAPACITY_TYPE_CPU) { usedCapacity += so.getCpu() * so.getSpeed(); - if (logger.isDebugEnabled()) { - logger.debug("Counting cpu capacity used by vm: " + vm.getId() + ", cpu: " + so.getCpu() + ", speed: " + so.getSpeed() + ", currently counted: " + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Counting cpu capacity used by vm: " + vm.getId() + ", cpu: " + so.getCpu() + ", speed: " + so.getSpeed() + ", currently counted: " + usedCapacity + " Bytes"); } } @@ -285,9 +287,9 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat * List<VMTemplateStoragePoolVO> tpvoList = _templatePoolDao.listByTemplateStatus(templateId, dcId, podId, * Status.DOWNLOADED); * - * if (thvoList != null && thvoList.size() > 0) { if (logger.isDebugEnabled()) { logger.debug("Found " + + * if (thvoList != null && thvoList.size() > 0) { if (s_logger.isDebugEnabled()) { s_logger.debug("Found " + * thvoList.size() + " storage hosts in pod " + podId + " with template " + templateId); } return true; } else if - * (tpvoList != null && tpvoList.size() > 0) { if (logger.isDebugEnabled()) { logger.debug("Found " + + * (tpvoList != null && tpvoList.size() > 0) { if (s_logger.isDebugEnabled()) { s_logger.debug("Found " + * tpvoList.size() + " storage pools in pod " + podId + " with template " + templateId); } return true; }else { return * false; } */ http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/agent/manager/authn/impl/BasicAgentAuthManager.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/agent/manager/authn/impl/BasicAgentAuthManager.java b/server/src/com/cloud/agent/manager/authn/impl/BasicAgentAuthManager.java index 24d3dfd..1aa8f91 100644 --- a/server/src/com/cloud/agent/manager/authn/impl/BasicAgentAuthManager.java +++ b/server/src/com/cloud/agent/manager/authn/impl/BasicAgentAuthManager.java @@ -22,6 +22,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; @@ -38,6 +39,7 @@ import com.cloud.utils.component.AdapterBase; @Component @Local(value = {AgentAuthorizer.class, StartupCommandProcessor.class}) public class BasicAgentAuthManager extends AdapterBase implements AgentAuthorizer, StartupCommandProcessor { + private static final Logger s_logger = Logger.getLogger(BasicAgentAuthManager.class); @Inject HostDao _hostDao = null; @Inject @@ -52,7 +54,7 @@ public class BasicAgentAuthManager extends AdapterBase implements AgentAuthorize } catch (AgentAuthnException e) { throw new ConnectionException(true, "Failed to authenticate/authorize", e); } - logger.debug("Authorized agent with guid " + cmd[0].getGuid()); + s_logger.debug("Authorized agent with guid " + cmd[0].getGuid()); return false;//so that the next host creator can process it } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/alert/AlertManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index 41a9dff..8653069 100644 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -40,6 +40,7 @@ import javax.mail.URLName; import javax.mail.internet.InternetAddress; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import com.sun.mail.smtp.SMTPMessage; import com.sun.mail.smtp.SMTPSSLTransport; @@ -88,6 +89,8 @@ import com.cloud.utils.db.SearchCriteria; @Local(value = {AlertManager.class}) public class AlertManagerImpl extends ManagerBase implements AlertManager, Configurable { + private static final Logger s_logger = Logger.getLogger(AlertManagerImpl.class.getName()); + private static final Logger s_alertsLogger = Logger.getLogger("org.apache.cloudstack.alerts"); private static final long INITIAL_CAPACITY_CHECK_DELAY = 30L * 1000L; // thirty seconds expressed in milliseconds @@ -232,7 +235,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi _emailAlert.clearAlert(alertType.getType(), dataCenterId, podId); } } catch (Exception ex) { - logger.error("Problem clearing email alert", ex); + s_logger.error("Problem clearing email alert", ex); } } @@ -248,11 +251,11 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi if (_emailAlert != null) { _emailAlert.sendAlert(alertType, dataCenterId, podId, null, subject, body); } else { - logger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " + podId + + s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " + podId + " // message:: " + subject + " // body:: " + body); } } catch (Exception ex) { - logger.error("Problem sending email alert", ex); + s_logger.error("Problem sending email alert", ex); } } @@ -267,9 +270,9 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi try { - if (logger.isDebugEnabled()) { - logger.debug("recalculating system capacity"); - logger.debug("Executing cpu/ram capacity update"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("recalculating system capacity"); + s_logger.debug("Executing cpu/ram capacity update"); } // Calculate CPU and RAM capacities @@ -280,9 +283,9 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi _capacityMgr.updateCapacityForHost(host); } } - if (logger.isDebugEnabled()) { - logger.debug("Done executing cpu/ram capacity update"); - logger.debug("Executing storage capacity update"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Done executing cpu/ram capacity update"); + s_logger.debug("Executing storage capacity update"); } // Calculate storage pool capacity List<StoragePoolVO> storagePools = _storagePoolDao.listAll(); @@ -295,9 +298,9 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi } } - if (logger.isDebugEnabled()) { - logger.debug("Done executing storage capacity update"); - logger.debug("Executing capacity updates for public ip and Vlans"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Done executing storage capacity update"); + s_logger.debug("Executing capacity updates for public ip and Vlans"); } List<DataCenterVO> datacenters = _dcDao.listAll(); @@ -324,9 +327,9 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi } } - if (logger.isDebugEnabled()) { - logger.debug("Done capacity updates for public ip and Vlans"); - logger.debug("Executing capacity updates for private ip"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Done capacity updates for public ip and Vlans"); + s_logger.debug("Executing capacity updates for private ip"); } // Calculate new Private IP capacity @@ -338,13 +341,13 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi createOrUpdateIpCapacity(dcId, podId, Capacity.CAPACITY_TYPE_PRIVATE_IP, _configMgr.findPodAllocationState(pod)); } - if (logger.isDebugEnabled()) { - logger.debug("Done executing capacity updates for private ip"); - logger.debug("Done recalculating system capacity"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Done executing capacity updates for private ip"); + s_logger.debug("Done recalculating system capacity"); } } catch (Throwable t) { - logger.error("Caught exception in recalculating capacity", t); + s_logger.error("Caught exception in recalculating capacity", t); } } @@ -417,11 +420,11 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi @Override protected void runInContext() { try { - logger.debug("Running Capacity Checker ... "); + s_logger.debug("Running Capacity Checker ... "); checkForAlerts(); - logger.debug("Done running Capacity Checker ... "); + s_logger.debug("Done running Capacity Checker ... "); } catch (Throwable t) { - logger.error("Exception in CapacityChecker", t); + s_logger.error("Exception in CapacityChecker", t); } } } @@ -629,13 +632,13 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi } try { - if (logger.isDebugEnabled()) { - logger.debug(msgSubject); - logger.debug(msgContent); + if (s_logger.isDebugEnabled()) { + s_logger.debug(msgSubject); + s_logger.debug(msgContent); } _emailAlert.sendAlert(alertType, dc.getId(), podId, clusterId, msgSubject, msgContent); } catch (Exception ex) { - logger.error("Exception in CapacityChecker", ex); + s_logger.error("Exception in CapacityChecker", ex); } } @@ -691,7 +694,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi try { _recipientList[i] = new InternetAddress(recipientList[i], recipientList[i]); } catch (Exception ex) { - logger.error("Exception creating address for: " + recipientList[i], ex); + s_logger.error("Exception creating address for: " + recipientList[i], ex); } } } @@ -746,7 +749,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi // TODO: make sure this handles SSL transport (useAuth is true) and regular public void sendAlert(AlertType alertType, long dataCenterId, Long podId, Long clusterId, String subject, String content) throws MessagingException, UnsupportedEncodingException { - logger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " + + s_alertsLogger.warn(" alertType:: " + alertType + " // dataCenterId:: " + dataCenterId + " // podId:: " + podId + " // clusterId:: " + clusterId + " // message:: " + subject); AlertVO alert = null; if ((alertType != AlertManager.AlertType.ALERT_TYPE_HOST) && @@ -773,8 +776,8 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi newAlert.setName(alertType.getName()); _alertDao.persist(newAlert); } else { - if (logger.isDebugEnabled()) { - logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Have already sent: " + alert.getSentCount() + " emails for alert type '" + alertType + "' -- skipping send email"); } return; } @@ -810,9 +813,9 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi smtpTrans.sendMessage(msg, msg.getAllRecipients()); smtpTrans.close(); } catch (SendFailedException e) { - logger.error(" Failed to send email alert " + e); + s_logger.error(" Failed to send email alert " + e); } catch (MessagingException e) { - logger.error(" Failed to send email alert " + e); + s_logger.error(" Failed to send email alert " + e); } } }); @@ -856,7 +859,7 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi sendAlert(alertType, dataCenterId, podId, msg, msg); return true; } catch (Exception ex) { - logger.warn("Failed to generate an alert of type=" + alertType + "; msg=" + msg); + s_logger.warn("Failed to generate an alert of type=" + alertType + "; msg=" + msg); return false; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/alert/ClusterAlertAdapter.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/alert/ClusterAlertAdapter.java b/server/src/com/cloud/alert/ClusterAlertAdapter.java index db1e5ce..ccb1074 100644 --- a/server/src/com/cloud/alert/ClusterAlertAdapter.java +++ b/server/src/com/cloud/alert/ClusterAlertAdapter.java @@ -22,6 +22,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.cluster.ClusterManager; @@ -37,6 +38,7 @@ import com.cloud.utils.events.SubscriptionMgr; @Local(value = AlertAdapter.class) public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter { + private static final Logger s_logger = Logger.getLogger(ClusterAlertAdapter.class); @Inject private AlertManager _alertMgr; @@ -44,8 +46,8 @@ public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter { private ManagementServerHostDao _mshostDao; public void onClusterAlert(Object sender, EventArgs args) { - if (logger.isDebugEnabled()) { - logger.debug("Receive cluster alert, EventArgs: " + args.getClass().getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Receive cluster alert, EventArgs: " + args.getClass().getName()); } if (args instanceof ClusterNodeJoinEventArgs) { @@ -53,21 +55,21 @@ public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter { } else if (args instanceof ClusterNodeLeftEventArgs) { onClusterNodeLeft(sender, (ClusterNodeLeftEventArgs)args); } else { - logger.error("Unrecognized cluster alert event"); + s_logger.error("Unrecognized cluster alert event"); } } private void onClusterNodeJoined(Object sender, ClusterNodeJoinEventArgs args) { - if (logger.isDebugEnabled()) { + if (s_logger.isDebugEnabled()) { for (ManagementServerHostVO mshost : args.getJoinedNodes()) { - logger.debug("Handle cluster node join alert, joined node: " + mshost.getServiceIP() + ", msidL: " + mshost.getMsid()); + s_logger.debug("Handle cluster node join alert, joined node: " + mshost.getServiceIP() + ", msidL: " + mshost.getMsid()); } } for (ManagementServerHostVO mshost : args.getJoinedNodes()) { if (mshost.getId() == args.getSelf().longValue()) { - if (logger.isDebugEnabled()) { - logger.debug("Management server node " + mshost.getServiceIP() + " is up, send alert"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Management server node " + mshost.getServiceIP() + " is up, send alert"); } _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management server node " + mshost.getServiceIP() + " is up", ""); @@ -78,23 +80,23 @@ public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter { private void onClusterNodeLeft(Object sender, ClusterNodeLeftEventArgs args) { - if (logger.isDebugEnabled()) { + if (s_logger.isDebugEnabled()) { for (ManagementServerHostVO mshost : args.getLeftNodes()) { - logger.debug("Handle cluster node left alert, leaving node: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid()); + s_logger.debug("Handle cluster node left alert, leaving node: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid()); } } for (ManagementServerHostVO mshost : args.getLeftNodes()) { if (mshost.getId() != args.getSelf().longValue()) { if (_mshostDao.increaseAlertCount(mshost.getId()) > 0) { - if (logger.isDebugEnabled()) { - logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, send alert"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, send alert"); } _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_MANAGMENT_NODE, 0, new Long(0), "Management server node " + mshost.getServiceIP() + " is down", ""); } else { - if (logger.isDebugEnabled()) { - logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, but alert has already been set"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Detected management server node " + mshost.getServiceIP() + " is down, but alert has already been set"); } } } @@ -104,8 +106,8 @@ public class ClusterAlertAdapter extends AdapterBase implements AlertAdapter { @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { - if (logger.isInfoEnabled()) { - logger.info("Start configuring cluster alert manager : " + name); + if (s_logger.isInfoEnabled()) { + s_logger.info("Start configuring cluster alert manager : " + name); } try { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java b/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java index 7962906..ba1dca4 100644 --- a/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java +++ b/server/src/com/cloud/alert/ConsoleProxyAlertAdapter.java @@ -22,6 +22,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.consoleproxy.ConsoleProxyAlertEventArgs; @@ -38,6 +39,7 @@ import com.cloud.vm.dao.ConsoleProxyDao; @Local(value = AlertAdapter.class) public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapter { + private static final Logger s_logger = Logger.getLogger(ConsoleProxyAlertAdapter.class); @Inject private AlertManager _alertMgr; @@ -47,8 +49,8 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte private ConsoleProxyDao _consoleProxyDao; public void onProxyAlert(Object sender, ConsoleProxyAlertEventArgs args) { - if (logger.isDebugEnabled()) - logger.debug("received console proxy alert"); + if (s_logger.isDebugEnabled()) + s_logger.debug("received console proxy alert"); DataCenterVO dc = _dcDao.findById(args.getZoneId()); ConsoleProxyVO proxy = args.getProxy(); @@ -62,14 +64,14 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte switch (args.getType()) { case ConsoleProxyAlertEventArgs.PROXY_CREATED: - if (logger.isDebugEnabled()) - logger.debug("New console proxy created, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + + if (s_logger.isDebugEnabled()) + s_logger.debug("New console proxy created, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + proxy.getPrivateIpAddress()); break; case ConsoleProxyAlertEventArgs.PROXY_UP: - if (logger.isDebugEnabled()) - logger.debug("Console proxy is up, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + + if (s_logger.isDebugEnabled()) + s_logger.debug("Console proxy is up, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + proxy.getPrivateIpAddress()); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), @@ -79,8 +81,8 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte break; case ConsoleProxyAlertEventArgs.PROXY_DOWN: - if (logger.isDebugEnabled()) - logger.debug("Console proxy is down, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + + if (s_logger.isDebugEnabled()) + s_logger.debug("Console proxy is down, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress())); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), @@ -90,8 +92,8 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte break; case ConsoleProxyAlertEventArgs.PROXY_REBOOTED: - if (logger.isDebugEnabled()) - logger.debug("Console proxy is rebooted, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + + if (s_logger.isDebugEnabled()) + s_logger.debug("Console proxy is rebooted, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress())); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), @@ -101,16 +103,16 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte break; case ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE: - if (logger.isDebugEnabled()) - logger.debug("Console proxy creation failure, zone: " + dc.getName()); + if (s_logger.isDebugEnabled()) + s_logger.debug("Console proxy creation failure, zone: " + dc.getName()); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), null, "Console proxy creation failure. zone: " + dc.getName() + ", error details: " + args.getMessage(), "Console proxy creation failure (zone " + dc.getName() + ")"); break; case ConsoleProxyAlertEventArgs.PROXY_START_FAILURE: - if (logger.isDebugEnabled()) - logger.debug("Console proxy startup failure, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Console proxy startup failure, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress())); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), @@ -120,8 +122,8 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte break; case ConsoleProxyAlertEventArgs.PROXY_FIREWALL_ALERT: - if (logger.isDebugEnabled()) - logger.debug("Console proxy firewall alert, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Console proxy firewall alert, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress())); _alertMgr.sendAlert( @@ -134,8 +136,8 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte break; case ConsoleProxyAlertEventArgs.PROXY_STORAGE_ALERT: - if (logger.isDebugEnabled()) - logger.debug("Console proxy storage alert, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Console proxy storage alert, zone: " + dc.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + proxy.getPrivateIpAddress() + ", message: " + args.getMessage()); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC, args.getZoneId(), proxy.getPodIdToDeployIn(), @@ -147,8 +149,8 @@ public class ConsoleProxyAlertAdapter extends AdapterBase implements AlertAdapte @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { - if (logger.isInfoEnabled()) - logger.info("Start configuring console proxy alert manager : " + name); + if (s_logger.isInfoEnabled()) + s_logger.info("Start configuring console proxy alert manager : " + name); try { SubscriptionMgr.getInstance().subscribe(ConsoleProxyManager.ALERT_SUBJECT, this, "onProxyAlert"); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java b/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java index eaf918f..392015b 100644 --- a/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java +++ b/server/src/com/cloud/alert/SecondaryStorageVmAlertAdapter.java @@ -22,6 +22,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.dc.DataCenterVO; @@ -38,6 +39,7 @@ import com.cloud.vm.dao.SecondaryStorageVmDao; @Local(value = AlertAdapter.class) public class SecondaryStorageVmAlertAdapter extends AdapterBase implements AlertAdapter { + private static final Logger s_logger = Logger.getLogger(SecondaryStorageVmAlertAdapter.class); @Inject private AlertManager _alertMgr; @@ -47,8 +49,8 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert private SecondaryStorageVmDao _ssvmDao; public void onSSVMAlert(Object sender, SecStorageVmAlertEventArgs args) { - if (logger.isDebugEnabled()) - logger.debug("received secondary storage vm alert"); + if (s_logger.isDebugEnabled()) + s_logger.debug("received secondary storage vm alert"); DataCenterVO dc = _dcDao.findById(args.getZoneId()); SecondaryStorageVmVO secStorageVm = args.getSecStorageVm(); @@ -61,14 +63,14 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert switch (args.getType()) { case SecStorageVmAlertEventArgs.SSVM_CREATED: - if (logger.isDebugEnabled()) - logger.debug("New secondary storage vm created, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("New secondary storage vm created, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress()); break; case SecStorageVmAlertEventArgs.SSVM_UP: - if (logger.isDebugEnabled()) - logger.debug("Secondary Storage Vm is up, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Secondary Storage Vm is up, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress()); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), "Secondary Storage Vm up in zone: " + @@ -77,8 +79,8 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert break; case SecStorageVmAlertEventArgs.SSVM_DOWN: - if (logger.isDebugEnabled()) - logger.debug("Secondary Storage Vm is down, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Secondary Storage Vm is down, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())); _alertMgr.sendAlert( @@ -91,8 +93,8 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert break; case SecStorageVmAlertEventArgs.SSVM_REBOOTED: - if (logger.isDebugEnabled()) - logger.debug("Secondary Storage Vm is rebooted, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Secondary Storage Vm is rebooted, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())); _alertMgr.sendAlert( @@ -105,8 +107,8 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert break; case SecStorageVmAlertEventArgs.SSVM_CREATE_FAILURE: - if (logger.isDebugEnabled()) - logger.debug("Secondary Storage Vm creation failure, zone: " + dc.getName()); + if (s_logger.isDebugEnabled()) + s_logger.debug("Secondary Storage Vm creation failure, zone: " + dc.getName()); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), null, "Secondary Storage Vm creation failure. zone: " + dc.getName() + ", error details: " + args.getMessage(), @@ -114,8 +116,8 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert break; case SecStorageVmAlertEventArgs.SSVM_START_FAILURE: - if (logger.isDebugEnabled()) - logger.debug("Secondary Storage Vm startup failure, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Secondary Storage Vm startup failure, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), @@ -126,8 +128,8 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert break; case SecStorageVmAlertEventArgs.SSVM_FIREWALL_ALERT: - if (logger.isDebugEnabled()) - logger.debug("Secondary Storage Vm firewall alert, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Secondary Storage Vm firewall alert, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_SSVM, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), @@ -137,8 +139,8 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert break; case SecStorageVmAlertEventArgs.SSVM_STORAGE_ALERT: - if (logger.isDebugEnabled()) - logger.debug("Secondary Storage Vm storage alert, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + + if (s_logger.isDebugEnabled()) + s_logger.debug("Secondary Storage Vm storage alert, zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " + secStorageVm.getPrivateIpAddress() + ", message: " + args.getMessage()); _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC, args.getZoneId(), secStorageVm.getPodIdToDeployIn(), @@ -151,8 +153,8 @@ public class SecondaryStorageVmAlertAdapter extends AdapterBase implements Alert @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { - if (logger.isInfoEnabled()) - logger.info("Start configuring secondary storage vm alert manager : " + name); + if (s_logger.isInfoEnabled()) + s_logger.info("Start configuring secondary storage vm alert manager : " + name); try { SubscriptionMgr.getInstance().subscribe(SecondaryStorageVmManager.ALERT_SUBJECT, this, "onSSVMAlert"); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/api/ApiAsyncJobDispatcher.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/api/ApiAsyncJobDispatcher.java b/server/src/com/cloud/api/ApiAsyncJobDispatcher.java index c925e1a..0b7d681 100644 --- a/server/src/com/cloud/api/ApiAsyncJobDispatcher.java +++ b/server/src/com/cloud/api/ApiAsyncJobDispatcher.java @@ -21,6 +21,7 @@ import java.util.Map; import javax.inject.Inject; +import org.apache.log4j.Logger; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; @@ -44,6 +45,7 @@ import com.cloud.utils.component.ComponentContext; import com.cloud.utils.db.EntityManager; public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispatcher { + private static final Logger s_logger = Logger.getLogger(ApiAsyncJobDispatcher.class); @Inject private ApiDispatcher _dispatcher; @@ -116,7 +118,7 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat String errorMsg = null; int errorCode = ApiErrorCode.INTERNAL_ERROR.getHttpCode(); if (!(e instanceof ServerApiException)) { - logger.error("Unexpected exception while executing " + job.getCmd(), e); + s_logger.error("Unexpected exception while executing " + job.getCmd(), e); errorMsg = e.getMessage(); } else { ServerApiException sApiEx = (ServerApiException)e;
