http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java index 5d39e0d..2dcd2e2 100644 --- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java +++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java @@ -27,6 +27,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd; import org.apache.cloudstack.context.CallContext; @@ -101,6 +102,7 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDao; @Component @Local(value = { VMSnapshotManager.class, VMSnapshotService.class }) public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotManager, VMSnapshotService, VmWorkJobHandler { + private static final Logger s_logger = Logger.getLogger(VMSnapshotManagerImpl.class); public static final String VM_WORK_JOB_HANDLER = VMSnapshotManagerImpl.class.getSimpleName(); @@ -339,7 +341,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana return vmSnapshot; } catch (Exception e) { String msg = e.getMessage(); - logger.error("Create vm snapshot record failed for vm: " + vmId + " due to: " + msg); + s_logger.error("Create vm snapshot record failed for vm: " + vmId + " due to: " + msg); } return null; } @@ -435,7 +437,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana VMSnapshot snapshot = strategy.takeVMSnapshot(vmSnapshot); return snapshot; } catch (Exception e) { - logger.debug("Failed to create vm snapshot: " + vmSnapshotId, e); + s_logger.debug("Failed to create vm snapshot: " + vmSnapshotId, e); return null; } } @@ -472,7 +474,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana if (hasActiveVMSnapshotTasks(vmSnapshot.getVmId())) { List<VMSnapshotVO> expungingSnapshots = _vmSnapshotDao.listByInstanceId(vmSnapshot.getVmId(), VMSnapshot.State.Expunging); if (expungingSnapshots.size() > 0 && expungingSnapshots.get(0).getId() == vmSnapshot.getId()) - logger.debug("Target VM snapshot already in expunging state, go on deleting it: " + vmSnapshot.getDisplayName()); + s_logger.debug("Target VM snapshot already in expunging state, go on deleting it: " + vmSnapshot.getDisplayName()); else throw new InvalidParameterValueException("There is other active vm snapshot tasks on the instance, please try again later"); } @@ -534,7 +536,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana if (hasActiveVMSnapshotTasks(vmSnapshot.getVmId())) { List<VMSnapshotVO> expungingSnapshots = _vmSnapshotDao.listByInstanceId(vmSnapshot.getVmId(), VMSnapshot.State.Expunging); if (expungingSnapshots.size() > 0 && expungingSnapshots.get(0).getId() == vmSnapshot.getId()) - logger.debug("Target VM snapshot already in expunging state, go on deleting it: " + vmSnapshot.getDisplayName()); + s_logger.debug("Target VM snapshot already in expunging state, go on deleting it: " + vmSnapshot.getDisplayName()); else throw new InvalidParameterValueException("There is other active vm snapshot tasks on the instance, please try again later"); } @@ -546,7 +548,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana VMSnapshotStrategy strategy = findVMSnapshotStrategy(vmSnapshot); return strategy.deleteVMSnapshot(vmSnapshot); } catch (Exception e) { - logger.debug("Failed to delete vm snapshot: " + vmSnapshotId, e); + s_logger.debug("Failed to delete vm snapshot: " + vmSnapshotId, e); return false; } } @@ -682,7 +684,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana vm = _userVMDao.findById(userVm.getId()); hostId = vm.getHostId(); } catch (Exception e) { - logger.error("Start VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); + s_logger.error("Start VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); throw new CloudRuntimeException(e.getMessage()); } } else { @@ -690,7 +692,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana try { _itMgr.advanceStop(userVm.getUuid(), true); } catch (Exception e) { - logger.error("Stop VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); + s_logger.error("Stop VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); throw new CloudRuntimeException(e.getMessage()); } } @@ -706,7 +708,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana strategy.revertVMSnapshot(vmSnapshotVo); return userVm; } catch (Exception e) { - logger.debug("Failed to revert vmsnapshot: " + vmSnapshotId, e); + s_logger.debug("Failed to revert vmsnapshot: " + vmSnapshotId, e); throw new CloudRuntimeException(e.getMessage()); } } @@ -810,7 +812,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana } } } catch (Exception e) { - logger.error(e.getMessage(), e); + s_logger.error(e.getMessage(), e); if (_vmSnapshotDao.listByInstanceId(vm.getId(), VMSnapshot.State.Expunging).size() == 0) return true; else
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java index ee2c691..d25bddb 100644 --- a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java +++ b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java @@ -27,6 +27,7 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; import com.cloud.utils.fsm.StateMachine2; +import org.apache.log4j.Logger; import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity.ACLType; @@ -72,6 +73,7 @@ import com.cloud.vm.dao.UserVmDao; @Local(value = {AffinityGroupService.class}) public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGroupService, Manager, StateListener<State, VirtualMachine.Event, VirtualMachine> { + public static final Logger s_logger = Logger.getLogger(AffinityGroupServiceImpl.class); private String _name; @Inject @@ -228,8 +230,8 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro } }); - if (logger.isDebugEnabled()) { - logger.debug("Created affinity group =" + affinityGroupName); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Created affinity group =" + affinityGroupName); } return group; @@ -305,8 +307,8 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro Pair<Class<?>, Long> params = new Pair<Class<?>, Long>(AffinityGroup.class, affinityGroupIdFinal); _messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, params); - if (logger.isDebugEnabled()) { - logger.debug("Deleted affinity group id=" + affinityGroupId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Deleted affinity group id=" + affinityGroupId); } return true; } @@ -463,7 +465,7 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro // Check that the VM is stopped if (!vmInstance.getState().equals(State.Stopped)) { - logger.warn("Unable to update affinity groups of the virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState()); + s_logger.warn("Unable to update affinity groups of the virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState()); throw new InvalidParameterValueException("Unable update affinity groups of the virtual machine " + vmInstance.toString() + " " + "in state " + vmInstance.getState() + "; make sure the virtual machine is stopped and not in an error state before updating."); } @@ -489,8 +491,8 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro } } _affinityGroupVMMapDao.updateMap(vmId, affinityGroupIds); - if (logger.isDebugEnabled()) { - logger.debug("Updated VM :" + vmId + " affinity groups to =" + affinityGroupIds); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Updated VM :" + vmId + " affinity groups to =" + affinityGroupIds); } // APIResponseHelper will pull out the updated affinitygroups. return vmInstance; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java b/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java index c912981..bc2f1c4 100644 --- a/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java +++ b/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java @@ -24,6 +24,7 @@ import java.util.Map; import javax.ejb.Local; import javax.inject.Inject; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.acl.SecurityChecker.AccessType; @@ -80,6 +81,7 @@ import com.cloud.utils.net.NetUtils; @Component @Local(value = {ApplicationLoadBalancerService.class}) public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements ApplicationLoadBalancerService { + private static final Logger s_logger = Logger.getLogger(ApplicationLoadBalancerManagerImpl.class); @Inject NetworkModel _networkModel; @@ -182,7 +184,7 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A if (!_firewallDao.setStateToAdd(newRule)) { throw new CloudRuntimeException("Unable to update the state to add for " + newRule); } - logger.debug("Load balancer " + newRule.getId() + " for Ip address " + newRule.getSourceIp().addr() + ", source port " + + s_logger.debug("Load balancer " + newRule.getId() + " for Ip address " + newRule.getSourceIp().addr() + ", source port " + newRule.getSourcePortStart().intValue() + ", instance port " + newRule.getDefaultPortStart() + " is added successfully."); CallContext.current().setEventDetails("Load balancer Id: " + newRule.getId()); Network ntwk = _networkModel.getNetwork(newRule.getNetworkId()); @@ -259,7 +261,7 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A if (requestedIp != null) { if (_lbDao.countBySourceIp(new Ip(requestedIp), sourceIpNtwk.getId()) > 0) { - logger.debug("IP address " + requestedIp + " is already used by existing LB rule, returning it"); + s_logger.debug("IP address " + requestedIp + " is already used by existing LB rule, returning it"); return new Ip(requestedIp); } @@ -530,8 +532,8 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A } } - if (logger.isDebugEnabled()) { - logger.debug("No network rule conflicts detected for " + newLbRule + " against " + (lbRules.size() - 1) + " existing rules"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("No network rule conflicts detected for " + newLbRule + " against " + (lbRules.size() - 1) + " existing rules"); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/org/apache/cloudstack/region/RegionManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/org/apache/cloudstack/region/RegionManagerImpl.java b/server/src/org/apache/cloudstack/region/RegionManagerImpl.java index ae8bc4b..8910714 100644 --- a/server/src/org/apache/cloudstack/region/RegionManagerImpl.java +++ b/server/src/org/apache/cloudstack/region/RegionManagerImpl.java @@ -25,6 +25,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd; @@ -49,6 +50,7 @@ import com.cloud.utils.db.DbProperties; @Component @Local(value = {RegionManager.class}) public class RegionManagerImpl extends ManagerBase implements RegionManager, Manager { + public static final Logger s_logger = Logger.getLogger(RegionManagerImpl.class); @Inject RegionDao _regionDao; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/src/org/apache/cloudstack/region/RegionServiceImpl.java ---------------------------------------------------------------------- diff --git a/server/src/org/apache/cloudstack/region/RegionServiceImpl.java b/server/src/org/apache/cloudstack/region/RegionServiceImpl.java index 03eb217..98cf500 100644 --- a/server/src/org/apache/cloudstack/region/RegionServiceImpl.java +++ b/server/src/org/apache/cloudstack/region/RegionServiceImpl.java @@ -23,6 +23,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import org.apache.cloudstack.api.command.admin.account.DeleteAccountCmd; @@ -48,6 +49,7 @@ import com.cloud.utils.component.ManagerBase; @Component @Local(value = {RegionService.class}) public class RegionServiceImpl extends ManagerBase implements RegionService, Manager { + public static final Logger s_logger = Logger.getLogger(RegionServiceImpl.class); @Inject private RegionManager _regionMgr; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/test/com/cloud/consoleproxy/ConsoleProxyManagerTest.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/consoleproxy/ConsoleProxyManagerTest.java b/server/test/com/cloud/consoleproxy/ConsoleProxyManagerTest.java index f9adece..fd12d23 100644 --- a/server/test/com/cloud/consoleproxy/ConsoleProxyManagerTest.java +++ b/server/test/com/cloud/consoleproxy/ConsoleProxyManagerTest.java @@ -43,7 +43,6 @@ public class ConsoleProxyManagerTest { public void setup() throws Exception { MockitoAnnotations.initMocks(this); ReflectionTestUtils.setField(cpvmManager, "_allocProxyLock", globalLock); - ReflectionTestUtils.setField(cpvmManager, "logger", Logger.getLogger(ConsoleProxyManagerImpl.class)); Mockito.doCallRealMethod().when(cpvmManager).expandPool(Mockito.anyLong(), Mockito.anyObject()); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/test/com/cloud/vpc/MockNetworkManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java index 7441d57..111df93 100644 --- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java @@ -34,6 +34,7 @@ import org.apache.cloudstack.api.command.user.network.ListNetworksCmd; import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd; import org.apache.cloudstack.api.command.user.vm.ListNicsCmd; import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; +import org.apache.log4j.Logger; import org.springframework.stereotype.Component; import com.cloud.deploy.DataCenterDeployment; @@ -92,6 +93,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches List<NetworkElement> _networkElements; private static HashMap<String, String> s_providerToNetworkElementMap = new HashMap<String, String>(); + private static final Logger s_logger = Logger.getLogger(MockNetworkManagerImpl.class); /* (non-Javadoc) * @see com.cloud.utils.component.Manager#start() @@ -102,7 +104,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches Provider implementedProvider = element.getProvider(); if (implementedProvider != null) { if (s_providerToNetworkElementMap.containsKey(implementedProvider.getName())) { - logger.error("Cannot start MapNetworkManager: Provider <-> NetworkElement must be a one-to-one map, " + + s_logger.error("Cannot start MapNetworkManager: Provider <-> NetworkElement must be a one-to-one map, " + "multiple NetworkElements found for Provider: " + implementedProvider.getName()); return false; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java b/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java index 07b067d..7ea0a80 100644 --- a/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java +++ b/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java @@ -21,6 +21,7 @@ import java.util.List; import javax.ejb.Local; +import org.apache.log4j.Logger; import com.cloud.network.Network; import com.cloud.network.Network.GuestType; @@ -36,6 +37,7 @@ import com.cloud.utils.db.DB; @Local(value = NetworkOfferingDao.class) @DB() public class MockNetworkOfferingDaoImpl extends NetworkOfferingDaoImpl implements NetworkOfferingDao { + private static final Logger s_logger = Logger.getLogger(MockNetworkOfferingDaoImpl.class); /* (non-Javadoc) * @see com.cloud.offerings.dao.NetworkOfferingDao#findByUniqueName(java.lang.String) @@ -142,10 +144,10 @@ public class MockNetworkOfferingDaoImpl extends NetworkOfferingDaoImpl implement f.setAccessible(true); f.setLong(voToReturn, id); } catch (NoSuchFieldException ex) { - logger.warn(ex); + s_logger.warn(ex); return null; } catch (IllegalAccessException ex) { - logger.warn(ex); + s_logger.warn(ex); return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java b/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java index 3220979..a436a92 100644 --- a/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java +++ b/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java @@ -22,6 +22,7 @@ import java.util.Map; import javax.ejb.Local; +import org.apache.log4j.Logger; import com.cloud.network.vpc.Vpc; import com.cloud.network.vpc.Vpc.State; @@ -33,6 +34,7 @@ import com.cloud.utils.db.GenericDaoBase; @Local(value = VpcDao.class) @DB() public class MockVpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements VpcDao { + private static final Logger s_logger = Logger.getLogger(MockNetworkOfferingDaoImpl.class); /* (non-Javadoc) * @see com.cloud.network.vpc.Dao.VpcDao#getVpcCountByOfferingId(long) @@ -115,10 +117,10 @@ public class MockVpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements VpcDa f.setAccessible(true); f.setLong(voToReturn, id); } catch (NoSuchFieldException ex) { - logger.warn(ex); + s_logger.warn(ex); return null; } catch (IllegalAccessException ex) { - logger.warn(ex); + s_logger.warn(ex); return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java ---------------------------------------------------------------------- diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index af9f3c7..dd81809 100644 --- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -44,6 +44,7 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreVO; import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao; import org.apache.cloudstack.utils.identity.ManagementServerNode; +import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.agent.api.Answer; @@ -163,6 +164,7 @@ import com.cloud.vm.dao.VMInstanceDao; @Local(value = {SecondaryStorageVmManager.class}) public class SecondaryStorageManagerImpl extends ManagerBase implements SecondaryStorageVmManager, VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter { + private static final Logger s_logger = Logger.getLogger(SecondaryStorageManagerImpl.class); private static final int DEFAULT_CAPACITY_SCAN_INTERVAL = 30000; // 30 // seconds @@ -260,16 +262,16 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _itMgr.advanceStart(secStorageVm.getUuid(), null, null); return _secStorageVmDao.findById(secStorageVm.getId()); } catch (StorageUnavailableException e) { - logger.warn("Exception while trying to start secondary storage vm", e); + s_logger.warn("Exception while trying to start secondary storage vm", e); return null; } catch (InsufficientCapacityException e) { - logger.warn("Exception while trying to start secondary storage vm", e); + s_logger.warn("Exception while trying to start secondary storage vm", e); return null; } catch (ResourceUnavailableException e) { - logger.warn("Exception while trying to start secondary storage vm", e); + s_logger.warn("Exception while trying to start secondary storage vm", e); return null; } catch (Exception e) { - logger.warn("Exception while trying to start secondary storage vm", e); + s_logger.warn("Exception while trying to start secondary storage vm", e); return null; } } @@ -289,7 +291,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findByInstanceName(cssHost.getName()); if (secStorageVm == null) { - logger.warn("secondary storage VM " + cssHost.getName() + " doesn't exist"); + s_logger.warn("secondary storage VM " + cssHost.getName() + " doesn't exist"); return false; } @@ -320,12 +322,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar svo.setParent(an.get_dir()); _imageStoreDao.update(ssStore.getId(), svo); } - if (logger.isDebugEnabled()) { - logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName()); } } else { - if (logger.isDebugEnabled()) { - logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName()); } return false; } @@ -340,12 +342,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar HostVO host = _resourceMgr.findHostByName(ssVm.getInstanceName()); Answer answer = _agentMgr.easySend(host.getId(), setupCmd); if (answer != null && answer.getResult()) { - if (logger.isDebugEnabled()) { - logger.debug("Successfully programmed secondary storage " + host.getName() + " in secondary storage VM " + ssVm.getInstanceName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully programmed secondary storage " + host.getName() + " in secondary storage VM " + ssVm.getInstanceName()); } } else { - if (logger.isDebugEnabled()) { - logger.debug("Successfully programmed secondary storage " + host.getName() + " in secondary storage VM " + ssVm.getInstanceName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully programmed secondary storage " + host.getName() + " in secondary storage VM " + ssVm.getInstanceName()); } return false; } @@ -363,7 +365,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findByInstanceName(ssAHost.getName()); if (secStorageVm == null) { - logger.warn("secondary storage VM " + ssAHost.getName() + " doesn't exist"); + s_logger.warn("secondary storage VM " + ssAHost.getName() + " doesn't exist"); return false; } @@ -383,13 +385,13 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar setupCmd.setCopyUserName(TemplateConstants.DEFAULT_HTTP_AUTH_USER); Answer answer = _agentMgr.easySend(ssAHostId, setupCmd); if (answer != null && answer.getResult()) { - if (logger.isDebugEnabled()) { - logger.debug("Successfully programmed http auth into " + secStorageVm.getHostName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully programmed http auth into " + secStorageVm.getHostName()); } return true; } else { - if (logger.isDebugEnabled()) { - logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getHostName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getHostName()); } return false; } @@ -409,7 +411,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar SecondaryStorageVmVO thisSecStorageVm = _secStorageVmDao.findByInstanceName(ssAHost.getName()); if (thisSecStorageVm == null) { - logger.warn("secondary storage VM " + ssAHost.getName() + " doesn't exist"); + s_logger.warn("secondary storage VM " + ssAHost.getName() + " doesn't exist"); return false; } @@ -427,12 +429,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } Answer answer = _agentMgr.easySend(ssvm.getId(), thiscpc); if (answer != null && answer.getResult()) { - if (logger.isDebugEnabled()) { - logger.debug("Successfully programmed firewall rules into SSVM " + ssvm.getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully programmed firewall rules into SSVM " + ssvm.getName()); } } else { - if (logger.isDebugEnabled()) { - logger.debug("failed to program firewall rules into secondary storage vm : " + ssvm.getName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("failed to program firewall rules into secondary storage vm : " + ssvm.getName()); } return false; } @@ -448,12 +450,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar Answer answer = _agentMgr.easySend(ssAHostId, allSSVMIpList); if (answer != null && answer.getResult()) { - if (logger.isDebugEnabled()) { - logger.debug("Successfully programmed firewall rules into " + thisSecStorageVm.getHostName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully programmed firewall rules into " + thisSecStorageVm.getHostName()); } } else { - if (logger.isDebugEnabled()) { - logger.debug("failed to program firewall rules into secondary storage vm : " + thisSecStorageVm.getHostName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("failed to program firewall rules into secondary storage vm : " + thisSecStorageVm.getHostName()); } return false; } @@ -475,21 +477,21 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar public SecondaryStorageVmVO startNew(long dataCenterId, SecondaryStorageVm.Role role) { if (!isSecondaryStorageVmRequired(dataCenterId)) { - if (logger.isDebugEnabled()) { - logger.debug("Secondary storage vm not required in zone " + dataCenterId + " acc. to zone config"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Secondary storage vm not required in zone " + dataCenterId + " acc. to zone config"); } return null; } - if (logger.isDebugEnabled()) { - logger.debug("Assign secondary storage vm from a newly started instance for request from data center : " + dataCenterId); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Assign secondary storage vm from a newly started instance for request from data center : " + dataCenterId); } Map<String, Object> context = createSecStorageVmInstance(dataCenterId, role); long secStorageVmId = (Long)context.get("secStorageVmId"); if (secStorageVmId == 0) { - if (logger.isTraceEnabled()) { - logger.trace("Creating secondary storage vm instance failed, data center id : " + dataCenterId); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Creating secondary storage vm instance failed, data center id : " + dataCenterId); } return null; @@ -503,8 +505,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_CREATED, dataCenterId, secStorageVmId, secStorageVm, null)); return secStorageVm; } else { - if (logger.isDebugEnabled()) { - logger.debug("Unable to allocate secondary storage vm storage, remove the secondary storage vm record from DB, secondary storage vm id: " + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Unable to allocate secondary storage vm storage, remove the secondary storage vm record from DB, secondary storage vm id: " + secStorageVmId); } SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this, @@ -517,7 +519,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar DataStore secStore = _dataStoreMgr.getImageStore(dataCenterId); if (secStore == null) { String msg = "No secondary storage available in zone " + dataCenterId + ", cannot create secondary storage vm"; - logger.warn(msg); + s_logger.warn(msg); throw new CloudRuntimeException(msg); } @@ -563,7 +565,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar networks.put(_networkMgr.setupNetwork(systemAcct, offering, plan, null, null, false).get(0), new ArrayList<NicProfile>()); } } catch (ConcurrentOperationException e) { - logger.info("Unable to setup due to concurrent operation. " + e); + s_logger.info("Unable to setup due to concurrent operation. " + e); return new HashMap<String, Object>(); } @@ -587,7 +589,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _itMgr.allocate(name, template, serviceOffering, networks, plan, null); secStorageVm = _secStorageVmDao.findById(secStorageVm.getId()); } catch (InsufficientCapacityException e) { - logger.warn("InsufficientCapacity", e); + s_logger.warn("InsufficientCapacity", e); throw new CloudRuntimeException("Insufficient capacity exception", e); } @@ -612,18 +614,18 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar public SecondaryStorageVmVO assignSecStorageVmFromRunningPool(long dataCenterId, SecondaryStorageVm.Role role) { - if (logger.isTraceEnabled()) { - logger.trace("Assign secondary storage vm from running pool for request from data center : " + dataCenterId); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Assign secondary storage vm from running pool for request from data center : " + dataCenterId); } SecondaryStorageVmAllocator allocator = getCurrentAllocator(); assert (allocator != null); List<SecondaryStorageVmVO> runningList = _secStorageVmDao.getSecStorageVmListInStates(role, dataCenterId, State.Running); if (runningList != null && runningList.size() > 0) { - if (logger.isTraceEnabled()) { - logger.trace("Running secondary storage vm pool size : " + runningList.size()); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Running secondary storage vm pool size : " + runningList.size()); for (SecondaryStorageVmVO secStorageVm : runningList) { - logger.trace("Running secStorageVm instance : " + secStorageVm.getHostName()); + s_logger.trace("Running secStorageVm instance : " + secStorageVm.getHostName()); } } @@ -631,8 +633,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar return allocator.allocSecondaryStorageVm(runningList, loadInfo, dataCenterId); } else { - if (logger.isTraceEnabled()) { - logger.trace("Empty running secStorageVm pool for now in data center : " + dataCenterId); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Empty running secStorageVm pool for now in data center : " + dataCenterId); } } return null; @@ -648,13 +650,13 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } private void allocCapacity(long dataCenterId, SecondaryStorageVm.Role role) { - if (logger.isTraceEnabled()) { - logger.trace("Allocate secondary storage vm standby capacity for data center : " + dataCenterId); + if (s_logger.isTraceEnabled()) { + s_logger.trace("Allocate secondary storage vm standby capacity for data center : " + dataCenterId); } if (!isSecondaryStorageVmRequired(dataCenterId)) { - if (logger.isDebugEnabled()) { - logger.debug("Secondary storage vm not required in zone " + dataCenterId + " according to zone config"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Secondary storage vm not required in zone " + dataCenterId + " according to zone config"); } return; } @@ -664,8 +666,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar boolean secStorageVmFromStoppedPool = false; secStorageVm = assignSecStorageVmFromStoppedPool(dataCenterId, role); if (secStorageVm == null) { - if (logger.isInfoEnabled()) { - logger.info("No stopped secondary storage vm is available, need to allocate a new secondary storage vm"); + if (s_logger.isInfoEnabled()) { + s_logger.info("No stopped secondary storage vm is available, need to allocate a new secondary storage vm"); } if (_allocLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) { @@ -678,14 +680,14 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _allocLock.unlock(); } } else { - if (logger.isInfoEnabled()) { - logger.info("Unable to acquire synchronization lock for secondary storage vm allocation, wait for next scan"); + if (s_logger.isInfoEnabled()) { + s_logger.info("Unable to acquire synchronization lock for secondary storage vm allocation, wait for next scan"); } return; } } else { - if (logger.isInfoEnabled()) { - logger.info("Found a stopped secondary storage vm, starting it. Vm id : " + secStorageVm.getId()); + if (s_logger.isInfoEnabled()) { + s_logger.info("Found a stopped secondary storage vm, starting it. Vm id : " + secStorageVm.getId()); } secStorageVmFromStoppedPool = true; } @@ -701,8 +703,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar secStorageVmLock.unlock(); } } else { - if (logger.isInfoEnabled()) { - logger.info("Unable to acquire synchronization lock for starting secondary storage vm id : " + secStorageVm.getId()); + if (s_logger.isInfoEnabled()) { + s_logger.info("Unable to acquire synchronization lock for starting secondary storage vm id : " + secStorageVm.getId()); } return; } @@ -711,8 +713,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } if (secStorageVm == null) { - if (logger.isInfoEnabled()) { - logger.info("Unable to start secondary storage vm for standby capacity, vm id : " + secStorageVmId + ", will recycle it and start a new one"); + if (s_logger.isInfoEnabled()) { + s_logger.info("Unable to start secondary storage vm for standby capacity, vm id : " + secStorageVmId + ", will recycle it and start a new one"); } if (secStorageVmFromStoppedPool) { @@ -721,8 +723,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } else { SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this, new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_UP, dataCenterId, secStorageVmId, secStorageVm, null)); - if (logger.isInfoEnabled()) { - logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started"); + if (s_logger.isInfoEnabled()) { + s_logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started"); } } } @@ -743,22 +745,22 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar if (zoneHostInfo != null && (zoneHostInfo.getFlags() & RunningHostInfoAgregator.ZoneHostInfo.ROUTING_HOST_MASK) != 0) { VMTemplateVO template = _templateDao.findSystemVMReadyTemplate(dataCenterId, HypervisorType.Any); if (template == null) { - if (logger.isDebugEnabled()) { - logger.debug("System vm template is not ready at data center " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("System vm template is not ready at data center " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); } return false; } List<DataStore> stores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(dataCenterId)); if (stores.size() < 1) { - logger.debug("No image store added in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); + s_logger.debug("No image store added in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); return false; } DataStore store = templateMgr.getImageStore(dataCenterId, template.getId()); if (store == null) { - if (logger.isDebugEnabled()) { - logger.debug("No secondary storage available in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("No secondary storage available in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); } return false; } @@ -772,8 +774,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) { return true; } else { - if (logger.isDebugEnabled()) { - logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + + if (s_logger.isDebugEnabled()) { + s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + ", " + ConfigurationManagerImpl.SystemVMUseLocalStorage.key() + ": " + useLocalStorage + ". " + "If you want to use local storage to start SSVM, need to set " + ConfigurationManagerImpl.SystemVMUseLocalStorage.key() + " to true"); } @@ -799,8 +801,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar @Override public boolean start() { - if (logger.isInfoEnabled()) { - logger.info("Start secondary storage vm manager"); + if (s_logger.isInfoEnabled()) { + s_logger.info("Start secondary storage vm manager"); } return true; @@ -816,8 +818,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { - if (logger.isInfoEnabled()) { - logger.info("Start configuring secondary storage vm manager : " + name); + if (s_logger.isInfoEnabled()) { + s_logger.info("Start configuring secondary storage vm manager : " + name); } Map<String, String> configs = _configDao.getConfiguration("management-server", params); @@ -837,7 +839,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar //default to HTTP in case of missing domain String ssvmUrlDomain = _configDao.getValue("secstorage.ssl.cert.domain"); if(_useSSlCopy && (ssvmUrlDomain == null || ssvmUrlDomain.isEmpty())){ - logger.warn("Empty secondary storage url domain, explicitly disabling SSL"); + s_logger.warn("Empty secondary storage url domain, explicitly disabling SSL"); _useSSlCopy = false; } @@ -869,11 +871,11 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar try { _serviceOffering = _offeringDao.findById(Long.parseLong(ssvmSrvcOffIdStr)); } catch (NumberFormatException ex) { - logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); + s_logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); } } if (_serviceOffering == null) { - logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); + s_logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); } } @@ -886,7 +888,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar // this can sometimes happen, if DB is manually or programmatically manipulated if (offerings == null || offerings.size() < 2) { String msg = "Data integrity problem : System Offering For Secondary Storage VM has been removed?"; - logger.error(msg); + s_logger.error(msg); throw new ConfigurationException(msg); } } @@ -915,13 +917,13 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar errMsg = e.toString(); } finally { if (!valid) { - logger.debug("ssvm http proxy " + _httpProxy + " is invalid: " + errMsg); + s_logger.debug("ssvm http proxy " + _httpProxy + " is invalid: " + errMsg); throw new ConfigurationException("ssvm http proxy " + _httpProxy + "is invalid: " + errMsg); } } } - if (logger.isInfoEnabled()) { - logger.info("Secondary storage vm Manager is configured."); + if (s_logger.isInfoEnabled()) { + s_logger.info("Secondary storage vm Manager is configured."); } _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return true; @@ -932,8 +934,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId); if (secStorageVm == null) { String msg = "Stopping secondary storage vm failed: secondary storage vm " + secStorageVmId + " no longer exists"; - if (logger.isDebugEnabled()) { - logger.debug(msg); + if (s_logger.isDebugEnabled()) { + s_logger.debug(msg); } return false; } @@ -950,7 +952,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } } else { String msg = "Unable to acquire secondary storage vm lock : " + secStorageVm.toString(); - logger.debug(msg); + s_logger.debug(msg); return false; } } finally { @@ -961,8 +963,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar // vm was already stopped, return true return true; } catch (ResourceUnavailableException e) { - if (logger.isDebugEnabled()) { - logger.debug("Stopping secondary storage vm " + secStorageVm.getHostName() + " faled : exception " + e.toString()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Stopping secondary storage vm " + secStorageVm.getHostName() + " faled : exception " + e.toString()); } return false; } @@ -981,8 +983,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar final Answer answer = _agentMgr.easySend(secStorageVm.getHostId(), cmd); if (answer != null && answer.getResult()) { - if (logger.isDebugEnabled()) { - logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName()); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName()); } SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this, @@ -991,8 +993,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar return true; } else { String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getHostName(); - if (logger.isDebugEnabled()) { - logger.debug(msg); + if (s_logger.isDebugEnabled()) { + s_logger.debug(msg); } return false; } @@ -1010,7 +1012,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _secStorageVmDao.remove(ssvm.getId()); HostVO host = _hostDao.findByTypeNameAndZoneId(ssvm.getDataCenterId(), ssvm.getHostName(), Host.Type.SecondaryStorageVM); if (host != null) { - logger.debug("Removing host entry for ssvm id=" + vmId); + s_logger.debug("Removing host entry for ssvm id=" + vmId); _hostDao.remove(host.getId()); //Expire the download urls in the entire zone for templates and volumes. _tmplStoreDao.expireDnldUrlsForZone(host.getDataCenterId()); @@ -1019,7 +1021,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } return false; } catch (ResourceUnavailableException e) { - logger.warn("Unable to expunge " + ssvm, e); + s_logger.warn("Unable to expunge " + ssvm, e); return false; } } @@ -1062,7 +1064,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar buf.append(" workers=").append(_configDao.getValue("workers")); if (_configDao.isPremium()) { - logger.debug("VmWare hypervisor configured, telling the ssvm to load the PremiumSecondaryStorageResource"); + s_logger.debug("VmWare hypervisor configured, telling the ssvm to load the PremiumSecondaryStorageResource"); buf.append(" resource=com.cloud.storage.resource.PremiumSecondaryStorageResource"); } else { buf.append(" resource=org.apache.cloudstack.storage.resource.NfsSecondaryStorageResource"); @@ -1127,8 +1129,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } String bootArgs = buf.toString(); - if (logger.isDebugEnabled()) { - logger.debug("Boot Args for " + profile + ": " + bootArgs); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Boot Args for " + profile + ": " + bootArgs); } return true; @@ -1172,7 +1174,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar if (controlNic == null) { if (managementNic == null) { - logger.error("Management network doesn't exist for the secondaryStorageVm " + profile.getVirtualMachine()); + s_logger.error("Management network doesn't exist for the secondaryStorageVm " + profile.getVirtualMachine()); return false; } controlNic = managementNic; @@ -1193,7 +1195,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar public boolean finalizeStart(VirtualMachineProfile profile, long hostId, Commands cmds, ReservationContext context) { CheckSshAnswer answer = (CheckSshAnswer)cmds.getAnswer("checkSsh"); if (!answer.getResult()) { - logger.warn("Unable to ssh to the VM: " + answer.getDetails()); + s_logger.warn("Unable to ssh to the VM: " + answer.getDetails()); return false; } @@ -1208,7 +1210,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _secStorageVmDao.update(secVm.getId(), secVm); } } catch (Exception ex) { - logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", ex); + s_logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", ex); return false; } @@ -1224,7 +1226,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar try { _rulesMgr.disableStaticNat(ip.getId(), ctx.getCallingAccount(), ctx.getCallingUserId(), true); } catch (Exception ex) { - logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", + s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex); } } @@ -1274,14 +1276,14 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar long dataCenterId = pool.longValue(); if (!isZoneReady(_zoneHostInfoMap, dataCenterId)) { - if (logger.isDebugEnabled()) { - logger.debug("Zone " + dataCenterId + " is not ready to launch secondary storage VM yet"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Zone " + dataCenterId + " is not ready to launch secondary storage VM yet"); } return false; } - if (logger.isDebugEnabled()) { - logger.debug("Zone " + dataCenterId + " is ready to launch secondary storage VM"); + if (s_logger.isDebugEnabled()) { + s_logger.debug("Zone " + dataCenterId + " is ready to launch secondary storage VM"); } return true; } @@ -1297,7 +1299,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar List<DataStore> ssStores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(dataCenterId)); int storeSize = (ssStores == null) ? 0 : ssStores.size(); if (storeSize > vmSize) { - logger.info("No secondary storage vms found in datacenter id=" + dataCenterId + ", starting a new one"); + s_logger.info("No secondary storage vms found in datacenter id=" + dataCenterId + ", starting a new one"); return new Pair<AfterScanAction, Object>(AfterScanAction.expand, SecondaryStorageVm.Role.templateProcessor); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java ---------------------------------------------------------------------- diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java index ed6066e..ee50647 100644 --- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java +++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java @@ -30,6 +30,7 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import com.cloud.agent.AgentManager; import com.cloud.host.HostVO; @@ -54,6 +55,7 @@ import com.cloud.utils.script.Script; */ @Local(value = Discoverer.class) public class SecondaryStorageDiscoverer extends DiscovererBase implements Discoverer { + private static final Logger s_logger = Logger.getLogger(SecondaryStorageDiscoverer.class); long _timeout = 2 * 60 * 1000; // 2 minutes String _mountParent; @@ -77,7 +79,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov find(long dcId, Long podId, Long clusterId, URI uri, String username, String password, List<String> hostTags) { if (!uri.getScheme().equalsIgnoreCase("nfs") && !uri.getScheme().equalsIgnoreCase("cifs") && !uri.getScheme().equalsIgnoreCase("file") && !uri.getScheme().equalsIgnoreCase("iso") && !uri.getScheme().equalsIgnoreCase("dummy")) { - logger.debug("It's not NFS or file or ISO, so not a secondary storage server: " + uri.toString()); + s_logger.debug("It's not NFS or file or ISO, so not a secondary storage server: " + uri.toString()); return null; } @@ -99,7 +101,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov } String mountStr = NfsUtils.uri2Mount(uri); - Script script = new Script(true, "mount", _timeout, logger); + Script script = new Script(true, "mount", _timeout, s_logger); String mntPoint = null; File file = null; do { @@ -108,19 +110,19 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov } while (file.exists()); if (!file.mkdirs()) { - logger.warn("Unable to make directory: " + mntPoint); + s_logger.warn("Unable to make directory: " + mntPoint); return null; } script.add(mountStr, mntPoint); String result = script.execute(); if (result != null && !result.contains("already mounted")) { - logger.warn("Unable to mount " + uri.toString() + " due to " + result); + s_logger.warn("Unable to mount " + uri.toString() + " due to " + result); file.delete(); return null; } - script = new Script(true, "umount", 0, logger); + script = new Script(true, "umount", 0, s_logger); script.add(mntPoint); script.execute(); @@ -138,25 +140,25 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov constructor.setAccessible(true); storage = (NfsSecondaryStorageResource)constructor.newInstance(); } catch (final ClassNotFoundException e) { - logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to ClassNotFoundException"); + s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to ClassNotFoundException"); return null; } catch (final SecurityException e) { - logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to SecurityException"); + s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to SecurityException"); return null; } catch (final NoSuchMethodException e) { - logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to NoSuchMethodException"); + s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to NoSuchMethodException"); return null; } catch (final IllegalArgumentException e) { - logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to IllegalArgumentException"); + s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to IllegalArgumentException"); return null; } catch (final InstantiationException e) { - logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to InstantiationException"); + s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to InstantiationException"); return null; } catch (final IllegalAccessException e) { - logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to IllegalAccessException"); + s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to IllegalAccessException"); return null; } catch (final InvocationTargetException e) { - logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to InvocationTargetException"); + s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to InvocationTargetException"); return null; } } else { @@ -181,7 +183,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov try { storage.configure("Storage", params); } catch (ConfigurationException e) { - logger.warn("Unable to configure the storage ", e); + s_logger.warn("Unable to configure the storage ", e); return null; } srs.put(storage, details); @@ -212,7 +214,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov try { storage.configure("Storage", params); } catch (ConfigurationException e) { - logger.warn("Unable to configure the storage ", e); + s_logger.warn("Unable to configure the storage ", e); return null; } srs.put(storage, details); @@ -242,7 +244,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov try { storage.configure("Storage", params); } catch (ConfigurationException e) { - logger.warn("Unable to configure the storage ", e); + s_logger.warn("Unable to configure the storage ", e); return null; } srs.put(storage, details); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8bc02940/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java ---------------------------------------------------------------------- diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java index 447c4c1..25c0887 100644 --- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java +++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java @@ -41,6 +41,7 @@ import java.util.concurrent.Executors; import javax.ejb.Local; import javax.naming.ConfigurationException; +import org.apache.log4j.Logger; import org.apache.cloudstack.storage.command.DownloadCommand; import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType; @@ -216,6 +217,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager } } + public static final Logger s_logger = Logger.getLogger(DownloadManagerImpl.class); private String _templateDir; private String _volumeDir; private String createTmpltScr; @@ -248,12 +250,12 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager public void setDownloadStatus(String jobId, Status status) { DownloadJob dj = jobs.get(jobId); if (dj == null) { - logger.warn("setDownloadStatus for jobId: " + jobId + ", status=" + status + " no job found"); + s_logger.warn("setDownloadStatus for jobId: " + jobId + ", status=" + status + " no job found"); return; } TemplateDownloader td = dj.getTemplateDownloader(); - logger.info("Download Completion for jobId: " + jobId + ", status=" + status); - logger.info("local: " + td.getDownloadLocalPath() + ", bytes=" + td.getDownloadedBytes() + ", error=" + td.getDownloadError() + ", pct=" + + s_logger.info("Download Completion for jobId: " + jobId + ", status=" + status); + s_logger.info("local: " + td.getDownloadLocalPath() + ", bytes=" + td.getDownloadedBytes() + ", error=" + td.getDownloadError() + ", pct=" + td.getDownloadPercent()); switch (status) { @@ -266,7 +268,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager case UNKNOWN: return; case IN_PROGRESS: - logger.info("Resuming jobId: " + jobId + ", status=" + status); + s_logger.info("Resuming jobId: " + jobId + ", status=" + status); td.setResume(true); threadPool.execute(td); break; @@ -280,7 +282,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager td.setDownloadError("Download success, starting install "); String result = postDownload(jobId); if (result != null) { - logger.error("Failed post download script: " + result); + s_logger.error("Failed post download script: " + result); td.setStatus(Status.UNRECOVERABLE_ERROR); td.setDownloadError("Failed post download script: " + result); } else { @@ -355,7 +357,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager File originalTemplate = new File(td.getDownloadLocalPath()); String checkSum = computeCheckSum(originalTemplate); if (checkSum == null) { - logger.warn("Something wrong happened when try to calculate the checksum of downloaded template!"); + s_logger.warn("Something wrong happened when try to calculate the checksum of downloaded template!"); } dnld.setCheckSum(checkSum); @@ -364,7 +366,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager long timeout = (long)imgSizeGigs * installTimeoutPerGig; Script scr = null; String script = resourceType == ResourceType.TEMPLATE ? createTmpltScr : createVolScr; - scr = new Script(script, timeout, logger); + scr = new Script(script, timeout, s_logger); scr.add("-s", Integer.toString(imgSizeGigs)); scr.add("-S", Long.toString(td.getMaxTemplateSizeInBytes())); if (dnld.getDescription() != null && dnld.getDescription().length() > 1) { @@ -421,7 +423,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager try { loc.create(dnld.getId(), true, dnld.getTmpltName()); } catch (IOException e) { - logger.warn("Something is wrong with template location " + resourcePath, e); + s_logger.warn("Something is wrong with template location " + resourcePath, e); loc.purge(); return "Unable to download due to " + e.getMessage(); } @@ -434,7 +436,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager try { info = processor.process(resourcePath, null, templateName); } catch (InternalErrorException e) { - logger.error("Template process exception ", e); + s_logger.error("Template process exception ", e); return e.toString(); } if (info != null) { @@ -446,7 +448,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager } if (!loc.save()) { - logger.warn("Cleaning up because we're unable to save the formats"); + s_logger.warn("Cleaning up because we're unable to save the formats"); loc.purge(); } @@ -505,7 +507,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager try { if (!_storage.mkdirs(tmpDir)) { - logger.warn("Unable to create " + tmpDir); + s_logger.warn("Unable to create " + tmpDir); return "Unable to create " + tmpDir; } // TO DO - define constant for volume properties. @@ -517,7 +519,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager } if (!file.createNewFile()) { - logger.warn("Unable to create new file: " + file.getAbsolutePath()); + s_logger.warn("Unable to create new file: " + file.getAbsolutePath()); return "Unable to create new file: " + file.getAbsolutePath(); } @@ -557,7 +559,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager return jobId; } catch (IOException e) { - logger.warn("Unable to download to " + tmpDir, e); + s_logger.warn("Unable to download to " + tmpDir, e); return null; } } @@ -751,24 +753,24 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager private List<String> listVolumes(String rootdir) { List<String> result = new ArrayList<String>(); - Script script = new Script(listVolScr, logger); + Script script = new Script(listVolScr, s_logger); script.add("-r", rootdir); ZfsPathParser zpp = new ZfsPathParser(rootdir); script.execute(zpp); result.addAll(zpp.getPaths()); - logger.info("found " + zpp.getPaths().size() + " volumes" + zpp.getPaths()); + s_logger.info("found " + zpp.getPaths().size() + " volumes" + zpp.getPaths()); return result; } private List<String> listTemplates(String rootdir) { List<String> result = new ArrayList<String>(); - Script script = new Script(listTmpltScr, logger); + Script script = new Script(listTmpltScr, s_logger); script.add("-r", rootdir); ZfsPathParser zpp = new ZfsPathParser(rootdir); script.execute(zpp); result.addAll(zpp.getPaths()); - logger.info("found " + zpp.getPaths().size() + " templates" + zpp.getPaths()); + s_logger.info("found " + zpp.getPaths().size() + " templates" + zpp.getPaths()); return result; } @@ -787,13 +789,13 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager TemplateLocation loc = new TemplateLocation(_storage, path); try { if (!loc.load()) { - logger.warn("Post download installation was not completed for " + path); + s_logger.warn("Post download installation was not completed for " + path); // loc.purge(); _storage.cleanup(path, templateDir); continue; } } catch (IOException e) { - logger.warn("Unable to load template location " + path, e); + s_logger.warn("Unable to load template location " + path, e); continue; } @@ -808,12 +810,12 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager loc.updateVirtualSize(vSize); loc.save(); } catch (Exception e) { - logger.error("Unable to get the virtual size of the template: " + tInfo.getInstallPath() + " due to " + e.getMessage()); + s_logger.error("Unable to get the virtual size of the template: " + tInfo.getInstallPath() + " due to " + e.getMessage()); } } result.put(tInfo.getTemplateName(), tInfo); - logger.debug("Added template name: " + tInfo.getTemplateName() + ", path: " + tmplt); + s_logger.debug("Added template name: " + tInfo.getTemplateName() + ", path: " + tmplt); } /* for (String tmplt : isoTmplts) { @@ -822,7 +824,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager String tmpltName = tmp[tmp.length - 2]; tmplt = tmplt.substring(tmplt.lastIndexOf("iso/")); TemplateInfo tInfo = new TemplateInfo(tmpltName, tmplt, false); - logger.debug("Added iso template name: " + tmpltName + ", path: " + tmplt); + s_logger.debug("Added iso template name: " + tmpltName + ", path: " + tmplt); result.put(tmpltName, tInfo); } */ @@ -844,13 +846,13 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager TemplateLocation loc = new TemplateLocation(_storage, path); try { if (!loc.load()) { - logger.warn("Post download installation was not completed for " + path); + s_logger.warn("Post download installation was not completed for " + path); // loc.purge(); _storage.cleanup(path, volumeDir); continue; } } catch (IOException e) { - logger.warn("Unable to load volume location " + path, e); + s_logger.warn("Unable to load volume location " + path, e); continue; } @@ -865,12 +867,12 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager loc.updateVirtualSize(vSize); loc.save(); } catch (Exception e) { - logger.error("Unable to get the virtual size of the volume: " + vInfo.getInstallPath() + " due to " + e.getMessage()); + s_logger.error("Unable to get the virtual size of the volume: " + vInfo.getInstallPath() + " due to " + e.getMessage()); } } result.put(vInfo.getId(), vInfo); - logger.debug("Added volume name: " + vInfo.getTemplateName() + ", path: " + vol); + s_logger.debug("Added volume name: " + vInfo.getTemplateName() + ", path: " + vol); } return result; } @@ -934,7 +936,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager String inSystemVM = (String)params.get("secondary.storage.vm"); if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) { - logger.info("DownloadManager: starting additional services since we are inside system vm"); + s_logger.info("DownloadManager: starting additional services since we are inside system vm"); startAdditionalServices(); blockOutgoingOnPrivate(); } @@ -954,25 +956,25 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager if (listTmpltScr == null) { throw new ConfigurationException("Unable to find the listvmtmplt.sh"); } - logger.info("listvmtmplt.sh found in " + listTmpltScr); + s_logger.info("listvmtmplt.sh found in " + listTmpltScr); createTmpltScr = Script.findScript(scriptsDir, "createtmplt.sh"); if (createTmpltScr == null) { throw new ConfigurationException("Unable to find createtmplt.sh"); } - logger.info("createtmplt.sh found in " + createTmpltScr); + s_logger.info("createtmplt.sh found in " + createTmpltScr); listVolScr = Script.findScript(scriptsDir, "listvolume.sh"); if (listVolScr == null) { throw new ConfigurationException("Unable to find the listvolume.sh"); } - logger.info("listvolume.sh found in " + listVolScr); + s_logger.info("listvolume.sh found in " + listVolScr); createVolScr = Script.findScript(scriptsDir, "createvolume.sh"); if (createVolScr == null) { throw new ConfigurationException("Unable to find createvolume.sh"); } - logger.info("createvolume.sh found in " + createVolScr); + s_logger.info("createvolume.sh found in " + createVolScr); _processors = new HashMap<String, Processor>(); @@ -1016,7 +1018,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager } private void blockOutgoingOnPrivate() { - Script command = new Script("/bin/bash", logger); + Script command = new Script("/bin/bash", s_logger); String intf = "eth1"; command.add("-c"); command.add("iptables -A OUTPUT -o " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "80" + " -j REJECT;" + "iptables -A OUTPUT -o " + intf + @@ -1024,7 +1026,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager String result = command.execute(); if (result != null) { - logger.warn("Error in blocking outgoing to port 80/443 err=" + result); + s_logger.warn("Error in blocking outgoing to port 80/443 err=" + result); return; } } @@ -1046,41 +1048,41 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager private void startAdditionalServices() { - Script command = new Script("/bin/bash", logger); + Script command = new Script("/bin/bash", s_logger); command.add("-c"); command.add("if [ -d /etc/apache2 ] ; then service apache2 stop; else service httpd stop; fi "); String result = command.execute(); if (result != null) { - logger.warn("Error in stopping httpd service err=" + result); + s_logger.warn("Error in stopping httpd service err=" + result); } String port = Integer.toString(TemplateConstants.DEFAULT_TMPLT_COPY_PORT); String intf = TemplateConstants.DEFAULT_TMPLT_COPY_INTF; - command = new Script("/bin/bash", logger); + command = new Script("/bin/bash", s_logger); command.add("-c"); command.add("iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j ACCEPT;" + "iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j ACCEPT;"); result = command.execute(); if (result != null) { - logger.warn("Error in opening up httpd port err=" + result); + s_logger.warn("Error in opening up httpd port err=" + result); return; } - command = new Script("/bin/bash", logger); + command = new Script("/bin/bash", s_logger); command.add("-c"); command.add("if [ -d /etc/apache2 ] ; then service apache2 start; else service httpd start; fi "); result = command.execute(); if (result != null) { - logger.warn("Error in starting httpd service err=" + result); + s_logger.warn("Error in starting httpd service err=" + result); return; } - command = new Script("mkdir", logger); + command = new Script("mkdir", s_logger); command.add("-p"); command.add("/var/www/html/copy/template"); result = command.execute(); if (result != null) { - logger.warn("Error in creating directory =" + result); + s_logger.warn("Error in creating directory =" + result); return; } }
