http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/tags/TaggedResourceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java index 34eedeb..dfe3ae0 100644 --- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java +++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java @@ -33,6 +33,7 @@ import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import com.cloud.api.query.dao.ResourceTagJoinDao; import com.cloud.dc.DataCenterVO; @@ -90,6 +91,7 @@ import com.cloud.vm.snapshot.VMSnapshotVO; @Local(value = {TaggedResourceService.class}) public class TaggedResourceManagerImpl extends ManagerBase implements TaggedResourceService { + public static final Logger s_logger = Logger.getLogger(TaggedResourceManagerImpl.class); private static final Map<ResourceObjectType, Class<?>> s_typeMap = new HashMap<ResourceObjectType, Class<?>>(); static { @@ -352,7 +354,7 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso public void doInTransactionWithoutResult(TransactionStatus status) { for (ResourceTag tagToRemove : tagsToRemove) { _resourceTagDao.remove(tagToRemove.getId()); - logger.debug("Removed the tag " + tagToRemove); + s_logger.debug("Removed the tag " + tagToRemove); } } });
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/template/HypervisorTemplateAdapter.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/com/cloud/template/HypervisorTemplateAdapter.java index 09aa75b..0b7854e 100644 --- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java +++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java @@ -34,6 +34,7 @@ import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplat import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint; import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommand; +import org.apache.log4j.Logger; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd; import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd; @@ -87,6 +88,7 @@ import com.cloud.utils.exception.CloudRuntimeException; @Local(value = TemplateAdapter.class) public class HypervisorTemplateAdapter extends TemplateAdapterBase { + private final static Logger s_logger = Logger.getLogger(HypervisorTemplateAdapter.class); @Inject DownloadMonitor _downloadMonitor; @Inject @@ -173,19 +175,19 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { if (zoneId != null) { DataCenterVO zone = _dcDao.findById(zoneId); if (zone == null) { - logger.warn("Unable to find zone by id " + zoneId + ", so skip downloading template to its image store " + imageStore.getId()); + s_logger.warn("Unable to find zone by id " + zoneId + ", so skip downloading template to its image store " + imageStore.getId()); continue; } // Check if zone is disabled if (Grouping.AllocationState.Disabled == zone.getAllocationState()) { - logger.info("Zone " + zoneId + " is disabled, so skip downloading template to its image store " + imageStore.getId()); + s_logger.info("Zone " + zoneId + " is disabled, so skip downloading template to its image store " + imageStore.getId()); continue; } // Check if image store has enough capacity for template if (!_statsCollector.imageStoreHasEnoughCapacity(imageStore)) { - logger.info("Image store doesn't has enough capacity, so skip downloading template to this image store " + imageStore.getId()); + s_logger.info("Image store doesn't has enough capacity, so skip downloading template to this image store " + imageStore.getId()); continue; } // We want to download private template to one of the image store in a zone @@ -237,13 +239,13 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { if (zoneId != null) { DataCenterVO zone = _dcDao.findById(zoneId); if (zone == null) { - logger.warn("Unable to find zone by id " + zoneId + ", so skip downloading template to its image store " + imageStore.getId()); + s_logger.warn("Unable to find zone by id " + zoneId + ", so skip downloading template to its image store " + imageStore.getId()); continue; } // Check if zone is disabled if (Grouping.AllocationState.Disabled == zone.getAllocationState()) { - logger.info("Zone " + zoneId + " is disabled, so skip downloading template to its image store " + imageStore.getId()); + s_logger.info("Zone " + zoneId + " is disabled, so skip downloading template to its image store " + imageStore.getId()); continue; } @@ -266,7 +268,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { EndPoint ep = _epSelector.select(templateOnStore); if (ep == null) { String errMsg = "There is no secondary storage VM for downloading template to image store " + imageStore.getName(); - logger.warn(errMsg); + s_logger.warn(errMsg); throw new CloudRuntimeException(errMsg); } @@ -333,7 +335,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { if (tmpltStore != null) { physicalSize = tmpltStore.getPhysicalSize(); } else { - logger.warn("No entry found in template_store_ref for template id: " + template.getId() + " and image store id: " + ds.getId() + + s_logger.warn("No entry found in template_store_ref for template id: " + template.getId() + " and image store id: " + ds.getId() + " at the end of registering template!"); } Scope dsScope = ds.getScope(); @@ -342,7 +344,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { UsageEventUtils.publishUsageEvent(etype, template.getAccountId(), dsScope.getScopeId(), template.getId(), template.getName(), null, null, physicalSize, template.getSize(), VirtualMachineTemplate.class.getName(), template.getUuid()); } else { - logger.warn("Zone scope image store " + ds.getId() + " has a null scope id"); + s_logger.warn("Zone scope image store " + ds.getId() + " has a null scope id"); } } else if (dsScope.getScopeType() == ScopeType.REGION) { // publish usage event for region-wide image store using a -1 zoneId for 4.2, need to revisit post-4.2 @@ -367,7 +369,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { List<DataStore> imageStores = templateMgr.getImageStoreByTemplate(template.getId(), profile.getZoneId()); if (imageStores == null || imageStores.size() == 0) { // already destroyed on image stores - logger.info("Unable to find image store still having template: " + template.getName() + ", so just mark the template removed"); + s_logger.info("Unable to find image store still having template: " + template.getName() + ", so just mark the template removed"); } else { // Make sure the template is downloaded to all found image stores for (DataStore store : imageStores) { @@ -376,7 +378,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { for (TemplateDataStoreVO templateStore : templateStores) { if (templateStore.getDownloadState() == Status.DOWNLOAD_IN_PROGRESS) { String errorMsg = "Please specify a template that is not currently being downloaded."; - logger.debug("Template: " + template.getName() + " is currently being downloaded to secondary storage host: " + store.getName() + + s_logger.debug("Template: " + template.getName() + " is currently being downloaded to secondary storage host: " + store.getName() + "; cant' delete it."); throw new CloudRuntimeException(errorMsg); } @@ -397,13 +399,13 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { UsageEventUtils.publishUsageEvent(eventType, template.getAccountId(), sZoneId, template.getId(), null, null, null); } - logger.info("Delete template from image store: " + imageStore.getName()); + s_logger.info("Delete template from image store: " + imageStore.getName()); AsyncCallFuture<TemplateApiResult> future = imageService.deleteTemplateAsync(imageFactory.getTemplate(template.getId(), imageStore)); try { TemplateApiResult result = future.get(); success = result.isSuccess(); if (!success) { - logger.warn("Failed to delete the template " + template + " from the image store: " + imageStore.getName() + " due to: " + result.getResult()); + s_logger.warn("Failed to delete the template " + template + " from the image store: " + imageStore.getName() + " due to: " + result.getResult()); break; } @@ -418,10 +420,10 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { templateDataStoreDao.removeByTemplateStore(template.getId(), imageStore.getId()); } catch (InterruptedException e) { - logger.debug("delete template Failed", e); + s_logger.debug("delete template Failed", e); throw new CloudRuntimeException("delete template Failed", e); } catch (ExecutionException e) { - logger.debug("delete template Failed", e); + s_logger.debug("delete template Failed", e); throw new CloudRuntimeException("delete template Failed", e); } } @@ -435,7 +437,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase { // delete all cache entries for this template List<TemplateInfo> cacheTmpls = imageFactory.listTemplateOnCache(template.getId()); for (TemplateInfo tmplOnCache : cacheTmpls) { - logger.info("Delete template from image cache store: " + tmplOnCache.getDataStore().getName()); + s_logger.info("Delete template from image cache store: " + tmplOnCache.getDataStore().getName()); tmplOnCache.delete(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/template/TemplateAdapterBase.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java index b5e6210..c5d0c5b 100644 --- a/server/src/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/com/cloud/template/TemplateAdapterBase.java @@ -23,6 +23,7 @@ import java.util.Map; import javax.inject.Inject; import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd; +import org.apache.log4j.Logger; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd; @@ -73,6 +74,7 @@ import com.cloud.vm.UserVmVO; import com.cloud.vm.dao.UserVmDao; public abstract class TemplateAdapterBase extends AdapterBase implements TemplateAdapter { + private final static Logger s_logger = Logger.getLogger(TemplateAdapterBase.class); protected @Inject DomainDao _domainDao; protected @Inject @@ -200,7 +202,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat try { imgfmt = ImageFormat.valueOf(format.toUpperCase()); } catch (IllegalArgumentException e) { - logger.debug("ImageFormat IllegalArgumentException: " + e.getMessage()); + s_logger.debug("ImageFormat IllegalArgumentException: " + e.getMessage()); throw new IllegalArgumentException("Image format: " + format + " is incorrect. Supported formats are " + EnumUtils.listValues(ImageFormat.values())); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/template/TemplateManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 8a75c98..3911340 100644 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -43,6 +43,7 @@ import org.apache.cloudstack.api.response.GetUploadParamsResponse; import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommand; import org.apache.cloudstack.utils.imagestore.ImageStoreUtil; import org.apache.commons.collections.CollectionUtils; +import org.apache.log4j.Logger; import org.apache.cloudstack.acl.SecurityChecker.AccessType; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd; @@ -195,6 +196,7 @@ import org.joda.time.DateTimeZone; @Local(value = {TemplateManager.class, TemplateApiService.class}) public class TemplateManagerImpl extends ManagerBase implements TemplateManager, TemplateApiService, Configurable { + private final static Logger s_logger = Logger.getLogger(TemplateManagerImpl.class); @Inject private VMTemplateDao _tmpltDao; @@ -449,7 +451,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, if (pool.getStatus() == StoragePoolStatus.Up && pool.getDataCenterId() == zoneId) { prepareTemplateInOneStoragePool(vmTemplate, pool); } else { - logger.warn("Skip loading template " + vmTemplate.getId() + " into primary storage " + pool.getId() + " as either the pool zone " + s_logger.warn("Skip loading template " + vmTemplate.getId() + " into primary storage " + pool.getId() + " as either the pool zone " + pool.getDataCenterId() + " is different from the requested zone " + zoneId + " or the pool is currently not available."); } } @@ -541,7 +543,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, if (vm.getIsoId() != null) { TemplateInfo template = prepareIso(vm.getIsoId(), vm.getDataCenterId()); if (template == null){ - logger.error("Failed to prepare ISO on secondary or cache storage"); + s_logger.error("Failed to prepare ISO on secondary or cache storage"); throw new CloudRuntimeException("Failed to prepare ISO on secondary or cache storage"); } if (template.isBootable()) { @@ -567,22 +569,22 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, } private void prepareTemplateInOneStoragePool(final VMTemplateVO template, final StoragePoolVO pool) { - logger.info("Schedule to preload template " + template.getId() + " into primary storage " + pool.getId()); + s_logger.info("Schedule to preload template " + template.getId() + " into primary storage " + pool.getId()); _preloadExecutor.execute(new ManagedContextRunnable() { @Override protected void runInContext() { try { reallyRun(); } catch (Throwable e) { - logger.warn("Unexpected exception ", e); + s_logger.warn("Unexpected exception ", e); } } private void reallyRun() { - logger.info("Start to preload template " + template.getId() + " into primary storage " + pool.getId()); + s_logger.info("Start to preload template " + template.getId() + " into primary storage " + pool.getId()); StoragePool pol = (StoragePool)_dataStoreMgr.getPrimaryDataStore(pool.getId()); prepareTemplateForCreate(template, pol); - logger.info("End of preloading template " + template.getId() + " into primary storage " + pool.getId()); + s_logger.info("End of preloading template " + template.getId() + " into primary storage " + pool.getId()); } }); } @@ -593,7 +595,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, if (pool.getDataCenterId() == zoneId) { prepareTemplateInOneStoragePool(template, pool); } else { - logger.info("Skip loading template " + template.getId() + " into primary storage " + pool.getId() + " as pool zone " + pool.getDataCenterId() + + s_logger.info("Skip loading template " + template.getId() + " into primary storage " + pool.getId() + " as pool zone " + pool.getDataCenterId() + " is different from the requested zone " + zoneId); } } @@ -615,8 +617,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, _tmpltPoolDao.update(templateStoragePoolRef.getId(), templateStoragePoolRef); if (templateStoragePoolRef.getDownloadState() == Status.DOWNLOADED) { - if (logger.isDebugEnabled()) { - logger.debug("Template " + templateId + " has already been downloaded to pool " + poolId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Template " + templateId + " has already been downloaded to pool " + poolId); } return templateStoragePoolRef; @@ -625,7 +627,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, templateStoreRef = _tmplStoreDao.findByTemplateZoneDownloadStatus(templateId, pool.getDataCenterId(), VMTemplateStorageResourceAssoc.Status.DOWNLOADED); if (templateStoreRef == null) { - logger.error("Unable to find a secondary storage host who has completely downloaded the template."); + s_logger.error("Unable to find a secondary storage host who has completely downloaded the template."); return null; } @@ -635,8 +637,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, } if (templateStoragePoolRef == null) { - if (logger.isDebugEnabled()) { - logger.debug("Downloading template " + templateId + " to pool " + poolId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Downloading template " + templateId + " to pool " + poolId); } DataStore srcSecStore = _dataStoreMgr.getDataStore(templateStoreRef.getDataStoreId(), DataStoreRole.Image); TemplateInfo srcTemplate = _tmplFactory.getTemplate(templateId, srcSecStore); @@ -645,13 +647,13 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, try { TemplateApiResult result = future.get(); if (result.isFailed()) { - logger.debug("prepare template failed:" + result.getResult()); + s_logger.debug("prepare template failed:" + result.getResult()); return null; } return _tmpltPoolDao.findByPoolTemplate(poolId, templateId); } catch (Exception ex) { - logger.debug("failed to copy template from image store:" + srcSecStore.getName() + " to primary storage"); + s_logger.debug("failed to copy template from image store:" + srcSecStore.getName() + " to primary storage"); } } @@ -665,7 +667,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, Answer answer = null; if (ep == null) { String errMsg = "No remote endpoint to send command, check if host or ssvm is down?"; - logger.error(errMsg); + s_logger.error(errMsg); answer = new Answer(cmd, false, errMsg); } else { answer = ep.sendMessage(cmd); @@ -684,7 +686,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, VMTemplateStoragePoolVO templateStoragePoolRef = _tmpltPoolDao.acquireInLockTable(templateStoragePoolRefId, 1200); if (templateStoragePoolRef == null) { - logger.warn("resetTemplateDownloadStateOnPool failed - unable to lock TemplateStorgePoolRef " + templateStoragePoolRefId); + s_logger.warn("resetTemplateDownloadStateOnPool failed - unable to lock TemplateStorgePoolRef " + templateStoragePoolRefId); return false; } @@ -740,7 +742,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, try { TemplateApiResult result = future.get(); if (result.isFailed()) { - logger.debug("copy template failed for image store " + dstSecStore.getName() + ":" + result.getResult()); + s_logger.debug("copy template failed for image store " + dstSecStore.getName() + ":" + result.getResult()); continue; // try next image store } @@ -752,7 +754,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, } return true; } catch (Exception ex) { - logger.debug("failed to copy template to image store:" + dstSecStore.getName() + " ,will try next one"); + s_logger.debug("failed to copy template to image store:" + dstSecStore.getName() + " ,will try next one"); } } return false; @@ -790,7 +792,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, if (template.isCrossZones()) { // sync template from cache store to region store if it is not there, for cases where we are going to migrate existing NFS to S3. _tmpltSvr.syncTemplateToRegionStore(templateId, srcSecStore); - logger.debug("Template " + templateId + " is cross-zone, don't need to copy"); + s_logger.debug("Template " + templateId + " is cross-zone, don't need to copy"); return template; } @@ -812,7 +814,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, DataStore dstSecStore = getImageStore(destZoneId, templateId); if (dstSecStore != null) { - logger.debug("There is template " + templateId + " in secondary storage " + dstSecStore.getName() + " in zone " + destZoneId + " , don't need to copy"); + s_logger.debug("There is template " + templateId + " in secondary storage " + dstSecStore.getName() + " in zone " + destZoneId + " , don't need to copy"); return template; } @@ -877,7 +879,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, //Assumption here is that, we will hold the same lock during create volume from template VMTemplateStoragePoolVO templatePoolRef = _tmpltPoolDao.acquireInLockTable(templatePoolVO.getId()); if (templatePoolRef == null) { - logger.debug("can't aquire the lock for template pool ref:" + templatePoolVO.getId()); + s_logger.debug("can't aquire the lock for template pool ref:" + templatePoolVO.getId()); return; } @@ -885,8 +887,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, StoragePool pool = (StoragePool)_dataStoreMgr.getPrimaryDataStore(templatePoolVO.getPoolId()); VMTemplateVO template = _tmpltDao.findByIdIncludingRemoved(templatePoolVO.getTemplateId()); - if (logger.isDebugEnabled()) { - logger.debug("Evicting " + templatePoolVO); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Evicting " + templatePoolVO); } DestroyCommand cmd = new DestroyCommand(pool, templatePoolVO); @@ -896,13 +898,13 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, if (answer != null && answer.getResult()) { // Remove the templatePoolVO if (_tmpltPoolDao.remove(templatePoolVO.getId())) { - logger.debug("Successfully evicted template: " + template.getName() + " from storage pool: " + pool.getName()); + s_logger.debug("Successfully evicted template: " + template.getName() + " from storage pool: " + pool.getName()); } } else { - logger.info("Will retry evicte template: " + template.getName() + " from storage pool: " + pool.getName()); + s_logger.info("Will retry evicte template: " + template.getName() + " from storage pool: " + pool.getName()); } } catch (StorageUnavailableException e) { - logger.info("Storage is unavailable currently. Will retry evicte template: " + template.getName() + " from storage pool: " + pool.getName()); + s_logger.info("Storage is unavailable currently. Will retry evicte template: " + template.getName() + " from storage pool: " + pool.getName()); } } finally { _tmpltPoolDao.releaseFromLockTable(templatePoolRef.getId()); @@ -947,14 +949,14 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, List<VMInstanceVO> nonExpungedVms = _vmInstanceDao.listNonExpungedByZoneAndTemplate(zoneId, templateId); if (!nonExpungedVms.isEmpty()) { - logger.debug("Template " + template.getName() + " in zone " + zone.getName() + + s_logger.debug("Template " + template.getName() + " in zone " + zone.getName() + " is not deleteable because there are non-expunged VMs deployed from this template."); return false; } List<UserVmVO> userVmUsingIso = _userVmDao.listByIsoId(templateId); // check if there is any VM using this ISO. if (!userVmUsingIso.isEmpty()) { - logger.debug("ISO " + template.getName() + " in zone " + zone.getName() + " is not deleteable because it is attached to " + userVmUsingIso.size() + " VMs"); + s_logger.debug("ISO " + template.getName() + " in zone " + zone.getName() + " is not deleteable because it is attached to " + userVmUsingIso.size() + " VMs"); return false; } // Check if there are any snapshots for the template in the template @@ -963,7 +965,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, for (VolumeVO volume : volumes) { List<SnapshotVO> snapshots = _snapshotDao.listByVolumeIdVersion(volume.getId(), "2.1"); if (!snapshots.isEmpty()) { - logger.debug("Template " + template.getName() + " in zone " + zone.getName() + + s_logger.debug("Template " + template.getName() + " in zone " + zone.getName() + " is not deleteable because there are 2.1 snapshots using this template."); return false; } @@ -981,7 +983,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, // always be copied to // primary storage before deploying VM. if (!userVmUsingIso.isEmpty()) { - logger.debug("ISO " + templateId + " is not deleteable because it is attached to " + userVmUsingIso.size() + " VMs"); + s_logger.debug("ISO " + templateId + " is not deleteable because it is attached to " + userVmUsingIso.size() + " VMs"); return false; } @@ -1078,7 +1080,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, public TemplateInfo prepareIso(long isoId, long dcId) { TemplateInfo tmplt = _tmplFactory.getTemplate(isoId, DataStoreRole.Image, dcId); if (tmplt == null || tmplt.getFormat() != ImageFormat.ISO) { - logger.warn("ISO: " + isoId + " does not exist in vm_template table"); + s_logger.warn("ISO: " + isoId + " does not exist in vm_template table"); return null; } @@ -1087,7 +1089,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, Scope destScope = new ZoneScope(dcId); TemplateInfo cacheData = (TemplateInfo)cacheMgr.createCacheObject(tmplt, destScope); if (cacheData == null) { - logger.error("Failed in copy iso from S3 to cache storage"); + s_logger.error("Failed in copy iso from S3 to cache storage"); return null; } return cacheData; @@ -1112,7 +1114,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, HostVO host = _hostDao.findById(vm.getHostId()); if (host == null) { - logger.warn("Host: " + vm.getHostId() + " does not exist"); + s_logger.warn("Host: " + vm.getHostId() + " does not exist"); return false; } @@ -1306,7 +1308,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, // If the template is removed throw an error. if (template.getRemoved() != null) { - logger.error("unable to update permissions for " + mediaType + " with id " + id + " as it is removed "); + s_logger.error("unable to update permissions for " + mediaType + " with id " + id + " as it is removed "); throw new InvalidParameterValueException("unable to update permissions for " + mediaType + " with id " + id + " as it is removed "); } @@ -1492,7 +1494,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, result = future.get(); if (result.isFailed()) { privateTemplate = null; - logger.debug("Failed to create template" + result.getResult()); + s_logger.debug("Failed to create template" + result.getResult()); throw new CloudRuntimeException("Failed to create template" + result.getResult()); } @@ -1512,10 +1514,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, privateTemplate.getSourceTemplateId(), srcTmpltStore.getPhysicalSize(), privateTemplate.getSize()); _usageEventDao.persist(usageEvent); } catch (InterruptedException e) { - logger.debug("Failed to create template", e); + s_logger.debug("Failed to create template", e); throw new CloudRuntimeException("Failed to create template", e); } catch (ExecutionException e) { - logger.debug("Failed to create template", e); + s_logger.debug("Failed to create template", e); throw new CloudRuntimeException("Failed to create template", e); } @@ -1627,8 +1629,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, // created if (!_volumeMgr.volumeInactive(volume)) { String msg = "Unable to create private template for volume: " + volume.getName() + "; volume is attached to a non-stopped VM, please stop the VM first"; - if (logger.isInfoEnabled()) { - logger.info(msg); + if (s_logger.isInfoEnabled()) { + s_logger.info(msg); } throw new CloudRuntimeException(msg); } @@ -1692,8 +1694,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, } String templateTag = cmd.getTemplateTag(); if (templateTag != null) { - if (logger.isDebugEnabled()) { - logger.debug("Adding template tag: " + templateTag); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Adding template tag: " + templateTag); } } privateTemplate = new VMTemplateVO(nextTemplateId, name, ImageFormat.RAW, isPublic, featured, isExtractable, @@ -1701,8 +1703,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager, passwordEnabledValue, guestOS.getId(), true, hyperType, templateTag, cmd.getDetails(), false, isDynamicScalingEnabled); if (sourceTemplateId != null) { - if (logger.isDebugEnabled()) { - logger.debug("This template is getting created from other template, setting source template Id to: " + sourceTemplateId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("This template is getting created from other template, setting source template Id to: " + sourceTemplateId); } } privateTemplate.setSourceTemplateId(sourceTemplateId); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/usage/UsageServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/usage/UsageServiceImpl.java b/server/src/com/cloud/usage/UsageServiceImpl.java index 54fb7d7..df43a00 100644 --- a/server/src/com/cloud/usage/UsageServiceImpl.java +++ b/server/src/com/cloud/usage/UsageServiceImpl.java @@ -64,6 +64,7 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.usage.Usage; import org.apache.cloudstack.usage.UsageService; import org.apache.cloudstack.usage.UsageTypes; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import javax.ejb.Local; @@ -79,6 +80,7 @@ import java.util.TimeZone; @Component @Local(value = {UsageService.class}) public class UsageServiceImpl extends ManagerBase implements UsageService, Manager { + public static final Logger s_logger = Logger.getLogger(UsageServiceImpl.class); //ToDo: Move implementation to ManagaerImpl @@ -211,7 +213,7 @@ public class UsageServiceImpl extends ManagerBase implements UsageService, Manag } else if (_accountService.isDomainAdmin(caller.getId())) { isDomainAdmin = true; } - logger.debug("Account details not available. Using userContext accountId: " + accountId); + s_logger.debug("Account details not available. Using userContext accountId: " + accountId); } Date startDate = cmd.getStartDate(); @@ -223,8 +225,8 @@ public class UsageServiceImpl extends ManagerBase implements UsageService, Manag Date adjustedStartDate = computeAdjustedTime(startDate, usageTZ); Date adjustedEndDate = computeAdjustedTime(endDate, usageTZ); - if (logger.isDebugEnabled()) { - logger.debug("getting usage records for account: " + accountId + ", domainId: " + domainId + ", between " + adjustedStartDate + " and " + adjustedEndDate + + if (s_logger.isDebugEnabled()) { + s_logger.debug("getting usage records for account: " + accountId + ", domainId: " + domainId + ", between " + adjustedStartDate + " and " + adjustedEndDate + ", using pageSize: " + cmd.getPageSizeVal() + " and startIndex: " + cmd.getStartIndex()); } @@ -392,7 +394,7 @@ public class UsageServiceImpl extends ManagerBase implements UsageService, Manag cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); long execTS = cal.getTimeInMillis(); - logger.debug("Trying to remove old raw cloud_usage records older than " + interval + " day(s), current time=" + curTS + " next job execution time=" + execTS); + s_logger.debug("Trying to remove old raw cloud_usage records older than " + interval + " day(s), current time=" + curTS + " next job execution time=" + execTS); // Let's avoid cleanup when job runs and around a 15 min interval if (Math.abs(curTS - execTS) < 15 * 60 * 1000) { return false; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/user/AccountManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index c6821a2..2d07e84 100644 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -41,6 +41,7 @@ import javax.naming.ConfigurationException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.QuerySelector; @@ -170,6 +171,7 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDao; @Local(value = {AccountManager.class, AccountService.class}) public class AccountManagerImpl extends ManagerBase implements AccountManager, Manager { + public static final Logger s_logger = Logger.getLogger(AccountManagerImpl.class); @Inject private AccountDao _accountDao; @@ -395,8 +397,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M for (SecurityChecker checker : _securityCheckers) { try { if (checker.checkAccess(acct, null, null, "SystemCapability")) { - if (logger.isTraceEnabled()) { - logger.trace("Root Access granted to " + acct + " by " + checker.getName()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Root Access granted to " + acct + " by " + checker.getName()); } return true; } @@ -418,8 +420,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M for (SecurityChecker checker : _securityCheckers) { try { if (checker.checkAccess(acct, null, null, "DomainCapability")) { - if (logger.isTraceEnabled()) { - logger.trace("DomainAdmin Access granted to " + acct + " by " + checker.getName()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("DomainAdmin Access granted to " + acct + " by " + checker.getName()); } return true; } @@ -449,8 +451,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M for (SecurityChecker checker : _securityCheckers) { try { if (checker.checkAccess(acct, null, null, "DomainResourceCapability")) { - if (logger.isTraceEnabled()) { - logger.trace("ResourceDomainAdmin Access granted to " + acct + " by " + checker.getName()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("ResourceDomainAdmin Access granted to " + acct + " by " + checker.getName()); } return true; } @@ -477,8 +479,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M public void checkAccess(Account caller, Domain domain) throws PermissionDeniedException { for (SecurityChecker checker : _securityCheckers) { if (checker.checkAccess(caller, domain)) { - if (logger.isDebugEnabled()) { - logger.debug("Access granted to " + caller + " to " + domain + " by " + checker.getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Access granted to " + caller + " to " + domain + " by " + checker.getName()); } return; } @@ -515,8 +517,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M if (caller.getId() == Account.ACCOUNT_ID_SYSTEM || isRootAdmin(caller.getId())) { // no need to make permission checks if the system/root admin makes the call - if (logger.isTraceEnabled()) { - logger.trace("No need to make permission check for System/RootAdmin account, returning true"); + if (s_logger.isTraceEnabled()) { + s_logger.trace("No need to make permission check for System/RootAdmin account, returning true"); } return; } @@ -543,8 +545,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M boolean granted = false; for (SecurityChecker checker : _securityCheckers) { if (checker.checkAccess(caller, entity, accessType, apiName)) { - if (logger.isDebugEnabled()) { - logger.debug("Access to " + entity + " granted to " + caller + " by " + checker.getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Access to " + entity + " granted to " + caller + " by " + checker.getName()); } granted = true; break; @@ -619,7 +621,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M } }); } catch (Exception e) { - logger.error("Failed to update login attempts for user with id " + id); + s_logger.error("Failed to update login attempts for user with id " + id); } } @@ -650,12 +652,12 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M acctForUpdate.setState(State.locked); success = _accountDao.update(Long.valueOf(accountId), acctForUpdate); } else { - if (logger.isInfoEnabled()) { - logger.info("Attempting to lock a non-enabled account, current state is " + account.getState() + " (accountId: " + accountId + "), locking failed."); + if (s_logger.isInfoEnabled()) { + s_logger.info("Attempting to lock a non-enabled account, current state is " + account.getState() + " (accountId: " + accountId + "), locking failed."); } } } else { - logger.warn("Failed to lock account " + accountId + ", account not found."); + s_logger.warn("Failed to lock account " + accountId + ", account not found."); } return success; } @@ -666,12 +668,12 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M // delete the account record if (!_accountDao.remove(accountId)) { - logger.error("Unable to delete account " + accountId); + s_logger.error("Unable to delete account " + accountId); return false; } - if (logger.isDebugEnabled()) { - logger.debug("Removed account " + accountId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Removed account " + accountId); } return cleanupAccount(account, callerUserId, caller); @@ -686,7 +688,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M List<UserVO> users = _userDao.listByAccount(accountId); for (UserVO user : users) { if (!_userDao.remove(user.getId())) { - logger.error("Unable to delete user: " + user + " as a part of account " + account + " cleanup"); + s_logger.error("Unable to delete user: " + user + " as a part of account " + account + " cleanup"); accountCleanupNeeded = true; } } @@ -709,7 +711,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M List<InstanceGroupVO> groups = _vmGroupDao.listByAccountId(accountId); for (InstanceGroupVO group : groups) { if (!_vmMgr.deleteVmGroup(group.getId())) { - logger.error("Unable to delete group: " + group.getId()); + s_logger.error("Unable to delete group: " + group.getId()); accountCleanupNeeded = true; } } @@ -717,7 +719,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M // Delete the snapshots dir for the account. Have to do this before destroying the VMs. boolean success = _snapMgr.deleteSnapshotDirsForAccount(accountId); if (success) { - logger.debug("Successfully deleted snapshots directories for all volumes under account " + accountId + " across all zones"); + s_logger.debug("Successfully deleted snapshots directories for all volumes under account " + accountId + " across all zones"); } // clean up templates @@ -728,14 +730,14 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M try { allTemplatesDeleted = _tmpltMgr.delete(callerUserId, template.getId(), null); } catch (Exception e) { - logger.warn("Failed to delete template while removing account: " + template.getName() + " due to: ", e); + s_logger.warn("Failed to delete template while removing account: " + template.getName() + " due to: ", e); allTemplatesDeleted = false; } } } if (!allTemplatesDeleted) { - logger.warn("Failed to delete templates while removing account id=" + accountId); + s_logger.warn("Failed to delete templates while removing account id=" + accountId); accountCleanupNeeded = true; } @@ -745,20 +747,20 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M try { _vmSnapshotMgr.deleteVMSnapshot(vmSnapshot.getId()); } catch (Exception e) { - logger.debug("Failed to cleanup vm snapshot " + vmSnapshot.getId() + " due to " + e.toString()); + s_logger.debug("Failed to cleanup vm snapshot " + vmSnapshot.getId() + " due to " + e.toString()); } } // Destroy the account's VMs List<UserVmVO> vms = _userVmDao.listByAccountId(accountId); - if (logger.isDebugEnabled()) { - logger.debug("Expunging # of vms (accountId=" + accountId + "): " + vms.size()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Expunging # of vms (accountId=" + accountId + "): " + vms.size()); } // no need to catch exception at this place as expunging vm should pass in order to perform further cleanup for (UserVmVO vm : vms) { if (!_vmMgr.expunge(vm, callerUserId, caller)) { - logger.error("Unable to expunge vm: " + vm.getId()); + s_logger.error("Unable to expunge vm: " + vm.getId()); accountCleanupNeeded = true; } } @@ -770,7 +772,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M try { volumeService.deleteVolume(volume.getId(), caller); } catch (Exception ex) { - logger.warn("Failed to cleanup volumes as a part of account id=" + accountId + " cleanup due to Exception: ", ex); + s_logger.warn("Failed to cleanup volumes as a part of account id=" + accountId + " cleanup due to Exception: ", ex); accountCleanupNeeded = true; } } @@ -789,21 +791,21 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M _remoteAccessVpnMgr.destroyRemoteAccessVpnForIp(vpn.getServerAddressId(), caller); } } catch (ResourceUnavailableException ex) { - logger.warn("Failed to cleanup remote access vpn resources as a part of account id=" + accountId + " cleanup due to Exception: ", ex); + s_logger.warn("Failed to cleanup remote access vpn resources as a part of account id=" + accountId + " cleanup due to Exception: ", ex); accountCleanupNeeded = true; } // Cleanup security groups int numRemoved = _securityGroupDao.removeByAccountId(accountId); - logger.info("deleteAccount: Deleted " + numRemoved + " network groups for account " + accountId); + s_logger.info("deleteAccount: Deleted " + numRemoved + " network groups for account " + accountId); // Cleanup affinity groups int numAGRemoved = _affinityGroupDao.removeByAccountId(accountId); - logger.info("deleteAccount: Deleted " + numAGRemoved + " affinity groups for account " + accountId); + s_logger.info("deleteAccount: Deleted " + numAGRemoved + " affinity groups for account " + accountId); // Delete all the networks boolean networksDeleted = true; - logger.debug("Deleting networks for account " + account.getId()); + s_logger.debug("Deleting networks for account " + account.getId()); List<NetworkVO> networks = _networkDao.listByOwner(accountId); if (networks != null) { for (NetworkVO network : networks) { @@ -811,27 +813,27 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M ReservationContext context = new ReservationContextImpl(null, null, getActiveUser(callerUserId), caller); if (!_networkMgr.destroyNetwork(network.getId(), context, false)) { - logger.warn("Unable to destroy network " + network + " as a part of account id=" + accountId + " cleanup."); + s_logger.warn("Unable to destroy network " + network + " as a part of account id=" + accountId + " cleanup."); accountCleanupNeeded = true; networksDeleted = false; } else { - logger.debug("Network " + network.getId() + " successfully deleted as a part of account id=" + accountId + " cleanup."); + s_logger.debug("Network " + network.getId() + " successfully deleted as a part of account id=" + accountId + " cleanup."); } } } // Delete all VPCs boolean vpcsDeleted = true; - logger.debug("Deleting vpcs for account " + account.getId()); + s_logger.debug("Deleting vpcs for account " + account.getId()); List<? extends Vpc> vpcs = _vpcMgr.getVpcsForAccount(account.getId()); for (Vpc vpc : vpcs) { if (!_vpcMgr.destroyVpc(vpc, caller, callerUserId)) { - logger.warn("Unable to destroy VPC " + vpc + " as a part of account id=" + accountId + " cleanup."); + s_logger.warn("Unable to destroy VPC " + vpc + " as a part of account id=" + accountId + " cleanup."); accountCleanupNeeded = true; vpcsDeleted = false; } else { - logger.debug("VPC " + vpc.getId() + " successfully deleted as a part of account id=" + accountId + " cleanup."); + s_logger.debug("VPC " + vpc.getId() + " successfully deleted as a part of account id=" + accountId + " cleanup."); } } @@ -839,9 +841,9 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M // release ip addresses belonging to the account List<? extends IpAddress> ipsToRelease = _ipAddressDao.listByAccount(accountId); for (IpAddress ip : ipsToRelease) { - logger.debug("Releasing ip " + ip + " as a part of account id=" + accountId + " cleanup"); + s_logger.debug("Releasing ip " + ip + " as a part of account id=" + accountId + " cleanup"); if (!_ipAddrMgr.disassociatePublicIpAddress(ip.getId(), callerUserId, caller)) { - logger.warn("Failed to release ip address " + ip + s_logger.warn("Failed to release ip address " + ip + " as a part of account id=" + accountId + " clenaup"); accountCleanupNeeded = true; @@ -850,16 +852,16 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M } // Delete Site 2 Site VPN customer gateway - logger.debug("Deleting site-to-site VPN customer gateways for account " + accountId); + s_logger.debug("Deleting site-to-site VPN customer gateways for account " + accountId); if (!_vpnMgr.deleteCustomerGatewayByAccount(accountId)) { - logger.warn("Fail to delete site-to-site VPN customer gateways for account " + accountId); + s_logger.warn("Fail to delete site-to-site VPN customer gateways for account " + accountId); } // Delete autoscale resources if any try { _autoscaleMgr.cleanUpAutoScaleResources(accountId); } catch (CloudRuntimeException ex) { - logger.warn("Failed to cleanup AutoScale resources as a part of account id=" + accountId + " cleanup due to exception:", ex); + s_logger.warn("Failed to cleanup AutoScale resources as a part of account id=" + accountId + " cleanup due to exception:", ex); accountCleanupNeeded = true; } @@ -869,7 +871,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M if (!_configMgr.releaseAccountSpecificVirtualRanges(accountId)) { accountCleanupNeeded = true; } else { - logger.debug("Account specific Virtual IP ranges " + " are successfully released as a part of account id=" + accountId + " cleanup."); + s_logger.debug("Account specific Virtual IP ranges " + " are successfully released as a part of account id=" + accountId + " cleanup."); } } @@ -879,14 +881,14 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M _dataCenterVnetDao.releaseDedicatedGuestVlans(map.getId()); } int vlansReleased = _accountGuestVlanMapDao.removeByAccountId(accountId); - logger.info("deleteAccount: Released " + vlansReleased + " dedicated guest vlan ranges from account " + accountId); + s_logger.info("deleteAccount: Released " + vlansReleased + " dedicated guest vlan ranges from account " + accountId); // release account specific acquired portable IP's. Since all the portable IP's must have been already // disassociated with VPC/guest network (due to deletion), so just mark portable IP as free. List<? extends IpAddress> ipsToRelease = _ipAddressDao.listByAccount(accountId); for (IpAddress ip : ipsToRelease) { if (ip.isPortable()) { - logger.debug("Releasing portable ip " + ip + " as a part of account id=" + accountId + " cleanup"); + s_logger.debug("Releasing portable ip " + ip + " as a part of account id=" + accountId + " cleanup"); _ipAddrMgr.releasePortableIpAddress(ip.getId()); } } @@ -894,10 +896,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M // release dedication if any List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByAccountId(accountId); if (dedicatedResources != null && !dedicatedResources.isEmpty()) { - logger.debug("Releasing dedicated resources for account " + accountId); + s_logger.debug("Releasing dedicated resources for account " + accountId); for (DedicatedResourceVO dr : dedicatedResources) { if (!_dedicatedDao.remove(dr.getId())) { - logger.warn("Fail to release dedicated resources for account " + accountId); + s_logger.warn("Fail to release dedicated resources for account " + accountId); } } } @@ -915,11 +917,11 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M _resourceLimitDao.removeEntriesByOwner(accountId, ResourceOwnerType.Account); return true; } catch (Exception ex) { - logger.warn("Failed to cleanup account " + account + " due to ", ex); + s_logger.warn("Failed to cleanup account " + account + " due to ", ex); accountCleanupNeeded = true; return true; } finally { - logger.info("Cleanup for account " + account.getId() + (accountCleanupNeeded ? " is needed." : " is not needed.")); + s_logger.info("Cleanup for account " + account.getId() + (accountCleanupNeeded ? " is needed." : " is not needed.")); if (accountCleanupNeeded) { _accountDao.markForCleanup(accountId); } else { @@ -933,8 +935,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M public boolean disableAccount(long accountId) throws ConcurrentOperationException, ResourceUnavailableException { boolean success = false; if (accountId <= 2) { - if (logger.isInfoEnabled()) { - logger.info("disableAccount -- invalid account id: " + accountId); + if (s_logger.isInfoEnabled()) { + s_logger.info("disableAccount -- invalid account id: " + accountId); } return false; } @@ -953,7 +955,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M disableAccountResult = doDisableAccount(accountId); } finally { if (!disableAccountResult) { - logger.warn("Failed to disable account " + account + " resources as a part of disableAccount call, marking the account for cleanup"); + s_logger.warn("Failed to disable account " + account + " resources as a part of disableAccount call, marking the account for cleanup"); _accountDao.markForCleanup(accountId); } else { acctForUpdate = _accountDao.createForUpdate(); @@ -974,13 +976,13 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M try { _itMgr.advanceStop(vm.getUuid(), false); } catch (OperationTimedoutException ote) { - logger.warn( + s_logger.warn( "Operation for stopping vm timed out, unable to stop vm " + vm.getHostName(), ote); success = false; } } catch (AgentUnavailableException aue) { - logger.warn("Agent running on host " + vm.getHostId() + " is unavailable, unable to stop vm " + vm.getHostName(), aue); + s_logger.warn("Agent running on host " + vm.getHostId() + " is unavailable, unable to stop vm " + vm.getHostName(), aue); success = false; } } @@ -1231,8 +1233,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M user.setSecretKey(secretKey); } - if (logger.isDebugEnabled()) { - logger.debug("updating user with id: " + userId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("updating user with id: " + userId); } try { // check if the apiKey and secretKey are globally unique @@ -1251,7 +1253,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M _userDao.update(userId, user); } catch (Throwable th) { - logger.error("error updating user", th); + s_logger.error("error updating user", th); throw new CloudRuntimeException("Unable to update user " + userId); } @@ -1419,8 +1421,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M success = (success && lockAccount(user.getAccountId())); } } else { - if (logger.isInfoEnabled()) { - logger.info("Attempting to lock a non-enabled user, current state is " + user.getState() + " (userId: " + user.getId() + "), locking failed."); + if (s_logger.isInfoEnabled()) { + s_logger.info("Attempting to lock a non-enabled user, current state is " + user.getState() + " (userId: " + user.getId() + "), locking failed."); } success = false; } @@ -1449,7 +1451,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M if (account == null || account.getRemoved() != null) { if (account != null) { - logger.info("The account:" + account.getAccountName() + " is already removed"); + s_logger.info("The account:" + account.getAccountName() + " is already removed"); } return true; } @@ -1599,7 +1601,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M // Check if account exists if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) { - logger.error("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId); + s_logger.error("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId); throw new InvalidParameterValueException("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId); } @@ -1698,39 +1700,39 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M try { GlobalLock lock = GlobalLock.getInternLock("AccountCleanup"); if (lock == null) { - logger.debug("Couldn't get the global lock"); + s_logger.debug("Couldn't get the global lock"); return; } if (!lock.lock(30)) { - logger.debug("Couldn't lock the db"); + s_logger.debug("Couldn't lock the db"); return; } try { // Cleanup removed accounts List<AccountVO> removedAccounts = _accountDao.findCleanupsForRemovedAccounts(null); - logger.info("Found " + removedAccounts.size() + " removed accounts to cleanup"); + s_logger.info("Found " + removedAccounts.size() + " removed accounts to cleanup"); for (AccountVO account : removedAccounts) { - logger.debug("Cleaning up " + account.getId()); + s_logger.debug("Cleaning up " + account.getId()); cleanupAccount(account, getSystemUser().getId(), getSystemAccount()); } // cleanup disabled accounts List<AccountVO> disabledAccounts = _accountDao.findCleanupsForDisabledAccounts(); - logger.info("Found " + disabledAccounts.size() + " disabled accounts to cleanup"); + s_logger.info("Found " + disabledAccounts.size() + " disabled accounts to cleanup"); for (AccountVO account : disabledAccounts) { - logger.debug("Disabling account " + account.getId()); + s_logger.debug("Disabling account " + account.getId()); try { disableAccount(account.getId()); } catch (Exception e) { - logger.error("Skipping due to error on account " + account.getId(), e); + s_logger.error("Skipping due to error on account " + account.getId(), e); } } // cleanup inactive domains List<? extends Domain> inactiveDomains = _domainMgr.findInactiveDomains(); - logger.info("Found " + inactiveDomains.size() + " inactive domains to cleanup"); + s_logger.info("Found " + inactiveDomains.size() + " inactive domains to cleanup"); for (Domain inactiveDomain : inactiveDomains) { long domainId = inactiveDomain.getId(); try { @@ -1739,47 +1741,47 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M // release dedication if any, before deleting the domain List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByDomainId(domainId); if (dedicatedResources != null && !dedicatedResources.isEmpty()) { - logger.debug("Releasing dedicated resources for domain" + domainId); + s_logger.debug("Releasing dedicated resources for domain" + domainId); for (DedicatedResourceVO dr : dedicatedResources) { if (!_dedicatedDao.remove(dr.getId())) { - logger.warn("Fail to release dedicated resources for domain " + domainId); + s_logger.warn("Fail to release dedicated resources for domain " + domainId); } } } - logger.debug("Removing inactive domain id=" + domainId); + s_logger.debug("Removing inactive domain id=" + domainId); _domainMgr.removeDomain(domainId); } else { - logger.debug("Can't remove inactive domain id=" + domainId + " as it has accounts that need cleanup"); + s_logger.debug("Can't remove inactive domain id=" + domainId + " as it has accounts that need cleanup"); } } catch (Exception e) { - logger.error("Skipping due to error on domain " + domainId, e); + s_logger.error("Skipping due to error on domain " + domainId, e); } } // cleanup inactive projects List<ProjectVO> inactiveProjects = _projectDao.listByState(Project.State.Disabled); - logger.info("Found " + inactiveProjects.size() + " disabled projects to cleanup"); + s_logger.info("Found " + inactiveProjects.size() + " disabled projects to cleanup"); for (ProjectVO project : inactiveProjects) { try { Account projectAccount = getAccount(project.getProjectAccountId()); if (projectAccount == null) { - logger.debug("Removing inactive project id=" + project.getId()); + s_logger.debug("Removing inactive project id=" + project.getId()); _projectMgr.deleteProject(CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId(), project); } else { - logger.debug("Can't remove disabled project " + project + " as it has non removed account id=" + project.getId()); + s_logger.debug("Can't remove disabled project " + project + " as it has non removed account id=" + project.getId()); } } catch (Exception e) { - logger.error("Skipping due to error on project " + project, e); + s_logger.error("Skipping due to error on project " + project, e); } } } catch (Exception e) { - logger.error("Exception ", e); + s_logger.error("Exception ", e); } finally { lock.unlock(); } } catch (Exception e) { - logger.error("Exception ", e); + s_logger.error("Exception ", e); } } } @@ -1980,8 +1982,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M protected UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String userUUID, User.Source source) { - if (logger.isDebugEnabled()) { - logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone); } String encodedPassword = null; @@ -2063,14 +2065,14 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M timestamp = Long.parseLong(timestampStr); long currentTime = System.currentTimeMillis(); if (Math.abs(currentTime - timestamp) > tolerance) { - if (logger.isDebugEnabled()) { - logger.debug("Expired timestamp passed in to login, current time = " + currentTime + ", timestamp = " + timestamp); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Expired timestamp passed in to login, current time = " + currentTime + ", timestamp = " + timestamp); } return null; } } catch (NumberFormatException nfe) { - if (logger.isDebugEnabled()) { - logger.debug("Invalid timestamp passed in to login: " + timestampStr); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Invalid timestamp passed in to login: " + timestampStr); } return null; } @@ -2084,8 +2086,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M } if ((signature == null) || (timestamp == 0L)) { - if (logger.isDebugEnabled()) { - logger.debug("Missing parameters in login request, signature = " + signature + ", timestamp = " + timestamp); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Missing parameters in login request, signature = " + signature + ", timestamp = " + timestamp); } return null; } @@ -2100,12 +2102,12 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M String computedSignature = new String(Base64.encodeBase64(encryptedBytes)); boolean equalSig = ConstantTimeComparator.compareStrings(signature, computedSignature); if (!equalSig) { - logger.info("User signature: " + signature + " is not equaled to computed signature: " + computedSignature); + s_logger.info("User signature: " + signature + " is not equaled to computed signature: " + computedSignature); } else { user = _userAccountDao.getUserAccount(username, domainId); } } catch (Exception ex) { - logger.error("Exception authenticating user", ex); + s_logger.error("Exception authenticating user", ex); return null; } } @@ -2113,17 +2115,17 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M if (user != null) { // don't allow to authenticate system user if (user.getId() == User.UID_SYSTEM) { - logger.error("Failed to authenticate user: " + username + " in domain " + domainId); + s_logger.error("Failed to authenticate user: " + username + " in domain " + domainId); return null; } // don't allow baremetal system user if (BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME.equals(user.getUsername())) { - logger.error("Won't authenticate user: " + username + " in domain " + domainId); + s_logger.error("Won't authenticate user: " + username + " in domain " + domainId); return null; } - if (logger.isDebugEnabled()) { - logger.debug("User: " + username + " in domain " + domainId + " has successfully logged in"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("User: " + username + " in domain " + domainId + " has successfully logged in"); } ActionEventUtils.onActionEvent(user.getId(), user.getAccountId(), user.getDomainId(), EventTypes.EVENT_USER_LOGIN, "user has logged in from IP Address " + @@ -2131,20 +2133,20 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M return user; } else { - if (logger.isDebugEnabled()) { - logger.debug("User: " + username + " in domain " + domainId + " has failed to log in"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("User: " + username + " in domain " + domainId + " has failed to log in"); } return null; } } private UserAccount getUserAccount(String username, String password, Long domainId, Map<String, Object[]> requestParameters) { - if (logger.isDebugEnabled()) { - logger.debug("Attempting to log in user: " + username + " in domain " + domainId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Attempting to log in user: " + username + " in domain " + domainId); } UserAccount userAccount = _userAccountDao.getUserAccount(username, domainId); if (userAccount == null) { - logger.warn("Unable to find an user with username " + username + " in domain " + domainId); + s_logger.warn("Unable to find an user with username " + username + " in domain " + domainId); return null; } @@ -2178,8 +2180,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M if (!userAccount.getState().equalsIgnoreCase(Account.State.enabled.toString()) || !userAccount.getAccountState().equalsIgnoreCase(Account.State.enabled.toString())) { - if (logger.isInfoEnabled()) { - logger.info("User " + username + " in domain " + domainName + " is disabled/locked (or account is disabled/locked)"); + if (s_logger.isInfoEnabled()) { + s_logger.info("User " + username + " in domain " + domainName + " is disabled/locked (or account is disabled/locked)"); } throw new CloudAuthenticationException("User " + username + " in domain " + domainName + " is disabled/locked (or account is disabled/locked)"); // return null; @@ -2190,8 +2192,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M return userAccount; } else { - if (logger.isDebugEnabled()) { - logger.debug("Unable to authenticate user with username " + username + " in domain " + domainId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Unable to authenticate user with username " + username + " in domain " + domainId); } if (userAccount.getState().equalsIgnoreCase(Account.State.enabled.toString())) { @@ -2201,15 +2203,15 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M if (updateIncorrectLoginCount) { if (attemptsMade < _allowedLoginAttempts) { updateLoginAttempts(userAccount.getId(), attemptsMade, false); - logger.warn("Login attempt failed. You have " + (_allowedLoginAttempts - attemptsMade) + " attempt(s) remaining"); + s_logger.warn("Login attempt failed. You have " + (_allowedLoginAttempts - attemptsMade) + " attempt(s) remaining"); } else { updateLoginAttempts(userAccount.getId(), _allowedLoginAttempts, true); - logger.warn("User " + userAccount.getUsername() + " has been disabled due to multiple failed login attempts." + " Please contact admin."); + s_logger.warn("User " + userAccount.getUsername() + " has been disabled due to multiple failed login attempts." + " Please contact admin."); } } } } else { - logger.info("User " + userAccount.getUsername() + " is disabled/locked"); + s_logger.info("User " + userAccount.getUsername() + " is disabled/locked"); } return null; } @@ -2295,7 +2297,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M _userDao.update(userId, updatedUser); return encodedKey; } catch (NoSuchAlgorithmException ex) { - logger.error("error generating secret key for user id=" + userId, ex); + s_logger.error("error generating secret key for user id=" + userId, ex); } return null; } @@ -2322,7 +2324,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M _userDao.update(userId, updatedUser); return encodedKey; } catch (NoSuchAlgorithmException ex) { - logger.error("error generating secret key for user id=" + userId, ex); + s_logger.error("error generating secret key for user id=" + userId, ex); } return null; } @@ -2690,8 +2692,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M throws PermissionDeniedException { for (SecurityChecker checker : _securityCheckers) { if (checker.checkAccess(account, so)) { - if (logger.isDebugEnabled()) { - logger.debug("Access granted to " + account + " to " + so + " by " + checker.getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Access granted to " + account + " to " + so + " by " + checker.getName()); } return; } @@ -2706,8 +2708,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M throws PermissionDeniedException { for (SecurityChecker checker : _securityCheckers) { if (checker.checkAccess(account, dof)) { - if (logger.isDebugEnabled()) { - logger.debug("Access granted to " + account + " to " + dof + " by " + checker.getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Access granted to " + account + " to " + dof + " by " + checker.getName()); } return; }
