http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3818257a/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 2dcd2e2..5d39e0d 100644 --- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java +++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java @@ -27,7 +27,6 @@ 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; @@ -102,7 +101,6 @@ 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(); @@ -341,7 +339,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana return vmSnapshot; } catch (Exception e) { String msg = e.getMessage(); - s_logger.error("Create vm snapshot record failed for vm: " + vmId + " due to: " + msg); + logger.error("Create vm snapshot record failed for vm: " + vmId + " due to: " + msg); } return null; } @@ -437,7 +435,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana VMSnapshot snapshot = strategy.takeVMSnapshot(vmSnapshot); return snapshot; } catch (Exception e) { - s_logger.debug("Failed to create vm snapshot: " + vmSnapshotId, e); + logger.debug("Failed to create vm snapshot: " + vmSnapshotId, e); return null; } } @@ -474,7 +472,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()) - s_logger.debug("Target VM snapshot already in expunging state, go on deleting it: " + vmSnapshot.getDisplayName()); + 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"); } @@ -536,7 +534,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()) - s_logger.debug("Target VM snapshot already in expunging state, go on deleting it: " + vmSnapshot.getDisplayName()); + 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"); } @@ -548,7 +546,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana VMSnapshotStrategy strategy = findVMSnapshotStrategy(vmSnapshot); return strategy.deleteVMSnapshot(vmSnapshot); } catch (Exception e) { - s_logger.debug("Failed to delete vm snapshot: " + vmSnapshotId, e); + logger.debug("Failed to delete vm snapshot: " + vmSnapshotId, e); return false; } } @@ -684,7 +682,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana vm = _userVMDao.findById(userVm.getId()); hostId = vm.getHostId(); } catch (Exception e) { - s_logger.error("Start VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); + logger.error("Start VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); throw new CloudRuntimeException(e.getMessage()); } } else { @@ -692,7 +690,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana try { _itMgr.advanceStop(userVm.getUuid(), true); } catch (Exception e) { - s_logger.error("Stop VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); + logger.error("Stop VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); throw new CloudRuntimeException(e.getMessage()); } } @@ -708,7 +706,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana strategy.revertVMSnapshot(vmSnapshotVo); return userVm; } catch (Exception e) { - s_logger.debug("Failed to revert vmsnapshot: " + vmSnapshotId, e); + logger.debug("Failed to revert vmsnapshot: " + vmSnapshotId, e); throw new CloudRuntimeException(e.getMessage()); } } @@ -812,7 +810,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana } } } catch (Exception e) { - s_logger.error(e.getMessage(), e); + 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/3818257a/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 d25bddb..ee2c691 100644 --- a/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java +++ b/server/src/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java @@ -27,7 +27,6 @@ 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; @@ -73,7 +72,6 @@ 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 @@ -230,8 +228,8 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro } }); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Created affinity group =" + affinityGroupName); + if (logger.isDebugEnabled()) { + logger.debug("Created affinity group =" + affinityGroupName); } return group; @@ -307,8 +305,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 (s_logger.isDebugEnabled()) { - s_logger.debug("Deleted affinity group id=" + affinityGroupId); + if (logger.isDebugEnabled()) { + logger.debug("Deleted affinity group id=" + affinityGroupId); } return true; } @@ -465,7 +463,7 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro // Check that the VM is stopped if (!vmInstance.getState().equals(State.Stopped)) { - s_logger.warn("Unable to update affinity groups of the virtual machine " + vmInstance.toString() + " in state " + vmInstance.getState()); + 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."); } @@ -491,8 +489,8 @@ public class AffinityGroupServiceImpl extends ManagerBase implements AffinityGro } } _affinityGroupVMMapDao.updateMap(vmId, affinityGroupIds); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Updated VM :" + vmId + " affinity groups to =" + affinityGroupIds); + if (logger.isDebugEnabled()) { + 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/3818257a/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 bc2f1c4..c912981 100644 --- a/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java +++ b/server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java @@ -24,7 +24,6 @@ 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; @@ -81,7 +80,6 @@ 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; @@ -184,7 +182,7 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A if (!_firewallDao.setStateToAdd(newRule)) { throw new CloudRuntimeException("Unable to update the state to add for " + newRule); } - s_logger.debug("Load balancer " + newRule.getId() + " for Ip address " + newRule.getSourceIp().addr() + ", source port " + + 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()); @@ -261,7 +259,7 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A if (requestedIp != null) { if (_lbDao.countBySourceIp(new Ip(requestedIp), sourceIpNtwk.getId()) > 0) { - s_logger.debug("IP address " + requestedIp + " is already used by existing LB rule, returning it"); + logger.debug("IP address " + requestedIp + " is already used by existing LB rule, returning it"); return new Ip(requestedIp); } @@ -532,8 +530,8 @@ public class ApplicationLoadBalancerManagerImpl extends ManagerBase implements A } } - if (s_logger.isDebugEnabled()) { - s_logger.debug("No network rule conflicts detected for " + newLbRule + " against " + (lbRules.size() - 1) + " existing rules"); + if (logger.isDebugEnabled()) { + 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/3818257a/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 8910714..ae8bc4b 100644 --- a/server/src/org/apache/cloudstack/region/RegionManagerImpl.java +++ b/server/src/org/apache/cloudstack/region/RegionManagerImpl.java @@ -25,7 +25,6 @@ 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; @@ -50,7 +49,6 @@ 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/3818257a/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 98cf500..03eb217 100644 --- a/server/src/org/apache/cloudstack/region/RegionServiceImpl.java +++ b/server/src/org/apache/cloudstack/region/RegionServiceImpl.java @@ -23,7 +23,6 @@ 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; @@ -49,7 +48,6 @@ 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/3818257a/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 fd12d23..f9adece 100644 --- a/server/test/com/cloud/consoleproxy/ConsoleProxyManagerTest.java +++ b/server/test/com/cloud/consoleproxy/ConsoleProxyManagerTest.java @@ -43,6 +43,7 @@ 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/3818257a/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 111df93..7441d57 100644 --- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java +++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java @@ -34,7 +34,6 @@ 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; @@ -93,7 +92,6 @@ 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() @@ -104,7 +102,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches Provider implementedProvider = element.getProvider(); if (implementedProvider != null) { if (s_providerToNetworkElementMap.containsKey(implementedProvider.getName())) { - s_logger.error("Cannot start MapNetworkManager: Provider <-> NetworkElement must be a one-to-one map, " + + 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/3818257a/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 7ea0a80..07b067d 100644 --- a/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java +++ b/server/test/com/cloud/vpc/dao/MockNetworkOfferingDaoImpl.java @@ -21,7 +21,6 @@ import java.util.List; import javax.ejb.Local; -import org.apache.log4j.Logger; import com.cloud.network.Network; import com.cloud.network.Network.GuestType; @@ -37,7 +36,6 @@ 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) @@ -144,10 +142,10 @@ public class MockNetworkOfferingDaoImpl extends NetworkOfferingDaoImpl implement f.setAccessible(true); f.setLong(voToReturn, id); } catch (NoSuchFieldException ex) { - s_logger.warn(ex); + logger.warn(ex); return null; } catch (IllegalAccessException ex) { - s_logger.warn(ex); + logger.warn(ex); return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3818257a/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 a436a92..3220979 100644 --- a/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java +++ b/server/test/com/cloud/vpc/dao/MockVpcDaoImpl.java @@ -22,7 +22,6 @@ 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; @@ -34,7 +33,6 @@ 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) @@ -117,10 +115,10 @@ public class MockVpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements VpcDa f.setAccessible(true); f.setLong(voToReturn, id); } catch (NoSuchFieldException ex) { - s_logger.warn(ex); + logger.warn(ex); return null; } catch (IllegalAccessException ex) { - s_logger.warn(ex); + logger.warn(ex); return null; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3818257a/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 dd81809..af9f3c7 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,7 +44,6 @@ 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; @@ -164,7 +163,6 @@ 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 @@ -262,16 +260,16 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _itMgr.advanceStart(secStorageVm.getUuid(), null, null); return _secStorageVmDao.findById(secStorageVm.getId()); } catch (StorageUnavailableException e) { - s_logger.warn("Exception while trying to start secondary storage vm", e); + logger.warn("Exception while trying to start secondary storage vm", e); return null; } catch (InsufficientCapacityException e) { - s_logger.warn("Exception while trying to start secondary storage vm", e); + logger.warn("Exception while trying to start secondary storage vm", e); return null; } catch (ResourceUnavailableException e) { - s_logger.warn("Exception while trying to start secondary storage vm", e); + logger.warn("Exception while trying to start secondary storage vm", e); return null; } catch (Exception e) { - s_logger.warn("Exception while trying to start secondary storage vm", e); + logger.warn("Exception while trying to start secondary storage vm", e); return null; } } @@ -291,7 +289,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findByInstanceName(cssHost.getName()); if (secStorageVm == null) { - s_logger.warn("secondary storage VM " + cssHost.getName() + " doesn't exist"); + logger.warn("secondary storage VM " + cssHost.getName() + " doesn't exist"); return false; } @@ -322,12 +320,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar svo.setParent(an.get_dir()); _imageStoreDao.update(ssStore.getId(), svo); } - if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName()); } } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully programmed secondary storage " + ssStore.getName() + " in secondary storage VM " + secStorageVm.getInstanceName()); } return false; } @@ -342,12 +340,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 (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed secondary storage " + host.getName() + " in secondary storage VM " + ssVm.getInstanceName()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully programmed secondary storage " + host.getName() + " in secondary storage VM " + ssVm.getInstanceName()); } } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed secondary storage " + host.getName() + " in secondary storage VM " + ssVm.getInstanceName()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully programmed secondary storage " + host.getName() + " in secondary storage VM " + ssVm.getInstanceName()); } return false; } @@ -365,7 +363,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findByInstanceName(ssAHost.getName()); if (secStorageVm == null) { - s_logger.warn("secondary storage VM " + ssAHost.getName() + " doesn't exist"); + logger.warn("secondary storage VM " + ssAHost.getName() + " doesn't exist"); return false; } @@ -385,13 +383,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 (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed http auth into " + secStorageVm.getHostName()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully programmed http auth into " + secStorageVm.getHostName()); } return true; } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getHostName()); + if (logger.isDebugEnabled()) { + logger.debug("failed to program http auth into secondary storage vm : " + secStorageVm.getHostName()); } return false; } @@ -411,7 +409,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar SecondaryStorageVmVO thisSecStorageVm = _secStorageVmDao.findByInstanceName(ssAHost.getName()); if (thisSecStorageVm == null) { - s_logger.warn("secondary storage VM " + ssAHost.getName() + " doesn't exist"); + logger.warn("secondary storage VM " + ssAHost.getName() + " doesn't exist"); return false; } @@ -429,12 +427,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } Answer answer = _agentMgr.easySend(ssvm.getId(), thiscpc); if (answer != null && answer.getResult()) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed firewall rules into SSVM " + ssvm.getName()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully programmed firewall rules into SSVM " + ssvm.getName()); } } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("failed to program firewall rules into secondary storage vm : " + ssvm.getName()); + if (logger.isDebugEnabled()) { + logger.debug("failed to program firewall rules into secondary storage vm : " + ssvm.getName()); } return false; } @@ -450,12 +448,12 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar Answer answer = _agentMgr.easySend(ssAHostId, allSSVMIpList); if (answer != null && answer.getResult()) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully programmed firewall rules into " + thisSecStorageVm.getHostName()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully programmed firewall rules into " + thisSecStorageVm.getHostName()); } } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("failed to program firewall rules into secondary storage vm : " + thisSecStorageVm.getHostName()); + if (logger.isDebugEnabled()) { + logger.debug("failed to program firewall rules into secondary storage vm : " + thisSecStorageVm.getHostName()); } return false; } @@ -477,21 +475,21 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar public SecondaryStorageVmVO startNew(long dataCenterId, SecondaryStorageVm.Role role) { if (!isSecondaryStorageVmRequired(dataCenterId)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Secondary storage vm not required in zone " + dataCenterId + " acc. to zone config"); + if (logger.isDebugEnabled()) { + logger.debug("Secondary storage vm not required in zone " + dataCenterId + " acc. to zone config"); } return null; } - if (s_logger.isDebugEnabled()) { - s_logger.debug("Assign secondary storage vm from a newly started instance for request from data center : " + dataCenterId); + if (logger.isDebugEnabled()) { + 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 (s_logger.isTraceEnabled()) { - s_logger.trace("Creating secondary storage vm instance failed, data center id : " + dataCenterId); + if (logger.isTraceEnabled()) { + logger.trace("Creating secondary storage vm instance failed, data center id : " + dataCenterId); } return null; @@ -505,8 +503,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_CREATED, dataCenterId, secStorageVmId, secStorageVm, null)); return secStorageVm; } else { - 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: " + + if (logger.isDebugEnabled()) { + 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, @@ -519,7 +517,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"; - s_logger.warn(msg); + logger.warn(msg); throw new CloudRuntimeException(msg); } @@ -565,7 +563,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) { - s_logger.info("Unable to setup due to concurrent operation. " + e); + logger.info("Unable to setup due to concurrent operation. " + e); return new HashMap<String, Object>(); } @@ -589,7 +587,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _itMgr.allocate(name, template, serviceOffering, networks, plan, null); secStorageVm = _secStorageVmDao.findById(secStorageVm.getId()); } catch (InsufficientCapacityException e) { - s_logger.warn("InsufficientCapacity", e); + logger.warn("InsufficientCapacity", e); throw new CloudRuntimeException("Insufficient capacity exception", e); } @@ -614,18 +612,18 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar public SecondaryStorageVmVO assignSecStorageVmFromRunningPool(long dataCenterId, SecondaryStorageVm.Role role) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Assign secondary storage vm from running pool for request from data center : " + dataCenterId); + if (logger.isTraceEnabled()) { + 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 (s_logger.isTraceEnabled()) { - s_logger.trace("Running secondary storage vm pool size : " + runningList.size()); + if (logger.isTraceEnabled()) { + logger.trace("Running secondary storage vm pool size : " + runningList.size()); for (SecondaryStorageVmVO secStorageVm : runningList) { - s_logger.trace("Running secStorageVm instance : " + secStorageVm.getHostName()); + logger.trace("Running secStorageVm instance : " + secStorageVm.getHostName()); } } @@ -633,8 +631,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar return allocator.allocSecondaryStorageVm(runningList, loadInfo, dataCenterId); } else { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Empty running secStorageVm pool for now in data center : " + dataCenterId); + if (logger.isTraceEnabled()) { + logger.trace("Empty running secStorageVm pool for now in data center : " + dataCenterId); } } return null; @@ -650,13 +648,13 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } private void allocCapacity(long dataCenterId, SecondaryStorageVm.Role role) { - if (s_logger.isTraceEnabled()) { - s_logger.trace("Allocate secondary storage vm standby capacity for data center : " + dataCenterId); + if (logger.isTraceEnabled()) { + logger.trace("Allocate secondary storage vm standby capacity for data center : " + dataCenterId); } if (!isSecondaryStorageVmRequired(dataCenterId)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Secondary storage vm not required in zone " + dataCenterId + " according to zone config"); + if (logger.isDebugEnabled()) { + logger.debug("Secondary storage vm not required in zone " + dataCenterId + " according to zone config"); } return; } @@ -666,8 +664,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar boolean secStorageVmFromStoppedPool = false; secStorageVm = assignSecStorageVmFromStoppedPool(dataCenterId, role); if (secStorageVm == null) { - if (s_logger.isInfoEnabled()) { - s_logger.info("No stopped secondary storage vm is available, need to allocate a new secondary storage vm"); + if (logger.isInfoEnabled()) { + 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)) { @@ -680,14 +678,14 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _allocLock.unlock(); } } else { - if (s_logger.isInfoEnabled()) { - s_logger.info("Unable to acquire synchronization lock for secondary storage vm allocation, wait for next scan"); + if (logger.isInfoEnabled()) { + logger.info("Unable to acquire synchronization lock for secondary storage vm allocation, wait for next scan"); } return; } } else { - if (s_logger.isInfoEnabled()) { - s_logger.info("Found a stopped secondary storage vm, starting it. Vm id : " + secStorageVm.getId()); + if (logger.isInfoEnabled()) { + logger.info("Found a stopped secondary storage vm, starting it. Vm id : " + secStorageVm.getId()); } secStorageVmFromStoppedPool = true; } @@ -703,8 +701,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar secStorageVmLock.unlock(); } } else { - if (s_logger.isInfoEnabled()) { - s_logger.info("Unable to acquire synchronization lock for starting secondary storage vm id : " + secStorageVm.getId()); + if (logger.isInfoEnabled()) { + logger.info("Unable to acquire synchronization lock for starting secondary storage vm id : " + secStorageVm.getId()); } return; } @@ -713,8 +711,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } if (secStorageVm == null) { - 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 (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 (secStorageVmFromStoppedPool) { @@ -723,8 +721,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 (s_logger.isInfoEnabled()) { - s_logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started"); + if (logger.isInfoEnabled()) { + logger.info("Secondary storage vm " + secStorageVm.getHostName() + " is started"); } } } @@ -745,22 +743,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 (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"); + 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"); } return false; } List<DataStore> stores = _dataStoreMgr.getImageStoresByScope(new ZoneScope(dataCenterId)); if (stores.size() < 1) { - s_logger.debug("No image store added in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); + 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 (s_logger.isDebugEnabled()) { - s_logger.debug("No secondary storage available in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); + if (logger.isDebugEnabled()) { + logger.debug("No secondary storage available in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm"); } return false; } @@ -774,8 +772,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) { return true; } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + + if (logger.isDebugEnabled()) { + 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"); } @@ -801,8 +799,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar @Override public boolean start() { - if (s_logger.isInfoEnabled()) { - s_logger.info("Start secondary storage vm manager"); + if (logger.isInfoEnabled()) { + logger.info("Start secondary storage vm manager"); } return true; @@ -818,8 +816,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { - if (s_logger.isInfoEnabled()) { - s_logger.info("Start configuring secondary storage vm manager : " + name); + if (logger.isInfoEnabled()) { + logger.info("Start configuring secondary storage vm manager : " + name); } Map<String, String> configs = _configDao.getConfiguration("management-server", params); @@ -839,7 +837,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())){ - s_logger.warn("Empty secondary storage url domain, explicitly disabling SSL"); + logger.warn("Empty secondary storage url domain, explicitly disabling SSL"); _useSSlCopy = false; } @@ -871,11 +869,11 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar try { _serviceOffering = _offeringDao.findById(Long.parseLong(ssvmSrvcOffIdStr)); } catch (NumberFormatException ex) { - s_logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); + logger.debug("The system service offering specified by global config is not id, but uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); } } if (_serviceOffering == null) { - s_logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); + logger.warn("Can't find system service offering specified by global config, uuid=" + ssvmSrvcOffIdStr + " for secondary storage vm"); } } @@ -888,7 +886,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?"; - s_logger.error(msg); + logger.error(msg); throw new ConfigurationException(msg); } } @@ -917,13 +915,13 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar errMsg = e.toString(); } finally { if (!valid) { - s_logger.debug("ssvm http proxy " + _httpProxy + " is invalid: " + errMsg); + logger.debug("ssvm http proxy " + _httpProxy + " is invalid: " + errMsg); throw new ConfigurationException("ssvm http proxy " + _httpProxy + "is invalid: " + errMsg); } } } - if (s_logger.isInfoEnabled()) { - s_logger.info("Secondary storage vm Manager is configured."); + if (logger.isInfoEnabled()) { + logger.info("Secondary storage vm Manager is configured."); } _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); return true; @@ -934,8 +932,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 (s_logger.isDebugEnabled()) { - s_logger.debug(msg); + if (logger.isDebugEnabled()) { + logger.debug(msg); } return false; } @@ -952,7 +950,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } } else { String msg = "Unable to acquire secondary storage vm lock : " + secStorageVm.toString(); - s_logger.debug(msg); + logger.debug(msg); return false; } } finally { @@ -963,8 +961,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar // vm was already stopped, return true return true; } catch (ResourceUnavailableException e) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Stopping secondary storage vm " + secStorageVm.getHostName() + " faled : exception " + e.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Stopping secondary storage vm " + secStorageVm.getHostName() + " faled : exception " + e.toString()); } return false; } @@ -983,8 +981,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar final Answer answer = _agentMgr.easySend(secStorageVm.getHostId(), cmd); if (answer != null && answer.getResult()) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName()); } SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this, @@ -993,8 +991,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar return true; } else { String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getHostName(); - if (s_logger.isDebugEnabled()) { - s_logger.debug(msg); + if (logger.isDebugEnabled()) { + logger.debug(msg); } return false; } @@ -1012,7 +1010,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) { - s_logger.debug("Removing host entry for ssvm id=" + vmId); + 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()); @@ -1021,7 +1019,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } return false; } catch (ResourceUnavailableException e) { - s_logger.warn("Unable to expunge " + ssvm, e); + logger.warn("Unable to expunge " + ssvm, e); return false; } } @@ -1064,7 +1062,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar buf.append(" workers=").append(_configDao.getValue("workers")); if (_configDao.isPremium()) { - s_logger.debug("VmWare hypervisor configured, telling the ssvm to load the PremiumSecondaryStorageResource"); + 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"); @@ -1129,8 +1127,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar } String bootArgs = buf.toString(); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Boot Args for " + profile + ": " + bootArgs); + if (logger.isDebugEnabled()) { + logger.debug("Boot Args for " + profile + ": " + bootArgs); } return true; @@ -1174,7 +1172,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar if (controlNic == null) { if (managementNic == null) { - s_logger.error("Management network doesn't exist for the secondaryStorageVm " + profile.getVirtualMachine()); + logger.error("Management network doesn't exist for the secondaryStorageVm " + profile.getVirtualMachine()); return false; } controlNic = managementNic; @@ -1195,7 +1193,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()) { - s_logger.warn("Unable to ssh to the VM: " + answer.getDetails()); + logger.warn("Unable to ssh to the VM: " + answer.getDetails()); return false; } @@ -1210,7 +1208,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _secStorageVmDao.update(secVm.getId(), secVm); } } catch (Exception ex) { - s_logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", ex); + logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", ex); return false; } @@ -1226,7 +1224,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar try { _rulesMgr.disableStaticNat(ip.getId(), ctx.getCallingAccount(), ctx.getCallingUserId(), true); } catch (Exception ex) { - s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", + logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex); } } @@ -1276,14 +1274,14 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar long dataCenterId = pool.longValue(); if (!isZoneReady(_zoneHostInfoMap, dataCenterId)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Zone " + dataCenterId + " is not ready to launch secondary storage VM yet"); + if (logger.isDebugEnabled()) { + logger.debug("Zone " + dataCenterId + " is not ready to launch secondary storage VM yet"); } return false; } - if (s_logger.isDebugEnabled()) { - s_logger.debug("Zone " + dataCenterId + " is ready to launch secondary storage VM"); + if (logger.isDebugEnabled()) { + logger.debug("Zone " + dataCenterId + " is ready to launch secondary storage VM"); } return true; } @@ -1299,7 +1297,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) { - s_logger.info("No secondary storage vms found in datacenter id=" + dataCenterId + ", starting a new one"); + 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/3818257a/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 ee50647..ed6066e 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,7 +30,6 @@ 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; @@ -55,7 +54,6 @@ 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; @@ -79,7 +77,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")) { - s_logger.debug("It's not NFS or file or ISO, so not a secondary storage server: " + uri.toString()); + logger.debug("It's not NFS or file or ISO, so not a secondary storage server: " + uri.toString()); return null; } @@ -101,7 +99,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov } String mountStr = NfsUtils.uri2Mount(uri); - Script script = new Script(true, "mount", _timeout, s_logger); + Script script = new Script(true, "mount", _timeout, logger); String mntPoint = null; File file = null; do { @@ -110,19 +108,19 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov } while (file.exists()); if (!file.mkdirs()) { - s_logger.warn("Unable to make directory: " + mntPoint); + logger.warn("Unable to make directory: " + mntPoint); return null; } script.add(mountStr, mntPoint); String result = script.execute(); if (result != null && !result.contains("already mounted")) { - s_logger.warn("Unable to mount " + uri.toString() + " due to " + result); + logger.warn("Unable to mount " + uri.toString() + " due to " + result); file.delete(); return null; } - script = new Script(true, "umount", 0, s_logger); + script = new Script(true, "umount", 0, logger); script.add(mntPoint); script.execute(); @@ -140,25 +138,25 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov constructor.setAccessible(true); storage = (NfsSecondaryStorageResource)constructor.newInstance(); } catch (final ClassNotFoundException e) { - s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to ClassNotFoundException"); + logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to ClassNotFoundException"); return null; } catch (final SecurityException e) { - s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to SecurityException"); + logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to SecurityException"); return null; } catch (final NoSuchMethodException e) { - s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to NoSuchMethodException"); + logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to NoSuchMethodException"); return null; } catch (final IllegalArgumentException e) { - s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to IllegalArgumentException"); + logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to IllegalArgumentException"); return null; } catch (final InstantiationException e) { - s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to InstantiationException"); + logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to InstantiationException"); return null; } catch (final IllegalAccessException e) { - s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to IllegalAccessException"); + logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to IllegalAccessException"); return null; } catch (final InvocationTargetException e) { - s_logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to InvocationTargetException"); + logger.error("Unable to load com.cloud.storage.resource.PremiumSecondaryStorageResource due to InvocationTargetException"); return null; } } else { @@ -183,7 +181,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov try { storage.configure("Storage", params); } catch (ConfigurationException e) { - s_logger.warn("Unable to configure the storage ", e); + logger.warn("Unable to configure the storage ", e); return null; } srs.put(storage, details); @@ -214,7 +212,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov try { storage.configure("Storage", params); } catch (ConfigurationException e) { - s_logger.warn("Unable to configure the storage ", e); + logger.warn("Unable to configure the storage ", e); return null; } srs.put(storage, details); @@ -244,7 +242,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov try { storage.configure("Storage", params); } catch (ConfigurationException e) { - s_logger.warn("Unable to configure the storage ", e); + logger.warn("Unable to configure the storage ", e); return null; } srs.put(storage, details); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3818257a/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 25c0887..447c4c1 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,7 +41,6 @@ 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; @@ -217,7 +216,6 @@ 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; @@ -250,12 +248,12 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager public void setDownloadStatus(String jobId, Status status) { DownloadJob dj = jobs.get(jobId); if (dj == null) { - s_logger.warn("setDownloadStatus for jobId: " + jobId + ", status=" + status + " no job found"); + logger.warn("setDownloadStatus for jobId: " + jobId + ", status=" + status + " no job found"); return; } TemplateDownloader td = dj.getTemplateDownloader(); - s_logger.info("Download Completion for jobId: " + jobId + ", status=" + status); - s_logger.info("local: " + td.getDownloadLocalPath() + ", bytes=" + td.getDownloadedBytes() + ", error=" + td.getDownloadError() + ", pct=" + + logger.info("Download Completion for jobId: " + jobId + ", status=" + status); + logger.info("local: " + td.getDownloadLocalPath() + ", bytes=" + td.getDownloadedBytes() + ", error=" + td.getDownloadError() + ", pct=" + td.getDownloadPercent()); switch (status) { @@ -268,7 +266,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager case UNKNOWN: return; case IN_PROGRESS: - s_logger.info("Resuming jobId: " + jobId + ", status=" + status); + logger.info("Resuming jobId: " + jobId + ", status=" + status); td.setResume(true); threadPool.execute(td); break; @@ -282,7 +280,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager td.setDownloadError("Download success, starting install "); String result = postDownload(jobId); if (result != null) { - s_logger.error("Failed post download script: " + result); + logger.error("Failed post download script: " + result); td.setStatus(Status.UNRECOVERABLE_ERROR); td.setDownloadError("Failed post download script: " + result); } else { @@ -357,7 +355,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager File originalTemplate = new File(td.getDownloadLocalPath()); String checkSum = computeCheckSum(originalTemplate); if (checkSum == null) { - s_logger.warn("Something wrong happened when try to calculate the checksum of downloaded template!"); + logger.warn("Something wrong happened when try to calculate the checksum of downloaded template!"); } dnld.setCheckSum(checkSum); @@ -366,7 +364,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, s_logger); + scr = new Script(script, timeout, logger); scr.add("-s", Integer.toString(imgSizeGigs)); scr.add("-S", Long.toString(td.getMaxTemplateSizeInBytes())); if (dnld.getDescription() != null && dnld.getDescription().length() > 1) { @@ -423,7 +421,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager try { loc.create(dnld.getId(), true, dnld.getTmpltName()); } catch (IOException e) { - s_logger.warn("Something is wrong with template location " + resourcePath, e); + logger.warn("Something is wrong with template location " + resourcePath, e); loc.purge(); return "Unable to download due to " + e.getMessage(); } @@ -436,7 +434,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager try { info = processor.process(resourcePath, null, templateName); } catch (InternalErrorException e) { - s_logger.error("Template process exception ", e); + logger.error("Template process exception ", e); return e.toString(); } if (info != null) { @@ -448,7 +446,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager } if (!loc.save()) { - s_logger.warn("Cleaning up because we're unable to save the formats"); + logger.warn("Cleaning up because we're unable to save the formats"); loc.purge(); } @@ -507,7 +505,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager try { if (!_storage.mkdirs(tmpDir)) { - s_logger.warn("Unable to create " + tmpDir); + logger.warn("Unable to create " + tmpDir); return "Unable to create " + tmpDir; } // TO DO - define constant for volume properties. @@ -519,7 +517,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager } if (!file.createNewFile()) { - s_logger.warn("Unable to create new file: " + file.getAbsolutePath()); + logger.warn("Unable to create new file: " + file.getAbsolutePath()); return "Unable to create new file: " + file.getAbsolutePath(); } @@ -559,7 +557,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager return jobId; } catch (IOException e) { - s_logger.warn("Unable to download to " + tmpDir, e); + logger.warn("Unable to download to " + tmpDir, e); return null; } } @@ -753,24 +751,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, s_logger); + Script script = new Script(listVolScr, logger); script.add("-r", rootdir); ZfsPathParser zpp = new ZfsPathParser(rootdir); script.execute(zpp); result.addAll(zpp.getPaths()); - s_logger.info("found " + zpp.getPaths().size() + " volumes" + zpp.getPaths()); + 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, s_logger); + Script script = new Script(listTmpltScr, logger); script.add("-r", rootdir); ZfsPathParser zpp = new ZfsPathParser(rootdir); script.execute(zpp); result.addAll(zpp.getPaths()); - s_logger.info("found " + zpp.getPaths().size() + " templates" + zpp.getPaths()); + logger.info("found " + zpp.getPaths().size() + " templates" + zpp.getPaths()); return result; } @@ -789,13 +787,13 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager TemplateLocation loc = new TemplateLocation(_storage, path); try { if (!loc.load()) { - s_logger.warn("Post download installation was not completed for " + path); + logger.warn("Post download installation was not completed for " + path); // loc.purge(); _storage.cleanup(path, templateDir); continue; } } catch (IOException e) { - s_logger.warn("Unable to load template location " + path, e); + logger.warn("Unable to load template location " + path, e); continue; } @@ -810,12 +808,12 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager loc.updateVirtualSize(vSize); loc.save(); } catch (Exception e) { - s_logger.error("Unable to get the virtual size of the template: " + tInfo.getInstallPath() + " due to " + e.getMessage()); + logger.error("Unable to get the virtual size of the template: " + tInfo.getInstallPath() + " due to " + e.getMessage()); } } result.put(tInfo.getTemplateName(), tInfo); - s_logger.debug("Added template name: " + tInfo.getTemplateName() + ", path: " + tmplt); + logger.debug("Added template name: " + tInfo.getTemplateName() + ", path: " + tmplt); } /* for (String tmplt : isoTmplts) { @@ -824,7 +822,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); - s_logger.debug("Added iso template name: " + tmpltName + ", path: " + tmplt); + logger.debug("Added iso template name: " + tmpltName + ", path: " + tmplt); result.put(tmpltName, tInfo); } */ @@ -846,13 +844,13 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager TemplateLocation loc = new TemplateLocation(_storage, path); try { if (!loc.load()) { - s_logger.warn("Post download installation was not completed for " + path); + logger.warn("Post download installation was not completed for " + path); // loc.purge(); _storage.cleanup(path, volumeDir); continue; } } catch (IOException e) { - s_logger.warn("Unable to load volume location " + path, e); + logger.warn("Unable to load volume location " + path, e); continue; } @@ -867,12 +865,12 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager loc.updateVirtualSize(vSize); loc.save(); } catch (Exception e) { - s_logger.error("Unable to get the virtual size of the volume: " + vInfo.getInstallPath() + " due to " + e.getMessage()); + logger.error("Unable to get the virtual size of the volume: " + vInfo.getInstallPath() + " due to " + e.getMessage()); } } result.put(vInfo.getId(), vInfo); - s_logger.debug("Added volume name: " + vInfo.getTemplateName() + ", path: " + vol); + logger.debug("Added volume name: " + vInfo.getTemplateName() + ", path: " + vol); } return result; } @@ -936,7 +934,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager String inSystemVM = (String)params.get("secondary.storage.vm"); if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) { - s_logger.info("DownloadManager: starting additional services since we are inside system vm"); + logger.info("DownloadManager: starting additional services since we are inside system vm"); startAdditionalServices(); blockOutgoingOnPrivate(); } @@ -956,25 +954,25 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager if (listTmpltScr == null) { throw new ConfigurationException("Unable to find the listvmtmplt.sh"); } - s_logger.info("listvmtmplt.sh found in " + listTmpltScr); + logger.info("listvmtmplt.sh found in " + listTmpltScr); createTmpltScr = Script.findScript(scriptsDir, "createtmplt.sh"); if (createTmpltScr == null) { throw new ConfigurationException("Unable to find createtmplt.sh"); } - s_logger.info("createtmplt.sh found in " + createTmpltScr); + 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"); } - s_logger.info("listvolume.sh found in " + listVolScr); + logger.info("listvolume.sh found in " + listVolScr); createVolScr = Script.findScript(scriptsDir, "createvolume.sh"); if (createVolScr == null) { throw new ConfigurationException("Unable to find createvolume.sh"); } - s_logger.info("createvolume.sh found in " + createVolScr); + logger.info("createvolume.sh found in " + createVolScr); _processors = new HashMap<String, Processor>(); @@ -1018,7 +1016,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager } private void blockOutgoingOnPrivate() { - Script command = new Script("/bin/bash", s_logger); + Script command = new Script("/bin/bash", 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 + @@ -1026,7 +1024,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager String result = command.execute(); if (result != null) { - s_logger.warn("Error in blocking outgoing to port 80/443 err=" + result); + logger.warn("Error in blocking outgoing to port 80/443 err=" + result); return; } } @@ -1048,41 +1046,41 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager private void startAdditionalServices() { - Script command = new Script("/bin/bash", s_logger); + Script command = new Script("/bin/bash", 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) { - s_logger.warn("Error in stopping httpd service err=" + result); + 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", s_logger); + command = new Script("/bin/bash", 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) { - s_logger.warn("Error in opening up httpd port err=" + result); + logger.warn("Error in opening up httpd port err=" + result); return; } - command = new Script("/bin/bash", s_logger); + command = new Script("/bin/bash", 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) { - s_logger.warn("Error in starting httpd service err=" + result); + logger.warn("Error in starting httpd service err=" + result); return; } - command = new Script("mkdir", s_logger); + command = new Script("mkdir", logger); command.add("-p"); command.add("/var/www/html/copy/template"); result = command.execute(); if (result != null) { - s_logger.warn("Error in creating directory =" + result); + logger.warn("Error in creating directory =" + result); return; } }
