http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java ---------------------------------------------------------------------- diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java index b2216cb..b1cac3e 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java @@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.framework.jobs.AsyncJob; import org.apache.cloudstack.framework.jobs.AsyncJobManager; @@ -36,6 +37,7 @@ import org.apache.cloudstack.managed.context.ManagedContextTimerTask; import com.cloud.utils.component.ManagerBase; public class AsyncJobMonitor extends ManagerBase { + public static final Logger s_logger = Logger.getLogger(AsyncJobMonitor.class); @Inject private MessageBus _messageBus; @@ -84,7 +86,7 @@ public class AsyncJobMonitor extends ManagerBase { synchronized (this) { for (Map.Entry<Long, ActiveTaskRecord> entry : _activeTasks.entrySet()) { if (entry.getValue().millisSinceLastJobHeartbeat() > _inactivityWarningThresholdMs) { - logger.warn("Task (job-" + entry.getValue().getJobId() + ") has been pending for " + s_logger.warn("Task (job-" + entry.getValue().getJobId() + ") has been pending for " + entry.getValue().millisSinceLastJobHeartbeat() / 1000 + " seconds"); } } @@ -108,7 +110,7 @@ public class AsyncJobMonitor extends ManagerBase { public void registerActiveTask(long runNumber, long jobId) { synchronized (this) { - logger.info("Add job-" + jobId + " into job monitoring"); + s_logger.info("Add job-" + jobId + " into job monitoring"); assert (_activeTasks.get(runNumber) == null); @@ -128,7 +130,7 @@ public class AsyncJobMonitor extends ManagerBase { ActiveTaskRecord record = _activeTasks.get(runNumber); assert (record != null); if (record != null) { - logger.info("Remove job-" + record.getJobId() + " from job monitoring"); + s_logger.info("Remove job-" + record.getJobId() + " from job monitoring"); if (record.isPoolThread()) _activePoolThreads.decrementAndGet(); @@ -146,7 +148,7 @@ public class AsyncJobMonitor extends ManagerBase { while (it.hasNext()) { Map.Entry<Long, ActiveTaskRecord> entry = it.next(); if (entry.getValue().getJobId() == jobId) { - logger.info("Remove Job-" + entry.getValue().getJobId() + " from job monitoring due to job cancelling"); + s_logger.info("Remove Job-" + entry.getValue().getJobId() + " from job monitoring due to job cancelling"); if (entry.getValue().isPoolThread()) _activePoolThreads.decrementAndGet();
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java ---------------------------------------------------------------------- diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java index 3397daa..2f97991 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/SyncQueueManagerImpl.java @@ -22,6 +22,7 @@ import java.util.List; import javax.inject.Inject; +import org.apache.log4j.Logger; import org.apache.cloudstack.framework.jobs.dao.SyncQueueDao; import org.apache.cloudstack.framework.jobs.dao.SyncQueueItemDao; @@ -35,6 +36,7 @@ import com.cloud.utils.db.TransactionStatus; import com.cloud.utils.exception.CloudRuntimeException; public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManager { + public static final Logger s_logger = Logger.getLogger(SyncQueueManagerImpl.class.getName()); @Inject private SyncQueueDao _syncQueueDao; @@ -68,7 +70,7 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage } }); } catch (Exception e) { - logger.error("Unexpected exception: ", e); + s_logger.error("Unexpected exception: ", e); } return null; } @@ -82,7 +84,7 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage public SyncQueueItemVO doInTransaction(TransactionStatus status) { SyncQueueVO queueVO = _syncQueueDao.findById(queueId); if(queueVO == null) { - logger.error("Sync queue(id: " + queueId + ") does not exist"); + s_logger.error("Sync queue(id: " + queueId + ") does not exist"); return null; } @@ -107,19 +109,19 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage return itemVO; } else { - if (logger.isDebugEnabled()) - logger.debug("Sync queue (" + queueId + ") is currently empty"); + if (s_logger.isDebugEnabled()) + s_logger.debug("Sync queue (" + queueId + ") is currently empty"); } } else { - if (logger.isDebugEnabled()) - logger.debug("There is a pending process in sync queue(id: " + queueId + ")"); + if (s_logger.isDebugEnabled()) + s_logger.debug("There is a pending process in sync queue(id: " + queueId + ")"); } return null; } }); } catch (Exception e) { - logger.error("Unexpected exception: ", e); + s_logger.error("Unexpected exception: ", e); } return null; @@ -167,7 +169,7 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage return resultList; } catch (Exception e) { - logger.error("Unexpected exception: ", e); + s_logger.error("Unexpected exception: ", e); } return null; @@ -198,14 +200,14 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage } }); } catch (Exception e) { - logger.error("Unexpected exception: ", e); + s_logger.error("Unexpected exception: ", e); } } @Override @DB public void returnItem(final long queueItemId) { - logger.info("Returning queue item " + queueItemId + " back to queue for second try in case of DB deadlock"); + s_logger.info("Returning queue item " + queueItemId + " back to queue for second try in case of DB deadlock"); try { Transaction.execute(new TransactionCallbackNoReturn() { @Override @@ -226,7 +228,7 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage } }); } catch (Exception e) { - logger.error("Unexpected exception: ", e); + s_logger.error("Unexpected exception: ", e); } } @@ -245,8 +247,8 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage if (nActiveItems < queueVO.getQueueSizeLimit()) return true; - if (logger.isDebugEnabled()) - logger.debug("Queue (queue id, sync type, sync id) - (" + queueVO.getId() + if (s_logger.isDebugEnabled()) + s_logger.debug("Queue (queue id, sync type, sync id) - (" + queueVO.getId() + "," + queueVO.getSyncObjType() + ", " + queueVO.getSyncObjId() + ") is reaching concurrency limit " + queueVO.getQueueSizeLimit()); return false; @@ -264,8 +266,8 @@ public class SyncQueueManagerImpl extends ManagerBase implements SyncQueueManage public void cleanupActiveQueueItems(Long msid, boolean exclusive) { List<SyncQueueItemVO> l = getActiveQueueItems(msid, false); for (SyncQueueItemVO item : l) { - if (logger.isInfoEnabled()) { - logger.info("Discard left-over queue item: " + item.toString()); + if (s_logger.isInfoEnabled()) { + s_logger.info("Discard left-over queue item: " + item.toString()); } purgeItem(item.getId()); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/framework/jobs/test/org/apache/cloudstack/framework/jobs/AsyncJobTestDispatcher.java ---------------------------------------------------------------------- diff --git a/framework/jobs/test/org/apache/cloudstack/framework/jobs/AsyncJobTestDispatcher.java b/framework/jobs/test/org/apache/cloudstack/framework/jobs/AsyncJobTestDispatcher.java index 604eae7..eb30a80 100644 --- a/framework/jobs/test/org/apache/cloudstack/framework/jobs/AsyncJobTestDispatcher.java +++ b/framework/jobs/test/org/apache/cloudstack/framework/jobs/AsyncJobTestDispatcher.java @@ -20,12 +20,15 @@ import java.util.Random; import javax.inject.Inject; +import org.apache.log4j.Logger; import org.apache.cloudstack.jobs.JobInfo.Status; import com.cloud.utils.component.AdapterBase; public class AsyncJobTestDispatcher extends AdapterBase implements AsyncJobDispatcher { + private static final Logger s_logger = + Logger.getLogger(AsyncJobTestDispatcher.class); @Inject private AsyncJobManager _asyncJobMgr; @@ -42,14 +45,14 @@ public class AsyncJobTestDispatcher extends AdapterBase implements AsyncJobDispa public void runJob(final AsyncJob job) { _testDashboard.increaseConcurrency(); - logger.info("Execute job " + job.getId() + ", current concurrency " + _testDashboard.getConcurrencyCount()); + s_logger.info("Execute job " + job.getId() + ", current concurrency " + _testDashboard.getConcurrencyCount()); int interval = 3000; try { Thread.sleep(interval); } catch (InterruptedException e) { - logger.debug("[ignored] ."); + s_logger.debug("[ignored] ."); } _asyncJobMgr.completeAsyncJob(job.getId(), Status.SUCCEEDED, 0, null); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/framework/security/src/org/apache/cloudstack/framework/security/keystore/KeystoreManagerImpl.java ---------------------------------------------------------------------- diff --git a/framework/security/src/org/apache/cloudstack/framework/security/keystore/KeystoreManagerImpl.java b/framework/security/src/org/apache/cloudstack/framework/security/keystore/KeystoreManagerImpl.java index ec1ead7..374c080 100644 --- a/framework/security/src/org/apache/cloudstack/framework/security/keystore/KeystoreManagerImpl.java +++ b/framework/security/src/org/apache/cloudstack/framework/security/keystore/KeystoreManagerImpl.java @@ -32,6 +32,7 @@ import javax.ejb.Local; import javax.inject.Inject; import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.utils.Ternary; @@ -42,6 +43,7 @@ import com.cloud.utils.security.CertificateHelper; @Component @Local(value = KeystoreManager.class) public class KeystoreManagerImpl extends ManagerBase implements KeystoreManager { + private static final Logger s_logger = Logger.getLogger(KeystoreManagerImpl.class); @Inject private KeystoreDao _ksDao; @@ -49,7 +51,7 @@ public class KeystoreManagerImpl extends ManagerBase implements KeystoreManager @Override public boolean validateCertificate(String certificate, String key, String domainSuffix) { if (certificate == null || certificate.isEmpty() || key == null || key.isEmpty() || domainSuffix == null || domainSuffix.isEmpty()) { - logger.error("Invalid parameter found in (certificate, key, domainSuffix) tuple for domain: " + domainSuffix); + s_logger.error("Invalid parameter found in (certificate, key, domainSuffix) tuple for domain: " + domainSuffix); return false; } @@ -60,9 +62,9 @@ public class KeystoreManagerImpl extends ManagerBase implements KeystoreManager if (ks != null) return true; - logger.error("Unabled to construct keystore for domain: " + domainSuffix); + s_logger.error("Unabled to construct keystore for domain: " + domainSuffix); } catch (Exception e) { - logger.error("Certificate validation failed due to exception for domain: " + domainSuffix, e); + s_logger.error("Certificate validation failed due to exception for domain: " + domainSuffix, e); } return false; } @@ -108,15 +110,15 @@ public class KeystoreManagerImpl extends ManagerBase implements KeystoreManager try { return CertificateHelper.buildAndSaveKeystore(certs, storePassword); } catch (KeyStoreException e) { - logger.warn("Unable to build keystore for " + name + " due to KeyStoreException"); + s_logger.warn("Unable to build keystore for " + name + " due to KeyStoreException"); } catch (CertificateException e) { - logger.warn("Unable to build keystore for " + name + " due to CertificateException"); + s_logger.warn("Unable to build keystore for " + name + " due to CertificateException"); } catch (NoSuchAlgorithmException e) { - logger.warn("Unable to build keystore for " + name + " due to NoSuchAlgorithmException"); + s_logger.warn("Unable to build keystore for " + name + " due to NoSuchAlgorithmException"); } catch (InvalidKeySpecException e) { - logger.warn("Unable to build keystore for " + name + " due to InvalidKeySpecException"); + s_logger.warn("Unable to build keystore for " + name + " due to InvalidKeySpecException"); } catch (IOException e) { - logger.warn("Unable to build keystore for " + name + " due to IOException"); + s_logger.warn("Unable to build keystore for " + name + " due to IOException"); } return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java ---------------------------------------------------------------------- diff --git a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java index 100431c..79e35f1 100644 --- a/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java +++ b/framework/spring/lifecycle/src/main/java/org/apache/cloudstack/spring/lifecycle/registry/DumpRegistry.java @@ -22,12 +22,17 @@ import java.util.List; import javax.inject.Inject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.cloud.utils.component.ComponentLifecycleBase; import com.cloud.utils.component.Named; import com.cloud.utils.component.Registry; public class DumpRegistry extends ComponentLifecycleBase { + private static final Logger log = LoggerFactory.getLogger(DumpRegistry.class); + List<Registry<?>> registries; public List<Registry<?>> getRegistries() { @@ -50,8 +55,10 @@ public class DumpRegistry extends ComponentLifecycleBase { buffer.append(getName(o)); } - logger.info(String.format("Registry [%s] contains [%s]", registry.getName(), buffer)); + + log.info("Registry [{}] contains [{}]", registry.getName(), buffer); } + return super.start(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java ---------------------------------------------------------------------- diff --git a/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java b/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java index edc51b6..4383b45 100644 --- a/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java +++ b/plugins/acl/static-role-based/src/org/apache/cloudstack/acl/StaticRoleBasedAPIAccessChecker.java @@ -26,6 +26,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.api.APICommand; @@ -42,6 +43,7 @@ import com.cloud.utils.component.PluggableService; @Local(value = APIChecker.class) public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIChecker { + protected static final Logger s_logger = Logger.getLogger(StaticRoleBasedAPIAccessChecker.class); Set<String> commandPropertyFiles = new HashSet<String>(); Set<String> commandsPropertiesOverrides = new HashSet<String>(); @@ -116,7 +118,7 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIC commandsPropertiesRoleBasedApisMap.get(roleType).add(apiName); } } catch (NumberFormatException nfe) { - logger.info("Malformed key=value pair for entry: " + entry.toString()); + s_logger.info("Malformed key=value pair for entry: " + entry.toString()); } } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java ---------------------------------------------------------------------- diff --git a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java index 8eef201..9aad5f4 100644 --- a/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java +++ b/plugins/affinity-group-processors/explicit-dedication/src/org/apache/cloudstack/affinity/ExplicitDedicationProcessor.java @@ -25,6 +25,7 @@ import javax.inject.Inject; import org.apache.cloudstack.affinity.dao.AffinityGroupDao; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; +import org.apache.log4j.Logger; import com.cloud.dc.ClusterVO; import com.cloud.dc.DataCenter; @@ -57,6 +58,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Local(value = AffinityGroupProcessor.class) public class ExplicitDedicationProcessor extends AffinityProcessorBase implements AffinityGroupProcessor { + private static final Logger s_logger = Logger.getLogger(ExplicitDedicationProcessor.class); @Inject protected UserVmDao _vmDao; @Inject @@ -96,8 +98,8 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement for (AffinityGroupVMMapVO vmGroupMapping : vmGroupMappings) { if (vmGroupMapping != null) { - if (logger.isDebugEnabled()) { - logger.debug("Processing affinity group " + vmGroupMapping.getAffinityGroupId() + "of type 'ExplicitDedication' for VM Id: " + vm.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Processing affinity group " + vmGroupMapping.getAffinityGroupId() + "of type 'ExplicitDedication' for VM Id: " + vm.getId()); } long affinityGroupId = vmGroupMapping.getAffinityGroupId(); @@ -234,13 +236,13 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement avoid = updateAvoidList(resourceList, avoid, dc); } else { avoid.addDataCenter(dc.getId()); - if (logger.isDebugEnabled()) { - logger.debug("No dedicated resources available for this domain or account under this group"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("No dedicated resources available for this domain or account under this group"); } } - if (logger.isDebugEnabled()) { - logger.debug("ExplicitDedicationProcessor returns Avoid List as: Deploy avoids pods: " + avoid.getPodsToAvoid() + ", clusters: " + + if (s_logger.isDebugEnabled()) { + s_logger.debug("ExplicitDedicationProcessor returns Avoid List as: Deploy avoids pods: " + avoid.getPodsToAvoid() + ", clusters: " + avoid.getClustersToAvoid() + ", hosts: " + avoid.getHostsToAvoid()); } } @@ -407,8 +409,8 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement if (group != null) { List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByAffinityGroupId(group.getId()); if (!dedicatedResources.isEmpty()) { - if (logger.isDebugEnabled()) { - logger.debug("Releasing the dedicated resources under group: " + group); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Releasing the dedicated resources under group: " + group); } Transaction.execute(new TransactionCallbackNoReturn() { @@ -425,8 +427,8 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement } }); } else { - if (logger.isDebugEnabled()) { - logger.debug("No dedicated resources to releease under group: " + group); + if (s_logger.isDebugEnabled()) { + s_logger.debug("No dedicated resources to releease under group: " + group); } } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java ---------------------------------------------------------------------- diff --git a/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java b/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java index 35039fd..0504dc6 100644 --- a/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java +++ b/plugins/affinity-group-processors/host-anti-affinity/src/org/apache/cloudstack/affinity/HostAntiAffinityProcessor.java @@ -23,6 +23,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.affinity.dao.AffinityGroupDao; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; @@ -46,6 +47,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Local(value = AffinityGroupProcessor.class) public class HostAntiAffinityProcessor extends AffinityProcessorBase implements AffinityGroupProcessor { + private static final Logger s_logger = Logger.getLogger(HostAntiAffinityProcessor.class); @Inject protected UserVmDao _vmDao; @Inject @@ -70,8 +72,8 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements if (vmGroupMapping != null) { AffinityGroupVO group = _affinityGroupDao.findById(vmGroupMapping.getAffinityGroupId()); - if (logger.isDebugEnabled()) { - logger.debug("Processing affinity group " + group.getName() + " for VM Id: " + vm.getId()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Processing affinity group " + group.getName() + " for VM Id: " + vm.getId()); } List<Long> groupVMIds = _affinityGroupVMMapDao.listVmIdsByAffinityGroup(group.getId()); @@ -82,15 +84,15 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements if (groupVM != null && !groupVM.isRemoved()) { if (groupVM.getHostId() != null) { avoid.addHost(groupVM.getHostId()); - if (logger.isDebugEnabled()) { - logger.debug("Added host " + groupVM.getHostId() + " to avoid set, since VM " + groupVM.getId() + " is present on the host"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Added host " + groupVM.getHostId() + " to avoid set, since VM " + groupVM.getId() + " is present on the host"); } } else if (VirtualMachine.State.Stopped.equals(groupVM.getState()) && groupVM.getLastHostId() != null) { long secondsSinceLastUpdate = (DateUtil.currentGMTTime().getTime() - groupVM.getUpdateTime().getTime()) / 1000; if (secondsSinceLastUpdate < _vmCapacityReleaseInterval) { avoid.addHost(groupVM.getLastHostId()); - if (logger.isDebugEnabled()) { - logger.debug("Added host " + groupVM.getLastHostId() + " to avoid set, since VM " + groupVM.getId() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Added host " + groupVM.getLastHostId() + " to avoid set, since VM " + groupVM.getId() + " is present on the host, in Stopped state but has reserved capacity"); } } @@ -130,8 +132,8 @@ public class HostAntiAffinityProcessor extends AffinityProcessorBase implements for (Long groupVMId : groupVMIds) { VMReservationVO vmReservation = _reservationDao.findByVmId(groupVMId); if (vmReservation != null && vmReservation.getHostId() != null && vmReservation.getHostId().equals(plannedHostId)) { - if (logger.isDebugEnabled()) { - logger.debug("Planned destination for VM " + vm.getId() + " conflicts with an existing VM " + vmReservation.getVmId() + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Planned destination for VM " + vm.getId() + " conflicts with an existing VM " + vmReservation.getVmId() + " reserved on the same host " + plannedHostId); } return false; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java ---------------------------------------------------------------------- diff --git a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java index 5c6682a..cb691a9 100644 --- a/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java +++ b/plugins/api/discovery/src/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java @@ -27,6 +27,7 @@ import java.util.Set; import javax.ejb.Local; import javax.inject.Inject; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.google.gson.annotations.SerializedName; @@ -54,6 +55,7 @@ import com.cloud.utils.component.PluggableService; @Component @Local(value = ApiDiscoveryService.class) public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements ApiDiscoveryService { + private static final Logger s_logger = Logger.getLogger(ApiDiscoveryServiceImpl.class); List<APIChecker> _apiAccessCheckers = null; List<PluggableService> _services = null; @@ -70,13 +72,13 @@ public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements A s_apiNameDiscoveryResponseMap = new HashMap<String, ApiDiscoveryResponse>(); Set<Class<?>> cmdClasses = new HashSet<Class<?>>(); for (PluggableService service : _services) { - logger.debug(String.format("getting api commands of service: %s", service.getClass().getName())); + s_logger.debug(String.format("getting api commands of service: %s", service.getClass().getName())); cmdClasses.addAll(service.getCommands()); } cmdClasses.addAll(this.getCommands()); cacheResponseMap(cmdClasses); long endTime = System.nanoTime(); - logger.info("Api Discovery Service: Annotation, docstrings, api relation graph processed in " + (endTime - startTime) / 1000000.0 + " ms"); + s_logger.info("Api Discovery Service: Annotation, docstrings, api relation graph processed in " + (endTime - startTime) / 1000000.0 + " ms"); } return true; @@ -95,8 +97,8 @@ public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements A } String apiName = apiCmdAnnotation.name(); - if (logger.isTraceEnabled()) { - logger.trace("Found api: " + apiName); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Found api: " + apiName); } ApiDiscoveryResponse response = getCmdRequestMap(cmdClass, apiCmdAnnotation); @@ -225,7 +227,7 @@ public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements A try { apiChecker.checkAccess(user, name); } catch (Exception ex) { - logger.debug("API discovery access check failed for " + name + " with " + ex.getMessage()); + s_logger.debug("API discovery access check failed for " + name + " with " + ex.getMessage()); return null; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java ---------------------------------------------------------------------- diff --git a/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java b/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java index 55b3b28..b46dc15 100644 --- a/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java +++ b/plugins/api/rate-limit/src/org/apache/cloudstack/ratelimit/ApiRateLimitServiceImpl.java @@ -27,6 +27,7 @@ import javax.naming.ConfigurationException; import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.acl.APIChecker; @@ -46,6 +47,7 @@ import com.cloud.utils.component.AdapterBase; @Component @Local(value = APIChecker.class) public class ApiRateLimitServiceImpl extends AdapterBase implements APIChecker, ApiRateLimitService { + private static final Logger s_logger = Logger.getLogger(ApiRateLimitServiceImpl.class); /** * True if api rate limiting is enabled @@ -98,7 +100,7 @@ public class ApiRateLimitServiceImpl extends AdapterBase implements APIChecker, CacheManager cm = CacheManager.create(); Cache cache = new Cache("api-limit-cache", maxElements, false, false, timeToLive, timeToLive); cm.addCache(cache); - logger.info("Limit Cache created with timeToLive=" + timeToLive + ", maxAllowed=" + maxAllowed + ", maxElements=" + maxElements); + s_logger.info("Limit Cache created with timeToLive=" + timeToLive + ", maxAllowed=" + maxAllowed + ", maxElements=" + maxElements); cacheStore.setCache(cache); _store = cacheStore; @@ -163,13 +165,13 @@ public class ApiRateLimitServiceImpl extends AdapterBase implements APIChecker, int current = entry.incrementAndGet(); if (current <= maxAllowed) { - logger.trace("account (" + account.getAccountId() + "," + account.getAccountName() + ") has current count = " + current); + s_logger.trace("account (" + account.getAccountId() + "," + account.getAccountName() + ") has current count = " + current); return true; } else { long expireAfter = entry.getExpireDuration(); // for this exception, we can just show the same message to user and admin users. String msg = "The given user has reached his/her account api limit, please retry after " + expireAfter + " ms."; - logger.warn(msg); + s_logger.warn(msg); throw new RequestLimitException(msg); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/deployment-planners/implicit-dedication/src/com/cloud/deploy/ImplicitDedicationPlanner.java ---------------------------------------------------------------------- diff --git a/plugins/deployment-planners/implicit-dedication/src/com/cloud/deploy/ImplicitDedicationPlanner.java b/plugins/deployment-planners/implicit-dedication/src/com/cloud/deploy/ImplicitDedicationPlanner.java index 6970965..9500cac 100644 --- a/plugins/deployment-planners/implicit-dedication/src/com/cloud/deploy/ImplicitDedicationPlanner.java +++ b/plugins/deployment-planners/implicit-dedication/src/com/cloud/deploy/ImplicitDedicationPlanner.java @@ -26,6 +26,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import com.cloud.configuration.Config; import com.cloud.exception.InsufficientServerCapacityException; @@ -43,6 +44,7 @@ import com.cloud.vm.VirtualMachineProfile; @Local(value = DeploymentPlanner.class) public class ImplicitDedicationPlanner extends FirstFitPlanner implements DeploymentClusterPlanner { + private static final Logger s_logger = Logger.getLogger(ImplicitDedicationPlanner.class); @Inject private ServiceOfferingDao serviceOfferingDao; @@ -157,12 +159,12 @@ public class ImplicitDedicationPlanner extends FirstFitPlanner implements Deploy for (VMInstanceVO vm : allVmsOnHost) { if (vm.getAccountId() != accountId) { - logger.info("Host " + vm.getHostId() + " found to be unsuitable for implicit dedication as it is " + "running instances of another account"); + s_logger.info("Host " + vm.getHostId() + " found to be unsuitable for implicit dedication as it is " + "running instances of another account"); suitable = false; break; } else { if (!isImplicitPlannerUsedByOffering(vm.getServiceOfferingId())) { - logger.info("Host " + vm.getHostId() + " found to be unsuitable for implicit dedication as it " + + s_logger.info("Host " + vm.getHostId() + " found to be unsuitable for implicit dedication as it " + "is running instances of this account which haven't been created using implicit dedication."); suitable = false; break; @@ -178,11 +180,11 @@ public class ImplicitDedicationPlanner extends FirstFitPlanner implements Deploy return false; for (VMInstanceVO vm : allVmsOnHost) { if (!isImplicitPlannerUsedByOffering(vm.getServiceOfferingId())) { - logger.info("Host " + vm.getHostId() + " found to be running a vm created by a planner other" + " than implicit."); + s_logger.info("Host " + vm.getHostId() + " found to be running a vm created by a planner other" + " than implicit."); createdByImplicitStrict = false; break; } else if (isServiceOfferingUsingPlannerInPreferredMode(vm.getServiceOfferingId())) { - logger.info("Host " + vm.getHostId() + " found to be running a vm created by an implicit planner" + " in preferred mode."); + s_logger.info("Host " + vm.getHostId() + " found to be running a vm created by an implicit planner" + " in preferred mode."); createdByImplicitStrict = false; break; } @@ -194,7 +196,7 @@ public class ImplicitDedicationPlanner extends FirstFitPlanner implements Deploy boolean implicitPlannerUsed = false; ServiceOfferingVO offering = serviceOfferingDao.findByIdIncludingRemoved(offeringId); if (offering == null) { - logger.error("Couldn't retrieve the offering by the given id : " + offeringId); + s_logger.error("Couldn't retrieve the offering by the given id : " + offeringId); } else { String plannerName = offering.getDeploymentPlanner(); if (plannerName == null) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java ---------------------------------------------------------------------- diff --git a/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java b/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java index 6c74715..df6531e 100644 --- a/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java +++ b/plugins/deployment-planners/user-concentrated-pod/src/com/cloud/deploy/UserConcentratedPodPlanner.java @@ -22,6 +22,7 @@ import java.util.Map; import javax.ejb.Local; +import org.apache.log4j.Logger; import com.cloud.utils.Pair; import com.cloud.vm.VirtualMachineProfile; @@ -29,6 +30,7 @@ import com.cloud.vm.VirtualMachineProfile; @Local(value = DeploymentPlanner.class) public class UserConcentratedPodPlanner extends FirstFitPlanner implements DeploymentClusterPlanner { + private static final Logger s_logger = Logger.getLogger(UserConcentratedPodPlanner.class); /** * This method should reorder the given list of Cluster Ids by applying any necessary heuristic @@ -62,14 +64,14 @@ public class UserConcentratedPodPlanner extends FirstFitPlanner implements Deplo private List<Long> reorderClustersByPods(List<Long> clusterIds, List<Long> podIds) { - if (logger.isDebugEnabled()) { - logger.debug("Reordering cluster list as per pods ordered by user concentration"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Reordering cluster list as per pods ordered by user concentration"); } Map<Long, List<Long>> podClusterMap = _clusterDao.getPodClusterIdMap(clusterIds); - if (logger.isTraceEnabled()) { - logger.trace("Pod To cluster Map is: " + podClusterMap); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Pod To cluster Map is: " + podClusterMap); } List<Long> reorderedClusters = new ArrayList<Long>(); @@ -88,22 +90,22 @@ public class UserConcentratedPodPlanner extends FirstFitPlanner implements Deplo } reorderedClusters.addAll(clusterIds); - if (logger.isTraceEnabled()) { - logger.trace("Reordered cluster list: " + reorderedClusters); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Reordered cluster list: " + reorderedClusters); } return reorderedClusters; } protected List<Long> listPodsByUserConcentration(long zoneId, long accountId) { - if (logger.isDebugEnabled()) { - logger.debug("Applying UserConcentratedPod heuristic for account: " + accountId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Applying UserConcentratedPod heuristic for account: " + accountId); } List<Long> prioritizedPods = _vmDao.listPodIdsHavingVmsforAccount(zoneId, accountId); - if (logger.isTraceEnabled()) { - logger.trace("List of pods to be considered, after applying UserConcentratedPod heuristic: " + prioritizedPods); + if (s_logger.isTraceEnabled()) { + s_logger.trace("List of pods to be considered, after applying UserConcentratedPod heuristic: " + prioritizedPods); } return prioritizedPods; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java ---------------------------------------------------------------------- diff --git a/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java b/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java index 2b1e7c7..5df4d13 100644 --- a/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java +++ b/plugins/deployment-planners/user-dispersing/src/com/cloud/deploy/UserDispersingPlanner.java @@ -26,6 +26,7 @@ import java.util.TreeMap; import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import com.cloud.configuration.Config; import com.cloud.utils.NumbersUtil; @@ -35,6 +36,7 @@ import com.cloud.vm.VirtualMachineProfile; @Local(value = DeploymentPlanner.class) public class UserDispersingPlanner extends FirstFitPlanner implements DeploymentClusterPlanner { + private static final Logger s_logger = Logger.getLogger(UserDispersingPlanner.class); /** * This method should reorder the given list of Cluster Ids by applying any necessary heuristic @@ -97,8 +99,8 @@ public class UserDispersingPlanner extends FirstFitPlanner implements Deployment } protected Pair<List<Long>, Map<Long, Double>> listClustersByUserDispersion(long id, boolean isZone, long accountId) { - if (logger.isDebugEnabled()) { - logger.debug("Applying Userdispersion heuristic to clusters for account: " + accountId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Applying Userdispersion heuristic to clusters for account: " + accountId); } Pair<List<Long>, Map<Long, Double>> clusterIdsVmCountInfo; if (isZone) { @@ -106,19 +108,19 @@ public class UserDispersingPlanner extends FirstFitPlanner implements Deployment } else { clusterIdsVmCountInfo = _vmInstanceDao.listClusterIdsInPodByVmCount(id, accountId); } - if (logger.isTraceEnabled()) { - logger.trace("List of clusters in ascending order of number of VMs: " + clusterIdsVmCountInfo.first()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("List of clusters in ascending order of number of VMs: " + clusterIdsVmCountInfo.first()); } return clusterIdsVmCountInfo; } protected Pair<List<Long>, Map<Long, Double>> listPodsByUserDispersion(long dataCenterId, long accountId) { - if (logger.isDebugEnabled()) { - logger.debug("Applying Userdispersion heuristic to pods for account: " + accountId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Applying Userdispersion heuristic to pods for account: " + accountId); } Pair<List<Long>, Map<Long, Double>> podIdsVmCountInfo = _vmInstanceDao.listPodIdsInZoneByVmCount(dataCenterId, accountId); - if (logger.isTraceEnabled()) { - logger.trace("List of pods in ascending order of number of VMs: " + podIdsVmCountInfo.first()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("List of pods in ascending order of number of VMs: " + podIdsVmCountInfo.first()); } return podIdsVmCountInfo; @@ -130,25 +132,25 @@ public class UserDispersingPlanner extends FirstFitPlanner implements Deployment Map<Long, Double> capacityMap = capacityInfo.second(); Map<Long, Double> vmCountMap = vmCountInfo.second(); - if (logger.isTraceEnabled()) { - logger.trace("Capacity Id list: " + capacityOrderedIds + " , capacityMap:" + capacityMap); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Capacity Id list: " + capacityOrderedIds + " , capacityMap:" + capacityMap); } - if (logger.isTraceEnabled()) { - logger.trace("Vm Count Id list: " + vmCountOrderedIds + " , vmCountMap:" + vmCountMap); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Vm Count Id list: " + vmCountOrderedIds + " , vmCountMap:" + vmCountMap); } List<Long> idsReorderedByWeights = new ArrayList<Long>(); float capacityWeight = (1.0f - _userDispersionWeight); - if (logger.isDebugEnabled()) { - logger.debug("Applying userDispersionWeight: " + _userDispersionWeight); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Applying userDispersionWeight: " + _userDispersionWeight); } //normalize the vmCountMap LinkedHashMap<Long, Double> normalisedVmCountIdMap = new LinkedHashMap<Long, Double>(); Long totalVmsOfAccount = _vmInstanceDao.countRunningByAccount(accountId); - if (logger.isDebugEnabled()) { - logger.debug("Total VMs for account: " + totalVmsOfAccount); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Total VMs for account: " + totalVmsOfAccount); } for (Long id : vmCountOrderedIds) { Double normalisedCount = vmCountMap.get(id) / totalVmsOfAccount; @@ -177,8 +179,8 @@ public class UserDispersingPlanner extends FirstFitPlanner implements Deployment idsReorderedByWeights.addAll(idList); } - if (logger.isTraceEnabled()) { - logger.trace("Reordered Id list: " + idsReorderedByWeights); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Reordered Id list: " + idsReorderedByWeights); } return idsReorderedByWeights; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java ---------------------------------------------------------------------- diff --git a/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java b/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java index ebed807..fd2f9f3 100644 --- a/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java +++ b/plugins/event-bus/inmemory/src/org/apache/cloudstack/mom/inmemory/InMemoryEventBus.java @@ -26,6 +26,7 @@ import java.util.concurrent.ConcurrentHashMap; import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.framework.events.Event; import org.apache.cloudstack.framework.events.EventBus; @@ -39,6 +40,7 @@ import com.cloud.utils.component.ManagerBase; @Local(value = EventBus.class) public class InMemoryEventBus extends ManagerBase implements EventBus { + private static final Logger s_logger = Logger.getLogger(InMemoryEventBus.class); private final static Map<UUID, Pair<EventTopic, EventSubscriber>> subscribers; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java ---------------------------------------------------------------------- diff --git a/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java b/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java index a981645..6d943df 100644 --- a/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java +++ b/plugins/event-bus/kafka/src/org/apache/cloudstack/mom/kafka/KafkaEventBus.java @@ -28,6 +28,7 @@ import java.util.Properties; import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.framework.events.Event; import org.apache.cloudstack.framework.events.EventBus; @@ -51,6 +52,7 @@ public class KafkaEventBus extends ManagerBase implements EventBus { private String _topic = null; private Producer<String,String> _producer; + private static final Logger s_logger = Logger.getLogger(KafkaEventBus.class); @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java ---------------------------------------------------------------------- diff --git a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java index d69147b..e53d2e9 100644 --- a/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java +++ b/plugins/event-bus/rabbitmq/src/org/apache/cloudstack/mom/rabbitmq/RabbitMQEventBus.java @@ -30,6 +30,7 @@ import java.util.concurrent.Executors; import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import com.rabbitmq.client.AMQP; import com.rabbitmq.client.AlreadyClosedException; @@ -92,6 +93,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { private ExecutorService executorService; private static DisconnectHandler disconnectHandler; + private static final Logger s_logger = Logger.getLogger(RabbitMQEventBus.class); @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { @@ -233,9 +235,9 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { s_subscribers.put(queueName, queueDetails); } catch (AlreadyClosedException closedException) { - logger.warn("Connection to AMQP service is lost. Subscription:" + queueName + " will be active after reconnection"); + s_logger.warn("Connection to AMQP service is lost. Subscription:" + queueName + " will be active after reconnection"); } catch (ConnectException connectException) { - logger.warn("Connection to AMQP service is lost. Subscription:" + queueName + " will be active after reconnection"); + s_logger.warn("Connection to AMQP service is lost. Subscription:" + queueName + " will be active after reconnection"); } catch (Exception e) { throw new EventBusException("Failed to subscribe to event due to " + e.getMessage()); } @@ -355,7 +357,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { try { return createConnection(); } catch (Exception e) { - logger.error("Failed to create a connection to AMQP server due to " + e.getMessage()); + s_logger.error("Failed to create a connection to AMQP server due to " + e.getMessage()); throw e; } } else { @@ -395,7 +397,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { s_connection.close(); } } catch (Exception e) { - logger.warn("Failed to close connection to AMQP server due to " + e.getMessage()); + s_logger.warn("Failed to close connection to AMQP server due to " + e.getMessage()); } s_connection = null; } @@ -407,7 +409,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { try { s_connection.abort(); } catch (Exception e) { - logger.warn("Failed to abort connection due to " + e.getMessage()); + s_logger.warn("Failed to abort connection due to " + e.getMessage()); } s_connection = null; } @@ -424,7 +426,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { try { return connection.createChannel(); } catch (java.io.IOException exception) { - logger.warn("Failed to create a channel due to " + exception.getMessage()); + s_logger.warn("Failed to create a channel due to " + exception.getMessage()); throw exception; } } @@ -433,7 +435,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { try { channel.exchangeDeclare(exchangeName, "topic", true); } catch (java.io.IOException exception) { - logger.error("Failed to create exchange" + exchangeName + " on RabbitMQ server"); + s_logger.error("Failed to create exchange" + exchangeName + " on RabbitMQ server"); throw exception; } } @@ -443,7 +445,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { byte[] messageBodyBytes = eventDescription.getBytes(); channel.basicPublish(exchangeName, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, messageBodyBytes); } catch (Exception e) { - logger.error("Failed to publish event " + routingKey + " on exchange " + exchangeName + " of message broker due to " + e.getMessage()); + s_logger.error("Failed to publish event " + routingKey + " on exchange " + exchangeName + " of message broker due to " + e.getMessage()); throw e; } } @@ -496,7 +498,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { channel.queueDelete(queueName); channel.abort(); } catch (IOException ioe) { - logger.warn("Failed to delete queue: " + queueName + " on AMQP server due to " + ioe.getMessage()); + s_logger.warn("Failed to delete queue: " + queueName + " on AMQP server due to " + ioe.getMessage()); } } } @@ -519,7 +521,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { } abortConnection(); // disconnected to AMQP server, so abort the connection and channels - logger.warn("Connection has been shutdown by AMQP server. Attempting to reconnect."); + s_logger.warn("Connection has been shutdown by AMQP server. Attempting to reconnect."); // initiate re-connect process ReconnectionTask reconnect = new ReconnectionTask(); @@ -597,7 +599,7 @@ public class RabbitMQEventBus extends ManagerBase implements EventBus { s_subscribers.put(subscriberId, subscriberDetails); } } catch (Exception e) { - logger.warn("Failed to recreate queues and binding for the subscribers due to " + e.getMessage()); + s_logger.warn("Failed to recreate queues and binding for the subscribers due to " + e.getMessage()); } } return; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java ---------------------------------------------------------------------- diff --git a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java index 15014af..510e6c6 100644 --- a/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java +++ b/plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java @@ -35,6 +35,7 @@ import netapp.manage.NaElement; import netapp.manage.NaException; import netapp.manage.NaServer; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.api.commands.netapp.AssociateLunCmd; @@ -67,6 +68,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { roundrobin, leastfull } + public static final Logger s_logger = Logger.getLogger(NetappManagerImpl.class.getName()); @Inject public VolumeDao _volumeDao; @Inject @@ -83,8 +85,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { @Override public void createPool(String poolName, String algorithm) throws InvalidParameterValueException { - if (logger.isDebugEnabled()) - logger.debug("Request --> createPool "); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> createPool "); PoolVO pool = null; validAlgorithm(algorithm); @@ -92,8 +94,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { pool = new PoolVO(poolName, algorithm); _poolDao.persist(pool); - if (logger.isDebugEnabled()) - logger.debug("Response --> createPool:success"); + if (s_logger.isDebugEnabled()) + s_logger.debug("Response --> createPool:success"); } catch (CloudRuntimeException cre) { pool = _poolDao.findPool(poolName); @@ -172,8 +174,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { @Override public void deletePool(String poolName) throws InvalidParameterValueException, ResourceInUseException { - if (logger.isDebugEnabled()) - logger.debug("Request --> deletePool "); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> deletePool "); PoolVO pool = _poolDao.findPool(poolName); if (pool == null) { @@ -184,8 +186,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { if (volCount == 0) { _poolDao.remove(pool.getId()); - if (logger.isDebugEnabled()) - logger.debug("Request --> deletePool: Success "); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> deletePool: Success "); } else { throw new ResourceInUseException("Cannot delete non-empty pool"); @@ -216,14 +218,14 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { volume = _volumeDao.findVolume(ipAddress, aggrName, volName); if (volume == null) { - logger.warn("The volume does not exist in our system"); + s_logger.warn("The volume does not exist in our system"); throw new InvalidParameterValueException("The given tuple:" + ipAddress + "," + aggrName + "," + volName + " doesn't exist in our system"); } List<LunVO> lunsOnVol = _lunDao.listLunsByVolId(volume.getId()); if (lunsOnVol != null && lunsOnVol.size() > 0) { - logger.warn("There are luns on the volume"); + s_logger.warn("There are luns on the volume"); throw new ResourceInUseException("There are luns on the volume"); } @@ -256,12 +258,12 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { txn.commit(); } catch (UnknownHostException uhe) { - logger.warn("Unable to delete volume on filer ", uhe); + s_logger.warn("Unable to delete volume on filer ", uhe); throw new ServerException("Unable to delete volume on filer", uhe); } catch (NaAPIFailedException naf) { - logger.warn("Unable to delete volume on filer ", naf); + s_logger.warn("Unable to delete volume on filer ", naf); if (naf.getErrno() == 13040) { - logger.info("Deleting the volume: " + volName); + s_logger.info("Deleting the volume: " + volName); _volumeDao.remove(volume.getId()); txn.commit(); } @@ -269,11 +271,11 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { throw new ServerException("Unable to delete volume on filer", naf); } catch (NaException nae) { txn.rollback(); - logger.warn("Unable to delete volume on filer ", nae); + s_logger.warn("Unable to delete volume on filer ", nae); throw new ServerException("Unable to delete volume on filer", nae); } catch (IOException ioe) { txn.rollback(); - logger.warn("Unable to delete volume on filer ", ioe); + s_logger.warn("Unable to delete volume on filer ", ioe); throw new ServerException("Unable to delete volume on filer", ioe); } finally { if (pool != null) { @@ -304,8 +306,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { public void createVolumeOnFiler(String ipAddress, String aggName, String poolName, String volName, String volSize, String snapshotPolicy, Integer snapshotReservation, String username, String password) throws UnknownHostException, ServerException, InvalidParameterValueException { - if (logger.isDebugEnabled()) - logger.debug("Request --> createVolume " + "serverIp:" + ipAddress); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> createVolume " + "serverIp:" + ipAddress); boolean snapPolicy = false; boolean snapshotRes = false; @@ -392,7 +394,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { } pool = _poolDao.acquireInLockTable(pool.getId()); if (pool == null) { - logger.warn("Failed to acquire lock on pool " + poolName); + s_logger.warn("Failed to acquire lock on pool " + poolName); throw new ConcurrentModificationException("Failed to acquire lock on pool " + poolName); } volume = new NetappVolumeVO(ipAddress, aggName, pool.getId(), volName, volSize, "", 0, username, password, 0, pool.getName()); @@ -417,34 +419,34 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { txn.commit(); } catch (NaException nae) { //zapi call failed, log and throw e - logger.warn("Failed to create volume on the netapp filer:", nae); + s_logger.warn("Failed to create volume on the netapp filer:", nae); txn.rollback(); if (volumeCreated) { try { deleteRogueVolume(volName, s);//deletes created volume on filer } catch (NaException e) { - logger.warn("Failed to cleanup created volume whilst rolling back on the netapp filer:", e); + s_logger.warn("Failed to cleanup created volume whilst rolling back on the netapp filer:", e); throw new ServerException("Unable to create volume via cloudtools." + "Failed to cleanup created volume on netapp filer whilst rolling back on the cloud db:", e); } catch (IOException e) { - logger.warn("Failed to cleanup created volume whilst rolling back on the netapp filer:", e); + s_logger.warn("Failed to cleanup created volume whilst rolling back on the netapp filer:", e); throw new ServerException("Unable to create volume via cloudtools." + "Failed to cleanup created volume on netapp filer whilst rolling back on the cloud db:", e); } } throw new ServerException("Unable to create volume", nae); } catch (IOException ioe) { - logger.warn("Failed to create volume on the netapp filer:", ioe); + s_logger.warn("Failed to create volume on the netapp filer:", ioe); txn.rollback(); if (volumeCreated) { try { deleteRogueVolume(volName, s);//deletes created volume on filer } catch (NaException e) { - logger.warn("Failed to cleanup created volume whilst rolling back on the netapp filer:", e); + s_logger.warn("Failed to cleanup created volume whilst rolling back on the netapp filer:", e); throw new ServerException("Unable to create volume via cloudtools." + "Failed to cleanup created volume on netapp filer whilst rolling back on the cloud db:", e); } catch (IOException e) { - logger.warn("Failed to cleanup created volume whilst rolling back on the netapp filer:", e); + s_logger.warn("Failed to cleanup created volume whilst rolling back on the netapp filer:", e); throw new ServerException("Unable to create volume via cloudtools." + "Failed to cleanup created volume on netapp filer whilst rolling back on the cloud db:", e); } @@ -495,7 +497,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { vol.setSnapshotPolicy(snapScheduleOnFiler); } catch (ServerException e) { - logger.warn("Error trying to get snapshot schedule for volume" + vol.getVolumeName()); + s_logger.warn("Error trying to get snapshot schedule for volume" + vol.getVolumeName()); } } return vols; @@ -536,10 +538,10 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { .append(whichMinutes); return sB.toString(); } catch (NaException nae) { - logger.warn("Failed to get volume size ", nae); + s_logger.warn("Failed to get volume size ", nae); throw new ServerException("Failed to get volume size", nae); } catch (IOException ioe) { - logger.warn("Failed to get volume size ", ioe); + s_logger.warn("Failed to get volume size ", ioe); throw new ServerException("Failed to get volume size", ioe); } finally { if (s != null) @@ -595,10 +597,10 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { } } catch (NaException nae) { - logger.warn("Failed to get volume size ", nae); + s_logger.warn("Failed to get volume size ", nae); throw new ServerException("Failed to get volume size", nae); } catch (IOException ioe) { - logger.warn("Failed to get volume size ", ioe); + s_logger.warn("Failed to get volume size ", ioe); throw new ServerException("Failed to get volume size", ioe); } finally { if (s != null) @@ -644,7 +646,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { } pool = _poolDao.acquireInLockTable(pool.getId()); if (pool == null) { - logger.warn("Failed to acquire lock on the pool " + poolName); + s_logger.warn("Failed to acquire lock on the pool " + poolName); return result; } NaServer s = null; @@ -661,8 +663,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { throw new ServerException("Could not find a suitable volume to create lun on"); } - if (logger.isDebugEnabled()) - logger.debug("Request --> createLun " + "serverIp:" + selectedVol.getIpAddress()); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> createLun " + "serverIp:" + selectedVol.getIpAddress()); StringBuilder exportPath = new StringBuilder("/vol/"); exportPath.append(selectedVol.getVolumeName()); @@ -713,7 +715,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { } catch (NaAPIFailedException e) { if (e.getErrno() == 9004) { //igroup already exists hence no error - logger.warn("Igroup already exists"); + s_logger.warn("Igroup already exists"); } } @@ -792,15 +794,15 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { NetappVolumeVO vol = _volumeDao.acquireInLockTable(lun.getVolumeId()); if (vol == null) { - logger.warn("Failed to lock volume id= " + lun.getVolumeId()); + s_logger.warn("Failed to lock volume id= " + lun.getVolumeId()); return; } NaServer s = null; try { s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword()); - if (logger.isDebugEnabled()) - logger.debug("Request --> destroyLun " + ":serverIp:" + vol.getIpAddress()); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> destroyLun " + ":serverIp:" + vol.getIpAddress()); try { //Unmap lun @@ -810,7 +812,7 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { s.invokeElem(xi2); } catch (NaAPIFailedException naf) { if (naf.getErrno() == 9016) - logger.warn("no map exists excpn 9016 caught in deletelun, continuing with delete"); + s_logger.warn("no map exists excpn 9016 caught in deletelun, continuing with delete"); } //destroy lun @@ -829,30 +831,30 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { txn.commit(); } catch (UnknownHostException uhe) { txn.rollback(); - logger.warn("Failed to delete lun", uhe); + s_logger.warn("Failed to delete lun", uhe); throw new ServerException("Failed to delete lun", uhe); } catch (IOException ioe) { txn.rollback(); - logger.warn("Failed to delete lun", ioe); + s_logger.warn("Failed to delete lun", ioe); throw new ServerException("Failed to delete lun", ioe); } catch (NaAPIFailedException naf) { if (naf.getErrno() == 9017) {//no such group exists excpn - logger.warn("no such group exists excpn 9017 caught in deletelun, continuing with delete"); + s_logger.warn("no such group exists excpn 9017 caught in deletelun, continuing with delete"); _lunDao.remove(lun.getId()); txn.commit(); } else if (naf.getErrno() == 9029) {//LUN maps for this initiator group exist - logger.warn("LUN maps for this initiator group exist errno 9029 caught in deletelun, continuing with delete"); + s_logger.warn("LUN maps for this initiator group exist errno 9029 caught in deletelun, continuing with delete"); _lunDao.remove(lun.getId()); txn.commit(); } else { txn.rollback(); - logger.warn("Failed to delete lun", naf); + s_logger.warn("Failed to delete lun", naf); throw new ServerException("Failed to delete lun", naf); } } catch (NaException nae) { txn.rollback(); - logger.warn("Failed to delete lun", nae); + s_logger.warn("Failed to delete lun", nae); throw new ServerException("Failed to delete lun", nae); } finally { if (vol != null) { @@ -873,8 +875,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { */ @Override public List<LunVO> listLunsOnFiler(String poolName) { - if (logger.isDebugEnabled()) - logger.debug("Request --> listLunsOnFiler "); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> listLunsOnFiler "); List<LunVO> luns = new ArrayList<LunVO>(); @@ -884,8 +886,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { luns.addAll(_lunDao.listLunsByVolId(vol.getId())); } - if (logger.isDebugEnabled()) - logger.debug("Response --> listLunsOnFiler:success"); + if (s_logger.isDebugEnabled()) + s_logger.debug("Response --> listLunsOnFiler:success"); return luns; } @@ -908,8 +910,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { try { s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword()); - if (logger.isDebugEnabled()) - logger.debug("Request --> disassociateLun " + ":serverIp:" + vol.getIpAddress()); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> disassociateLun " + ":serverIp:" + vol.getIpAddress()); xi = new NaElement("igroup-remove"); xi.addNewChild("force", "true"); @@ -970,8 +972,8 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { try { s = getServer(vol.getIpAddress(), vol.getUsername(), vol.getPassword()); - if (logger.isDebugEnabled()) - logger.debug("Request --> associateLun " + ":serverIp:" + vol.getIpAddress()); + if (s_logger.isDebugEnabled()) + s_logger.debug("Request --> associateLun " + ":serverIp:" + vol.getIpAddress()); //add iqn to the group xi2 = new NaElement("igroup-add"); @@ -982,19 +984,19 @@ public class NetappManagerImpl extends ManagerBase implements NetappManager { return returnVal; } catch (UnknownHostException uhe) { - logger.warn("Unable to associate LUN ", uhe); + s_logger.warn("Unable to associate LUN ", uhe); throw new ServerException("Unable to associate LUN", uhe); } catch (NaAPIFailedException naf) { if (naf.getErrno() == 9008) { //initiator group already contains node return returnVal; } - logger.warn("Unable to associate LUN ", naf); + s_logger.warn("Unable to associate LUN ", naf); throw new ServerException("Unable to associate LUN", naf); } catch (NaException nae) { - logger.warn("Unable to associate LUN ", nae); + s_logger.warn("Unable to associate LUN ", nae); throw new ServerException("Unable to associate LUN", nae); } catch (IOException ioe) { - logger.warn("Unable to associate LUN ", ioe); + s_logger.warn("Unable to associate LUN ", ioe); throw new ServerException("Unable to associate LUN", ioe); } finally { if (s != null) http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/file-systems/netapp/src/com/cloud/netapp/dao/LunDaoImpl.java ---------------------------------------------------------------------- diff --git a/plugins/file-systems/netapp/src/com/cloud/netapp/dao/LunDaoImpl.java b/plugins/file-systems/netapp/src/com/cloud/netapp/dao/LunDaoImpl.java index 1bb2da8..60a15b5 100644 --- a/plugins/file-systems/netapp/src/com/cloud/netapp/dao/LunDaoImpl.java +++ b/plugins/file-systems/netapp/src/com/cloud/netapp/dao/LunDaoImpl.java @@ -20,6 +20,7 @@ import java.util.List; import javax.ejb.Local; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.netapp.LunVO; @@ -31,6 +32,7 @@ import com.cloud.utils.db.SearchCriteria; @Component @Local(value = {LunDao.class}) public class LunDaoImpl extends GenericDaoBase<LunVO, Long> implements LunDao { + private static final Logger s_logger = Logger.getLogger(PoolDaoImpl.class); protected final SearchBuilder<LunVO> LunSearch; protected final SearchBuilder<LunVO> LunNameSearch; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/file-systems/netapp/src/com/cloud/netapp/dao/PoolDaoImpl.java ---------------------------------------------------------------------- diff --git a/plugins/file-systems/netapp/src/com/cloud/netapp/dao/PoolDaoImpl.java b/plugins/file-systems/netapp/src/com/cloud/netapp/dao/PoolDaoImpl.java index ff2573f..4ac76df 100644 --- a/plugins/file-systems/netapp/src/com/cloud/netapp/dao/PoolDaoImpl.java +++ b/plugins/file-systems/netapp/src/com/cloud/netapp/dao/PoolDaoImpl.java @@ -20,6 +20,7 @@ import java.util.List; import javax.ejb.Local; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.netapp.PoolVO; @@ -30,6 +31,7 @@ import com.cloud.utils.db.SearchCriteria; @Component @Local(value = {PoolDao.class}) public class PoolDaoImpl extends GenericDaoBase<PoolVO, Long> implements PoolDao { + private static final Logger s_logger = Logger.getLogger(PoolDaoImpl.class); protected final SearchBuilder<PoolVO> PoolSearch; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/file-systems/netapp/src/com/cloud/netapp/dao/VolumeDaoImpl.java ---------------------------------------------------------------------- diff --git a/plugins/file-systems/netapp/src/com/cloud/netapp/dao/VolumeDaoImpl.java b/plugins/file-systems/netapp/src/com/cloud/netapp/dao/VolumeDaoImpl.java index ea4fdbd..e239b1e 100644 --- a/plugins/file-systems/netapp/src/com/cloud/netapp/dao/VolumeDaoImpl.java +++ b/plugins/file-systems/netapp/src/com/cloud/netapp/dao/VolumeDaoImpl.java @@ -20,6 +20,7 @@ import java.util.List; import javax.ejb.Local; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.netapp.NetappVolumeVO; @@ -31,6 +32,7 @@ import com.cloud.utils.db.SearchCriteria; @Component(value = "netappVolumeDaoImpl") @Local(value = {VolumeDao.class}) public class VolumeDaoImpl extends GenericDaoBase<NetappVolumeVO, Long> implements VolumeDao { + private static final Logger s_logger = Logger.getLogger(VolumeDaoImpl.class); protected final SearchBuilder<NetappVolumeVO> NetappVolumeSearch; protected final SearchBuilder<NetappVolumeVO> NetappListVolumeSearch; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/ha-planners/skip-heurestics/src/com/cloud/deploy/SkipHeuresticsPlanner.java ---------------------------------------------------------------------- diff --git a/plugins/ha-planners/skip-heurestics/src/com/cloud/deploy/SkipHeuresticsPlanner.java b/plugins/ha-planners/skip-heurestics/src/com/cloud/deploy/SkipHeuresticsPlanner.java index 9ea3d82..b67d112 100644 --- a/plugins/ha-planners/skip-heurestics/src/com/cloud/deploy/SkipHeuresticsPlanner.java +++ b/plugins/ha-planners/skip-heurestics/src/com/cloud/deploy/SkipHeuresticsPlanner.java @@ -17,6 +17,7 @@ package com.cloud.deploy; import com.cloud.vm.VirtualMachineProfile; +import org.apache.log4j.Logger; import javax.ejb.Local; @@ -26,6 +27,7 @@ import java.util.Map; @Local(value=HAPlanner.class) public class SkipHeuresticsPlanner extends FirstFitPlanner implements HAPlanner { + private static final Logger s_logger = Logger.getLogger(SkipHeuresticsPlanner.class); /** @@ -37,8 +39,8 @@ public class SkipHeuresticsPlanner extends FirstFitPlanner implements HAPlanner @Override protected void removeClustersCrossingThreshold(List<Long> clusterListForVmAllocation, ExcludeList avoid, VirtualMachineProfile vmProfile, DeploymentPlan plan){ - if (logger.isDebugEnabled()) { - logger.debug("Deploying vm during HA process, so skipping disable threshold check"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Deploying vm during HA process, so skipping disable threshold check"); } return; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java ---------------------------------------------------------------------- diff --git a/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java b/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java index 1df6458..390a8af 100644 --- a/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java +++ b/plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java @@ -23,6 +23,7 @@ import java.util.List; import javax.ejb.Local; import javax.inject.Inject; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.agent.manager.allocator.HostAllocator; @@ -41,6 +42,7 @@ import com.cloud.vm.VirtualMachineProfile; @Component @Local(value = HostAllocator.class) public class RandomAllocator extends AdapterBase implements HostAllocator { + private static final Logger s_logger = Logger.getLogger(RandomAllocator.class); @Inject private HostDao _hostDao; @Inject @@ -67,9 +69,9 @@ public class RandomAllocator extends AdapterBase implements HostAllocator { String hostTag = offering.getHostTag(); if (hostTag != null) { - logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having host tag:" + hostTag); + s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having host tag:" + hostTag); } else { - logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId); + s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId); } // list all computing hosts, regardless of whether they support routing...it's random after all @@ -79,7 +81,7 @@ public class RandomAllocator extends AdapterBase implements HostAllocator { hostsCopy.retainAll(_resourceMgr.listAllUpAndEnabledHosts(type, clusterId, podId, dcId)); } - logger.debug("Random Allocator found " + hostsCopy.size() + " hosts"); + s_logger.debug("Random Allocator found " + hostsCopy.size() + " hosts"); if (hostsCopy.size() == 0) { return suitableHosts; } @@ -93,14 +95,14 @@ public class RandomAllocator extends AdapterBase implements HostAllocator { if (!avoid.shouldAvoid(host)) { suitableHosts.add(host); } else { - 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"); } } } - if (logger.isDebugEnabled()) { - logger.debug("Random Host Allocator returning " + suitableHosts.size() + " suitable hosts"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Random Host Allocator returning " + suitableHosts.size() + " suitable hosts"); } return suitableHosts; @@ -122,9 +124,9 @@ public class RandomAllocator extends AdapterBase implements HostAllocator { String hostTag = offering.getHostTag(); if (hostTag != null) { - logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having host tag:" + hostTag); + s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId + " having host tag:" + hostTag); } else { - logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId); + s_logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId); } // list all computing hosts, regardless of whether they support routing...it's random after all @@ -135,7 +137,7 @@ public class RandomAllocator extends AdapterBase implements HostAllocator { hosts = _resourceMgr.listAllUpAndEnabledHosts(type, clusterId, podId, dcId); } - logger.debug("Random Allocator found " + hosts.size() + " hosts"); + s_logger.debug("Random Allocator found " + hosts.size() + " hosts"); if (hosts.size() == 0) { return suitableHosts; @@ -150,13 +152,13 @@ public class RandomAllocator extends AdapterBase implements HostAllocator { if (!avoid.shouldAvoid(host)) { suitableHosts.add(host); } else { - 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"); } } } - if (logger.isDebugEnabled()) { - logger.debug("Random Host Allocator returning " + suitableHosts.size() + " suitable hosts"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Random Host Allocator returning " + suitableHosts.size() + " suitable hosts"); } return suitableHosts; }
