mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Revert "Merge pull request #714 from rafaelweingartner/master-lrg-cs-hackday-003"
This reverts commit cd7218e241a8ac93df7a73f938320487aa526de6, reversing changes made to f5a7395cc2ec37364a2e210eac60720e9b327451. Reason for Revert: noredist build failed with the below error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project cloud-plugin-hypervisor-vmware: Compilation failure [ERROR] /home/jenkins/acs/workspace/build-master-noredist/plugins/hypervisors/vmware/src/com/cloud/hypervisor/guru/VMwareGuru.java:[484,12] error: non-static variable logger cannot be referenced from a static context [ERROR] -> [Help 1] even the normal build is broken as reported by @koushik-das on dev list http://markmail.org/message/nngimssuzkj5gpbz
This commit is contained in:
		
							parent
							
								
									cd7218e241
								
							
						
					
					
						commit
						8bc0294014
					
				| @ -25,6 +25,7 @@ import java.util.Map; | ||||
| import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.storage.Storage.ImageFormat; | ||||
| import com.cloud.storage.StorageLayer; | ||||
| @ -32,20 +33,21 @@ import com.cloud.utils.component.AdapterBase; | ||||
| 
 | ||||
| @Local(value = Processor.class) | ||||
| public class IsoProcessor extends AdapterBase implements Processor { | ||||
|     private static final Logger s_logger = Logger.getLogger(IsoProcessor.class); | ||||
| 
 | ||||
|     StorageLayer _storage; | ||||
| 
 | ||||
|     @Override | ||||
|     public FormatInfo process(String templatePath, ImageFormat format, String templateName) { | ||||
|         if (format != null) { | ||||
|             logger.debug("We don't handle conversion from " + format + " to ISO."); | ||||
|             s_logger.debug("We don't handle conversion from " + format + " to ISO."); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         String isoPath = templatePath + File.separator + templateName + "." + ImageFormat.ISO.getFileExtension(); | ||||
| 
 | ||||
|         if (!_storage.exists(isoPath)) { | ||||
|             logger.debug("Unable to find the iso file: " + isoPath); | ||||
|             s_logger.debug("Unable to find the iso file: " + isoPath); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -26,6 +26,7 @@ import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| import javax.xml.parsers.DocumentBuilderFactory; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.w3c.dom.Document; | ||||
| import org.w3c.dom.Element; | ||||
| 
 | ||||
| @ -37,38 +38,39 @@ import com.cloud.utils.script.Script; | ||||
| 
 | ||||
| @Local(value = Processor.class) | ||||
| public class OVAProcessor extends AdapterBase implements Processor { | ||||
|     private static final Logger s_logger = Logger.getLogger(OVAProcessor.class); | ||||
| 
 | ||||
|     StorageLayer _storage; | ||||
| 
 | ||||
|     @Override | ||||
|     public FormatInfo process(String templatePath, ImageFormat format, String templateName) throws InternalErrorException { | ||||
|         if (format != null) { | ||||
|             if (logger.isInfoEnabled()) { | ||||
|                 logger.info("We currently don't handle conversion from " + format + " to OVA."); | ||||
|             if (s_logger.isInfoEnabled()) { | ||||
|                 s_logger.info("We currently don't handle conversion from " + format + " to OVA."); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName); | ||||
|         s_logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName); | ||||
|         String templateFilePath = templatePath + File.separator + templateName + "." + ImageFormat.OVA.getFileExtension(); | ||||
|         if (!_storage.exists(templateFilePath)) { | ||||
|             if (logger.isInfoEnabled()) { | ||||
|                 logger.info("Unable to find the vmware template file: " + templateFilePath); | ||||
|             if (s_logger.isInfoEnabled()) { | ||||
|                 s_logger.info("Unable to find the vmware template file: " + templateFilePath); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         logger.info("Template processing - untar OVA package. templatePath: " + templatePath + ", templateName: " + templateName); | ||||
|         s_logger.info("Template processing - untar OVA package. templatePath: " + templatePath + ", templateName: " + templateName); | ||||
|         String templateFileFullPath = templatePath + File.separator + templateName + "." + ImageFormat.OVA.getFileExtension(); | ||||
|         File templateFile = new File(templateFileFullPath); | ||||
| 
 | ||||
|         Script command = new Script("tar", 0, logger); | ||||
|         Script command = new Script("tar", 0, s_logger); | ||||
|         command.add("--no-same-owner"); | ||||
|         command.add("-xf", templateFileFullPath); | ||||
|         command.setWorkDir(templateFile.getParent()); | ||||
|         String result = command.execute(); | ||||
|         if (result != null) { | ||||
|             logger.info("failed to untar OVA package due to " + result + ". templatePath: " + templatePath + ", templateName: " + templateName); | ||||
|             s_logger.info("failed to untar OVA package due to " + result + ". templatePath: " + templatePath + ", templateName: " + templateName); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
| @ -89,7 +91,7 @@ public class OVAProcessor extends AdapterBase implements Processor { | ||||
|             long size = getTemplateVirtualSize(file.getParent(), file.getName()); | ||||
|             return size; | ||||
|         } catch (Exception e) { | ||||
|             logger.info("[ignored]" | ||||
|             s_logger.info("[ignored]" | ||||
|                     + "failed to get virtual template size for ova: " + e.getLocalizedMessage()); | ||||
|         } | ||||
|         return file.length(); | ||||
| @ -103,7 +105,7 @@ public class OVAProcessor extends AdapterBase implements Processor { | ||||
|         String ovfFileName = getOVFFilePath(templateFileFullPath); | ||||
|         if (ovfFileName == null) { | ||||
|             String msg = "Unable to locate OVF file in template package directory: " + templatePath; | ||||
|             logger.error(msg); | ||||
|             s_logger.error(msg); | ||||
|             throw new InternalErrorException(msg); | ||||
|         } | ||||
|         try { | ||||
| @ -128,7 +130,7 @@ public class OVAProcessor extends AdapterBase implements Processor { | ||||
|             return virtualSize; | ||||
|         } catch (Exception e) { | ||||
|             String msg = "Unable to parse OVF XML document to get the virtual disk size due to" + e; | ||||
|             logger.error(msg); | ||||
|             s_logger.error(msg); | ||||
|             throw new InternalErrorException(msg); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.Map; | ||||
| import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.storage.Storage.ImageFormat; | ||||
| import com.cloud.storage.StorageLayer; | ||||
| @ -35,6 +36,7 @@ import com.cloud.utils.component.AdapterBase; | ||||
| 
 | ||||
| @Local(value = Processor.class) | ||||
| public class QCOW2Processor extends AdapterBase implements Processor { | ||||
|     private static final Logger s_logger = Logger.getLogger(QCOW2Processor.class); | ||||
|     private static final int VIRTUALSIZE_HEADER_LOCATION = 24; | ||||
| 
 | ||||
|     private StorageLayer _storage; | ||||
| @ -42,14 +44,14 @@ public class QCOW2Processor extends AdapterBase implements Processor { | ||||
|     @Override | ||||
|     public FormatInfo process(String templatePath, ImageFormat format, String templateName) { | ||||
|         if (format != null) { | ||||
|             logger.debug("We currently don't handle conversion from " + format + " to QCOW2."); | ||||
|             s_logger.debug("We currently don't handle conversion from " + format + " to QCOW2."); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         String qcow2Path = templatePath + File.separator + templateName + "." + ImageFormat.QCOW2.getFileExtension(); | ||||
| 
 | ||||
|         if (!_storage.exists(qcow2Path)) { | ||||
|             logger.debug("Unable to find the qcow2 file: " + qcow2Path); | ||||
|             s_logger.debug("Unable to find the qcow2 file: " + qcow2Path); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
| @ -64,7 +66,7 @@ public class QCOW2Processor extends AdapterBase implements Processor { | ||||
|         try { | ||||
|             info.virtualSize = getVirtualSize(qcow2File); | ||||
|         } catch (IOException e) { | ||||
|             logger.error("Unable to get virtual size from " + qcow2File.getName()); | ||||
|             s_logger.error("Unable to get virtual size from " + qcow2File.getName()); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.Map; | ||||
| import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.exception.InternalErrorException; | ||||
| import com.cloud.storage.Storage.ImageFormat; | ||||
| @ -33,6 +34,7 @@ import com.cloud.utils.component.AdapterBase; | ||||
| 
 | ||||
| @Local(value = Processor.class) | ||||
| public class RawImageProcessor extends AdapterBase implements Processor { | ||||
|     private static final Logger s_logger = Logger.getLogger(RawImageProcessor.class); | ||||
|     StorageLayer _storage; | ||||
| 
 | ||||
|     @Override | ||||
| @ -48,13 +50,13 @@ public class RawImageProcessor extends AdapterBase implements Processor { | ||||
|     @Override | ||||
|     public FormatInfo process(String templatePath, ImageFormat format, String templateName) throws InternalErrorException { | ||||
|         if (format != null) { | ||||
|             logger.debug("We currently don't handle conversion from " + format + " to raw image."); | ||||
|             s_logger.debug("We currently don't handle conversion from " + format + " to raw image."); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         String imgPath = templatePath + File.separator + templateName + "." + ImageFormat.RAW.getFileExtension(); | ||||
|         if (!_storage.exists(imgPath)) { | ||||
|             logger.debug("Unable to find raw image:" + imgPath); | ||||
|             s_logger.debug("Unable to find raw image:" + imgPath); | ||||
|             return null; | ||||
|         } | ||||
|         FormatInfo info = new FormatInfo(); | ||||
| @ -62,7 +64,7 @@ public class RawImageProcessor extends AdapterBase implements Processor { | ||||
|         info.filename = templateName + "." + ImageFormat.RAW.getFileExtension(); | ||||
|         info.size = _storage.getSize(imgPath); | ||||
|         info.virtualSize = info.size; | ||||
|         logger.debug("Process raw image " + info.filename + " successfully"); | ||||
|         s_logger.debug("Process raw image " + info.filename + " successfully"); | ||||
|         return info; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -22,6 +22,7 @@ package com.cloud.storage.template; | ||||
| import com.cloud.storage.Storage.ImageFormat; | ||||
| import com.cloud.storage.StorageLayer; | ||||
| import com.cloud.utils.component.AdapterBase; | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| @ -30,20 +31,21 @@ import java.util.Map; | ||||
| 
 | ||||
| @Local(value = Processor.class) | ||||
| public class TARProcessor extends AdapterBase implements Processor { | ||||
|     private static final Logger s_logger = Logger.getLogger(TARProcessor.class); | ||||
| 
 | ||||
|     private StorageLayer _storage; | ||||
| 
 | ||||
|     @Override | ||||
|     public FormatInfo process(String templatePath, ImageFormat format, String templateName) { | ||||
|         if (format != null) { | ||||
|             logger.debug("We currently don't handle conversion from " + format + " to TAR."); | ||||
|             s_logger.debug("We currently don't handle conversion from " + format + " to TAR."); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         String tarPath = templatePath + File.separator + templateName + "." + ImageFormat.TAR.getFileExtension(); | ||||
| 
 | ||||
|         if (!_storage.exists(tarPath)) { | ||||
|             logger.debug("Unable to find the tar file: " + tarPath); | ||||
|             s_logger.debug("Unable to find the tar file: " + tarPath); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.Map; | ||||
| import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.storage.Storage.ImageFormat; | ||||
| import com.cloud.storage.StorageLayer; | ||||
| @ -42,6 +43,7 @@ import com.cloud.utils.component.AdapterBase; | ||||
| @Local(value = Processor.class) | ||||
| public class VhdProcessor extends AdapterBase implements Processor { | ||||
| 
 | ||||
|     private static final Logger s_logger = Logger.getLogger(VhdProcessor.class); | ||||
|     StorageLayer _storage; | ||||
|     private int vhdFooterSize = 512; | ||||
|     private int vhdFooterCreatorAppOffset = 28; | ||||
| @ -52,13 +54,13 @@ public class VhdProcessor extends AdapterBase implements Processor { | ||||
|     @Override | ||||
|     public FormatInfo process(String templatePath, ImageFormat format, String templateName) { | ||||
|         if (format != null) { | ||||
|             logger.debug("We currently don't handle conversion from " + format + " to VHD."); | ||||
|             s_logger.debug("We currently don't handle conversion from " + format + " to VHD."); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         String vhdPath = templatePath + File.separator + templateName + "." + ImageFormat.VHD.getFileExtension(); | ||||
|         if (!_storage.exists(vhdPath)) { | ||||
|             logger.debug("Unable to find the vhd file: " + vhdPath); | ||||
|             s_logger.debug("Unable to find the vhd file: " + vhdPath); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
| @ -72,7 +74,7 @@ public class VhdProcessor extends AdapterBase implements Processor { | ||||
|         try { | ||||
|             info.virtualSize = getVirtualSize(vhdFile); | ||||
|         } catch (IOException e) { | ||||
|             logger.error("Unable to get the virtual size for " + vhdPath); | ||||
|             s_logger.error("Unable to get the virtual size for " + vhdPath); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -31,6 +31,7 @@ import java.util.regex.Pattern; | ||||
| import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.exception.InternalErrorException; | ||||
| import com.cloud.storage.Storage.ImageFormat; | ||||
| @ -39,23 +40,24 @@ import com.cloud.utils.component.AdapterBase; | ||||
| 
 | ||||
| @Local(value = Processor.class) | ||||
| public class VmdkProcessor extends AdapterBase implements Processor { | ||||
|     private static final Logger s_logger = Logger.getLogger(VmdkProcessor.class); | ||||
| 
 | ||||
|     StorageLayer _storage; | ||||
| 
 | ||||
|     @Override | ||||
|     public FormatInfo process(String templatePath, ImageFormat format, String templateName) throws InternalErrorException { | ||||
|         if (format != null) { | ||||
|             if (logger.isInfoEnabled()) { | ||||
|                 logger.info("We currently don't handle conversion from " + format + " to VMDK."); | ||||
|             if (s_logger.isInfoEnabled()) { | ||||
|                 s_logger.info("We currently don't handle conversion from " + format + " to VMDK."); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName); | ||||
|         s_logger.info("Template processing. templatePath: " + templatePath + ", templateName: " + templateName); | ||||
|         String templateFilePath = templatePath + File.separator + templateName + "." + ImageFormat.VMDK.getFileExtension(); | ||||
|         if (!_storage.exists(templateFilePath)) { | ||||
|             if (logger.isInfoEnabled()) { | ||||
|                 logger.info("Unable to find the vmware template file: " + templateFilePath); | ||||
|             if (s_logger.isInfoEnabled()) { | ||||
|                 s_logger.info("Unable to find the vmware template file: " + templateFilePath); | ||||
|             } | ||||
|             return null; | ||||
|         } | ||||
| @ -75,7 +77,7 @@ public class VmdkProcessor extends AdapterBase implements Processor { | ||||
|             long size = getTemplateVirtualSize(file.getParent(), file.getName()); | ||||
|             return size; | ||||
|         } catch (Exception e) { | ||||
|             logger.info("[ignored]" | ||||
|             s_logger.info("[ignored]" | ||||
|                     + "failed to get template virtual size for vmdk: " + e.getLocalizedMessage()); | ||||
|         } | ||||
|         return file.length(); | ||||
| @ -101,15 +103,15 @@ public class VmdkProcessor extends AdapterBase implements Processor { | ||||
|             } | ||||
|         } catch(FileNotFoundException ex) { | ||||
|             String msg = "Unable to open file '" + templateFileFullPath + "' " + ex.toString(); | ||||
|             logger.error(msg); | ||||
|             s_logger.error(msg); | ||||
|             throw new InternalErrorException(msg); | ||||
|         } catch(IOException ex) { | ||||
|             String msg = "Unable read open file '" + templateFileFullPath + "' " + ex.toString(); | ||||
|             logger.error(msg); | ||||
|             s_logger.error(msg); | ||||
|             throw new InternalErrorException(msg); | ||||
|         } | ||||
| 
 | ||||
|         logger.debug("vmdk file had size="+virtualSize); | ||||
|         s_logger.debug("vmdk file had size="+virtualSize); | ||||
|         return virtualSize; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -45,6 +45,7 @@ import org.apache.cloudstack.framework.jobs.AsyncJob; | ||||
| import org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext; | ||||
| import org.apache.cloudstack.managed.context.ManagedContextRunnable; | ||||
| import org.apache.cloudstack.utils.identity.ManagementServerNode; | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.agent.AgentManager; | ||||
| import com.cloud.agent.Listener; | ||||
| @ -115,6 +116,8 @@ import com.cloud.utils.time.InaccurateClock; | ||||
|  **/ | ||||
| @Local(value = {AgentManager.class}) | ||||
| public class AgentManagerImpl extends ManagerBase implements AgentManager, HandlerFactory, Configurable { | ||||
|     protected static final Logger s_logger = Logger.getLogger(AgentManagerImpl.class); | ||||
|     protected static final Logger status_logger = Logger.getLogger(Status.class); | ||||
| 
 | ||||
|     /** | ||||
|      * _agents is a ConcurrentHashMap, but it is used from within a synchronized block. | ||||
| @ -197,12 +200,12 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|     @Override | ||||
|     public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException { | ||||
| 
 | ||||
|         logger.info("Ping Timeout is " + PingTimeout.value()); | ||||
|         s_logger.info("Ping Timeout is " + PingTimeout.value()); | ||||
| 
 | ||||
|         final int threads = DirectAgentLoadSize.value(); | ||||
| 
 | ||||
|         _nodeId = ManagementServerNode.getManagementServerId(); | ||||
|         logger.info("Configuring AgentManagerImpl. management server node id(msid): " + _nodeId); | ||||
|         s_logger.info("Configuring AgentManagerImpl. management server node id(msid): " + _nodeId); | ||||
| 
 | ||||
|         final long lastPing = (System.currentTimeMillis() >> 10) - (long)(PingTimeout.value() * PingInterval.value()); | ||||
|         _hostDao.markHostsAsDisconnected(_nodeId, lastPing); | ||||
| @ -216,13 +219,13 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         _connectExecutor.allowCoreThreadTimeOut(true); | ||||
| 
 | ||||
|         _connection = new NioServer("AgentManager", Port.value(), Workers.value() + 10, this); | ||||
|         logger.info("Listening on " + Port.value() + " with " + Workers.value() + " workers"); | ||||
|         s_logger.info("Listening on " + Port.value() + " with " + Workers.value() + " workers"); | ||||
| 
 | ||||
|         // executes all agent commands other than cron and ping | ||||
|         _directAgentExecutor = new ScheduledThreadPoolExecutor(DirectAgentPoolSize.value(), new NamedThreadFactory("DirectAgent")); | ||||
|         // executes cron and ping agent commands | ||||
|         _cronJobExecutor = new ScheduledThreadPoolExecutor(DirectAgentPoolSize.value(), new NamedThreadFactory("DirectAgentCronJob")); | ||||
|         logger.debug("Created DirectAgentAttache pool with size: " + DirectAgentPoolSize.value()); | ||||
|         s_logger.debug("Created DirectAgentAttache pool with size: " + DirectAgentPoolSize.value()); | ||||
|         _directAgentThreadCap = Math.round(DirectAgentPoolSize.value() * DirectAgentThreadCap.value()) + 1; // add 1 to always make the value > 0 | ||||
| 
 | ||||
|         _monitorExecutor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("AgentMonitor")); | ||||
| @ -257,8 +260,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                     _cmdMonitors.add(new Pair<Integer, Listener>(_monitorId, listener)); | ||||
|                 } | ||||
|             } | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Registering listener " + listener.getClass().getSimpleName() + " with id " + _monitorId); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Registering listener " + listener.getClass().getSimpleName() + " with id " + _monitorId); | ||||
|             } | ||||
|             return _monitorId; | ||||
|         } | ||||
| @ -279,7 +282,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
| 
 | ||||
|     @Override | ||||
|     public void unregisterForHostEvents(final int id) { | ||||
|         logger.debug("Deregistering " + id); | ||||
|         s_logger.debug("Deregistering " + id); | ||||
|         _hostMonitors.remove(id); | ||||
|     } | ||||
| 
 | ||||
| @ -294,15 +297,15 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         logger.warn("No handling of agent control command: " + cmd + " sent from " + attache.getId()); | ||||
|         s_logger.warn("No handling of agent control command: " + cmd + " sent from " + attache.getId()); | ||||
|         return new AgentControlAnswer(cmd); | ||||
|     } | ||||
| 
 | ||||
|     public void handleCommands(final AgentAttache attache, final long sequence, final Command[] cmds) { | ||||
|         for (final Pair<Integer, Listener> listener : _cmdMonitors) { | ||||
|             final boolean processed = listener.second().processCommands(attache.getId(), sequence, cmds); | ||||
|             if (logger.isTraceEnabled()) { | ||||
|                 logger.trace("SeqA " + attache.getId() + "-" + sequence + ": " + (processed ? "processed" : "not processed") + " by " + listener.getClass()); | ||||
|             if (s_logger.isTraceEnabled()) { | ||||
|                 s_logger.trace("SeqA " + attache.getId() + "-" + sequence + ": " + (processed ? "processed" : "not processed") + " by " + listener.getClass()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -362,7 +365,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         } | ||||
| 
 | ||||
|         if (answers != null && answers[0] instanceof UnsupportedAnswer) { | ||||
|             logger.warn("Unsupported Command: " + answers[0].getDetails()); | ||||
|             s_logger.warn("Unsupported Command: " + answers[0].getDetails()); | ||||
|             return answers[0]; | ||||
|         } | ||||
| 
 | ||||
| @ -455,14 +458,14 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         final Long hostId = agent.getId(); | ||||
|         final HostVO host = _hostDao.findById(hostId); | ||||
|         if (host != null && host.getType() != null && !host.getType().isVirtual()) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("checking if agent (" + hostId + ") is alive"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("checking if agent (" + hostId + ") is alive"); | ||||
|             } | ||||
|             final Answer answer = easySend(hostId, new CheckHealthCommand()); | ||||
|             if (answer != null && answer.getResult()) { | ||||
|                 final Status status = Status.Up; | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("agent (" + hostId + ") responded to checkHeathCommand, reporting that agent is " + status); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("agent (" + hostId + ") responded to checkHeathCommand, reporting that agent is " + status); | ||||
|                 } | ||||
|                 return status; | ||||
|             } | ||||
| @ -477,7 +480,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         } | ||||
|         final AgentAttache agent = findAttache(hostId); | ||||
|         if (agent == null) { | ||||
|             logger.debug("Unable to find agent for " + hostId); | ||||
|             s_logger.debug("Unable to find agent for " + hostId); | ||||
|             throw new AgentUnavailableException("Unable to find agent ", hostId); | ||||
|         } | ||||
| 
 | ||||
| @ -505,8 +508,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|             return; | ||||
|         } | ||||
|         final long hostId = attache.getId(); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Remove Agent : " + hostId); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Remove Agent : " + hostId); | ||||
|         } | ||||
|         AgentAttache removed = null; | ||||
|         boolean conflict = false; | ||||
| @ -519,15 +522,15 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|             } | ||||
|         } | ||||
|         if (conflict) { | ||||
|             logger.debug("Agent for host " + hostId + " is created when it is being disconnected"); | ||||
|             s_logger.debug("Agent for host " + hostId + " is created when it is being disconnected"); | ||||
|         } | ||||
|         if (removed != null) { | ||||
|             removed.disconnect(nextState); | ||||
|         } | ||||
| 
 | ||||
|         for (final Pair<Integer, Listener> monitor : _hostMonitors) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Sending Disconnect to listener: " + monitor.second().getClass().getName()); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Sending Disconnect to listener: " + monitor.second().getClass().getName()); | ||||
|             } | ||||
|             monitor.second().processDisconnect(hostId, nextState); | ||||
|         } | ||||
| @ -537,8 +540,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         final long hostId = attache.getId(); | ||||
|         final HostVO host = _hostDao.findById(hostId); | ||||
|         for (final Pair<Integer, Listener> monitor : _hostMonitors) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Sending Connect to listener: " + monitor.second().getClass().getSimpleName()); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Sending Connect to listener: " + monitor.second().getClass().getSimpleName()); | ||||
|             } | ||||
|             for (int i = 0; i < cmd.length; i++) { | ||||
|                 try { | ||||
| @ -547,12 +550,12 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                     if (e instanceof ConnectionException) { | ||||
|                         final ConnectionException ce = (ConnectionException)e; | ||||
|                         if (ce.isSetupError()) { | ||||
|                             logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + | ||||
|                             s_logger.warn("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + | ||||
|                                     " due to " + e.getMessage()); | ||||
|                             handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true); | ||||
|                             throw ce; | ||||
|                         } else { | ||||
|                             logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + | ||||
|                             s_logger.info("Monitor " + monitor.second().getClass().getSimpleName() + " says not to continue the connect process for " + hostId + | ||||
|                                     " due to " + e.getMessage()); | ||||
|                             handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true); | ||||
|                             return attache; | ||||
| @ -561,7 +564,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                         handleDisconnectWithoutInvestigation(attache, Event.ShutdownRequested, true, true); | ||||
|                         throw new CloudRuntimeException("Unable to connect " + attache.getId(), e); | ||||
|                     } else { | ||||
|                         logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + | ||||
|                         s_logger.error("Monitor " + monitor.second().getClass().getSimpleName() + " says there is an error in the connect process for " + hostId + | ||||
|                                 " due to " + e.getMessage(), e); | ||||
|                         handleDisconnectWithoutInvestigation(attache, Event.AgentDisconnected, true, true); | ||||
|                         throw new CloudRuntimeException("Unable to connect " + attache.getId(), e); | ||||
| @ -613,19 +616,19 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|             final Constructor<?> constructor = clazz.getConstructor(); | ||||
|             resource = (ServerResource)constructor.newInstance(); | ||||
|         } catch (final ClassNotFoundException e) { | ||||
|             logger.warn("Unable to find class " + host.getResource(), e); | ||||
|             s_logger.warn("Unable to find class " + host.getResource(), e); | ||||
|         } catch (final InstantiationException e) { | ||||
|             logger.warn("Unablet to instantiate class " + host.getResource(), e); | ||||
|             s_logger.warn("Unablet to instantiate class " + host.getResource(), e); | ||||
|         } catch (final IllegalAccessException e) { | ||||
|             logger.warn("Illegal access " + host.getResource(), e); | ||||
|             s_logger.warn("Illegal access " + host.getResource(), e); | ||||
|         } catch (final SecurityException e) { | ||||
|             logger.warn("Security error on " + host.getResource(), e); | ||||
|             s_logger.warn("Security error on " + host.getResource(), e); | ||||
|         } catch (final NoSuchMethodException e) { | ||||
|             logger.warn("NoSuchMethodException error on " + host.getResource(), e); | ||||
|             s_logger.warn("NoSuchMethodException error on " + host.getResource(), e); | ||||
|         } catch (final IllegalArgumentException e) { | ||||
|             logger.warn("IllegalArgumentException error on " + host.getResource(), e); | ||||
|             s_logger.warn("IllegalArgumentException error on " + host.getResource(), e); | ||||
|         } catch (final InvocationTargetException e) { | ||||
|             logger.warn("InvocationTargetException error on " + host.getResource(), e); | ||||
|             s_logger.warn("InvocationTargetException error on " + host.getResource(), e); | ||||
|         } | ||||
| 
 | ||||
|         if (resource != null) { | ||||
| @ -659,12 +662,12 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|             try { | ||||
|                 resource.configure(host.getName(), params); | ||||
|             } catch (final ConfigurationException e) { | ||||
|                 logger.warn("Unable to configure resource due to " + e.getMessage()); | ||||
|                 s_logger.warn("Unable to configure resource due to " + e.getMessage()); | ||||
|                 return null; | ||||
|             } | ||||
| 
 | ||||
|             if (!resource.start()) { | ||||
|                 logger.warn("Unable to start the resource"); | ||||
|                 s_logger.warn("Unable to start the resource"); | ||||
|                 return null; | ||||
|             } | ||||
|         } | ||||
| @ -682,14 +685,14 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|             //load the respective discoverer | ||||
|             final Discoverer discoverer = _resourceMgr.getMatchingDiscover(host.getHypervisorType()); | ||||
|             if (discoverer == null) { | ||||
|                 logger.info("Could not to find a Discoverer to load the resource: " + host.getId() + " for hypervisor type: " + host.getHypervisorType()); | ||||
|                 s_logger.info("Could not to find a Discoverer to load the resource: " + host.getId() + " for hypervisor type: " + host.getHypervisorType()); | ||||
|                 resource = loadResourcesWithoutHypervisor(host); | ||||
|             } else { | ||||
|                 resource = discoverer.reloadResource(host); | ||||
|             } | ||||
| 
 | ||||
|             if (resource == null) { | ||||
|                 logger.warn("Unable to load the resource: " + host.getId()); | ||||
|                 s_logger.warn("Unable to load the resource: " + host.getId()); | ||||
|                 return false; | ||||
|             } | ||||
| 
 | ||||
| @ -715,7 +718,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|     } | ||||
| 
 | ||||
|     protected AgentAttache createAttacheForDirectConnect(final Host host, final ServerResource resource) throws ConnectionException { | ||||
|         logger.debug("create DirectAgentAttache for " + host.getId()); | ||||
|         s_logger.debug("create DirectAgentAttache for " + host.getId()); | ||||
|         final DirectAgentAttache attache = new DirectAgentAttache(this, host.getId(), host.getName(), resource, host.isInMaintenanceStates()); | ||||
| 
 | ||||
|         AgentAttache old = null; | ||||
| @ -736,13 +739,13 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|             _connection.stop(); | ||||
|         } | ||||
| 
 | ||||
|         logger.info("Disconnecting agents: " + _agents.size()); | ||||
|         s_logger.info("Disconnecting agents: " + _agents.size()); | ||||
|         synchronized (_agents) { | ||||
|             for (final AgentAttache agent : _agents.values()) { | ||||
|                 final HostVO host = _hostDao.findById(agent.getId()); | ||||
|                 if (host == null) { | ||||
|                     if (logger.isDebugEnabled()) { | ||||
|                         logger.debug("Cant not find host " + agent.getId()); | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Cant not find host " + agent.getId()); | ||||
|                     } | ||||
|                 } else { | ||||
|                     if (!agent.forForward()) { | ||||
| @ -760,17 +763,17 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|     protected boolean handleDisconnectWithoutInvestigation(final AgentAttache attache, final Status.Event event, final boolean transitState, final boolean removeAgent) { | ||||
|         final long hostId = attache.getId(); | ||||
| 
 | ||||
|         logger.info("Host " + hostId + " is disconnecting with event " + event); | ||||
|         s_logger.info("Host " + hostId + " is disconnecting with event " + event); | ||||
|         Status nextStatus = null; | ||||
|         final HostVO host = _hostDao.findById(hostId); | ||||
|         if (host == null) { | ||||
|             logger.warn("Can't find host with " + hostId); | ||||
|             s_logger.warn("Can't find host with " + hostId); | ||||
|             nextStatus = Status.Removed; | ||||
|         } else { | ||||
|             final Status currentStatus = host.getStatus(); | ||||
|             if (currentStatus == Status.Down || currentStatus == Status.Alert || currentStatus == Status.Removed) { | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Host " + hostId + " is already " + currentStatus); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Host " + hostId + " is already " + currentStatus); | ||||
|                 } | ||||
|                 nextStatus = currentStatus; | ||||
|             } else { | ||||
| @ -778,18 +781,18 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                     nextStatus = currentStatus.getNextStatus(event); | ||||
|                 } catch (final NoTransitionException e) { | ||||
|                     final String err = "Cannot find next status for " + event + " as current status is " + currentStatus + " for agent " + hostId; | ||||
|                     logger.debug(err); | ||||
|                     s_logger.debug(err); | ||||
|                     throw new CloudRuntimeException(err); | ||||
|                 } | ||||
| 
 | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("The next status of agent " + hostId + "is " + nextStatus + ", current status is " + currentStatus); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("The next status of agent " + hostId + "is " + nextStatus + ", current status is " + currentStatus); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Deregistering link for " + hostId + " with state " + nextStatus); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Deregistering link for " + hostId + " with state " + nextStatus); | ||||
|         } | ||||
| 
 | ||||
|         removeAgent(attache, nextStatus); | ||||
| @ -814,48 +817,48 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                  * Why this can happen? Ask God not me. I hate there was no piece of comment for code handling race condition. | ||||
|                  * God knew what race condition the code dealt with! | ||||
|                  */ | ||||
|                 logger.debug("Caught exception while getting agent's next status", ne); | ||||
|                 s_logger.debug("Caught exception while getting agent's next status", ne); | ||||
|             } | ||||
| 
 | ||||
|             if (nextStatus == Status.Alert) { | ||||
|                 /* OK, we are going to the bad status, let's see what happened */ | ||||
|                 logger.info("Investigating why host " + hostId + " has disconnected with event " + event); | ||||
|                 s_logger.info("Investigating why host " + hostId + " has disconnected with event " + event); | ||||
| 
 | ||||
|                 Status determinedState = investigate(attache); | ||||
|                 // if state cannot be determined do nothing and bail out | ||||
|                 if (determinedState == null) { | ||||
|                     if (((System.currentTimeMillis() >> 10) - host.getLastPinged()) > AlertWait.value()) { | ||||
|                         logger.warn("Agent " + hostId + " state cannot be determined for more than " + AlertWait + "(" + AlertWait.value() + ") seconds, will go to Alert state"); | ||||
|                         s_logger.warn("Agent " + hostId + " state cannot be determined for more than " + AlertWait + "(" + AlertWait.value() + ") seconds, will go to Alert state"); | ||||
|                         determinedState = Status.Alert; | ||||
|                     } else { | ||||
|                         logger.warn("Agent " + hostId + " state cannot be determined, do nothing"); | ||||
|                         s_logger.warn("Agent " + hostId + " state cannot be determined, do nothing"); | ||||
|                         return false; | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 final Status currentStatus = host.getStatus(); | ||||
|                 logger.info("The agent " + hostId + " state determined is " + determinedState); | ||||
|                 s_logger.info("The agent " + hostId + " state determined is " + determinedState); | ||||
| 
 | ||||
|                 if (determinedState == Status.Down) { | ||||
|                     String message = "Host is down: " + host.getId() + "-" + host.getName() + ". Starting HA on the VMs"; | ||||
|                     logger.error(message); | ||||
|                     s_logger.error(message); | ||||
|                     if (host.getType() != Host.Type.SecondaryStorage && host.getType() != Host.Type.ConsoleProxy) { | ||||
|                         _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_HOST, host.getDataCenterId(), host.getPodId(), "Host down, " + host.getId(), message); | ||||
|                     } | ||||
|                     event = Status.Event.HostDown; | ||||
|                 } else if (determinedState == Status.Up) { | ||||
|                     /* Got ping response from host, bring it back */ | ||||
|                     logger.info("Agent is determined to be up and running"); | ||||
|                     s_logger.info("Agent is determined to be up and running"); | ||||
|                     agentStatusTransitTo(host, Status.Event.Ping, _nodeId); | ||||
|                     return false; | ||||
|                 } else if (determinedState == Status.Disconnected) { | ||||
|                     logger.warn("Agent is disconnected but the host is still up: " + host.getId() + "-" + host.getName()); | ||||
|                     s_logger.warn("Agent is disconnected but the host is still up: " + host.getId() + "-" + host.getName()); | ||||
|                     if (currentStatus == Status.Disconnected) { | ||||
|                         if ((System.currentTimeMillis() >> 10) - host.getLastPinged() > AlertWait.value()) { | ||||
|                             logger.warn("Host " + host.getId() + " has been disconnected past the wait time it should be disconnected."); | ||||
|                             s_logger.warn("Host " + host.getId() + " has been disconnected past the wait time it should be disconnected."); | ||||
|                             event = Status.Event.WaitedTooLong; | ||||
|                         } else { | ||||
|                             logger.debug("Host " + host.getId() + " has been determined to be disconnected but it hasn't passed the wait time yet."); | ||||
|                             s_logger.debug("Host " + host.getId() + " has been determined to be disconnected but it hasn't passed the wait time yet."); | ||||
|                             return false; | ||||
|                         } | ||||
|                     } else if (currentStatus == Status.Up) { | ||||
| @ -877,7 +880,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                             "In availability zone " + host.getDataCenterId() + ", host is in alert state: " + host.getId() + "-" + host.getName()); | ||||
|                 } | ||||
|             } else { | ||||
|                 logger.debug("The next status of agent " + host.getId() + " is not Alert, no need to investigate what happened"); | ||||
|                 s_logger.debug("The next status of agent " + host.getId() + " is not Alert, no need to investigate what happened"); | ||||
|             } | ||||
|         } | ||||
|         handleDisconnectWithoutInvestigation(attache, event, true, true); | ||||
| @ -908,7 +911,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                     handleDisconnectWithoutInvestigation(_attache, _event, true, false); | ||||
|                 } | ||||
|             } catch (final Exception e) { | ||||
|                 logger.error("Exception caught while handling disconnect: ", e); | ||||
|                 s_logger.error("Exception caught while handling disconnect: ", e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -918,34 +921,34 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         try { | ||||
|             final Host h = _hostDao.findById(hostId); | ||||
|             if (h == null || h.getRemoved() != null) { | ||||
|                 logger.debug("Host with id " + hostId + " doesn't exist"); | ||||
|                 s_logger.debug("Host with id " + hostId + " doesn't exist"); | ||||
|                 return null; | ||||
|             } | ||||
|             final Status status = h.getStatus(); | ||||
|             if (!status.equals(Status.Up) && !status.equals(Status.Connecting)) { | ||||
|                 logger.debug("Can not send command " + cmd + " due to Host " + hostId + " is not up"); | ||||
|                 s_logger.debug("Can not send command " + cmd + " due to Host " + hostId + " is not up"); | ||||
|                 return null; | ||||
|             } | ||||
|             final Answer answer = send(hostId, cmd); | ||||
|             if (answer == null) { | ||||
|                 logger.warn("send returns null answer"); | ||||
|                 s_logger.warn("send returns null answer"); | ||||
|                 return null; | ||||
|             } | ||||
| 
 | ||||
|             if (logger.isDebugEnabled() && answer.getDetails() != null) { | ||||
|                 logger.debug("Details from executing " + cmd.getClass() + ": " + answer.getDetails()); | ||||
|             if (s_logger.isDebugEnabled() && answer.getDetails() != null) { | ||||
|                 s_logger.debug("Details from executing " + cmd.getClass() + ": " + answer.getDetails()); | ||||
|             } | ||||
| 
 | ||||
|             return answer; | ||||
| 
 | ||||
|         } catch (final AgentUnavailableException e) { | ||||
|             logger.warn(e.getMessage()); | ||||
|             s_logger.warn(e.getMessage()); | ||||
|             return null; | ||||
|         } catch (final OperationTimedoutException e) { | ||||
|             logger.warn("Operation timed out: " + e.getMessage()); | ||||
|             s_logger.warn("Operation timed out: " + e.getMessage()); | ||||
|             return null; | ||||
|         } catch (final Exception e) { | ||||
|             logger.warn("Exception while sending", e); | ||||
|             s_logger.warn("Exception while sending", e); | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| @ -967,23 +970,23 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
| 
 | ||||
|         host = _hostDao.findById(hostId); | ||||
|         if (host == null || host.getRemoved() != null) { | ||||
|             logger.warn("Unable to find host " + hostId); | ||||
|             s_logger.warn("Unable to find host " + hostId); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         if (host.getStatus() == Status.Disconnected) { | ||||
|             logger.info("Host is already disconnected, no work to be done"); | ||||
|             s_logger.info("Host is already disconnected, no work to be done"); | ||||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         if (host.getStatus() != Status.Up && host.getStatus() != Status.Alert && host.getStatus() != Status.Rebalancing) { | ||||
|             logger.info("Unable to disconnect host because it is not in the correct state: host=" + hostId + "; Status=" + host.getStatus()); | ||||
|             s_logger.info("Unable to disconnect host because it is not in the correct state: host=" + hostId + "; Status=" + host.getStatus()); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         final AgentAttache attache = findAttache(hostId); | ||||
|         if (attache == null) { | ||||
|             logger.info("Unable to disconnect host because it is not connected to this server: " + hostId); | ||||
|             s_logger.info("Unable to disconnect host because it is not connected to this server: " + hostId); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
| @ -993,8 +996,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
| 
 | ||||
|     public boolean executeUserRequest(final long hostId, final Event event) throws AgentUnavailableException { | ||||
|         if (event == Event.AgentDisconnected) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Received agent disconnect event for host " + hostId); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Received agent disconnect event for host " + hostId); | ||||
|             } | ||||
|             AgentAttache attache = null; | ||||
|             attache = findAttache(hostId); | ||||
| @ -1015,7 +1018,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|     } | ||||
| 
 | ||||
|     protected AgentAttache createAttacheForConnect(final HostVO host, final Link link) throws ConnectionException { | ||||
|         logger.debug("create ConnectedAgentAttache for " + host.getId()); | ||||
|         s_logger.debug("create ConnectedAgentAttache for " + host.getId()); | ||||
|         final AgentAttache attache = new ConnectedAgentAttache(this, host.getId(), host.getName(), link, host.isInMaintenanceStates()); | ||||
|         link.attach(attache); | ||||
| 
 | ||||
| @ -1041,7 +1044,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                 attache = notifyMonitorsOfConnection(attache, startup, false); | ||||
|             } | ||||
|         } catch (final Exception e) { | ||||
|             logger.debug("Failed to handle host connection: " + e.toString()); | ||||
|             s_logger.debug("Failed to handle host connection: " + e.toString()); | ||||
|             ready = new ReadyCommand(null); | ||||
|             ready.setDetails(e.toString()); | ||||
|         } finally { | ||||
| @ -1058,7 +1061,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                 easySend(attache.getId(), ready); | ||||
|             } | ||||
|         } catch (final Exception e) { | ||||
|             logger.debug("Failed to send ready command:" + e.toString()); | ||||
|             s_logger.debug("Failed to send ready command:" + e.toString()); | ||||
|         } | ||||
|         return attache; | ||||
|     } | ||||
| @ -1077,28 +1080,28 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         @Override | ||||
|         protected void runInContext() { | ||||
|             try { | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Simulating start for resource " + resource.getName() + " id " + id); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Simulating start for resource " + resource.getName() + " id " + id); | ||||
|                 } | ||||
| 
 | ||||
|                 if (tapLoadingAgents(id, TapAgentsAction.Add)) { | ||||
|                     try { | ||||
|                         final AgentAttache agentattache = findAttache(id); | ||||
|                         if (agentattache == null) { | ||||
|                             logger.debug("Creating agent for host " + id); | ||||
|                             s_logger.debug("Creating agent for host " + id); | ||||
|                             _resourceMgr.createHostAndAgent(id, resource, details, false, null, false); | ||||
|                             logger.debug("Completed creating agent for host " + id); | ||||
|                             s_logger.debug("Completed creating agent for host " + id); | ||||
|                         } else { | ||||
|                             logger.debug("Agent already created in another thread for host " + id + ", ignore this"); | ||||
|                             s_logger.debug("Agent already created in another thread for host " + id + ", ignore this"); | ||||
|                         } | ||||
|                     } finally { | ||||
|                         tapLoadingAgents(id, TapAgentsAction.Del); | ||||
|                     } | ||||
|                 } else { | ||||
|                     logger.debug("Agent creation already getting processed in another thread for host " + id + ", ignore this"); | ||||
|                     s_logger.debug("Agent creation already getting processed in another thread for host " + id + ", ignore this"); | ||||
|                 } | ||||
|             } catch (final Exception e) { | ||||
|                 logger.warn("Unable to simulate start on resource " + id + " name " + resource.getName(), e); | ||||
|                 s_logger.warn("Unable to simulate start on resource " + id + " name " + resource.getName(), e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -1124,7 +1127,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
| 
 | ||||
|             final AgentAttache attache = handleConnectedAgent(_link, startups, _request); | ||||
|             if (attache == null) { | ||||
|                 logger.warn("Unable to create attache for agent: " + _request); | ||||
|                 s_logger.warn("Unable to create attache for agent: " + _request); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -1146,7 +1149,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         try { | ||||
|             link.send(response.toBytes()); | ||||
|         } catch (final ClosedChannelException e) { | ||||
|             logger.debug("Failed to send startupanswer: " + e.toString()); | ||||
|             s_logger.debug("Failed to send startupanswer: " + e.toString()); | ||||
|         } | ||||
|         _connectExecutor.execute(new HandleAgentConnectTask(link, cmds, request)); | ||||
|     } | ||||
| @ -1164,7 +1167,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
| 
 | ||||
|             if (attache == null) { | ||||
|                 if (!(cmd instanceof StartupCommand)) { | ||||
|                     logger.warn("Throwing away a request because it came through as the first command on a connect: " + request); | ||||
|                     s_logger.warn("Throwing away a request because it came through as the first command on a connect: " + request); | ||||
|                 } else { | ||||
|                     //submit the task for execution | ||||
|                     request.logD("Scheduling the first command "); | ||||
| @ -1175,17 +1178,17 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
| 
 | ||||
|             final long hostId = attache.getId(); | ||||
| 
 | ||||
|             if (logger.isDebugEnabled()) { | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 if (cmd instanceof PingRoutingCommand) { | ||||
|                     logD = false; | ||||
|                     logger.debug("Ping from " + hostId); | ||||
|                     logger.trace("SeqA " + hostId + "-" + request.getSequence() + ": Processing " + request); | ||||
|                     s_logger.debug("Ping from " + hostId); | ||||
|                     s_logger.trace("SeqA " + hostId + "-" + request.getSequence() + ": Processing " + request); | ||||
|                 } else if (cmd instanceof PingCommand) { | ||||
|                     logD = false; | ||||
|                     logger.debug("Ping from " + hostId); | ||||
|                     logger.trace("SeqA " + attache.getId() + "-" + request.getSequence() + ": Processing " + request); | ||||
|                     s_logger.debug("Ping from " + hostId); | ||||
|                     s_logger.trace("SeqA " + attache.getId() + "-" + request.getSequence() + ": Processing " + request); | ||||
|                 } else { | ||||
|                     logger.debug("SeqA " + attache.getId() + "-" + request.getSequence() + ": Processing " + request); | ||||
|                     s_logger.debug("SeqA " + attache.getId() + "-" + request.getSequence() + ": Processing " + request); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
| @ -1209,7 +1212,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                     } else if (cmd instanceof ShutdownCommand) { | ||||
|                         final ShutdownCommand shutdown = (ShutdownCommand)cmd; | ||||
|                         final String reason = shutdown.getReason(); | ||||
|                         logger.info("Host " + attache.getId() + " has informed us that it is shutting down with reason " + reason + " and detail " + | ||||
|                         s_logger.info("Host " + attache.getId() + " has informed us that it is shutting down with reason " + reason + " and detail " + | ||||
|                                 shutdown.getDetail()); | ||||
|                         if (reason.equals(ShutdownCommand.Update)) { | ||||
|                             //disconnectWithoutInvestigation(attache, Event.UpdateNeeded); | ||||
| @ -1247,7 +1250,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                                         _alertMgr.clearAlert(AlertManager.AlertType.ALERT_TYPE_ROUTING, host.getDataCenterId(), host.getPodId()); | ||||
|                                     } | ||||
|                                 } else { | ||||
|                                     logger.debug("Not processing " + PingRoutingCommand.class.getSimpleName() + " for agent id=" + cmdHostId + | ||||
|                                     s_logger.debug("Not processing " + PingRoutingCommand.class.getSimpleName() + " for agent id=" + cmdHostId + | ||||
|                                             "; can't find the host in the DB"); | ||||
|                                 } | ||||
|                             } | ||||
| @ -1255,8 +1258,8 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                         } else if (cmd instanceof ReadyAnswer) { | ||||
|                             final HostVO host = _hostDao.findById(attache.getId()); | ||||
|                             if (host == null) { | ||||
|                                 if (logger.isDebugEnabled()) { | ||||
|                                     logger.debug("Cant not find host " + attache.getId()); | ||||
|                                 if (s_logger.isDebugEnabled()) { | ||||
|                                     s_logger.debug("Cant not find host " + attache.getId()); | ||||
|                                 } | ||||
|                             } | ||||
|                             answer = new Answer(cmd); | ||||
| @ -1265,33 +1268,33 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                         } | ||||
|                     } | ||||
|                 } catch (final Throwable th) { | ||||
|                     logger.warn("Caught: ", th); | ||||
|                     s_logger.warn("Caught: ", th); | ||||
|                     answer = new Answer(cmd, false, th.getMessage()); | ||||
|                 } | ||||
|                 answers[i] = answer; | ||||
|             } | ||||
| 
 | ||||
|             final Response response = new Response(request, answers, _nodeId, attache.getId()); | ||||
|             if (logger.isDebugEnabled()) { | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 if (logD) { | ||||
|                     logger.debug("SeqA " + attache.getId() + "-" + response.getSequence() + ": Sending " + response); | ||||
|                     s_logger.debug("SeqA " + attache.getId() + "-" + response.getSequence() + ": Sending " + response); | ||||
|                 } else { | ||||
|                     logger.trace("SeqA " + attache.getId() + "-" + response.getSequence() + ": Sending " + response); | ||||
|                     s_logger.trace("SeqA " + attache.getId() + "-" + response.getSequence() + ": Sending " + response); | ||||
|                 } | ||||
|             } | ||||
|             try { | ||||
|                 link.send(response.toBytes()); | ||||
|             } catch (final ClosedChannelException e) { | ||||
|                 logger.warn("Unable to send response because connection is closed: " + response); | ||||
|                 s_logger.warn("Unable to send response because connection is closed: " + response); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         protected void processResponse(final Link link, final Response response) { | ||||
|             final AgentAttache attache = (AgentAttache)link.attachment(); | ||||
|             if (attache == null) { | ||||
|                 logger.warn("Unable to process: " + response); | ||||
|                 s_logger.warn("Unable to process: " + response); | ||||
|             } else if (!attache.processAnswers(response.getSequence(), response)) { | ||||
|                 logger.info("Host " + attache.getId() + " - Seq " + response.getSequence() + ": Response is not processed: " + response); | ||||
|                 s_logger.info("Host " + attache.getId() + " - Seq " + response.getSequence() + ": Response is not processed: " + response); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -1310,7 +1313,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                             processRequest(task.getLink(), event); | ||||
|                         } | ||||
|                     } catch (final UnsupportedVersionException e) { | ||||
|                         logger.warn(e.getMessage()); | ||||
|                         s_logger.warn(e.getMessage()); | ||||
|                         // upgradeAgent(task.getLink(), data, e.getReason()); | ||||
|                     } | ||||
|                 } else if (type == Task.Type.CONNECT) { | ||||
| @ -1320,7 +1323,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                     if (attache != null) { | ||||
|                         disconnectWithInvestigation(attache, Event.AgentDisconnected); | ||||
|                     } else { | ||||
|                         logger.info("Connection from " + link.getIpAddress() + " closed but no cleanup was done."); | ||||
|                         s_logger.info("Connection from " + link.getIpAddress() + " closed but no cleanup was done."); | ||||
|                         link.close(); | ||||
|                         link.terminated(); | ||||
|                     } | ||||
| @ -1357,20 +1360,20 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|     public boolean agentStatusTransitTo(final HostVO host, final Status.Event e, final long msId) { | ||||
|         try { | ||||
|             _agentStatusLock.lock(); | ||||
|             if (logger.isDebugEnabled()) { | ||||
|             if (status_logger.isDebugEnabled()) { | ||||
|                 final ResourceState state = host.getResourceState(); | ||||
|                 final StringBuilder msg = new StringBuilder("Transition:"); | ||||
|                 msg.append("[Resource state = ").append(state); | ||||
|                 msg.append(", Agent event = ").append(e.toString()); | ||||
|                 msg.append(", Host id = ").append(host.getId()).append(", name = " + host.getName()).append("]"); | ||||
|                 logger.debug(msg); | ||||
|                 status_logger.debug(msg); | ||||
|             } | ||||
| 
 | ||||
|             host.setManagementServerId(msId); | ||||
|             try { | ||||
|                 return _statusStateMachine.transitTo(host, e, host.getId(), _hostDao); | ||||
|             } catch (final NoTransitionException e1) { | ||||
|                 logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", name=" + host.getName() + | ||||
|                 status_logger.debug("Cannot transit agent status with event " + e + " for host " + host.getId() + ", name=" + host.getName() + | ||||
|                         ", mangement server id is " + msId); | ||||
|                 throw new CloudRuntimeException("Cannot transit agent status with event " + e + " for host " + host.getId() + ", mangement server id is " + msId + "," + | ||||
|                         e1.getMessage()); | ||||
| @ -1401,7 +1404,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|     protected boolean isHostOwnerSwitched(final long hostId) { | ||||
|         final HostVO host = _hostDao.findById(hostId); | ||||
|         if (host == null) { | ||||
|             logger.warn("Can't find the host " + hostId); | ||||
|             s_logger.warn("Can't find the host " + hostId); | ||||
|             return false; | ||||
|         } | ||||
|         return isHostOwnerSwitched(host); | ||||
| @ -1426,7 +1429,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|         } else { | ||||
|             /* Agent is still in connecting process, don't allow to disconnect right away */ | ||||
|             if (tapLoadingAgents(hostId, TapAgentsAction.Contains)) { | ||||
|                 logger.info("Host " + hostId + " is being loaded so no disconnects needed."); | ||||
|                 s_logger.info("Host " + hostId + " is being loaded so no disconnects needed."); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
| @ -1498,14 +1501,14 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|     public void pingBy(final long agentId) { | ||||
|         // Update PingMap with the latest time if agent entry exists in the PingMap | ||||
|         if (_pingMap.replace(agentId, InaccurateClock.getTimeInSeconds()) == null) { | ||||
|             logger.info("PingMap for agent: " + agentId + " will not be updated because agent is no longer in the PingMap"); | ||||
|             s_logger.info("PingMap for agent: " + agentId + " will not be updated because agent is no longer in the PingMap"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     protected class MonitorTask extends ManagedContextRunnable { | ||||
|         @Override | ||||
|         protected void runInContext() { | ||||
|             logger.trace("Agent Monitor is started."); | ||||
|             s_logger.trace("Agent Monitor is started."); | ||||
| 
 | ||||
|             try { | ||||
|                 final List<Long> behindAgents = findAgentsBehindOnPing(); | ||||
| @ -1521,17 +1524,17 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                              * investigation and direct put agent to | ||||
|                              * Disconnected | ||||
|                              */ | ||||
|                             logger.debug("Ping timeout but host " + agentId + " is in resource state of " + resourceState + ", so no investigation"); | ||||
|                             status_logger.debug("Ping timeout but host " + agentId + " is in resource state of " + resourceState + ", so no investigation"); | ||||
|                             disconnectWithoutInvestigation(agentId, Event.ShutdownRequested); | ||||
|                         } else { | ||||
|                             final HostVO host = _hostDao.findById(agentId); | ||||
|                             if (host != null && (host.getType() == Host.Type.ConsoleProxy || host.getType() == Host.Type.SecondaryStorageVM | ||||
|                                     || host.getType() == Host.Type.SecondaryStorageCmdExecutor)) { | ||||
| 
 | ||||
|                                 logger.warn("Disconnect agent for CPVM/SSVM due to physical connection close. host: " + host.getId()); | ||||
|                                 s_logger.warn("Disconnect agent for CPVM/SSVM due to physical connection close. host: " + host.getId()); | ||||
|                                 disconnectWithoutInvestigation(agentId, Event.ShutdownRequested); | ||||
|                             } else { | ||||
|                                 logger.debug("Ping timeout for host " + agentId + ", do invstigation"); | ||||
|                                 status_logger.debug("Ping timeout for host " + agentId + ", do invstigation"); | ||||
|                                 disconnectWithInvestigation(agentId, Event.PingTimeout); | ||||
|                             } | ||||
|                         } | ||||
| @ -1552,10 +1555,10 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|                     } | ||||
|                 } | ||||
|             } catch (final Throwable th) { | ||||
|                 logger.error("Caught the following exception: ", th); | ||||
|                 s_logger.error("Caught the following exception: ", th); | ||||
|             } | ||||
| 
 | ||||
|             logger.trace("Agent Monitor is leaving the building!"); | ||||
|             s_logger.trace("Agent Monitor is leaving the building!"); | ||||
|         } | ||||
| 
 | ||||
|         protected List<Long> findAgentsBehindOnPing() { | ||||
| @ -1568,7 +1571,7 @@ public class AgentManagerImpl extends ManagerBase implements AgentManager, Handl | ||||
|             } | ||||
| 
 | ||||
|             if (agentsBehind.size() > 0) { | ||||
|                 logger.info("Found the following agents behind on ping: " + agentsBehind); | ||||
|                 s_logger.info("Found the following agents behind on ping: " + agentsBehind); | ||||
|             } | ||||
| 
 | ||||
|             return agentsBehind; | ||||
|  | ||||
| @ -43,6 +43,10 @@ import javax.naming.ConfigurationException; | ||||
| import javax.net.ssl.SSLContext; | ||||
| import javax.net.ssl.SSLEngine; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.google.gson.Gson; | ||||
| 
 | ||||
| import org.apache.cloudstack.framework.config.ConfigDepot; | ||||
| import org.apache.cloudstack.framework.config.ConfigKey; | ||||
| import org.apache.cloudstack.framework.config.dao.ConfigurationDao; | ||||
| @ -91,10 +95,10 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| import com.cloud.utils.exception.CloudRuntimeException; | ||||
| import com.cloud.utils.nio.Link; | ||||
| import com.cloud.utils.nio.Task; | ||||
| import com.google.gson.Gson; | ||||
| 
 | ||||
| @Local(value = {AgentManager.class, ClusteredAgentRebalanceService.class}) | ||||
| public class ClusteredAgentManagerImpl extends AgentManagerImpl implements ClusterManagerListener, ClusteredAgentRebalanceService { | ||||
|     final static Logger s_logger = Logger.getLogger(ClusteredAgentManagerImpl.class); | ||||
|     private static final ScheduledExecutorService s_transferExecutor = Executors.newScheduledThreadPool(2, new NamedThreadFactory("Cluster-AgentRebalancingExecutor")); | ||||
|     private final long rebalanceTimeOut = 300000; // 5 mins - after this time remove the agent from the transfer list | ||||
| 
 | ||||
| @ -140,7 +144,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         _sslEngines = new HashMap<String, SSLEngine>(7); | ||||
|         _nodeId = ManagementServerNode.getManagementServerId(); | ||||
| 
 | ||||
|         logger.info("Configuring ClusterAgentManagerImpl. management server node id(msid): " + _nodeId); | ||||
|         s_logger.info("Configuring ClusterAgentManagerImpl. management server node id(msid): " + _nodeId); | ||||
| 
 | ||||
|         ClusteredAgentAttache.initialize(this); | ||||
| 
 | ||||
| @ -158,8 +162,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             return false; | ||||
|         } | ||||
|         _timer.schedule(new DirectAgentScanTimerTask(), STARTUP_DELAY, ScanInterval.value()); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Scheduled direct agent scan task to run at an interval of " + ScanInterval.value() + " seconds"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Scheduled direct agent scan task to run at an interval of " + ScanInterval.value() + " seconds"); | ||||
|         } | ||||
| 
 | ||||
|         // Schedule tasks for agent rebalancing | ||||
| @ -173,8 +177,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
| 
 | ||||
|     public void scheduleHostScanTask() { | ||||
|         _timer.schedule(new DirectAgentScanTimerTask(), 0); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Scheduled a direct agent scan task"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Scheduled a direct agent scan task"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -183,8 +187,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|     } | ||||
| 
 | ||||
|     private void scanDirectAgentToLoad() { | ||||
|         if (logger.isTraceEnabled()) { | ||||
|             logger.trace("Begin scanning directly connected hosts"); | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             s_logger.trace("Begin scanning directly connected hosts"); | ||||
|         } | ||||
| 
 | ||||
|         // for agents that are self-managed, threshold to be considered as disconnected after pingtimeout | ||||
| @ -192,18 +196,18 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         List<HostVO> hosts = _hostDao.findAndUpdateDirectAgentToLoad(cutSeconds, LoadSize.value().longValue(), _nodeId); | ||||
|         List<HostVO> appliances = _hostDao.findAndUpdateApplianceToLoad(cutSeconds, _nodeId); | ||||
| 
 | ||||
|         if (hosts != null) { | ||||
|        if (hosts != null) { | ||||
|             hosts.addAll(appliances); | ||||
|             if (hosts.size() > 0) { | ||||
|                 logger.debug("Found " + hosts.size() + " unmanaged direct hosts, processing connect for them..."); | ||||
|                 s_logger.debug("Found " + hosts.size() + " unmanaged direct hosts, processing connect for them..."); | ||||
|                 for (HostVO host : hosts) { | ||||
|                     try { | ||||
|                         AgentAttache agentattache = findAttache(host.getId()); | ||||
|                         if (agentattache != null) { | ||||
|                             // already loaded, skip | ||||
|                             if (agentattache.forForward()) { | ||||
|                                 if (logger.isInfoEnabled()) { | ||||
|                                     logger.info(host + " is detected down, but we have a forward attache running, disconnect this one before launching the host"); | ||||
|                                 if (s_logger.isInfoEnabled()) { | ||||
|                                     s_logger.info(host + " is detected down, but we have a forward attache running, disconnect this one before launching the host"); | ||||
|                                 } | ||||
|                                 removeAgent(agentattache, Status.Disconnected); | ||||
|                             } else { | ||||
| @ -211,18 +215,18 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                             } | ||||
|                         } | ||||
| 
 | ||||
|                         if (logger.isDebugEnabled()) { | ||||
|                             logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ")"); | ||||
|                         if (s_logger.isDebugEnabled()) { | ||||
|                             s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ")"); | ||||
|                         } | ||||
|                         loadDirectlyConnectedHost(host, false); | ||||
|                     } catch (Throwable e) { | ||||
|                         logger.warn(" can not load directly connected host " + host.getId() + "(" + host.getName() + ") due to ", e); | ||||
|                         s_logger.warn(" can not load directly connected host " + host.getId() + "(" + host.getName() + ") due to ", e); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if (logger.isTraceEnabled()) { | ||||
|             logger.trace("End scanning directly connected hosts"); | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             s_logger.trace("End scanning directly connected hosts"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -232,7 +236,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             try { | ||||
|                 runDirectAgentScanTimerTask(); | ||||
|             } catch (Throwable e) { | ||||
|                 logger.error("Unexpected exception " + e.getMessage(), e); | ||||
|                 s_logger.error("Unexpected exception " + e.getMessage(), e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -243,7 +247,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|     } | ||||
| 
 | ||||
|     protected AgentAttache createAttache(long id) { | ||||
|         logger.debug("create forwarding ClusteredAgentAttache for " + id); | ||||
|         s_logger.debug("create forwarding ClusteredAgentAttache for " + id); | ||||
|         HostVO host = _hostDao.findById(id); | ||||
|         final AgentAttache attache = new ClusteredAgentAttache(this, id, host.getName()); | ||||
|         AgentAttache old = null; | ||||
| @ -252,8 +256,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             _agents.put(id, attache); | ||||
|         } | ||||
|         if (old != null) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Remove stale agent attache from current management server"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Remove stale agent attache from current management server"); | ||||
|             } | ||||
|             removeAgent(old, Status.Removed); | ||||
|         } | ||||
| @ -262,7 +266,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
| 
 | ||||
|     @Override | ||||
|     protected AgentAttache createAttacheForConnect(HostVO host, Link link) { | ||||
|         logger.debug("create ClusteredAgentAttache for " + host.getId()); | ||||
|         s_logger.debug("create ClusteredAgentAttache for " + host.getId()); | ||||
|         final AgentAttache attache = new ClusteredAgentAttache(this, host.getId(), host.getName(), link, host.isInMaintenanceStates()); | ||||
|         link.attach(attache); | ||||
|         AgentAttache old = null; | ||||
| @ -278,7 +282,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
| 
 | ||||
|     @Override | ||||
|     protected AgentAttache createAttacheForDirectConnect(Host host, ServerResource resource) { | ||||
|         logger.debug("create ClusteredDirectAgentAttache for " + host.getId()); | ||||
|         s_logger.debug("create ClusteredDirectAgentAttache for " + host.getId()); | ||||
|         final DirectAgentAttache attache = new ClusteredDirectAgentAttache(this, host.getId(), host.getName(), _nodeId, resource, host.isInMaintenanceStates()); | ||||
|         AgentAttache old = null; | ||||
|         synchronized (_agents) { | ||||
| @ -322,8 +326,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|     @Override | ||||
|     public boolean executeUserRequest(long hostId, Event event) throws AgentUnavailableException { | ||||
|         if (event == Event.AgentDisconnected) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Received agent disconnect event for host " + hostId); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Received agent disconnect event for host " + hostId); | ||||
|             } | ||||
|             AgentAttache attache = findAttache(hostId); | ||||
|             if (attache != null) { | ||||
| @ -332,7 +336,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                     HostTransferMapVO transferVO = _hostTransferDao.findById(hostId); | ||||
|                     if (transferVO != null) { | ||||
|                         if (transferVO.getFutureOwner() == _nodeId && transferVO.getState() == HostTransferState.TransferStarted) { | ||||
|                             logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + " as the host is being connected to " + | ||||
|                             s_logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + " as the host is being connected to " + | ||||
|                                     _nodeId); | ||||
|                             return true; | ||||
|                         } | ||||
| @ -342,7 +346,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 // don't process disconnect if the disconnect came for the host via delayed cluster notification, | ||||
|                 // but the host has already reconnected to the current management server | ||||
|                 if (!attache.forForward()) { | ||||
|                     logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + | ||||
|                     s_logger.debug("Not processing " + Event.AgentDisconnected + " event for the host id=" + hostId + | ||||
|                             " as the host is directly connected to the current management server " + _nodeId); | ||||
|                     return true; | ||||
|                 } | ||||
| @ -365,7 +369,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 return result; | ||||
|             } | ||||
|         } catch (AgentUnavailableException e) { | ||||
|             logger.debug("cannot propagate agent reconnect because agent is not available", e); | ||||
|             s_logger.debug("cannot propagate agent reconnect because agent is not available", e); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
| @ -373,27 +377,32 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|     } | ||||
| 
 | ||||
|     public void notifyNodesInCluster(AgentAttache attache) { | ||||
|         logger.debug("Notifying other nodes of to disconnect"); | ||||
|         s_logger.debug("Notifying other nodes of to disconnect"); | ||||
|         Command[] cmds = new Command[] {new ChangeAgentCommand(attache.getId(), Event.AgentDisconnected)}; | ||||
|         _clusterMgr.broadcast(attache.getId(), _gson.toJson(cmds)); | ||||
|     } | ||||
| 
 | ||||
|     // notifies MS peers to schedule a host scan task immediately, triggered during addHost operation | ||||
|     public void notifyNodesInClusterToScheduleHostScanTask() { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Notifying other MS nodes to run host scan task"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Notifying other MS nodes to run host scan task"); | ||||
|         } | ||||
|         Command[] cmds = new Command[] {new ScheduleHostScanTaskCommand()}; | ||||
|         _clusterMgr.broadcast(0, _gson.toJson(cmds)); | ||||
|     } | ||||
| 
 | ||||
|     protected void logD(byte[] bytes, final String msg) { | ||||
|         logger.debug("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " + | ||||
|     protected static void logT(byte[] bytes, final String msg) { | ||||
|         s_logger.trace("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " + | ||||
|                 (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); | ||||
|     } | ||||
| 
 | ||||
|     protected void logI(byte[] bytes, final String msg) { | ||||
|         logger.info("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " + | ||||
|     protected static void logD(byte[] bytes, final String msg) { | ||||
|         s_logger.debug("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " + | ||||
|                 (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); | ||||
|     } | ||||
| 
 | ||||
|     protected static void logI(byte[] bytes, final String msg) { | ||||
|         s_logger.info("Seq " + Request.getAgentId(bytes) + "-" + Request.getSequence(bytes) + ": MgmtId " + Request.getManagementServerId(bytes) + ": " + | ||||
|                 (Request.isRequest(bytes) ? "Req: " : "Resp: ") + msg); | ||||
|     } | ||||
| 
 | ||||
| @ -418,7 +427,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 return false; | ||||
|             } | ||||
|             try { | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     logD(bytes, "Routing to peer"); | ||||
|                 } | ||||
|                 Link.write(ch, new ByteBuffer[] {ByteBuffer.wrap(bytes)}, sslEngine); | ||||
| @ -458,7 +467,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 try { | ||||
|                     ch.close(); | ||||
|                 } catch (IOException e) { | ||||
|                     logger.warn("Unable to close peer socket connection to " + peerName); | ||||
|                     s_logger.warn("Unable to close peer socket connection to " + peerName); | ||||
|                 } | ||||
|             } | ||||
|             _peers.remove(peerName); | ||||
| @ -474,14 +483,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 try { | ||||
|                     prevCh.close(); | ||||
|                 } catch (Exception e) { | ||||
|                     logger.info("[ignored]" | ||||
|                     s_logger.info("[ignored]" | ||||
|                             + "failed to get close resource for previous channel Socket: " + e.getLocalizedMessage()); | ||||
|                 } | ||||
|             } | ||||
|             if (ch == null || ch == prevCh) { | ||||
|                 ManagementServerHost ms = _clusterMgr.getPeer(peerName); | ||||
|                 if (ms == null) { | ||||
|                     logger.info("Unable to find peer: " + peerName); | ||||
|                     s_logger.info("Unable to find peer: " + peerName); | ||||
|                     return null; | ||||
|                 } | ||||
|                 String ip = ms.getServiceIP(); | ||||
| @ -504,13 +513,13 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                         sslEngine.setEnabledProtocols(SSLUtils.getSupportedProtocols(sslEngine.getEnabledProtocols())); | ||||
| 
 | ||||
|                         Link.doHandshake(ch1, sslEngine, true); | ||||
|                         logger.info("SSL: Handshake done"); | ||||
|                         s_logger.info("SSL: Handshake done"); | ||||
|                     } catch (Exception e) { | ||||
|                         ch1.close(); | ||||
|                         throw new IOException("SSL: Fail to init SSL! " + e); | ||||
|                     } | ||||
|                     if (logger.isDebugEnabled()) { | ||||
|                         logger.debug("Connection to peer opened: " + peerName + ", ip: " + ip); | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Connection to peer opened: " + peerName + ", ip: " + ip); | ||||
|                     } | ||||
|                     _peers.put(peerName, ch1); | ||||
|                     _sslEngines.put(peerName, sslEngine); | ||||
| @ -519,15 +528,15 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                     try { | ||||
|                         ch1.close(); | ||||
|                     } catch (IOException ex) { | ||||
|                         logger.error("failed to close failed peer socket: " + ex); | ||||
|                         s_logger.error("failed to close failed peer socket: " + ex); | ||||
|                     } | ||||
|                     logger.warn("Unable to connect to peer management server: " + peerName + ", ip: " + ip + " due to " + e.getMessage(), e); | ||||
|                     s_logger.warn("Unable to connect to peer management server: " + peerName + ", ip: " + ip + " due to " + e.getMessage(), e); | ||||
|                     return null; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (logger.isTraceEnabled()) { | ||||
|                 logger.trace("Found open channel for peer: " + peerName); | ||||
|             if (s_logger.isTraceEnabled()) { | ||||
|                 s_logger.trace("Found open channel for peer: " + peerName); | ||||
|             } | ||||
|             return ch; | ||||
|         } | ||||
| @ -553,8 +562,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         AgentAttache agent = findAttache(hostId); | ||||
|         if (agent == null || !agent.forForward()) { | ||||
|             if (isHostOwnerSwitched(host)) { | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Host " + hostId + " has switched to another management server, need to update agent map with a forwarding agent attache"); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Host " + hostId + " has switched to another management server, need to update agent map with a forwarding agent attache"); | ||||
|                 } | ||||
|                 agent = createAttache(hostId); | ||||
|             } | ||||
| @ -573,10 +582,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         if (_peers != null) { | ||||
|             for (SocketChannel ch : _peers.values()) { | ||||
|                 try { | ||||
|                     logger.info("Closing: " + ch.toString()); | ||||
|                     s_logger.info("Closing: " + ch.toString()); | ||||
|                     ch.close(); | ||||
|                 } catch (IOException e) { | ||||
|                     logger.info("[ignored] error on closing channel: " +ch.toString(), e); | ||||
|                     s_logger.info("[ignored] error on closing channel: " +ch.toString(), e); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -613,7 +622,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 final byte[] data = task.getData(); | ||||
|                 Version ver = Request.getVersion(data); | ||||
|                 if (ver.ordinal() != Version.v1.ordinal() && ver.ordinal() != Version.v3.ordinal()) { | ||||
|                     logger.warn("Wrong version for clustered agent request"); | ||||
|                     s_logger.warn("Wrong version for clustered agent request"); | ||||
|                     super.doTask(task); | ||||
|                     return; | ||||
|                 } | ||||
| @ -633,7 +642,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                         Request req = Request.parse(data); | ||||
|                         Command[] cmds = req.getCommands(); | ||||
|                         CancelCommand cancel = (CancelCommand)cmds[0]; | ||||
|                         if (logger.isDebugEnabled()) { | ||||
|                         if (s_logger.isDebugEnabled()) { | ||||
|                             logD(data, "Cancel request received"); | ||||
|                         } | ||||
|                         agent.cancel(cancel.getSequence()); | ||||
| @ -681,7 +690,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                             AgentAttache attache = (AgentAttache)link.attachment(); | ||||
|                             if (attache != null) { | ||||
|                                 attache.sendNext(Request.getSequence(data)); | ||||
|                             } else if (logger.isDebugEnabled()) { | ||||
|                             } else if (s_logger.isDebugEnabled()) { | ||||
|                                 logD(data, "No attache to process " + Request.parse(data).toString()); | ||||
|                             } | ||||
|                         } | ||||
| @ -694,11 +703,11 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                             final Response response = Response.parse(data); | ||||
|                             AgentAttache attache = findAttache(response.getAgentId()); | ||||
|                             if (attache == null) { | ||||
|                                 logger.info("SeqA " + response.getAgentId() + "-" + response.getSequence() + "Unable to find attache to forward " + response.toString()); | ||||
|                                 s_logger.info("SeqA " + response.getAgentId() + "-" + response.getSequence() + "Unable to find attache to forward " + response.toString()); | ||||
|                                 return; | ||||
|                             } | ||||
|                             if (!attache.processAnswers(response.getSequence(), response)) { | ||||
|                                 logger.info("SeqA " + attache.getId() + "-" + response.getSequence() + ": Response is not processed: " + response.toString()); | ||||
|                                 s_logger.info("SeqA " + attache.getId() + "-" + response.getSequence() + ": Response is not processed: " + response.toString()); | ||||
|                             } | ||||
|                         } | ||||
|                         return; | ||||
| @ -717,10 +726,10 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|     @Override | ||||
|     public void onManagementNodeLeft(List<? extends ManagementServerHost> nodeList, long selfNodeId) { | ||||
|         for (ManagementServerHost vo : nodeList) { | ||||
|             logger.info("Marking hosts as disconnected on Management server" + vo.getMsid()); | ||||
|             s_logger.info("Marking hosts as disconnected on Management server" + vo.getMsid()); | ||||
|             long lastPing = (System.currentTimeMillis() >> 10) - getTimeout(); | ||||
|             _hostDao.markHostsAsDisconnected(vo.getMsid(), lastPing); | ||||
|             logger.info("Deleting entries from op_host_transfer table for Management server " + vo.getMsid()); | ||||
|             s_logger.info("Deleting entries from op_host_transfer table for Management server " + vo.getMsid()); | ||||
|             cleanupTransferMap(vo.getMsid()); | ||||
|         } | ||||
|     } | ||||
| @ -748,7 +757,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             try { | ||||
|                 result = rebalanceHost(agentId, currentOwnerId, futureOwnerId); | ||||
|             } catch (Exception e) { | ||||
|                 logger.warn("Unable to rebalance host id=" + agentId, e); | ||||
|                 s_logger.warn("Unable to rebalance host id=" + agentId, e); | ||||
|             } | ||||
|         } | ||||
|         return result; | ||||
| @ -763,14 +772,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         protected volatile boolean cancelled = false; | ||||
| 
 | ||||
|         public AgentLoadBalancerTask() { | ||||
|             logger.debug("Agent load balancer task created"); | ||||
|             s_logger.debug("Agent load balancer task created"); | ||||
|         } | ||||
| 
 | ||||
|         @Override | ||||
|         public synchronized boolean cancel() { | ||||
|             if (!cancelled) { | ||||
|                 cancelled = true; | ||||
|                 logger.debug("Agent load balancer task cancelled"); | ||||
|                 s_logger.debug("Agent load balancer task cancelled"); | ||||
|                 return super.cancel(); | ||||
|             } | ||||
|             return true; | ||||
| @ -781,19 +790,19 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             try { | ||||
|                 if (!cancelled) { | ||||
|                     startRebalanceAgents(); | ||||
|                     if (logger.isInfoEnabled()) { | ||||
|                         logger.info("The agent load balancer task is now being cancelled"); | ||||
|                     if (s_logger.isInfoEnabled()) { | ||||
|                         s_logger.info("The agent load balancer task is now being cancelled"); | ||||
|                     } | ||||
|                     cancelled = true; | ||||
|                 } | ||||
|             } catch (Throwable e) { | ||||
|                 logger.error("Unexpected exception " + e.toString(), e); | ||||
|                 s_logger.error("Unexpected exception " + e.toString(), e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void startRebalanceAgents() { | ||||
|         logger.debug("Management server " + _nodeId + " is asking other peers to rebalance their agents"); | ||||
|         s_logger.debug("Management server " + _nodeId + " is asking other peers to rebalance their agents"); | ||||
|         List<ManagementServerHostVO> allMS = _mshostDao.listBy(ManagementServerHost.State.Up); | ||||
|         QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class); | ||||
|         sc.and(sc.entity().getManagementServerId(), Op.NNULL); | ||||
| @ -805,16 +814,16 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         if (!allManagedAgents.isEmpty() && !allMS.isEmpty()) { | ||||
|             avLoad = allManagedAgents.size() / allMS.size(); | ||||
|         } else { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("There are no hosts to rebalance in the system. Current number of active management server nodes in the system is " + allMS.size() + | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("There are no hosts to rebalance in the system. Current number of active management server nodes in the system is " + allMS.size() + | ||||
|                         "; number of managed agents is " + allManagedAgents.size()); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         if (avLoad == 0L) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("As calculated average load is less than 1, rounding it to 1"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("As calculated average load is less than 1, rounding it to 1"); | ||||
|             } | ||||
|             avLoad = 1; | ||||
|         } | ||||
| @ -828,19 +837,19 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                     if (hostsToRebalance != null && !hostsToRebalance.isEmpty()) { | ||||
|                         break; | ||||
|                     } else { | ||||
|                         logger.debug("Agent load balancer planner " + lbPlanner.getName() + " found no hosts to be rebalanced from management server " + node.getMsid()); | ||||
|                         s_logger.debug("Agent load balancer planner " + lbPlanner.getName() + " found no hosts to be rebalanced from management server " + node.getMsid()); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 if (hostsToRebalance != null && !hostsToRebalance.isEmpty()) { | ||||
|                     logger.debug("Found " + hostsToRebalance.size() + " hosts to rebalance from management server " + node.getMsid()); | ||||
|                     s_logger.debug("Found " + hostsToRebalance.size() + " hosts to rebalance from management server " + node.getMsid()); | ||||
|                     for (HostVO host : hostsToRebalance) { | ||||
|                         long hostId = host.getId(); | ||||
|                         logger.debug("Asking management server " + node.getMsid() + " to give away host id=" + hostId); | ||||
|                         s_logger.debug("Asking management server " + node.getMsid() + " to give away host id=" + hostId); | ||||
|                         boolean result = true; | ||||
| 
 | ||||
|                         if (_hostTransferDao.findById(hostId) != null) { | ||||
|                             logger.warn("Somebody else is already rebalancing host id: " + hostId); | ||||
|                             s_logger.warn("Somebody else is already rebalancing host id: " + hostId); | ||||
|                             continue; | ||||
|                         } | ||||
| 
 | ||||
| @ -849,18 +858,18 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                             transfer = _hostTransferDao.startAgentTransfering(hostId, node.getMsid(), _nodeId); | ||||
|                             Answer[] answer = sendRebalanceCommand(node.getMsid(), hostId, node.getMsid(), _nodeId, Event.RequestAgentRebalance); | ||||
|                             if (answer == null) { | ||||
|                                 logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid()); | ||||
|                                 s_logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid()); | ||||
|                                 result = false; | ||||
|                             } | ||||
|                         } catch (Exception ex) { | ||||
|                             logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid(), ex); | ||||
|                             s_logger.warn("Failed to get host id=" + hostId + " from management server " + node.getMsid(), ex); | ||||
|                             result = false; | ||||
|                         } finally { | ||||
|                             if (transfer != null) { | ||||
|                                 HostTransferMapVO transferState = _hostTransferDao.findByIdAndFutureOwnerId(transfer.getId(), _nodeId); | ||||
|                                 if (!result && transferState != null && transferState.getState() == HostTransferState.TransferRequested) { | ||||
|                                     if (logger.isDebugEnabled()) { | ||||
|                                         logger.debug("Removing mapping from op_host_transfer as it failed to be set to transfer mode"); | ||||
|                                     if (s_logger.isDebugEnabled()) { | ||||
|                                         s_logger.debug("Removing mapping from op_host_transfer as it failed to be set to transfer mode"); | ||||
|                                     } | ||||
|                                     // just remove the mapping (if exists) as nothing was done on the peer management | ||||
| // server yet | ||||
| @ -870,7 +879,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                         } | ||||
|                     } | ||||
|                 } else { | ||||
|                     logger.debug("Found no hosts to rebalance from the management server " + node.getMsid()); | ||||
|                     s_logger.debug("Found no hosts to rebalance from the management server " + node.getMsid()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -884,8 +893,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         Command[] cmds = commands.toCommands(); | ||||
| 
 | ||||
|         try { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Forwarding " + cmds[0].toString() + " to " + peer); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Forwarding " + cmds[0].toString() + " to " + peer); | ||||
|             } | ||||
|             String peerName = Long.toString(peer); | ||||
|             String cmdStr = _gson.toJson(cmds); | ||||
| @ -893,7 +902,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             Answer[] answers = _gson.fromJson(ansStr, Answer[].class); | ||||
|             return answers; | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Caught exception while talking to " + currentOwnerId, e); | ||||
|             s_logger.warn("Caught exception while talking to " + currentOwnerId, e); | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| @ -917,8 +926,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Propagating agent change request event:" + event.toString() + " to agent:" + agentId); | ||||
|         } | ||||
|         Command[] cmds = new Command[1]; | ||||
|         cmds[0] = new ChangeAgentCommand(agentId, event); | ||||
| @ -930,8 +939,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
| 
 | ||||
|         Answer[] answers = _gson.fromJson(ansStr, Answer[].class); | ||||
| 
 | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Result for agent change is " + answers[0].getResult()); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Result for agent change is " + answers[0].getResult()); | ||||
|         } | ||||
| 
 | ||||
|         return answers[0].getResult(); | ||||
| @ -942,12 +951,12 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             @Override | ||||
|             protected void runInContext() { | ||||
|                 try { | ||||
|                     if (logger.isTraceEnabled()) { | ||||
|                         logger.trace("Clustered agent transfer scan check, management server id:" + _nodeId); | ||||
|                     if (s_logger.isTraceEnabled()) { | ||||
|                         s_logger.trace("Clustered agent transfer scan check, management server id:" + _nodeId); | ||||
|                     } | ||||
|                     synchronized (_agentToTransferIds) { | ||||
|                         if (_agentToTransferIds.size() > 0) { | ||||
|                             logger.debug("Found " + _agentToTransferIds.size() + " agents to transfer"); | ||||
|                             s_logger.debug("Found " + _agentToTransferIds.size() + " agents to transfer"); | ||||
|                             // for (Long hostId : _agentToTransferIds) { | ||||
|                             for (Iterator<Long> iterator = _agentToTransferIds.iterator(); iterator.hasNext();) { | ||||
|                                 Long hostId = iterator.next(); | ||||
| @ -964,14 +973,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                                         _hostTransferDao.findActiveHostTransferMapByHostId(hostId, new Date(cutTime.getTime() - rebalanceTimeOut)); | ||||
| 
 | ||||
|                                 if (transferMap == null) { | ||||
|                                     logger.debug("Timed out waiting for the host id=" + hostId + " to be ready to transfer, skipping rebalance for the host"); | ||||
|                                     s_logger.debug("Timed out waiting for the host id=" + hostId + " to be ready to transfer, skipping rebalance for the host"); | ||||
|                                     iterator.remove(); | ||||
|                                     _hostTransferDao.completeAgentTransfer(hostId); | ||||
|                                     continue; | ||||
|                                 } | ||||
| 
 | ||||
|                                 if (transferMap.getInitialOwner() != _nodeId || attache == null || attache.forForward()) { | ||||
|                                     logger.debug("Management server " + _nodeId + " doesn't own host id=" + hostId + " any more, skipping rebalance for the host"); | ||||
|                                     s_logger.debug("Management server " + _nodeId + " doesn't own host id=" + hostId + " any more, skipping rebalance for the host"); | ||||
|                                     iterator.remove(); | ||||
|                                     _hostTransferDao.completeAgentTransfer(hostId); | ||||
|                                     continue; | ||||
| @ -979,7 +988,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
| 
 | ||||
|                                 ManagementServerHostVO ms = _mshostDao.findByMsid(transferMap.getFutureOwner()); | ||||
|                                 if (ms != null && ms.getState() != ManagementServerHost.State.Up) { | ||||
|                                     logger.debug("Can't transfer host " + hostId + " as it's future owner is not in UP state: " + ms + | ||||
|                                     s_logger.debug("Can't transfer host " + hostId + " as it's future owner is not in UP state: " + ms + | ||||
|                                             ", skipping rebalance for the host"); | ||||
|                                     iterator.remove(); | ||||
|                                     _hostTransferDao.completeAgentTransfer(hostId); | ||||
| @ -991,31 +1000,31 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                                     try { | ||||
|                                         _executor.execute(new RebalanceTask(hostId, transferMap.getInitialOwner(), transferMap.getFutureOwner())); | ||||
|                                     } catch (RejectedExecutionException ex) { | ||||
|                                         logger.warn("Failed to submit rebalance task for host id=" + hostId + "; postponing the execution"); | ||||
|                                         s_logger.warn("Failed to submit rebalance task for host id=" + hostId + "; postponing the execution"); | ||||
|                                         continue; | ||||
|                                     } | ||||
| 
 | ||||
|                                 } else { | ||||
|                                     logger.debug("Agent " + hostId + " can't be transfered yet as its request queue size is " + attache.getQueueSize() + | ||||
|                                     s_logger.debug("Agent " + hostId + " can't be transfered yet as its request queue size is " + attache.getQueueSize() + | ||||
|                                             " and listener queue size is " + attache.getNonRecurringListenersSize()); | ||||
|                                 } | ||||
|                             } | ||||
|                         } else { | ||||
|                             if (logger.isTraceEnabled()) { | ||||
|                                 logger.trace("Found no agents to be transfered by the management server " + _nodeId); | ||||
|                             if (s_logger.isTraceEnabled()) { | ||||
|                                 s_logger.trace("Found no agents to be transfered by the management server " + _nodeId); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                 } catch (Throwable e) { | ||||
|                     logger.error("Problem with the clustered agent transfer scan check!", e); | ||||
|                     s_logger.error("Problem with the clustered agent transfer scan check!", e); | ||||
|                 } | ||||
|             } | ||||
|         }; | ||||
|     } | ||||
| 
 | ||||
|     private boolean setToWaitForRebalance(final long hostId, long currentOwnerId, long futureOwnerId) { | ||||
|         logger.debug("Adding agent " + hostId + " to the list of agents to transfer"); | ||||
|         s_logger.debug("Adding agent " + hostId + " to the list of agents to transfer"); | ||||
|         synchronized (_agentToTransferIds) { | ||||
|             return _agentToTransferIds.add(hostId); | ||||
|         } | ||||
| @ -1026,7 +1035,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         boolean result = true; | ||||
|         if (currentOwnerId == _nodeId) { | ||||
|             if (!startRebalance(hostId)) { | ||||
|                 logger.debug("Failed to start agent rebalancing"); | ||||
|                 s_logger.debug("Failed to start agent rebalancing"); | ||||
|                 finishRebalance(hostId, futureOwnerId, Event.RebalanceFailed); | ||||
|                 return false; | ||||
|             } | ||||
| @ -1037,23 +1046,23 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 } | ||||
| 
 | ||||
|             } catch (Exception ex) { | ||||
|                 logger.warn("Host " + hostId + " failed to connect to the management server " + futureOwnerId + " as a part of rebalance process", ex); | ||||
|                 s_logger.warn("Host " + hostId + " failed to connect to the management server " + futureOwnerId + " as a part of rebalance process", ex); | ||||
|                 result = false; | ||||
|             } | ||||
| 
 | ||||
|             if (result) { | ||||
|                 logger.debug("Successfully transfered host id=" + hostId + " to management server " + futureOwnerId); | ||||
|                 s_logger.debug("Successfully transfered host id=" + hostId + " to management server " + futureOwnerId); | ||||
|                 finishRebalance(hostId, futureOwnerId, Event.RebalanceCompleted); | ||||
|             } else { | ||||
|                 logger.warn("Failed to transfer host id=" + hostId + " to management server " + futureOwnerId); | ||||
|                 s_logger.warn("Failed to transfer host id=" + hostId + " to management server " + futureOwnerId); | ||||
|                 finishRebalance(hostId, futureOwnerId, Event.RebalanceFailed); | ||||
|             } | ||||
| 
 | ||||
|         } else if (futureOwnerId == _nodeId) { | ||||
|             HostVO host = _hostDao.findById(hostId); | ||||
|             try { | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Disconnecting host " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification"); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Disconnecting host " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification"); | ||||
|                 } | ||||
| 
 | ||||
|                 AgentAttache attache = findAttache(hostId); | ||||
| @ -1062,26 +1071,26 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 } | ||||
| 
 | ||||
|                 if (result) { | ||||
|                     if (logger.isDebugEnabled()) { | ||||
|                         logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Loading directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + | ||||
|                                 " as a part of rebalance process"); | ||||
|                     } | ||||
|                     result = loadDirectlyConnectedHost(host, true); | ||||
|                 } else { | ||||
|                     logger.warn("Failed to disconnect " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification"); | ||||
|                     s_logger.warn("Failed to disconnect " + host.getId() + "(" + host.getName() + " as a part of rebalance process without notification"); | ||||
|                 } | ||||
| 
 | ||||
|             } catch (Exception ex) { | ||||
|                 logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + | ||||
|                 s_logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + | ||||
|                         " as a part of rebalance process due to:", ex); | ||||
|                 result = false; | ||||
|             } | ||||
| 
 | ||||
|             if (result) { | ||||
|                 logger.debug("Successfully loaded directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + | ||||
|                 s_logger.debug("Successfully loaded directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + | ||||
|                         " as a part of rebalance process"); | ||||
|             } else { | ||||
|                 logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + | ||||
|                 s_logger.warn("Failed to load directly connected host " + host.getId() + "(" + host.getName() + ") to the management server " + _nodeId + | ||||
|                         " as a part of rebalance process"); | ||||
|             } | ||||
|         } | ||||
| @ -1092,13 +1101,13 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|     protected void finishRebalance(final long hostId, long futureOwnerId, Event event) { | ||||
| 
 | ||||
|         boolean success = (event == Event.RebalanceCompleted) ? true : false; | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Finishing rebalancing for the agent " + hostId + " with event " + event); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Finishing rebalancing for the agent " + hostId + " with event " + event); | ||||
|         } | ||||
| 
 | ||||
|         AgentAttache attache = findAttache(hostId); | ||||
|         if (attache == null || !(attache instanceof ClusteredAgentAttache)) { | ||||
|             logger.debug("Unable to find forward attache for the host id=" + hostId + ", assuming that the agent disconnected already"); | ||||
|             s_logger.debug("Unable to find forward attache for the host id=" + hostId + ", assuming that the agent disconnected already"); | ||||
|             _hostTransferDao.completeAgentTransfer(hostId); | ||||
|             return; | ||||
|         } | ||||
| @ -1113,7 +1122,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             // 2) Get all transfer requests and route them to peer | ||||
|             Request requestToTransfer = forwardAttache.getRequestToTransfer(); | ||||
|             while (requestToTransfer != null) { | ||||
|                 logger.debug("Forwarding request " + requestToTransfer.getSequence() + " held in transfer attache " + hostId + " from the management server " + | ||||
|                 s_logger.debug("Forwarding request " + requestToTransfer.getSequence() + " held in transfer attache " + hostId + " from the management server " + | ||||
|                         _nodeId + " to " + futureOwnerId); | ||||
|                 boolean routeResult = routeToPeer(Long.toString(futureOwnerId), requestToTransfer.getBytes()); | ||||
|                 if (!routeResult) { | ||||
| @ -1123,23 +1132,23 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 requestToTransfer = forwardAttache.getRequestToTransfer(); | ||||
|             } | ||||
| 
 | ||||
|             logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance to " + futureOwnerId); | ||||
|             s_logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance to " + futureOwnerId); | ||||
| 
 | ||||
|         } else { | ||||
|             failRebalance(hostId); | ||||
|         } | ||||
| 
 | ||||
|         logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance"); | ||||
|         s_logger.debug("Management server " + _nodeId + " completed agent " + hostId + " rebalance"); | ||||
|         _hostTransferDao.completeAgentTransfer(hostId); | ||||
|     } | ||||
| 
 | ||||
|     protected void failRebalance(final long hostId) { | ||||
|         try { | ||||
|             logger.debug("Management server " + _nodeId + " failed to rebalance agent " + hostId); | ||||
|             s_logger.debug("Management server " + _nodeId + " failed to rebalance agent " + hostId); | ||||
|             _hostTransferDao.completeAgentTransfer(hostId); | ||||
|             handleDisconnectWithoutInvestigation(findAttache(hostId), Event.RebalanceFailed, true, true); | ||||
|         } catch (Exception ex) { | ||||
|             logger.warn("Failed to reconnect host id=" + hostId + " as a part of failed rebalance task cleanup"); | ||||
|             s_logger.warn("Failed to reconnect host id=" + hostId + " as a part of failed rebalance task cleanup"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -1147,7 +1156,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         HostVO host = _hostDao.findById(hostId); | ||||
| 
 | ||||
|         if (host == null || host.getRemoved() != null) { | ||||
|             logger.warn("Unable to find host record, fail start rebalancing process"); | ||||
|             s_logger.warn("Unable to find host record, fail start rebalancing process"); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
| @ -1157,17 +1166,17 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 handleDisconnectWithoutInvestigation(attache, Event.StartAgentRebalance, true, true); | ||||
|                 ClusteredAgentAttache forwardAttache = (ClusteredAgentAttache)createAttache(hostId); | ||||
|                 if (forwardAttache == null) { | ||||
|                     logger.warn("Unable to create a forward attache for the host " + hostId + " as a part of rebalance process"); | ||||
|                     s_logger.warn("Unable to create a forward attache for the host " + hostId + " as a part of rebalance process"); | ||||
|                     return false; | ||||
|                 } | ||||
|                 logger.debug("Putting agent id=" + hostId + " to transfer mode"); | ||||
|                 s_logger.debug("Putting agent id=" + hostId + " to transfer mode"); | ||||
|                 forwardAttache.setTransferMode(true); | ||||
|                 _agents.put(hostId, forwardAttache); | ||||
|             } else { | ||||
|                 if (attache == null) { | ||||
|                     logger.warn("Attache for the agent " + hostId + " no longer exists on management server " + _nodeId + ", can't start host rebalancing"); | ||||
|                     s_logger.warn("Attache for the agent " + hostId + " no longer exists on management server " + _nodeId + ", can't start host rebalancing"); | ||||
|                 } else { | ||||
|                     logger.warn("Attache for the agent " + hostId + " has request queue size= " + attache.getQueueSize() + " and listener queue size " + | ||||
|                     s_logger.warn("Attache for the agent " + hostId + " has request queue size= " + attache.getQueueSize() + " and listener queue size " + | ||||
|                             attache.getNonRecurringListenersSize() + ", can't start host rebalancing"); | ||||
|                 } | ||||
|                 return false; | ||||
| @ -1204,19 +1213,19 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         @Override | ||||
|         protected void runInContext() { | ||||
|             try { | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Rebalancing host id=" + hostId); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Rebalancing host id=" + hostId); | ||||
|                 } | ||||
|                 rebalanceHost(hostId, currentOwnerId, futureOwnerId); | ||||
|             } catch (Exception e) { | ||||
|                 logger.warn("Unable to rebalance host id=" + hostId, e); | ||||
|                 s_logger.warn("Unable to rebalance host id=" + hostId, e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     private String handleScheduleHostScanTaskCommand(ScheduleHostScanTaskCommand cmd) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Intercepting resource manager command: " + _gson.toJson(cmd)); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Intercepting resource manager command: " + _gson.toJson(cmd)); | ||||
|         } | ||||
| 
 | ||||
|         try { | ||||
| @ -1224,7 +1233,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         } catch (Exception e) { | ||||
|             // Scheduling host scan task in peer MS is a best effort operation during host add, regular host scan | ||||
|             // happens at fixed intervals anyways. So handling any exceptions that may be thrown | ||||
|             logger.warn("Exception happened while trying to schedule host scan task on mgmt server " + _clusterMgr.getSelfPeerName() + | ||||
|             s_logger.warn("Exception happened while trying to schedule host scan task on mgmt server " + _clusterMgr.getSelfPeerName() + | ||||
|                     ", ignoring as regular host scan happens at fixed interval anyways", e); | ||||
|             return null; | ||||
|         } | ||||
| @ -1251,8 +1260,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|         @Override | ||||
|         public String dispatch(ClusterServicePdu pdu) { | ||||
| 
 | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Dispatch ->" + pdu.getAgentId() + ", json: " + pdu.getJsonPackage()); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Dispatch ->" + pdu.getAgentId() + ", json: " + pdu.getJsonPackage()); | ||||
|             } | ||||
| 
 | ||||
|             Command[] cmds = null; | ||||
| @ -1260,24 +1269,24 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                 cmds = _gson.fromJson(pdu.getJsonPackage(), Command[].class); | ||||
|             } catch (Throwable e) { | ||||
|                 assert (false); | ||||
|                 logger.error("Excection in gson decoding : ", e); | ||||
|                 s_logger.error("Excection in gson decoding : ", e); | ||||
|             } | ||||
| 
 | ||||
|             if (cmds.length == 1 && cmds[0] instanceof ChangeAgentCommand) { // intercepted | ||||
|                 ChangeAgentCommand cmd = (ChangeAgentCommand)cmds[0]; | ||||
| 
 | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Intercepting command for agent change: agent " + cmd.getAgentId() + " event: " + cmd.getEvent()); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Intercepting command for agent change: agent " + cmd.getAgentId() + " event: " + cmd.getEvent()); | ||||
|                 } | ||||
|                 boolean result = false; | ||||
|                 try { | ||||
|                     result = executeAgentUserRequest(cmd.getAgentId(), cmd.getEvent()); | ||||
|                     if (logger.isDebugEnabled()) { | ||||
|                         logger.debug("Result is " + result); | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Result is " + result); | ||||
|                     } | ||||
| 
 | ||||
|                 } catch (AgentUnavailableException e) { | ||||
|                     logger.warn("Agent is unavailable", e); | ||||
|                     s_logger.warn("Agent is unavailable", e); | ||||
|                     return null; | ||||
|                 } | ||||
| 
 | ||||
| @ -1287,21 +1296,21 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             } else if (cmds.length == 1 && cmds[0] instanceof TransferAgentCommand) { | ||||
|                 TransferAgentCommand cmd = (TransferAgentCommand)cmds[0]; | ||||
| 
 | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Intercepting command for agent rebalancing: agent " + cmd.getAgentId() + " event: " + cmd.getEvent()); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Intercepting command for agent rebalancing: agent " + cmd.getAgentId() + " event: " + cmd.getEvent()); | ||||
|                 } | ||||
|                 boolean result = false; | ||||
|                 try { | ||||
|                     result = rebalanceAgent(cmd.getAgentId(), cmd.getEvent(), cmd.getCurrentOwner(), cmd.getFutureOwner()); | ||||
|                     if (logger.isDebugEnabled()) { | ||||
|                         logger.debug("Result is " + result); | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Result is " + result); | ||||
|                     } | ||||
| 
 | ||||
|                 } catch (AgentUnavailableException e) { | ||||
|                     logger.warn("Agent is unavailable", e); | ||||
|                     s_logger.warn("Agent is unavailable", e); | ||||
|                     return null; | ||||
|                 } catch (OperationTimedoutException e) { | ||||
|                     logger.warn("Operation timed out", e); | ||||
|                     s_logger.warn("Operation timed out", e); | ||||
|                     return null; | ||||
|                 } | ||||
|                 Answer[] answers = new Answer[1]; | ||||
| @ -1310,14 +1319,14 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             } else if (cmds.length == 1 && cmds[0] instanceof PropagateResourceEventCommand) { | ||||
|                 PropagateResourceEventCommand cmd = (PropagateResourceEventCommand)cmds[0]; | ||||
| 
 | ||||
|                 logger.debug("Intercepting command to propagate event " + cmd.getEvent().name() + " for host " + cmd.getHostId()); | ||||
|                 s_logger.debug("Intercepting command to propagate event " + cmd.getEvent().name() + " for host " + cmd.getHostId()); | ||||
| 
 | ||||
|                 boolean result = false; | ||||
|                 try { | ||||
|                     result = _resourceMgr.executeUserRequest(cmd.getHostId(), cmd.getEvent()); | ||||
|                     logger.debug("Result is " + result); | ||||
|                     s_logger.debug("Result is " + result); | ||||
|                 } catch (AgentUnavailableException ex) { | ||||
|                     logger.warn("Agent is unavailable", ex); | ||||
|                     s_logger.warn("Agent is unavailable", ex); | ||||
|                     return null; | ||||
|                 } | ||||
| 
 | ||||
| @ -1332,30 +1341,30 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
| 
 | ||||
|             try { | ||||
|                 long startTick = System.currentTimeMillis(); | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Dispatch -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage()); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Dispatch -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage()); | ||||
|                 } | ||||
| 
 | ||||
|                 Answer[] answers = sendToAgent(pdu.getAgentId(), cmds, pdu.isStopOnError()); | ||||
|                 if (answers != null) { | ||||
|                     String jsonReturn = _gson.toJson(answers); | ||||
| 
 | ||||
|                     if (logger.isDebugEnabled()) { | ||||
|                         logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " + | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " + | ||||
|                                 (System.currentTimeMillis() - startTick) + " ms, return result: " + jsonReturn); | ||||
|                     } | ||||
| 
 | ||||
|                     return jsonReturn; | ||||
|                 } else { | ||||
|                     if (logger.isDebugEnabled()) { | ||||
|                         logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " + | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Completed dispatching -> " + pdu.getAgentId() + ", json: " + pdu.getJsonPackage() + " in " + | ||||
|                                 (System.currentTimeMillis() - startTick) + " ms, return null result"); | ||||
|                     } | ||||
|                 } | ||||
|             } catch (AgentUnavailableException e) { | ||||
|                 logger.warn("Agent is unavailable", e); | ||||
|                 s_logger.warn("Agent is unavailable", e); | ||||
|             } catch (OperationTimedoutException e) { | ||||
|                 logger.warn("Timed Out", e); | ||||
|                 s_logger.warn("Timed Out", e); | ||||
|             } | ||||
| 
 | ||||
|             return null; | ||||
| @ -1380,8 +1389,8 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|             @Override | ||||
|             protected void runInContext() { | ||||
|                 try { | ||||
|                     if (logger.isTraceEnabled()) { | ||||
|                         logger.trace("Agent rebalance task check, management server id:" + _nodeId); | ||||
|                     if (s_logger.isTraceEnabled()) { | ||||
|                         s_logger.trace("Agent rebalance task check, management server id:" + _nodeId); | ||||
|                     } | ||||
|                     // initiate agent lb task will be scheduled and executed only once, and only when number of agents | ||||
| // loaded exceeds _connectedAgentsThreshold | ||||
| @ -1399,18 +1408,18 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|                         if (allHostsCount > 0.0) { | ||||
|                             double load = managedHostsCount / allHostsCount; | ||||
|                             if (load >= ConnectedAgentThreshold.value()) { | ||||
|                                 logger.debug("Scheduling agent rebalancing task as the average agent load " + load + " is more than the threshold " + | ||||
|                                 s_logger.debug("Scheduling agent rebalancing task as the average agent load " + load + " is more than the threshold " + | ||||
|                                         ConnectedAgentThreshold.value()); | ||||
|                                 scheduleRebalanceAgents(); | ||||
|                                 _agentLbHappened = true; | ||||
|                             } else { | ||||
|                                 logger.debug("Not scheduling agent rebalancing task as the averages load " + load + " is less than the threshold " + | ||||
|                                 s_logger.debug("Not scheduling agent rebalancing task as the averages load " + load + " is less than the threshold " + | ||||
|                                         ConnectedAgentThreshold.value()); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } catch (Throwable e) { | ||||
|                     logger.error("Problem with the clustered agent transfer scan check!", e); | ||||
|                     s_logger.error("Problem with the clustered agent transfer scan check!", e); | ||||
|                 } | ||||
|             } | ||||
|         }; | ||||
| @ -1419,13 +1428,13 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust | ||||
|     @Override | ||||
|     public void rescan() { | ||||
|         // schedule a scan task immediately | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Scheduling a host scan task"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Scheduling a host scan task"); | ||||
|         } | ||||
|         // schedule host scan task on current MS | ||||
|         scheduleHostScanTask(); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Notifying all peer MS to schedule host scan task"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Notifying all peer MS to schedule host scan task"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.Map; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.host.Host; | ||||
| @ -40,6 +41,7 @@ import com.cloud.utils.db.SearchCriteria.Op; | ||||
| @Component | ||||
| @Local(value = AgentLoadBalancerPlanner.class) | ||||
| public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements AgentLoadBalancerPlanner { | ||||
|     private static final Logger s_logger = Logger.getLogger(AgentLoadBalancerPlanner.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     HostDao _hostDao = null; | ||||
| @ -52,7 +54,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements | ||||
|         List<HostVO> allHosts = sc.list(); | ||||
| 
 | ||||
|         if (allHosts.size() <= avLoad) { | ||||
|             logger.debug("Agent load = " + allHosts.size() + " for management server " + msId + " doesn't exceed average system agent load = " + avLoad + | ||||
|             s_logger.debug("Agent load = " + allHosts.size() + " for management server " + msId + " doesn't exceed average system agent load = " + avLoad + | ||||
|                 "; so it doesn't participate in agent rebalancing process"); | ||||
|             return null; | ||||
|         } | ||||
| @ -64,7 +66,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements | ||||
|         List<HostVO> directHosts = sc.list(); | ||||
| 
 | ||||
|         if (directHosts.isEmpty()) { | ||||
|             logger.debug("No direct agents in status " + Status.Up + " exist for the management server " + msId + | ||||
|             s_logger.debug("No direct agents in status " + Status.Up + " exist for the management server " + msId + | ||||
|                 "; so it doesn't participate in agent rebalancing process"); | ||||
|             return null; | ||||
|         } | ||||
| @ -90,23 +92,23 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements | ||||
|         int hostsLeft = directHosts.size(); | ||||
|         List<HostVO> hostsToReturn = new ArrayList<HostVO>(); | ||||
| 
 | ||||
|         logger.debug("Management server " + msId + " can give away " + hostsToGive + " as it currently owns " + allHosts.size() + | ||||
|         s_logger.debug("Management server " + msId + " can give away " + hostsToGive + " as it currently owns " + allHosts.size() + | ||||
|             " and the average agent load in the system is " + avLoad + "; finalyzing list of hosts to give away..."); | ||||
|         for (Long cluster : hostToClusterMap.keySet()) { | ||||
|             List<HostVO> hostsInCluster = hostToClusterMap.get(cluster); | ||||
|             hostsLeft = hostsLeft - hostsInCluster.size(); | ||||
|             if (hostsToReturn.size() < hostsToGive) { | ||||
|                 logger.debug("Trying cluster id=" + cluster); | ||||
|                 s_logger.debug("Trying cluster id=" + cluster); | ||||
| 
 | ||||
|                 if (hostsInCluster.size() > hostsLeftToGive) { | ||||
|                     logger.debug("Skipping cluster id=" + cluster + " as it has more hosts than we need: " + hostsInCluster.size() + " vs " + hostsLeftToGive); | ||||
|                     s_logger.debug("Skipping cluster id=" + cluster + " as it has more hosts than we need: " + hostsInCluster.size() + " vs " + hostsLeftToGive); | ||||
|                     if (hostsLeft >= hostsLeftToGive) { | ||||
|                         continue; | ||||
|                     } else { | ||||
|                         break; | ||||
|                     } | ||||
|                 } else { | ||||
|                     logger.debug("Taking all " + hostsInCluster.size() + " hosts: " + hostsInCluster + " from cluster id=" + cluster); | ||||
|                     s_logger.debug("Taking all " + hostsInCluster.size() + " hosts: " + hostsInCluster + " from cluster id=" + cluster); | ||||
|                     hostsToReturn.addAll(hostsInCluster); | ||||
|                     hostsLeftToGive = hostsLeftToGive - hostsInCluster.size(); | ||||
|                 } | ||||
| @ -115,7 +117,7 @@ public class ClusterBasedAgentLoadBalancerPlanner extends AdapterBase implements | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         logger.debug("Management server " + msId + " is ready to give away " + hostsToReturn.size() + " hosts"); | ||||
|         s_logger.debug("Management server " + msId + " is ready to give away " + hostsToReturn.size() + " hosts"); | ||||
|         return hostsToReturn; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -20,6 +20,7 @@ import java.util.Map; | ||||
| 
 | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import org.apache.cloudstack.context.CallContext; | ||||
| import org.apache.cloudstack.framework.jobs.AsyncJob; | ||||
| @ -33,6 +34,7 @@ import com.cloud.utils.component.AdapterBase; | ||||
| import com.cloud.vm.dao.VMInstanceDao; | ||||
| 
 | ||||
| public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatcher { | ||||
|     private static final Logger s_logger = Logger.getLogger(VmWorkJobDispatcher.class); | ||||
| 
 | ||||
|     @Inject private VirtualMachineManagerImpl _vmMgr; | ||||
|     @Inject | ||||
| @ -63,23 +65,23 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch | ||||
|             try { | ||||
|                 workClz = Class.forName(job.getCmd()); | ||||
|             } catch (ClassNotFoundException e) { | ||||
|                 logger.error("VM work class " + cmd + " is not found" + ", job origin: " + job.getRelated(), e); | ||||
|                 s_logger.error("VM work class " + cmd + " is not found" + ", job origin: " + job.getRelated(), e); | ||||
|                 _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, e.getMessage()); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             work = VmWorkSerializer.deserialize(workClz, job.getCmdInfo()); | ||||
|             if(work == null) { | ||||
|                 logger.error("Unable to deserialize VM work " + job.getCmd() + ", job info: " + job.getCmdInfo() + ", job origin: " + job.getRelated()); | ||||
|                 s_logger.error("Unable to deserialize VM work " + job.getCmd() + ", job info: " + job.getCmdInfo() + ", job origin: " + job.getRelated()); | ||||
|                 _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, "Unable to deserialize VM work"); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             if (logger.isDebugEnabled()) | ||||
|                 logger.debug("Run VM work job: " + cmd + " for VM " + work.getVmId() + ", job origin: " + job.getRelated()); | ||||
|             if (s_logger.isDebugEnabled()) | ||||
|                 s_logger.debug("Run VM work job: " + cmd + " for VM " + work.getVmId() + ", job origin: " + job.getRelated()); | ||||
|             try { | ||||
|                 if (_handlers == null || _handlers.isEmpty()) { | ||||
|                     logger.error("Invalid startup configuration, no work job handler is found. cmd: " + job.getCmd() + ", job info: " + job.getCmdInfo() | ||||
|                     s_logger.error("Invalid startup configuration, no work job handler is found. cmd: " + job.getCmd() + ", job info: " + job.getCmdInfo() | ||||
|                             + ", job origin: " + job.getRelated()); | ||||
|                     _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, "Invalid startup configuration. no job handler is found"); | ||||
|                     return; | ||||
| @ -88,7 +90,7 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch | ||||
|                 VmWorkJobHandler handler = _handlers.get(work.getHandlerName()); | ||||
| 
 | ||||
|                 if (handler == null) { | ||||
|                     logger.error("Unable to find work job handler. handler name: " + work.getHandlerName() + ", job cmd: " + job.getCmd() | ||||
|                     s_logger.error("Unable to find work job handler. handler name: " + work.getHandlerName() + ", job cmd: " + job.getCmd() | ||||
|                             + ", job info: " + job.getCmdInfo() + ", job origin: " + job.getRelated()); | ||||
|                     _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, "Unable to find work job handler"); | ||||
|                     return; | ||||
| @ -103,14 +105,14 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch | ||||
|                     CallContext.unregister(); | ||||
|                 } | ||||
|             } finally { | ||||
|                 if (logger.isDebugEnabled()) | ||||
|                     logger.debug("Done with run of VM work job: " + cmd + " for VM " + work.getVmId() + ", job origin: " + job.getRelated()); | ||||
|                 if (s_logger.isDebugEnabled()) | ||||
|                     s_logger.debug("Done with run of VM work job: " + cmd + " for VM " + work.getVmId() + ", job origin: " + job.getRelated()); | ||||
|             } | ||||
|         } catch(InvalidParameterValueException e) { | ||||
|             logger.error("Unable to complete " + job + ", job origin:" + job.getRelated()); | ||||
|             s_logger.error("Unable to complete " + job + ", job origin:" + job.getRelated()); | ||||
|             _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, _asyncJobMgr.marshallResultObject(e)); | ||||
|         } catch(Throwable e) { | ||||
|             logger.error("Unable to complete " + job + ", job origin:" + job.getRelated(), e); | ||||
|             s_logger.error("Unable to complete " + job + ", job origin:" + job.getRelated(), e); | ||||
| 
 | ||||
|             //RuntimeException ex = new RuntimeException("Job failed due to exception " + e.getMessage()); | ||||
|             _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, _asyncJobMgr.marshallResultObject(e)); | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.util.Map; | ||||
| 
 | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import org.apache.cloudstack.context.CallContext; | ||||
| import org.apache.cloudstack.framework.jobs.AsyncJob; | ||||
| @ -46,6 +47,7 @@ import com.cloud.vm.dao.VMInstanceDao; | ||||
|  * Current code base uses blocking calls to wait for job completion | ||||
|  */ | ||||
| public class VmWorkJobWakeupDispatcher extends AdapterBase implements AsyncJobDispatcher { | ||||
|     private static final Logger s_logger = Logger.getLogger(VmWorkJobWakeupDispatcher.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     private VmWorkJobDao _workjobDao; | ||||
| @ -67,7 +69,7 @@ public class VmWorkJobWakeupDispatcher extends AdapterBase implements AsyncJobDi | ||||
|         try { | ||||
|             List<AsyncJobJoinMapVO> joinRecords = _joinMapDao.listJoinRecords(job.getId()); | ||||
|             if (joinRecords.size() != 1) { | ||||
|                 logger.warn("AsyncJob-" + job.getId() | ||||
|                 s_logger.warn("AsyncJob-" + job.getId() | ||||
|                         + " received wakeup call with un-supported joining job number: " + joinRecords.size()); | ||||
| 
 | ||||
|                 // if we fail wakeup-execution for any reason, avoid release sync-source if there is any | ||||
| @ -82,7 +84,7 @@ public class VmWorkJobWakeupDispatcher extends AdapterBase implements AsyncJobDi | ||||
|             try { | ||||
|                 workClz = Class.forName(job.getCmd()); | ||||
|             } catch (ClassNotFoundException e) { | ||||
|                 logger.error("VM work class " + job.getCmd() + " is not found", e); | ||||
|                 s_logger.error("VM work class " + job.getCmd() + " is not found", e); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
| @ -103,14 +105,14 @@ public class VmWorkJobWakeupDispatcher extends AdapterBase implements AsyncJobDi | ||||
|                     handler.invoke(_vmMgr); | ||||
|                 } else { | ||||
|                     assert (false); | ||||
|                     logger.error("Unable to find wakeup handler " + joinRecord.getWakeupHandler() + | ||||
|                     s_logger.error("Unable to find wakeup handler " + joinRecord.getWakeupHandler() + | ||||
|                             " when waking up job-" + job.getId()); | ||||
|                 } | ||||
|             } finally { | ||||
|                 CallContext.unregister(); | ||||
|             } | ||||
|         } catch (Throwable e) { | ||||
|             logger.warn("Unexpected exception in waking up job-" + job.getId()); | ||||
|             s_logger.warn("Unexpected exception in waking up job-" + job.getId()); | ||||
| 
 | ||||
|             // if we fail wakeup-execution for any reason, avoid release sync-source if there is any | ||||
|             job.setSyncSource(null); | ||||
| @ -130,11 +132,11 @@ public class VmWorkJobWakeupDispatcher extends AdapterBase implements AsyncJobDi | ||||
|                 method.setAccessible(true); | ||||
|             } catch (SecurityException e) { | ||||
|                 assert (false); | ||||
|                 logger.error("Unexpected exception", e); | ||||
|                 s_logger.error("Unexpected exception", e); | ||||
|                 return null; | ||||
|             } catch (NoSuchMethodException e) { | ||||
|                 assert (false); | ||||
|                 logger.error("Unexpected exception", e); | ||||
|                 s_logger.error("Unexpected exception", e); | ||||
|                 return null; | ||||
|             } | ||||
| 
 | ||||
|  | ||||
| @ -28,6 +28,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.engine.datacenter.entity.api.DataCenterResourceEntity; | ||||
| @ -52,6 +53,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component(value = "EngineClusterDao") | ||||
| @Local(value = EngineClusterDao.class) | ||||
| public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long> implements EngineClusterDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(EngineClusterDaoImpl.class); | ||||
| 
 | ||||
|     protected final SearchBuilder<EngineClusterVO> PodSearch; | ||||
|     protected final SearchBuilder<EngineClusterVO> HyTypeWithoutGuidSearch; | ||||
| @ -272,7 +274,7 @@ public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long> | ||||
| 
 | ||||
|         int rows = update(vo, sc); | ||||
| 
 | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId()); | ||||
|             if (dbCluster != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -299,7 +301,7 @@ public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long> | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update dataCenter: id=" + vo.getId() + ", as there is no such dataCenter exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update dataCenter: id=" + vo.getId() + ", as there is no such dataCenter exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -30,6 +30,7 @@ import java.util.concurrent.ExecutionException; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo; | ||||
| @ -130,6 +131,7 @@ import com.cloud.vm.VmWorkTakeVolumeSnapshot; | ||||
| import com.cloud.vm.dao.UserVmDao; | ||||
| 
 | ||||
| public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService, Configurable { | ||||
|     private static final Logger s_logger = Logger.getLogger(VolumeOrchestrator.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     EntityManager _entityMgr; | ||||
| @ -341,8 +343,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
| 
 | ||||
|             if (pool == null) { | ||||
|                 //pool could not be found in the VM's pod/cluster. | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Could not find any storage pool to create Volume in the pod/cluster of the provided VM " + vm.getUuid()); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Could not find any storage pool to create Volume in the pod/cluster of the provided VM " + vm.getUuid()); | ||||
|                 } | ||||
|                 StringBuilder addDetails = new StringBuilder(msg); | ||||
|                 addDetails.append(", Could not find any storage pool to create Volume in the pod/cluster of the VM "); | ||||
| @ -359,8 +361,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                 } | ||||
| 
 | ||||
|                 if (pool != null) { | ||||
|                     if (logger.isDebugEnabled()) { | ||||
|                         logger.debug("Found a suitable pool for create volume: " + pool.getId()); | ||||
|                     if (s_logger.isDebugEnabled()) { | ||||
|                         s_logger.debug("Found a suitable pool for create volume: " + pool.getId()); | ||||
|                     } | ||||
|                     break; | ||||
|                 } | ||||
| @ -368,7 +370,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         } | ||||
| 
 | ||||
|         if (pool == null) { | ||||
|             logger.info(msg); | ||||
|             s_logger.info(msg); | ||||
|             throw new StorageUnavailableException(msg, -1); | ||||
|         } | ||||
| 
 | ||||
| @ -387,7 +389,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                 _snapshotSrv.syncVolumeSnapshotsToRegionStore(snapVolId, snapStore); | ||||
|             } catch (Exception ex) { | ||||
|                 // log but ignore the sync error to avoid any potential S3 down issue, it should be sync next time | ||||
|                 logger.warn(ex.getMessage(), ex); | ||||
|                 s_logger.warn(ex.getMessage(), ex); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -396,15 +398,15 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         try { | ||||
|             VolumeApiResult result = future.get(); | ||||
|             if (result.isFailed()) { | ||||
|                 logger.debug("Failed to create volume from snapshot:" + result.getResult()); | ||||
|                 s_logger.debug("Failed to create volume from snapshot:" + result.getResult()); | ||||
|                 throw new CloudRuntimeException("Failed to create volume from snapshot:" + result.getResult()); | ||||
|             } | ||||
|             return result.getVolume(); | ||||
|         } catch (InterruptedException e) { | ||||
|             logger.debug("Failed to create volume from snapshot", e); | ||||
|             s_logger.debug("Failed to create volume from snapshot", e); | ||||
|             throw new CloudRuntimeException("Failed to create volume from snapshot", e); | ||||
|         } catch (ExecutionException e) { | ||||
|             logger.debug("Failed to create volume from snapshot", e); | ||||
|             s_logger.debug("Failed to create volume from snapshot", e); | ||||
|             throw new CloudRuntimeException("Failed to create volume from snapshot", e); | ||||
|         } | ||||
| 
 | ||||
| @ -464,15 +466,15 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         try { | ||||
|             VolumeApiResult result = future.get(); | ||||
|             if (result.isFailed()) { | ||||
|                 logger.debug("copy volume failed: " + result.getResult()); | ||||
|                 s_logger.debug("copy volume failed: " + result.getResult()); | ||||
|                 throw new CloudRuntimeException("copy volume failed: " + result.getResult()); | ||||
|             } | ||||
|             return result.getVolume(); | ||||
|         } catch (InterruptedException e) { | ||||
|             logger.debug("Failed to copy volume: " + volume.getId(), e); | ||||
|             s_logger.debug("Failed to copy volume: " + volume.getId(), e); | ||||
|             throw new CloudRuntimeException("Failed to copy volume", e); | ||||
|         } catch (ExecutionException e) { | ||||
|             logger.debug("Failed to copy volume: " + volume.getId(), e); | ||||
|             s_logger.debug("Failed to copy volume: " + volume.getId(), e); | ||||
|             throw new CloudRuntimeException("Failed to copy volume", e); | ||||
|         } | ||||
|     } | ||||
| @ -502,12 +504,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
| 
 | ||||
|         pool = findStoragePool(dskCh, dc, pod, clusterId, vm.getHostId(), vm, avoidPools); | ||||
|         if (pool == null) { | ||||
|             logger.warn("Unable to find suitable primary storage when creating volume " + volume.getName()); | ||||
|             s_logger.warn("Unable to find suitable primary storage when creating volume " + volume.getName()); | ||||
|             throw new CloudRuntimeException("Unable to find suitable primary storage when creating volume " + volume.getName()); | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Trying to create " + volume + " on " + pool); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Trying to create " + volume + " on " + pool); | ||||
|         } | ||||
|         DataStore store = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); | ||||
|         for (int i = 0; i < 2; i++) { | ||||
| @ -524,20 +526,20 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                 VolumeApiResult result = future.get(); | ||||
|                 if (result.isFailed()) { | ||||
|                     if (result.getResult().contains("request template reload") && (i == 0)) { | ||||
|                         logger.debug("Retry template re-deploy for vmware"); | ||||
|                         s_logger.debug("Retry template re-deploy for vmware"); | ||||
|                         continue; | ||||
|                     } else { | ||||
|                         logger.debug("create volume failed: " + result.getResult()); | ||||
|                         s_logger.debug("create volume failed: " + result.getResult()); | ||||
|                         throw new CloudRuntimeException("create volume failed:" + result.getResult()); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
|                 return result.getVolume(); | ||||
|             } catch (InterruptedException e) { | ||||
|                 logger.error("create volume failed", e); | ||||
|                 s_logger.error("create volume failed", e); | ||||
|                 throw new CloudRuntimeException("create volume failed", e); | ||||
|             } catch (ExecutionException e) { | ||||
|                 logger.error("create volume failed", e); | ||||
|                 s_logger.error("create volume failed", e); | ||||
|                 throw new CloudRuntimeException("create volume failed", e); | ||||
|             } | ||||
|         } | ||||
| @ -672,10 +674,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         if (rootDisksize != null ) { | ||||
|             rootDisksize = rootDisksize * 1024 * 1024 * 1024; | ||||
|             if (rootDisksize > size) { | ||||
|                 logger.debug("Using root disk size of " + rootDisksize + " Bytes for volume " + name); | ||||
|                 s_logger.debug("Using root disk size of " + rootDisksize + " Bytes for volume " + name); | ||||
|                 size = rootDisksize; | ||||
|             } else { | ||||
|                 logger.debug("Using root disk size of " + size + " Bytes for volume " + name + "since specified root disk size of " + rootDisksize + " Bytes is smaller than template"); | ||||
|                 s_logger.debug("Using root disk size of " + size + " Bytes for volume " + name + "since specified root disk size of " + rootDisksize + " Bytes is smaller than template"); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -816,8 +818,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         Long volTemplateId = existingVolume.getTemplateId(); | ||||
|         long vmTemplateId = vm.getTemplateId(); | ||||
|         if (volTemplateId != null && volTemplateId.longValue() != vmTemplateId) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("switchVolume: Old Volume's templateId: " + volTemplateId + " does not match the VM's templateId: " + vmTemplateId | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("switchVolume: Old Volume's templateId: " + volTemplateId + " does not match the VM's templateId: " + vmTemplateId | ||||
|                         + ", updating templateId in the new Volume"); | ||||
|             } | ||||
|             templateIdToUse = vmTemplateId; | ||||
| @ -831,16 +833,16 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                 try { | ||||
|                     stateTransitTo(existingVolume, Volume.Event.DestroyRequested); | ||||
|                 } catch (NoTransitionException e) { | ||||
|                     logger.debug("Unable to destroy existing volume: " + e.toString()); | ||||
|                     s_logger.debug("Unable to destroy existing volume: " + e.toString()); | ||||
|                 } | ||||
|                 // In case of VMware VM will continue to use the old root disk until expunged, so force expunge old root disk | ||||
|                 if (vm.getHypervisorType() == HypervisorType.VMware) { | ||||
|                     logger.info("Expunging volume " + existingVolume.getId() + " from primary data store"); | ||||
|                     s_logger.info("Expunging volume " + existingVolume.getId() + " from primary data store"); | ||||
|                     AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(existingVolume.getId())); | ||||
|                     try { | ||||
|                         future.get(); | ||||
|                     } catch (Exception e) { | ||||
|                         logger.debug("Failed to expunge volume:" + existingVolume.getId(), e); | ||||
|                         s_logger.debug("Failed to expunge volume:" + existingVolume.getId(), e); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
| @ -857,8 +859,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|     @Override | ||||
|     @DB | ||||
|     public void cleanupVolumes(long vmId) throws ConcurrentOperationException { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Cleaning storage for vm: " + vmId); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Cleaning storage for vm: " + vmId); | ||||
|         } | ||||
|         final List<VolumeVO> volumesForVm = _volsDao.findByInstance(vmId); | ||||
|         final List<VolumeVO> toBeExpunged = new ArrayList<VolumeVO>(); | ||||
| @ -873,12 +875,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                         if (!volumeAlreadyDestroyed) { | ||||
|                             volService.destroyVolume(vol.getId()); | ||||
|                         } else { | ||||
|                             logger.debug("Skipping destroy for the volume " + vol + " as its in state " + vol.getState().toString()); | ||||
|                             s_logger.debug("Skipping destroy for the volume " + vol + " as its in state " + vol.getState().toString()); | ||||
|                         } | ||||
|                         toBeExpunged.add(vol); | ||||
|                     } else { | ||||
|                         if (logger.isDebugEnabled()) { | ||||
|                             logger.debug("Detaching " + vol); | ||||
|                         if (s_logger.isDebugEnabled()) { | ||||
|                             s_logger.debug("Detaching " + vol); | ||||
|                         } | ||||
|                         _volsDao.detachVolume(vol.getId()); | ||||
|                     } | ||||
| @ -892,9 +894,9 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|             try { | ||||
|                 future.get(); | ||||
|             } catch (InterruptedException e) { | ||||
|                 logger.debug("failed expunge volume" + expunge.getId(), e); | ||||
|                 s_logger.debug("failed expunge volume" + expunge.getId(), e); | ||||
|             } catch (ExecutionException e) { | ||||
|                 logger.debug("failed expunge volume" + expunge.getId(), e); | ||||
|                 s_logger.debug("failed expunge volume" + expunge.getId(), e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -936,7 +938,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         try { | ||||
|             VolumeApiResult result = future.get(); | ||||
|             if (result.isFailed()) { | ||||
|                 logger.error("Migrate volume failed:" + result.getResult()); | ||||
|                 s_logger.error("Migrate volume failed:" + result.getResult()); | ||||
|                 throw new StorageUnavailableException("Migrate volume failed: " + result.getResult(), destPool.getId()); | ||||
|             } else { | ||||
|                 // update the volumeId for snapshots on secondary | ||||
| @ -947,10 +949,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|             } | ||||
|             return result.getVolume(); | ||||
|         } catch (InterruptedException e) { | ||||
|             logger.debug("migrate volume failed", e); | ||||
|             s_logger.debug("migrate volume failed", e); | ||||
|             throw new CloudRuntimeException(e.getMessage()); | ||||
|         } catch (ExecutionException e) { | ||||
|             logger.debug("migrate volume failed", e); | ||||
|             s_logger.debug("migrate volume failed", e); | ||||
|             throw new CloudRuntimeException(e.getMessage()); | ||||
|         } | ||||
|     } | ||||
| @ -962,15 +964,15 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         try { | ||||
|             VolumeApiResult result = future.get(); | ||||
|             if (result.isFailed()) { | ||||
|                 logger.debug("migrate volume failed:" + result.getResult()); | ||||
|                 s_logger.debug("migrate volume failed:" + result.getResult()); | ||||
|                 return null; | ||||
|             } | ||||
|             return result.getVolume(); | ||||
|         } catch (InterruptedException e) { | ||||
|             logger.debug("migrate volume failed", e); | ||||
|             s_logger.debug("migrate volume failed", e); | ||||
|             return null; | ||||
|         } catch (ExecutionException e) { | ||||
|             logger.debug("migrate volume failed", e); | ||||
|             s_logger.debug("migrate volume failed", e); | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| @ -1001,13 +1003,13 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         try { | ||||
|             CommandResult result = future.get(); | ||||
|             if (result.isFailed()) { | ||||
|                 logger.debug("Failed to migrated vm " + vm + " along with its volumes. " + result.getResult()); | ||||
|                 s_logger.debug("Failed to migrated vm " + vm + " along with its volumes. " + result.getResult()); | ||||
|                 throw new CloudRuntimeException("Failed to migrated vm " + vm + " along with its volumes. "); | ||||
|             } | ||||
|         } catch (InterruptedException e) { | ||||
|             logger.debug("Failed to migrated vm " + vm + " along with its volumes.", e); | ||||
|             s_logger.debug("Failed to migrated vm " + vm + " along with its volumes.", e); | ||||
|         } catch (ExecutionException e) { | ||||
|             logger.debug("Failed to migrated vm " + vm + " along with its volumes.", e); | ||||
|             s_logger.debug("Failed to migrated vm " + vm + " along with its volumes.", e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -1018,12 +1020,12 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
| 
 | ||||
|         for (VolumeVO volume : vols) { | ||||
|             if (volume.getState() != Volume.State.Ready) { | ||||
|                 logger.debug("volume: " + volume.getId() + " is in " + volume.getState() + " state"); | ||||
|                 s_logger.debug("volume: " + volume.getId() + " is in " + volume.getState() + " state"); | ||||
|                 throw new CloudRuntimeException("volume: " + volume.getId() + " is in " + volume.getState() + " state"); | ||||
|             } | ||||
| 
 | ||||
|             if (volume.getPoolId() == destPool.getId()) { | ||||
|                 logger.debug("volume: " + volume.getId() + " is on the same storage pool: " + destPool.getId()); | ||||
|                 s_logger.debug("volume: " + volume.getId() + " is on the same storage pool: " + destPool.getId()); | ||||
|                 continue; | ||||
|             } | ||||
| 
 | ||||
| @ -1031,7 +1033,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         } | ||||
| 
 | ||||
|         if (volumesNeedToMigrate.isEmpty()) { | ||||
|             logger.debug("No volume need to be migrated"); | ||||
|             s_logger.debug("No volume need to be migrated"); | ||||
|             return true; | ||||
|         } | ||||
| 
 | ||||
| @ -1047,8 +1049,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|     @Override | ||||
|     public void prepareForMigration(VirtualMachineProfile vm, DeployDestination dest) { | ||||
|         List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId()); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Preparing " + vols.size() + " volumes for " + vm); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Preparing " + vols.size() + " volumes for " + vm); | ||||
|         } | ||||
| 
 | ||||
|         for (VolumeVO vol : vols) { | ||||
| @ -1136,21 +1138,21 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                     tasks.add(task); | ||||
|                 } else { | ||||
|                     if (vol.isRecreatable()) { | ||||
|                         if (logger.isDebugEnabled()) { | ||||
|                             logger.debug("Volume " + vol + " will be recreated on storage pool " + assignedPool + " assigned by deploymentPlanner"); | ||||
|                         if (s_logger.isDebugEnabled()) { | ||||
|                             s_logger.debug("Volume " + vol + " will be recreated on storage pool " + assignedPool + " assigned by deploymentPlanner"); | ||||
|                         } | ||||
|                         VolumeTask task = new VolumeTask(VolumeTaskType.RECREATE, vol, null); | ||||
|                         tasks.add(task); | ||||
|                     } else { | ||||
|                         if (assignedPool.getId() != vol.getPoolId()) { | ||||
|                             if (logger.isDebugEnabled()) { | ||||
|                                 logger.debug("Mismatch in storage pool " + assignedPool + " assigned by deploymentPlanner and the one associated with volume " + vol); | ||||
|                             if (s_logger.isDebugEnabled()) { | ||||
|                                 s_logger.debug("Mismatch in storage pool " + assignedPool + " assigned by deploymentPlanner and the one associated with volume " + vol); | ||||
|                             } | ||||
|                             DiskOffering diskOffering = _entityMgr.findById(DiskOffering.class, vol.getDiskOfferingId()); | ||||
|                             if (diskOffering.getUseLocalStorage()) { | ||||
|                                 // Currently migration of local volume is not supported so bail out | ||||
|                                 if (logger.isDebugEnabled()) { | ||||
|                                     logger.debug("Local volume " + vol + " cannot be recreated on storagepool " + assignedPool + " assigned by deploymentPlanner"); | ||||
|                                 if (s_logger.isDebugEnabled()) { | ||||
|                                     s_logger.debug("Local volume " + vol + " cannot be recreated on storagepool " + assignedPool + " assigned by deploymentPlanner"); | ||||
|                                 } | ||||
|                                 throw new CloudRuntimeException("Local volume " + vol + " cannot be recreated on storagepool " + assignedPool + " assigned by deploymentPlanner"); | ||||
|                             } else { | ||||
| @ -1163,8 +1165,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                                     storageMigrationEnabled = StorageMigrationEnabled.value(); | ||||
|                                 } | ||||
|                                 if(storageMigrationEnabled){ | ||||
|                                     if (logger.isDebugEnabled()) { | ||||
|                                         logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner"); | ||||
|                                     if (s_logger.isDebugEnabled()) { | ||||
|                                         s_logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner"); | ||||
|                                     } | ||||
|                                     VolumeTask task = new VolumeTask(VolumeTaskType.MIGRATE, vol, assignedPool); | ||||
|                                     tasks.add(task); | ||||
| @ -1185,8 +1187,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                     throw new StorageUnavailableException("Volume has no pool associate and also no storage pool assigned in DeployDestination, Unable to create " + vol, | ||||
|                             Volume.class, vol.getId()); | ||||
|                 } | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("No need to recreate the volume: " + vol + ", since it already has a pool assigned: " + vol.getPoolId() + ", adding disk to VM"); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("No need to recreate the volume: " + vol + ", since it already has a pool assigned: " + vol.getPoolId() + ", adding disk to VM"); | ||||
|                 } | ||||
|                 StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId()); | ||||
|                 VolumeTask task = new VolumeTask(VolumeTaskType.NOP, vol, pool); | ||||
| @ -1203,7 +1205,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         DataStore destPool = null; | ||||
|         if (recreate && (dest.getStorageForDisks() == null || dest.getStorageForDisks().get(vol) == null)) { | ||||
|             destPool = dataStoreMgr.getDataStore(vol.getPoolId(), DataStoreRole.Primary); | ||||
|             logger.debug("existing pool: " + destPool.getId()); | ||||
|             s_logger.debug("existing pool: " + destPool.getId()); | ||||
|         } else { | ||||
|             StoragePool pool = dest.getStorageForDisks().get(vol); | ||||
|             destPool = dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); | ||||
| @ -1220,8 +1222,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                 dest.getStorageForDisks().put(newVol, poolWithOldVol); | ||||
|                 dest.getStorageForDisks().remove(vol); | ||||
|             } | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Created new volume " + newVol + " for old volume " + vol); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Created new volume " + newVol + " for old volume " + vol); | ||||
|             } | ||||
|         } | ||||
|         VolumeInfo volume = volFactory.getVolume(newVol.getId(), destPool); | ||||
| @ -1243,7 +1245,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
| 
 | ||||
|                 TemplateInfo templ = tmplFactory.getReadyTemplateOnImageStore(templateId, dest.getDataCenter().getId()); | ||||
|                 if (templ == null) { | ||||
|                     logger.debug("can't find ready template: " + templateId + " for data center " + dest.getDataCenter().getId()); | ||||
|                     s_logger.debug("can't find ready template: " + templateId + " for data center " + dest.getDataCenter().getId()); | ||||
|                     throw new CloudRuntimeException("can't find ready template: " + templateId + " for data center " + dest.getDataCenter().getId()); | ||||
|                 } | ||||
| 
 | ||||
| @ -1269,10 +1271,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                 result = future.get(); | ||||
|                 if (result.isFailed()) { | ||||
|                     if (result.getResult().contains("request template reload") && (i == 0)) { | ||||
|                         logger.debug("Retry template re-deploy for vmware"); | ||||
|                         s_logger.debug("Retry template re-deploy for vmware"); | ||||
|                         continue; | ||||
|                     } else { | ||||
|                         logger.debug("Unable to create " + newVol + ":" + result.getResult()); | ||||
|                         s_logger.debug("Unable to create " + newVol + ":" + result.getResult()); | ||||
|                         throw new StorageUnavailableException("Unable to create " + newVol + ":" + result.getResult(), destPool.getId()); | ||||
|                     } | ||||
|                 } | ||||
| @ -1289,10 +1291,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                 newVol = _volsDao.findById(newVol.getId()); | ||||
|                 break; //break out of template-redeploy retry loop | ||||
|             } catch (InterruptedException e) { | ||||
|                 logger.error("Unable to create " + newVol, e); | ||||
|                 s_logger.error("Unable to create " + newVol, e); | ||||
|                 throw new StorageUnavailableException("Unable to create " + newVol + ":" + e.toString(), destPool.getId()); | ||||
|             } catch (ExecutionException e) { | ||||
|                 logger.error("Unable to create " + newVol, e); | ||||
|                 s_logger.error("Unable to create " + newVol, e); | ||||
|                 throw new StorageUnavailableException("Unable to create " + newVol + ":" + e.toString(), destPool.getId()); | ||||
|             } | ||||
|         } | ||||
| @ -1304,8 +1306,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|     public void prepare(VirtualMachineProfile vm, DeployDestination dest) throws StorageUnavailableException, InsufficientStorageCapacityException, ConcurrentOperationException { | ||||
| 
 | ||||
|         if (dest == null) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("DeployDestination cannot be null, cannot prepare Volumes for the vm: " + vm); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("DeployDestination cannot be null, cannot prepare Volumes for the vm: " + vm); | ||||
|             } | ||||
|             throw new CloudRuntimeException("Unable to prepare Volume for vm because DeployDestination is null, vm:" + vm); | ||||
|         } | ||||
| @ -1316,8 +1318,8 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         } | ||||
| 
 | ||||
|         List<VolumeVO> vols = _volsDao.findUsableVolumesForInstance(vm.getId()); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Checking if we need to prepare " + vols.size() + " volumes for " + vm); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Checking if we need to prepare " + vols.size() + " volumes for " + vm); | ||||
|         } | ||||
| 
 | ||||
|         List<VolumeTask> tasks = getTasks(vols, dest.getStorageForDisks(), vm); | ||||
| @ -1396,7 +1398,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         } | ||||
| 
 | ||||
|         if (volume.getState().equals(Volume.State.Creating)) { | ||||
|             logger.debug("Remove volume: " + volume.getId() + ", as it's leftover from last mgt server stop"); | ||||
|             s_logger.debug("Remove volume: " + volume.getId() + ", as it's leftover from last mgt server stop"); | ||||
|             _volsDao.remove(volume.getId()); | ||||
|         } | ||||
|     } | ||||
| @ -1411,11 +1413,11 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         if (volume.getState() == Volume.State.Migrating) { | ||||
|             VolumeVO duplicateVol = _volsDao.findByPoolIdName(destPoolId, volume.getName()); | ||||
|             if (duplicateVol != null) { | ||||
|                 logger.debug("Remove volume " + duplicateVol.getId() + " on storage pool " + destPoolId); | ||||
|                 s_logger.debug("Remove volume " + duplicateVol.getId() + " on storage pool " + destPoolId); | ||||
|                 _volsDao.remove(duplicateVol.getId()); | ||||
|             } | ||||
| 
 | ||||
|             logger.debug("change volume state to ready from migrating in case migration failure for vol: " + volumeId); | ||||
|             s_logger.debug("change volume state to ready from migrating in case migration failure for vol: " + volumeId); | ||||
|             volume.setState(Volume.State.Ready); | ||||
|             _volsDao.update(volumeId, volume); | ||||
|         } | ||||
| @ -1426,7 +1428,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|         _snapshotSrv.cleanupVolumeDuringSnapshotFailure(volumeId, snapshotId); | ||||
|         VolumeVO volume = _volsDao.findById(volumeId); | ||||
|         if (volume.getState() == Volume.State.Snapshotting) { | ||||
|             logger.debug("change volume state back to Ready: " + volume.getId()); | ||||
|             s_logger.debug("change volume state back to Ready: " + volume.getId()); | ||||
|             volume.setState(Volume.State.Ready); | ||||
|             _volsDao.update(volume.getId(), volume); | ||||
|         } | ||||
| @ -1451,7 +1453,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|                     cleanupVolumeDuringSnapshotFailure(work.getVolumeId(), work.getSnapshotId()); | ||||
|                 } | ||||
|             } catch (Exception e) { | ||||
|                 logger.debug("clean up job failure, will continue", e); | ||||
|                 s_logger.debug("clean up job failure, will continue", e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -1484,7 +1486,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|             //FIXME - why recalculate and not decrement | ||||
|             _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(), ResourceType.primary_storage.getOrdinal()); | ||||
|         } catch (Exception e) { | ||||
|             logger.debug("Failed to destroy volume" + volume.getId(), e); | ||||
|             s_logger.debug("Failed to destroy volume" + volume.getId(), e); | ||||
|             throw new CloudRuntimeException("Failed to destroy volume" + volume.getId(), e); | ||||
|         } | ||||
|     } | ||||
| @ -1515,7 +1517,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati | ||||
|             needUpdate = true; | ||||
| 
 | ||||
|         if (needUpdate) { | ||||
|             logger.info("Update volume disk chain info. vol: " + vol.getId() + ", " + vol.getPath() + " -> " + path + ", " + vol.getChainInfo() + " -> " + chainInfo); | ||||
|             s_logger.info("Update volume disk chain info. vol: " + vol.getId() + ", " + vol.getPath() + " -> " + path + ", " + vol.getChainInfo() + " -> " + chainInfo); | ||||
|             vol.setPath(path); | ||||
|             vol.setChainInfo(chainInfo); | ||||
|             _volsDao.update(volumeId, vol); | ||||
|  | ||||
| @ -28,6 +28,7 @@ import java.util.Map.Entry; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; | ||||
| @ -51,6 +52,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {CapacityDao.class}) | ||||
| public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements CapacityDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(CapacityDaoImpl.class); | ||||
| 
 | ||||
|     private static final String ADD_ALLOCATED_SQL = "UPDATE `cloud`.`op_host_capacity` SET used_capacity = used_capacity + ? WHERE host_id = ? AND capacity_type = ?"; | ||||
|     private static final String SUBTRACT_ALLOCATED_SQL = | ||||
| @ -521,7 +523,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Exception updating capacity for host: " + hostId, e); | ||||
|             s_logger.warn("Exception updating capacity for host: " + hostId, e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -986,7 +988,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements | ||||
|             } | ||||
|             pstmt.executeUpdate(); | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Error updating CapacityVO", e); | ||||
|             s_logger.warn("Error updating CapacityVO", e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -1006,7 +1008,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements | ||||
|                 return rs.getFloat(1); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Error checking cluster threshold", e); | ||||
|             s_logger.warn("Error checking cluster threshold", e); | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
| @ -18,6 +18,7 @@ package com.cloud.certificate.dao; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.certificate.CertificateVO; | ||||
| @ -29,6 +30,7 @@ import com.cloud.utils.db.GenericDaoBase; | ||||
| @DB | ||||
| public class CertificateDaoImpl extends GenericDaoBase<CertificateVO, Long> implements CertificateDao { | ||||
| 
 | ||||
|     private static final Logger s_logger = Logger.getLogger(CertificateDaoImpl.class); | ||||
| 
 | ||||
|     public CertificateDaoImpl() { | ||||
| 
 | ||||
| @ -42,7 +44,7 @@ public class CertificateDaoImpl extends GenericDaoBase<CertificateVO, Long> impl | ||||
|             update(cert.getId(), cert); | ||||
|             return cert.getId(); | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unable to read the certificate: " + e); | ||||
|             s_logger.warn("Unable to read the certificate: " + e); | ||||
|             return new Long(0); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -22,6 +22,7 @@ import java.util.List; | ||||
| import javax.annotation.PostConstruct; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.cluster.agentlb.HostTransferMapVO; | ||||
| @ -35,6 +36,7 @@ import com.cloud.utils.db.SearchCriteria; | ||||
| @Local(value = {HostTransferMapDao.class}) | ||||
| @DB | ||||
| public class HostTransferMapDaoImpl extends GenericDaoBase<HostTransferMapVO, Long> implements HostTransferMapDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(HostTransferMapDaoImpl.class); | ||||
| 
 | ||||
|     protected SearchBuilder<HostTransferMapVO> AllFieldsSearch; | ||||
|     protected SearchBuilder<HostTransferMapVO> IntermediateStateSearch; | ||||
|  | ||||
| @ -26,6 +26,7 @@ import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| import javax.persistence.TableGenerator; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.dc.DataCenterDetailVO; | ||||
| @ -57,6 +58,7 @@ import com.cloud.utils.net.NetUtils; | ||||
| @Component | ||||
| @Local(value = {DataCenterDao.class}) | ||||
| public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implements DataCenterDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(DataCenterDaoImpl.class); | ||||
| 
 | ||||
|     protected SearchBuilder<DataCenterVO> NameSearch; | ||||
|     protected SearchBuilder<DataCenterVO> ListZonesByDomainIdSearch; | ||||
| @ -410,7 +412,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem | ||||
|                     Long dcId = Long.parseLong(tokenOrIdOrName); | ||||
|                     return findById(dcId); | ||||
|                 } catch (NumberFormatException nfe) { | ||||
|                     logger.debug("Cannot parse " + tokenOrIdOrName + " into long. " + nfe); | ||||
|                     s_logger.debug("Cannot parse " + tokenOrIdOrName + " into long. " + nfe); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -23,6 +23,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.dc.DataCenterIpAddressVO; | ||||
| @ -40,6 +41,7 @@ import com.cloud.utils.net.NetUtils; | ||||
| @Local(value = {DataCenterIpAddressDao.class}) | ||||
| @DB | ||||
| public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddressVO, Long> implements DataCenterIpAddressDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(DataCenterIpAddressDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<DataCenterIpAddressVO> AllFieldsSearch; | ||||
|     private final GenericSearchBuilder<DataCenterIpAddressVO, Integer> AllIpCount; | ||||
| @ -142,8 +144,8 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre | ||||
| 
 | ||||
|     @Override | ||||
|     public void releaseIpAddress(String ipAddress, long dcId, Long instanceId) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Releasing ip address: " + ipAddress + " data center " + dcId); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Releasing ip address: " + ipAddress + " data center " + dcId); | ||||
|         } | ||||
|         SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create(); | ||||
|         sc.setParameters("ip", ipAddress); | ||||
| @ -160,8 +162,8 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre | ||||
| 
 | ||||
|     @Override | ||||
|     public void releaseIpAddress(long nicId, String reservationId) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Releasing ip address for reservationId=" + reservationId + ", instance=" + nicId); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Releasing ip address for reservationId=" + reservationId + ", instance=" + nicId); | ||||
|         } | ||||
|         SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create(); | ||||
|         sc.setParameters("instance", nicId); | ||||
| @ -176,8 +178,8 @@ public class DataCenterIpAddressDaoImpl extends GenericDaoBase<DataCenterIpAddre | ||||
| 
 | ||||
|     @Override | ||||
|     public void releaseIpAddress(long nicId) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Releasing ip address for instance=" + nicId); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Releasing ip address for instance=" + nicId); | ||||
|         } | ||||
|         SearchCriteria<DataCenterIpAddressVO> sc = AllFieldsSearch.create(); | ||||
|         sc.setParameters("instance", nicId); | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.Map; | ||||
| import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.dc.DataCenterLinkLocalIpAddressVO; | ||||
| @ -42,6 +43,7 @@ import com.cloud.utils.net.NetUtils; | ||||
| @Local(value = {DataCenterLinkLocalIpAddressDaoImpl.class}) | ||||
| @DB | ||||
| public class DataCenterLinkLocalIpAddressDaoImpl extends GenericDaoBase<DataCenterLinkLocalIpAddressVO, Long> implements DataCenterLinkLocalIpAddressDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(DataCenterLinkLocalIpAddressDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<DataCenterLinkLocalIpAddressVO> AllFieldsSearch; | ||||
|     private final GenericSearchBuilder<DataCenterLinkLocalIpAddressVO, Integer> AllIpCount; | ||||
| @ -105,8 +107,8 @@ public class DataCenterLinkLocalIpAddressDaoImpl extends GenericDaoBase<DataCent | ||||
| 
 | ||||
|     @Override | ||||
|     public void releaseIpAddress(String ipAddress, long dcId, long instanceId) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Releasing ip address: " + ipAddress + " data center " + dcId); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Releasing ip address: " + ipAddress + " data center " + dcId); | ||||
|         } | ||||
|         SearchCriteria<DataCenterLinkLocalIpAddressVO> sc = AllFieldsSearch.create(); | ||||
|         sc.setParameters("ip", ipAddress); | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.dc.HostPodVO; | ||||
| @ -39,6 +40,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {HostPodDao.class}) | ||||
| public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements HostPodDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(HostPodDaoImpl.class); | ||||
| 
 | ||||
|     protected SearchBuilder<HostPodVO> DataCenterAndNameSearch; | ||||
|     protected SearchBuilder<HostPodVO> DataCenterIdSearch; | ||||
| @ -100,7 +102,7 @@ public class HostPodDaoImpl extends GenericDaoBase<HostPodVO, Long> implements H | ||||
|                 currentPodCidrSubnets.put(podId, cidrPair); | ||||
|             } | ||||
|         } catch (SQLException ex) { | ||||
|             logger.warn("DB exception " + ex.getMessage(), ex); | ||||
|             s_logger.warn("DB exception " + ex.getMessage(), ex); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.Set; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.domain.Domain; | ||||
| @ -39,6 +40,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {DomainDao.class}) | ||||
| public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements DomainDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(DomainDaoImpl.class); | ||||
| 
 | ||||
|     protected SearchBuilder<DomainVO> DomainNameLikeSearch; | ||||
|     protected SearchBuilder<DomainVO> ParentDomainNameLikeSearch; | ||||
| @ -110,7 +112,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom | ||||
| 
 | ||||
|         DomainVO parentDomain = findById(parent); | ||||
|         if (parentDomain == null) { | ||||
|             logger.error("Unable to load parent domain: " + parent); | ||||
|             s_logger.error("Unable to load parent domain: " + parent); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
| @ -120,7 +122,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom | ||||
| 
 | ||||
|             parentDomain = this.lockRow(parent, true); | ||||
|             if (parentDomain == null) { | ||||
|                 logger.error("Unable to lock parent domain: " + parent); | ||||
|                 s_logger.error("Unable to lock parent domain: " + parent); | ||||
|                 return null; | ||||
|             } | ||||
| 
 | ||||
| @ -135,7 +137,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom | ||||
|             txn.commit(); | ||||
|             return domain; | ||||
|         } catch (Exception e) { | ||||
|             logger.error("Unable to create domain due to " + e.getMessage(), e); | ||||
|             s_logger.error("Unable to create domain due to " + e.getMessage(), e); | ||||
|             txn.rollback(); | ||||
|             return null; | ||||
|         } | ||||
| @ -146,23 +148,23 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom | ||||
|     public boolean remove(Long id) { | ||||
|         // check for any active users / domains assigned to the given domain id and don't remove the domain if there are any | ||||
|         if (id != null && id.longValue() == Domain.ROOT_DOMAIN) { | ||||
|             logger.error("Can not remove domain " + id + " as it is ROOT domain"); | ||||
|             s_logger.error("Can not remove domain " + id + " as it is ROOT domain"); | ||||
|             return false; | ||||
|         } else { | ||||
|             if(id == null) { | ||||
|                 logger.error("Can not remove domain without id."); | ||||
|                 s_logger.error("Can not remove domain without id."); | ||||
|                 return false; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         DomainVO domain = findById(id); | ||||
|         if (domain == null) { | ||||
|             logger.info("Unable to remove domain as domain " + id + " no longer exists"); | ||||
|             s_logger.info("Unable to remove domain as domain " + id + " no longer exists"); | ||||
|             return true; | ||||
|         } | ||||
| 
 | ||||
|         if (domain.getParent() == null) { | ||||
|             logger.error("Invalid domain " + id + ", orphan?"); | ||||
|             s_logger.error("Invalid domain " + id + ", orphan?"); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
| @ -175,7 +177,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom | ||||
|             txn.start(); | ||||
|             DomainVO parentDomain = super.lockRow(domain.getParent(), true); | ||||
|             if (parentDomain == null) { | ||||
|                 logger.error("Unable to load parent domain: " + domain.getParent()); | ||||
|                 s_logger.error("Unable to load parent domain: " + domain.getParent()); | ||||
|                 return false; | ||||
|             } | ||||
| 
 | ||||
| @ -196,7 +198,7 @@ public class DomainDaoImpl extends GenericDaoBase<DomainVO, Long> implements Dom | ||||
|             txn.commit(); | ||||
|         } catch (SQLException ex) { | ||||
|             success = false; | ||||
|             logger.error("error removing domain: " + id, ex); | ||||
|             s_logger.error("error removing domain: " + id, ex); | ||||
|             txn.rollback(); | ||||
|         } | ||||
|         return success; | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.event.Event.State; | ||||
| @ -35,6 +36,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {EventDao.class}) | ||||
| public class EventDaoImpl extends GenericDaoBase<EventVO, Long> implements EventDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(EventDaoImpl.class.getName()); | ||||
|     protected final SearchBuilder<EventVO> CompletedEventSearch; | ||||
|     protected final SearchBuilder<EventVO> ToArchiveOrDeleteEventSearch; | ||||
| 
 | ||||
|  | ||||
| @ -26,6 +26,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.dc.Vlan; | ||||
| @ -43,6 +44,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {UsageEventDao.class}) | ||||
| public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implements UsageEventDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageEventDaoImpl.class.getName()); | ||||
| 
 | ||||
|     private final SearchBuilder<UsageEventVO> latestEventsSearch; | ||||
|     private final SearchBuilder<UsageEventVO> IpeventsSearch; | ||||
| @ -101,8 +103,8 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem | ||||
|         // Copy events from cloud db to usage db | ||||
|         String sql = COPY_EVENTS; | ||||
|         if (recentEventId == 0) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("no recent event date, copying all events"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("no recent event date, copying all events"); | ||||
|             } | ||||
|             sql = COPY_ALL_EVENTS; | ||||
|         } | ||||
| @ -120,7 +122,7 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error copying events from cloud db to usage db", ex); | ||||
|             s_logger.error("error copying events from cloud db to usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
| @ -129,8 +131,8 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem | ||||
|         // Copy event details from cloud db to usage db | ||||
|         sql = COPY_EVENT_DETAILS; | ||||
|         if (recentEventId == 0) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("no recent event date, copying all event detailss"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("no recent event date, copying all event detailss"); | ||||
|             } | ||||
|             sql = COPY_ALL_EVENT_DETAILS; | ||||
|         } | ||||
| @ -148,7 +150,7 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error copying event details from cloud db to usage db", ex); | ||||
|             s_logger.error("error copying event details from cloud db to usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
| @ -171,7 +173,7 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem | ||||
|             } | ||||
|             return 0; | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting most recent event id", ex); | ||||
|             s_logger.error("error getting most recent event id", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
| @ -183,7 +185,7 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem | ||||
|         try { | ||||
|             return listLatestEvents(endDate); | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting most recent event date", ex); | ||||
|             s_logger.error("error getting most recent event date", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
| @ -203,7 +205,7 @@ public class UsageEventDaoImpl extends GenericDaoBase<UsageEventVO, Long> implem | ||||
|             } | ||||
|             return 0; | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting max event id", ex); | ||||
|             s_logger.error("error getting max event id", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.Map; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.event.UsageEventDetailsVO; | ||||
| @ -32,6 +33,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageEventDetailsDao.class}) | ||||
| public class UsageEventDetailsDaoImpl extends GenericDaoBase<UsageEventDetailsVO, Long> implements UsageEventDetailsDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageEventDetailsDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected final SearchBuilder<UsageEventDetailsVO> EventDetailsSearch; | ||||
|     protected final SearchBuilder<UsageEventDetailsVO> DetailSearch; | ||||
|  | ||||
| @ -20,6 +20,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.gpu.HostGpuGroupsVO; | ||||
| @ -31,6 +32,7 @@ import com.cloud.utils.db.SearchCriteria; | ||||
| @Component | ||||
| @Local(value = HostGpuGroupsDao.class) | ||||
| public class HostGpuGroupsDaoImpl extends GenericDaoBase<HostGpuGroupsVO, Long> implements HostGpuGroupsDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(HostGpuGroupsDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<HostGpuGroupsVO> _hostIdGroupNameSearch; | ||||
|     private final SearchBuilder<HostGpuGroupsVO> _searchByHostId; | ||||
|  | ||||
| @ -28,6 +28,7 @@ import java.util.Map.Entry; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.agent.api.VgpuTypesInfo; | ||||
| @ -42,6 +43,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = VGPUTypesDao.class) | ||||
| public class VGPUTypesDaoImpl extends GenericDaoBase<VGPUTypesVO, Long> implements VGPUTypesDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(VGPUTypesDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<VGPUTypesVO> _searchByGroupId; | ||||
|     private final SearchBuilder<VGPUTypesVO> _searchByGroupIdVGPUType; | ||||
|  | ||||
| @ -31,6 +31,7 @@ import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| import javax.persistence.TableGenerator; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.agent.api.VgpuTypesInfo; | ||||
| @ -70,6 +71,9 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @DB | ||||
| @TableGenerator(name = "host_req_sq", table = "op_host", pkColumnName = "id", valueColumnName = "sequence", allocationSize = 1) | ||||
| public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao { //FIXME: , ExternalIdDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(HostDaoImpl.class); | ||||
|     private static final Logger status_logger = Logger.getLogger(Status.class); | ||||
|     private static final Logger state_logger = Logger.getLogger(ResourceState.class); | ||||
| 
 | ||||
|     protected SearchBuilder<HostVO> TypePodDcStatusSearch; | ||||
| 
 | ||||
| @ -285,7 +289,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|         try { | ||||
|             HostTransferSearch = _hostTransferDao.createSearchBuilder(); | ||||
|         } catch (Throwable e) { | ||||
|             logger.debug("error", e); | ||||
|             s_logger.debug("error", e); | ||||
|         } | ||||
|         HostTransferSearch.and("id", HostTransferSearch.entity().getId(), SearchCriteria.Op.NULL); | ||||
|         UnmanagedDirectConnectSearch.join("hostTransferSearch", HostTransferSearch, HostTransferSearch.entity().getId(), UnmanagedDirectConnectSearch.entity().getId(), | ||||
| @ -441,8 +445,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|             sb.append(" "); | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isTraceEnabled()) { | ||||
|             logger.trace("Following hosts got reset: " + sb.toString()); | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             s_logger.trace("Following hosts got reset: " + sb.toString()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -501,19 +505,19 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|         TransactionLegacy txn = TransactionLegacy.currentTxn(); | ||||
| 
 | ||||
|         txn.start(); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Resetting hosts suitable for reconnect"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Resetting hosts suitable for reconnect"); | ||||
|         } | ||||
|         // reset hosts that are suitable candidates for reconnect | ||||
|         resetHosts(managementServerId, lastPingSecondsAfter); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Completed resetting hosts suitable for reconnect"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Completed resetting hosts suitable for reconnect"); | ||||
|         } | ||||
| 
 | ||||
|         List<HostVO> assignedHosts = new ArrayList<HostVO>(); | ||||
| 
 | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Acquiring hosts for clusters already owned by this management server"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Acquiring hosts for clusters already owned by this management server"); | ||||
|         } | ||||
|         List<Long> clusters = findClustersOwnedByManagementServer(managementServerId); | ||||
|         if (clusters.size() > 0) { | ||||
| @ -531,17 +535,17 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|                 sb.append(host.getId()); | ||||
|                 sb.append(" "); | ||||
|             } | ||||
|             if (logger.isTraceEnabled()) { | ||||
|                 logger.trace("Following hosts got acquired for clusters already owned: " + sb.toString()); | ||||
|             if (s_logger.isTraceEnabled()) { | ||||
|                 s_logger.trace("Following hosts got acquired for clusters already owned: " + sb.toString()); | ||||
|             } | ||||
|         } | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Completed acquiring hosts for clusters already owned by this management server"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Completed acquiring hosts for clusters already owned by this management server"); | ||||
|         } | ||||
| 
 | ||||
|         if (assignedHosts.size() < limit) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Acquiring hosts for clusters not owned by any management server"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Acquiring hosts for clusters not owned by any management server"); | ||||
|             } | ||||
|             // for remaining hosts not owned by any MS check if they can be owned (by owning full cluster) | ||||
|             clusters = findClustersForHostsNotOwnedByAnyManagementServer(); | ||||
| @ -581,12 +585,12 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|                         break; | ||||
|                     } | ||||
|                 } | ||||
|                 if (logger.isTraceEnabled()) { | ||||
|                     logger.trace("Following hosts got acquired from newly owned clusters: " + sb.toString()); | ||||
|                 if (s_logger.isTraceEnabled()) { | ||||
|                     s_logger.trace("Following hosts got acquired from newly owned clusters: " + sb.toString()); | ||||
|                 } | ||||
|             } | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Completed acquiring hosts for clusters not owned by any management server"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Completed acquiring hosts for clusters not owned by any management server"); | ||||
|             } | ||||
|         } | ||||
|         txn.commit(); | ||||
| @ -750,7 +754,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|                 } | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.warn("Exception: ", e); | ||||
|             s_logger.warn("Exception: ", e); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| @ -861,15 +865,15 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|                 l.add(info); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("SQLException caught", e); | ||||
|             s_logger.debug("SQLException caught", e); | ||||
|         } | ||||
|         return l; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public long getNextSequence(long hostId) { | ||||
|         if (logger.isTraceEnabled()) { | ||||
|             logger.trace("getNextSequence(), hostId: " + hostId); | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             s_logger.trace("getNextSequence(), hostId: " + hostId); | ||||
|         } | ||||
| 
 | ||||
|         TableGenerator tg = _tgs.get("host_req_sq"); | ||||
| @ -949,7 +953,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|             HostVO ho = findById(host.getId()); | ||||
|             assert ho != null : "How how how? : " + host.getId(); | ||||
| 
 | ||||
|             if (logger.isDebugEnabled()) { | ||||
|             if (status_logger.isDebugEnabled()) { | ||||
| 
 | ||||
|                 StringBuilder str = new StringBuilder("Unable to update host for event:").append(event.toString()); | ||||
|                 str.append(". Name=").append(host.getName()); | ||||
| @ -971,7 +975,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|                         .append(":old update count=") | ||||
|                         .append(oldUpdateCount) | ||||
|                         .append("]"); | ||||
|                 logger.debug(str.toString()); | ||||
|                 status_logger.debug(str.toString()); | ||||
|             } else { | ||||
|                 StringBuilder msg = new StringBuilder("Agent status update: ["); | ||||
|                 msg.append("id = " + host.getId()); | ||||
| @ -981,11 +985,11 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|                 msg.append("; new status = " + newStatus); | ||||
|                 msg.append("; old update count = " + oldUpdateCount); | ||||
|                 msg.append("; new update count = " + newUpdateCount + "]"); | ||||
|                 logger.debug(msg.toString()); | ||||
|                 status_logger.debug(msg.toString()); | ||||
|             } | ||||
| 
 | ||||
|             if (ho.getState() == newStatus) { | ||||
|                 logger.debug("Host " + ho.getName() + " state has already been updated to " + newStatus); | ||||
|                 status_logger.debug("Host " + ho.getName() + " state has already been updated to " + newStatus); | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
| @ -1011,7 +1015,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|         int result = update(ub, sc, null); | ||||
|         assert result <= 1 : "How can this update " + result + " rows? "; | ||||
| 
 | ||||
|         if (logger.isDebugEnabled() && result == 0) { | ||||
|         if (state_logger.isDebugEnabled() && result == 0) { | ||||
|             HostVO ho = findById(host.getId()); | ||||
|             assert ho != null : "How how how? : " + host.getId(); | ||||
| 
 | ||||
| @ -1021,7 +1025,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|             str.append("; old state = " + oldState); | ||||
|             str.append("; event = " + event); | ||||
|             str.append("; new state = " + newState + "]"); | ||||
|             logger.debug(str.toString()); | ||||
|             state_logger.debug(str.toString()); | ||||
|         } else { | ||||
|             StringBuilder msg = new StringBuilder("Resource state update: ["); | ||||
|             msg.append("id = " + host.getId()); | ||||
| @ -1029,7 +1033,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao | ||||
|             msg.append("; old state = " + oldState); | ||||
|             msg.append("; event = " + event); | ||||
|             msg.append("; new state = " + newState + "]"); | ||||
|             logger.debug(msg.toString()); | ||||
|             state_logger.debug(msg.toString()); | ||||
|         } | ||||
| 
 | ||||
|         return result > 0; | ||||
|  | ||||
| @ -20,6 +20,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.hypervisor.Hypervisor.HypervisorType; | ||||
| @ -32,6 +33,7 @@ import com.cloud.utils.db.SearchCriteria; | ||||
| @Local(value = HypervisorCapabilitiesDao.class) | ||||
| public class HypervisorCapabilitiesDaoImpl extends GenericDaoBase<HypervisorCapabilitiesVO, Long> implements HypervisorCapabilitiesDao { | ||||
| 
 | ||||
|     private static final Logger s_logger = Logger.getLogger(HypervisorCapabilitiesDaoImpl.class); | ||||
| 
 | ||||
|     protected final SearchBuilder<HypervisorCapabilitiesVO> HypervisorTypeSearch; | ||||
|     protected final SearchBuilder<HypervisorCapabilitiesVO> HypervisorTypeAndVersionSearch; | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.utils.db.DB; | ||||
| @ -32,6 +33,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = FirewallRulesCidrsDao.class) | ||||
| public class FirewallRulesCidrsDaoImpl extends GenericDaoBase<FirewallRulesCidrsVO, Long> implements FirewallRulesCidrsDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(FirewallRulesCidrsDaoImpl.class); | ||||
|     protected final SearchBuilder<FirewallRulesCidrsVO> CidrsSearch; | ||||
| 
 | ||||
|     protected FirewallRulesCidrsDaoImpl() { | ||||
|  | ||||
| @ -26,6 +26,7 @@ import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.cloudstack.resourcedetail.dao.UserIpAddressDetailsDao; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.dc.Vlan.VlanType; | ||||
| @ -49,6 +50,7 @@ import com.cloud.utils.net.Ip; | ||||
| @Local(value = {IPAddressDao.class}) | ||||
| @DB | ||||
| public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implements IPAddressDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(IPAddressDaoImpl.class); | ||||
| 
 | ||||
|     protected SearchBuilder<IPAddressVO> AllFieldsSearch; | ||||
|     protected SearchBuilder<IPAddressVO> VlanDbIdSearchUnallocated; | ||||
| @ -320,7 +322,7 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen | ||||
|                 ipCount = rs.getInt(1); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Exception counting IP addresses", e); | ||||
|             s_logger.warn("Exception counting IP addresses", e); | ||||
|         } | ||||
| 
 | ||||
|         return ipCount; | ||||
|  | ||||
| @ -23,6 +23,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.utils.db.DB; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Local(value = PortProfileDao.class) | ||||
| @DB() | ||||
| public class PortProfileDaoImpl extends GenericDaoBase<PortProfileVO, Long> implements PortProfileDao { | ||||
|     protected static final Logger s_logger = Logger.getLogger(PortProfileDaoImpl.class); | ||||
| 
 | ||||
|     final SearchBuilder<PortProfileVO> nameSearch; | ||||
|     final SearchBuilder<PortProfileVO> accessVlanSearch; | ||||
|  | ||||
| @ -20,6 +20,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.network.RemoteAccessVpn; | ||||
| @ -30,6 +31,7 @@ import com.cloud.utils.db.SearchCriteria; | ||||
| @Component | ||||
| @Local(value = {RemoteAccessVpnDao.class}) | ||||
| public class RemoteAccessVpnDaoImpl extends GenericDaoBase<RemoteAccessVpnVO, Long> implements RemoteAccessVpnDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(RemoteAccessVpnDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<RemoteAccessVpnVO> AllFieldsSearch; | ||||
| 
 | ||||
|  | ||||
| @ -22,6 +22,7 @@ import javax.annotation.PostConstruct; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.utils.db.GenericDaoBase; | ||||
| @ -32,6 +33,7 @@ import com.cloud.utils.db.SearchCriteria; | ||||
| @Component | ||||
| @Local(value = {Site2SiteVpnConnectionDao.class}) | ||||
| public class Site2SiteVpnConnectionDaoImpl extends GenericDaoBase<Site2SiteVpnConnectionVO, Long> implements Site2SiteVpnConnectionDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(Site2SiteVpnConnectionDaoImpl.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     protected IPAddressDao _addrDao; | ||||
|  | ||||
| @ -19,6 +19,7 @@ package com.cloud.network.dao; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.utils.db.GenericDaoBase; | ||||
| @ -31,6 +32,7 @@ public class Site2SiteVpnGatewayDaoImpl extends GenericDaoBase<Site2SiteVpnGatew | ||||
|     @Inject | ||||
|     protected IPAddressDao _addrDao; | ||||
| 
 | ||||
|     private static final Logger s_logger = Logger.getLogger(Site2SiteVpnGatewayDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<Site2SiteVpnGatewayVO> AllFieldsSearch; | ||||
| 
 | ||||
|  | ||||
| @ -20,6 +20,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.network.UserIpv6AddressVO; | ||||
| @ -33,6 +34,7 @@ import com.cloud.utils.db.SearchCriteria.Op; | ||||
| @Component | ||||
| @Local(value = UserIpv6AddressDao.class) | ||||
| public class UserIpv6AddressDaoImpl extends GenericDaoBase<UserIpv6AddressVO, Long> implements UserIpv6AddressDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(IPAddressDaoImpl.class); | ||||
| 
 | ||||
|     protected final SearchBuilder<UserIpv6AddressVO> AllFieldsSearch; | ||||
|     protected GenericSearchBuilder<UserIpv6AddressVO, Long> CountFreePublicIps; | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.Set; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.network.security.VmRulesetLogVO; | ||||
| @ -38,6 +39,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {VmRulesetLogDao.class}) | ||||
| public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> implements VmRulesetLogDao { | ||||
|     protected static final Logger s_logger = Logger.getLogger(VmRulesetLogDaoImpl.class); | ||||
|     private SearchBuilder<VmRulesetLogVO> VmIdSearch; | ||||
|     private String InsertOrUpdateSQl = "INSERT INTO op_vm_ruleset_log (instance_id, created, logsequence) " | ||||
|         + " VALUES(?, now(), 1) ON DUPLICATE KEY UPDATE logsequence=logsequence+1"; | ||||
| @ -98,19 +100,19 @@ public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> im | ||||
|             } catch (SQLTransactionRollbackException e1) { | ||||
|                 if (i < maxTries - 1) { | ||||
|                     int delayMs = (i + 1) * 1000; | ||||
|                     logger.debug("Caught a deadlock exception while inserting security group rule log, retrying in " + delayMs); | ||||
|                     s_logger.debug("Caught a deadlock exception while inserting security group rule log, retrying in " + delayMs); | ||||
|                     try { | ||||
|                         Thread.sleep(delayMs); | ||||
|                     } catch (InterruptedException ie) { | ||||
|                         logger.debug("[ignored] interupted while inserting security group rule logger."); | ||||
|                         s_logger.debug("[ignored] interupted while inserting security group rule log."); | ||||
|                     } | ||||
|                 } else | ||||
|                     logger.warn("Caught another deadlock exception while retrying inserting security group rule log, giving up"); | ||||
|                     s_logger.warn("Caught another deadlock exception while retrying inserting security group rule log, giving up"); | ||||
| 
 | ||||
|             } | ||||
|         } | ||||
|         if (logger.isTraceEnabled()) { | ||||
|             logger.trace("Inserted or updated " + numUpdated + " rows"); | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             s_logger.trace("Inserted or updated " + numUpdated + " rows"); | ||||
|         } | ||||
|         return numUpdated; | ||||
|     } | ||||
| @ -134,8 +136,8 @@ public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> im | ||||
|                             vmIds.add(vmId); | ||||
|                         } | ||||
|                         int numUpdated = executeWithRetryOnDeadlock(txn, pstmt, vmIds); | ||||
|                         if (logger.isTraceEnabled()) { | ||||
|                             logger.trace("Inserted or updated " + numUpdated + " rows"); | ||||
|                         if (s_logger.isTraceEnabled()) { | ||||
|                             s_logger.trace("Inserted or updated " + numUpdated + " rows"); | ||||
|                         } | ||||
|                         if (numUpdated > 0) | ||||
|                             count += stmtSize; | ||||
| @ -145,7 +147,7 @@ public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> im | ||||
| 
 | ||||
|             } | ||||
|         } catch (SQLException sqe) { | ||||
|             logger.warn("Failed to execute multi insert ", sqe); | ||||
|             s_logger.warn("Failed to execute multi insert ", sqe); | ||||
|         } | ||||
| 
 | ||||
|         return count; | ||||
| @ -173,10 +175,10 @@ public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> im | ||||
|             queryResult = stmtInsert.executeBatch(); | ||||
| 
 | ||||
|             txn.commit(); | ||||
|             if (logger.isTraceEnabled()) | ||||
|                 logger.trace("Updated or inserted " + workItems.size() + " log items"); | ||||
|             if (s_logger.isTraceEnabled()) | ||||
|                 s_logger.trace("Updated or inserted " + workItems.size() + " log items"); | ||||
|         } catch (SQLException e) { | ||||
|             logger.warn("Failed to execute batch update statement for ruleset log: ", e); | ||||
|             s_logger.warn("Failed to execute batch update statement for ruleset log: ", e); | ||||
|             txn.rollback(); | ||||
|             success = false; | ||||
|         } | ||||
| @ -185,7 +187,7 @@ public class VmRulesetLogDaoImpl extends GenericDaoBase<VmRulesetLogVO, Long> im | ||||
|             workItems.toArray(arrayItems); | ||||
|             for (int i = 0; i < queryResult.length; i++) { | ||||
|                 if (queryResult[i] < 0) { | ||||
|                     logger.debug("Batch query update failed for vm " + arrayItems[i]); | ||||
|                     s_logger.debug("Batch query update failed for vm " + arrayItems[i]); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -23,6 +23,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.network.vpc.NetworkACLItemCidrsDao; | ||||
| @ -39,6 +40,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = NetworkACLItemCidrsDao.class) | ||||
| public class NetworkACLItemCidrsDaoImpl extends GenericDaoBase<NetworkACLItemCidrsVO, Long> implements NetworkACLItemCidrsDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(NetworkACLItemCidrsDaoImpl.class); | ||||
|     protected final SearchBuilder<NetworkACLItemCidrsVO> cidrsSearch; | ||||
| 
 | ||||
|     protected NetworkACLItemCidrsDaoImpl() { | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.List; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.network.vpc.NetworkACLItem.State; | ||||
| @ -39,6 +40,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Local(value = NetworkACLItemDao.class) | ||||
| @DB() | ||||
| public class NetworkACLItemDaoImpl extends GenericDaoBase<NetworkACLItemVO, Long> implements NetworkACLItemDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(NetworkACLItemDaoImpl.class); | ||||
| 
 | ||||
|     protected final SearchBuilder<NetworkACLItemVO> AllFieldsSearch; | ||||
|     protected final SearchBuilder<NetworkACLItemVO> NotRevokedSearch; | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.network.vpc.PrivateIpVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Local(value = PrivateIpDao.class) | ||||
| @DB() | ||||
| public class PrivateIpDaoImpl extends GenericDaoBase<PrivateIpVO, Long> implements PrivateIpDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(PrivateIpDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<PrivateIpVO> AllFieldsSearch; | ||||
|     private final GenericSearchBuilder<PrivateIpVO, Integer> CountAllocatedByNetworkId; | ||||
| @ -90,8 +92,8 @@ public class PrivateIpDaoImpl extends GenericDaoBase<PrivateIpVO, Long> implemen | ||||
| 
 | ||||
|     @Override | ||||
|     public void releaseIpAddress(String ipAddress, long networkId) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Releasing private ip address: " + ipAddress + " network id " + networkId); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Releasing private ip address: " + ipAddress + " network id " + networkId); | ||||
|         } | ||||
|         SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create(); | ||||
|         sc.setParameters("ip", ipAddress); | ||||
|  | ||||
| @ -20,6 +20,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.projects.ProjectAccount; | ||||
| @ -38,6 +39,7 @@ public class ProjectAccountDaoImpl extends GenericDaoBase<ProjectAccountVO, Long | ||||
|     final GenericSearchBuilder<ProjectAccountVO, Long> AdminSearch; | ||||
|     final GenericSearchBuilder<ProjectAccountVO, Long> ProjectAccountSearch; | ||||
|     final GenericSearchBuilder<ProjectAccountVO, Long> CountByRoleSearch; | ||||
|     public static final Logger s_logger = Logger.getLogger(ProjectAccountDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected ProjectAccountDaoImpl() { | ||||
|         AllFieldsSearch = createSearchBuilder(); | ||||
| @ -148,7 +150,7 @@ public class ProjectAccountDaoImpl extends GenericDaoBase<ProjectAccountVO, Long | ||||
| 
 | ||||
|         int rowsRemoved = remove(sc); | ||||
|         if (rowsRemoved > 0) { | ||||
|             logger.debug("Removed account id=" + accountId + " from " + rowsRemoved + " projects"); | ||||
|             s_logger.debug("Removed account id=" + accountId + " from " + rowsRemoved + " projects"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.List; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.projects.Project; | ||||
| @ -38,6 +39,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {ProjectDao.class}) | ||||
| public class ProjectDaoImpl extends GenericDaoBase<ProjectVO, Long> implements ProjectDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(ProjectDaoImpl.class); | ||||
|     protected final SearchBuilder<ProjectVO> AllFieldsSearch; | ||||
|     protected GenericSearchBuilder<ProjectVO, Long> CountByDomain; | ||||
|     protected GenericSearchBuilder<ProjectVO, Long> ProjectAccountSearch; | ||||
| @ -77,7 +79,7 @@ public class ProjectDaoImpl extends GenericDaoBase<ProjectVO, Long> implements P | ||||
|         ProjectVO projectToRemove = findById(projectId); | ||||
|         projectToRemove.setName(null); | ||||
|         if (!update(projectId, projectToRemove)) { | ||||
|             logger.warn("Failed to reset name for the project id=" + projectId + " as a part of project remove"); | ||||
|             s_logger.warn("Failed to reset name for the project id=" + projectId + " as a part of project remove"); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.projects.ProjectInvitation.State; | ||||
| @ -33,6 +34,7 @@ import com.cloud.utils.db.SearchCriteria; | ||||
| @Component | ||||
| @Local(value = {ProjectInvitationDao.class}) | ||||
| public class ProjectInvitationDaoImpl extends GenericDaoBase<ProjectInvitationVO, Long> implements ProjectInvitationDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(ProjectInvitationDaoImpl.class); | ||||
|     protected final SearchBuilder<ProjectInvitationVO> AllFieldsSearch; | ||||
|     protected final SearchBuilder<ProjectInvitationVO> InactiveSearch; | ||||
| 
 | ||||
| @ -89,7 +91,7 @@ public class ProjectInvitationDaoImpl extends GenericDaoBase<ProjectInvitationVO | ||||
|         for (ProjectInvitationVO invitationToExpire : invitationsToExpire) { | ||||
|             invitationToExpire.setState(State.Expired); | ||||
|             if (!update(invitationToExpire.getId(), invitationToExpire)) { | ||||
|                 logger.warn("Fail to expire invitation " + invitationToExpire.toString()); | ||||
|                 s_logger.warn("Fail to expire invitation " + invitationToExpire.toString()); | ||||
|                 success = false; | ||||
|             } | ||||
|         } | ||||
| @ -111,7 +113,7 @@ public class ProjectInvitationDaoImpl extends GenericDaoBase<ProjectInvitationVO | ||||
|         sc.setParameters("id", id); | ||||
| 
 | ||||
|         if (findOneBy(sc) == null) { | ||||
|             logger.warn("Unable to find project invitation by id " + id); | ||||
|             s_logger.warn("Unable to find project invitation by id " + id); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
| @ -163,7 +165,7 @@ public class ProjectInvitationDaoImpl extends GenericDaoBase<ProjectInvitationVO | ||||
|         sc.setParameters("projectId", projectId); | ||||
| 
 | ||||
|         int numberRemoved = remove(sc); | ||||
|         logger.debug("Removed " + numberRemoved + " invitations for project id=" + projectId); | ||||
|         s_logger.debug("Removed " + numberRemoved + " invitations for project id=" + projectId); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.storage.LaunchPermissionVO; | ||||
| @ -40,6 +41,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {LaunchPermissionDao.class}) | ||||
| public class LaunchPermissionDaoImpl extends GenericDaoBase<LaunchPermissionVO, Long> implements LaunchPermissionDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(LaunchPermissionDaoImpl.class); | ||||
|     private static final String REMOVE_LAUNCH_PERMISSION = "DELETE FROM `cloud`.`launch_permission`" + "  WHERE template_id = ? AND account_id = ?"; | ||||
| 
 | ||||
|     private static final String LIST_PERMITTED_TEMPLATES = | ||||
| @ -80,7 +82,7 @@ public class LaunchPermissionDaoImpl extends GenericDaoBase<LaunchPermissionVO, | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error removing launch permissions", e); | ||||
|             s_logger.warn("Error removing launch permissions", e); | ||||
|             throw new CloudRuntimeException("Error removing launch permissions", e); | ||||
|         } | ||||
|     } | ||||
| @ -145,7 +147,7 @@ public class LaunchPermissionDaoImpl extends GenericDaoBase<LaunchPermissionVO, | ||||
|                 permittedTemplates.add(template); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Error listing permitted templates", e); | ||||
|             s_logger.warn("Error listing permitted templates", e); | ||||
|         } | ||||
|         return permittedTemplates; | ||||
|     } | ||||
|  | ||||
| @ -24,6 +24,7 @@ import javax.annotation.PostConstruct; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.server.ResourceTag.ResourceObjectType; | ||||
| @ -52,6 +53,7 @@ import com.cloud.vm.dao.VMInstanceDao; | ||||
| @Component | ||||
| @Local(value = {SnapshotDao.class}) | ||||
| public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements SnapshotDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(SnapshotDaoImpl.class.getName()); | ||||
|     // TODO: we should remove these direct sqls | ||||
|     private static final String GET_LAST_SNAPSHOT = | ||||
|         "SELECT snapshots.id FROM snapshot_store_ref, snapshots where snapshots.id = snapshot_store_ref.snapshot_id AND snapshosts.volume_id = ? AND snapshot_store_ref.role = ? ORDER BY created DESC"; | ||||
| @ -206,7 +208,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements | ||||
|                 return rs.getLong(1); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.info("[ignored]" | ||||
|             s_logger.info("[ignored]" | ||||
|                     + "caught something while getting sec. host id: " + ex.getLocalizedMessage()); | ||||
|         } | ||||
|         return null; | ||||
| @ -226,7 +228,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements | ||||
|                 return rs.getLong(1); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting last snapshot", ex); | ||||
|             s_logger.error("error getting last snapshot", ex); | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
| @ -244,7 +246,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements | ||||
|             pstmt.executeUpdate(); | ||||
|             return 1; | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting last snapshot", ex); | ||||
|             s_logger.error("error getting last snapshot", ex); | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
| @ -261,7 +263,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements | ||||
|             pstmt.executeUpdate(); | ||||
|             return 1; | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error set secondary storage host id", ex); | ||||
|             s_logger.error("error set secondary storage host id", ex); | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.host.Status; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {StoragePoolHostDao.class}) | ||||
| public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Long> implements StoragePoolHostDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(StoragePoolHostDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected final SearchBuilder<StoragePoolHostVO> PoolSearch; | ||||
|     protected final SearchBuilder<StoragePoolHostVO> HostSearch; | ||||
| @ -113,10 +115,10 @@ public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Lo | ||||
|                     result.add(findById(id)); | ||||
|                 } | ||||
|             }catch (SQLException e) { | ||||
|                 logger.warn("listByHostStatus:Exception: ", e); | ||||
|                 s_logger.warn("listByHostStatus:Exception: ", e); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("listByHostStatus:Exception: ", e); | ||||
|             s_logger.warn("listByHostStatus:Exception: ", e); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| @ -136,7 +138,7 @@ public class StoragePoolHostDaoImpl extends GenericDaoBase<StoragePoolHostVO, Lo | ||||
|                 l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2))); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("SQLException: ", e); | ||||
|             s_logger.debug("SQLException: ", e); | ||||
|         } | ||||
|         return l; | ||||
|     } | ||||
|  | ||||
| @ -20,6 +20,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.storage.Upload.Mode; | ||||
| @ -32,6 +33,7 @@ import com.cloud.utils.db.SearchCriteria; | ||||
| @Component | ||||
| @Local(value = {UploadDao.class}) | ||||
| public class UploadDaoImpl extends GenericDaoBase<UploadVO, Long> implements UploadDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UploadDaoImpl.class.getName()); | ||||
|     protected final SearchBuilder<UploadVO> typeUploadStatusSearch; | ||||
|     protected final SearchBuilder<UploadVO> typeHostAndUploadStatusSearch; | ||||
|     protected final SearchBuilder<UploadVO> typeModeAndStatusSearch; | ||||
|  | ||||
| @ -30,6 +30,7 @@ import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; | ||||
| import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.dc.dao.DataCenterDao; | ||||
| @ -64,6 +65,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {VMTemplateDao.class}) | ||||
| public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implements VMTemplateDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(VMTemplateDaoImpl.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     VMTemplateZoneDao _templateZoneDao; | ||||
| @ -232,7 +234,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem | ||||
|                 l.add(rs.getLong(1)); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Exception: ", e); | ||||
|             s_logger.debug("Exception: ", e); | ||||
|         } | ||||
|         return l; | ||||
|     } | ||||
| @ -286,7 +288,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem | ||||
| 
 | ||||
|         routerTmpltName = (String)params.get("routing.uniquename"); | ||||
| 
 | ||||
|         logger.debug("Found parameter routing unique name " + routerTmpltName); | ||||
|         s_logger.debug("Found parameter routing unique name " + routerTmpltName); | ||||
|         if (routerTmpltName == null) { | ||||
|             routerTmpltName = "routing"; | ||||
|         } | ||||
| @ -295,8 +297,8 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem | ||||
|         if (consoleProxyTmpltName == null) { | ||||
|             consoleProxyTmpltName = "routing"; | ||||
|         } | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Use console proxy template : " + consoleProxyTmpltName); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Use console proxy template : " + consoleProxyTmpltName); | ||||
|         } | ||||
| 
 | ||||
|         UniqueNameSearch = createSearchBuilder(); | ||||
| @ -510,10 +512,10 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem | ||||
|      * (rs.next()) { Pair<Long, Long> templateZonePair = new Pair<Long, | ||||
|      * Long>(rs.getLong(1), -1L); templateZonePairList.add(templateZonePair); } | ||||
|      * | ||||
|      * } catch (Exception e) { logger.warn("Error listing templates", e); } | ||||
|      * } catch (Exception e) { s_logger.warn("Error listing templates", e); } | ||||
|      * finally { try { if (rs != null) { rs.close(); } if (pstmt != null) { | ||||
|      * pstmt.close(); } txn.commit(); } catch (SQLException sqle) { | ||||
|      * logger.warn("Error in cleaning up", sqle); } } | ||||
|      * s_logger.warn("Error in cleaning up", sqle); } } | ||||
|      * | ||||
|      * return templateZonePairList; } | ||||
|      * | ||||
| @ -694,9 +696,9 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem | ||||
|      * null)); continue; } else if (keyword == null && name == null){ | ||||
|      * templateZonePairList.add(new Pair<Long,Long>(publicIsos.get(i).getId(), | ||||
|      * null)); } } } } } catch (Exception e) { | ||||
|      * logger.warn("Error listing templates", e); } finally { try { if (rs != | ||||
|      * s_logger.warn("Error listing templates", e); } finally { try { if (rs != | ||||
|      * null) { rs.close(); } if (pstmt != null) { pstmt.close(); } txn.commit(); | ||||
|      * } catch( SQLException sqle) { logger.warn("Error in cleaning up", | ||||
|      * } catch( SQLException sqle) { s_logger.warn("Error in cleaning up", | ||||
|      * sqle); } } | ||||
|      * | ||||
|      * return templateZonePairList; } | ||||
| @ -1019,7 +1021,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem | ||||
|      * while (rs.next()) { final Pair<Long, Long> templateZonePair = new | ||||
|      * Pair<Long, Long>( rs.getLong(1), -1L); | ||||
|      * templateZonePairList.add(templateZonePair); } txn.commit(); } catch | ||||
|      * (Exception e) { logger.warn("Error listing S3 templates", e); if (txn | ||||
|      * (Exception e) { s_logger.warn("Error listing S3 templates", e); if (txn | ||||
|      * != null) { txn.rollback(); } } finally { closeResources(pstmt, rs); if | ||||
|      * (txn != null) { txn.close(); } } | ||||
|      * | ||||
| @ -1048,7 +1050,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem | ||||
|         builder.set(vo, "updated", new Date()); | ||||
| 
 | ||||
|         int rows = update((VMTemplateVO)vo, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             VMTemplateVO dbTemplate = findByIdIncludingRemoved(vo.getId()); | ||||
|             if (dbTemplate != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -1081,7 +1083,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update template: id=" + vo.getId() + ", as no such template exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update template: id=" + vo.getId() + ", as no such template exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
| @ -29,6 +29,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.engine.subsystem.api.storage.DataObjectInStore; | ||||
| @ -52,6 +53,7 @@ import com.cloud.utils.db.UpdateBuilder; | ||||
| @Component | ||||
| @Local(value = {VMTemplateHostDao.class}) | ||||
| public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long> implements VMTemplateHostDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(VMTemplateHostDaoImpl.class.getName()); | ||||
|     @Inject | ||||
|     HostDao _hostDao; | ||||
|     protected final SearchBuilder<VMTemplateHostVO> HostSearch; | ||||
| @ -170,7 +172,7 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long | ||||
|             pstmt.setLong(8, instance.getTemplateId()); | ||||
|             pstmt.executeUpdate(); | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Exception: ", e); | ||||
|             s_logger.warn("Exception: ", e); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -239,7 +241,7 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long | ||||
|                 result.add(toEntityBean(rs, false)); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Exception: ", e); | ||||
|             s_logger.warn("Exception: ", e); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| @ -271,10 +273,10 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long | ||||
|                     result.add(findById(id)); | ||||
|                 } | ||||
|             }catch (SQLException e) { | ||||
|                 logger.warn("listByTemplateStatus:Exception: "+e.getMessage(), e); | ||||
|                 s_logger.warn("listByTemplateStatus:Exception: "+e.getMessage(), e); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("listByTemplateStatus:Exception: "+e.getMessage(), e); | ||||
|             s_logger.warn("listByTemplateStatus:Exception: "+e.getMessage(), e); | ||||
|         } | ||||
|         return result; | ||||
| 
 | ||||
| @ -389,7 +391,7 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long | ||||
|         builder.set(vo, "updated", new Date()); | ||||
| 
 | ||||
|         int rows = update((VMTemplateHostVO)vo, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             VMTemplateHostVO dbVol = findByIdIncludingRemoved(templateHost.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -422,7 +424,7 @@ public class VMTemplateHostDaoImpl extends GenericDaoBase<VMTemplateHostVO, Long | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update objectIndatastore: id=" + templateHost.getId() + ", as there is no such object exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update objectIndatastore: id=" + templateHost.getId() + ", as there is no such object exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; | ||||
| @ -43,6 +44,7 @@ import com.cloud.utils.db.UpdateBuilder; | ||||
| @Component | ||||
| @Local(value = {VMTemplatePoolDao.class}) | ||||
| public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolVO, Long> implements VMTemplatePoolDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(VMTemplatePoolDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected final SearchBuilder<VMTemplateStoragePoolVO> PoolSearch; | ||||
|     protected final SearchBuilder<VMTemplateStoragePoolVO> TemplateSearch; | ||||
| @ -158,7 +160,7 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolV | ||||
|                 result.add(toEntityBean(rs, false)); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Exception: ", e); | ||||
|             s_logger.warn("Exception: ", e); | ||||
|         } | ||||
|         return result; | ||||
| 
 | ||||
| @ -182,10 +184,10 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolV | ||||
|                     result.add(findById(id)); | ||||
|                 } | ||||
|             }catch (Exception e) { | ||||
|                 logger.warn("Exception: ", e); | ||||
|                 s_logger.warn("Exception: ", e); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Exception: ", e); | ||||
|             s_logger.warn("Exception: ", e); | ||||
|         } | ||||
|         return result; | ||||
| 
 | ||||
| @ -206,10 +208,10 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolV | ||||
|                     result.add(findById(id)); | ||||
|                 } | ||||
|             }catch (Exception e) { | ||||
|                 logger.warn("Exception: ", e); | ||||
|                 s_logger.warn("Exception: ", e); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Exception: ", e); | ||||
|             s_logger.warn("Exception: ", e); | ||||
|         } | ||||
|         return result; | ||||
| 
 | ||||
| @ -257,7 +259,7 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolV | ||||
|         builder.set(vo, "updated", new Date()); | ||||
| 
 | ||||
|         int rows = update((VMTemplateStoragePoolVO)vo, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             VMTemplateStoragePoolVO dbVol = findByIdIncludingRemoved(templatePool.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -290,7 +292,7 @@ public class VMTemplatePoolDaoImpl extends GenericDaoBase<VMTemplateStoragePoolV | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update objectIndatastore: id=" + templatePool.getId() + ", as there is no such object exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update objectIndatastore: id=" + templatePool.getId() + ", as there is no such object exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
| @ -20,6 +20,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.storage.VMTemplateZoneVO; | ||||
| @ -31,6 +32,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {VMTemplateZoneDao.class}) | ||||
| public class VMTemplateZoneDaoImpl extends GenericDaoBase<VMTemplateZoneVO, Long> implements VMTemplateZoneDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(VMTemplateZoneDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected final SearchBuilder<VMTemplateZoneVO> ZoneSearch; | ||||
|     protected final SearchBuilder<VMTemplateZoneVO> TemplateSearch; | ||||
|  | ||||
| @ -26,6 +26,7 @@ import java.util.List; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.exception.InvalidParameterValueException; | ||||
| @ -54,6 +55,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = VolumeDao.class) | ||||
| public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements VolumeDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(VolumeDaoImpl.class); | ||||
|     protected final SearchBuilder<VolumeVO> DetachedAccountIdSearch; | ||||
|     protected final SearchBuilder<VolumeVO> TemplateZoneSearch; | ||||
|     protected final GenericSearchBuilder<VolumeVO, SumCount> TotalSizeByPoolSearch; | ||||
| @ -266,7 +268,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol | ||||
|                 else if (scope == ScopeType.ZONE) | ||||
|                     sql = SELECT_HYPERTYPE_FROM_ZONE_VOLUME; | ||||
|                 else | ||||
|                     logger.error("Unhandled scope type '" + scope + "' when running getHypervisorType on volume id " + volumeId); | ||||
|                     s_logger.error("Unhandled scope type '" + scope + "' when running getHypervisorType on volume id " + volumeId); | ||||
| 
 | ||||
|                 pstmt = txn.prepareAutoCloseStatement(sql); | ||||
|                 pstmt.setLong(1, volumeId); | ||||
| @ -295,7 +297,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol | ||||
|         } else if (type.equals(HypervisorType.VMware)) { | ||||
|             return ImageFormat.OVA; | ||||
|         } else { | ||||
|             logger.warn("Do not support hypervisor " + type.toString()); | ||||
|             s_logger.warn("Do not support hypervisor " + type.toString()); | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| @ -481,7 +483,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol | ||||
|         builder.set(vo, "updated", new Date()); | ||||
| 
 | ||||
|         int rows = update((VolumeVO)vo, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             VolumeVO dbVol = findByIdIncludingRemoved(vo.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -514,7 +516,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update volume: id=" + vo.getId() + ", as there is no such volume exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update volume: id=" + vo.getId() + ", as there is no such volume exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.UpdateBuilder; | ||||
| @Component | ||||
| @Local(value = {VolumeHostDao.class}) | ||||
| public class VolumeHostDaoImpl extends GenericDaoBase<VolumeHostVO, Long> implements VolumeHostDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(VolumeHostDaoImpl.class); | ||||
|     protected final SearchBuilder<VolumeHostVO> HostVolumeSearch; | ||||
|     protected final SearchBuilder<VolumeHostVO> ZoneVolumeSearch; | ||||
|     protected final SearchBuilder<VolumeHostVO> VolumeSearch; | ||||
| @ -139,7 +141,7 @@ public class VolumeHostDaoImpl extends GenericDaoBase<VolumeHostVO, Long> implem | ||||
|         builder.set(vo, "updated", new Date()); | ||||
| 
 | ||||
|         int rows = update((VolumeHostVO)vo, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             VolumeHostVO dbVol = findByIdIncludingRemoved(volHost.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -172,7 +174,7 @@ public class VolumeHostDaoImpl extends GenericDaoBase<VolumeHostVO, Long> implem | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update objectIndatastore: id=" + volHost.getId() + ", as there is no such object exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update objectIndatastore: id=" + volHost.getId() + ", as there is no such object exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.sql.SQLException; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.maint.Version; | ||||
| @ -38,6 +39,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {SystemIntegrityChecker.class}) | ||||
| public class DatabaseIntegrityChecker extends AdapterBase implements SystemIntegrityChecker { | ||||
|     private static final Logger s_logger = Logger.getLogger(DatabaseIntegrityChecker.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     VersionDao _dao; | ||||
| @ -101,32 +103,32 @@ public class DatabaseIntegrityChecker extends AdapterBase implements SystemInteg | ||||
|                                 } | ||||
|                                 catch (Exception e) | ||||
|                                 { | ||||
|                                     logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage()); | ||||
|                                     s_logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage()); | ||||
|                                     throw new CloudRuntimeException("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage(),e); | ||||
|                                 } | ||||
|                         } | ||||
|                         catch (Exception e) | ||||
|                         { | ||||
|                                 logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage()); | ||||
|                                 s_logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage()); | ||||
|                                 throw new CloudRuntimeException("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage(),e); | ||||
|                         } | ||||
|                     } | ||||
|                     if (noDuplicate) { | ||||
|                         logger.debug("No duplicate hosts with the same local storage found in database"); | ||||
|                         s_logger.debug("No duplicate hosts with the same local storage found in database"); | ||||
|                     } else { | ||||
|                         logger.error(helpInfo.toString()); | ||||
|                         s_logger.error(helpInfo.toString()); | ||||
|                     } | ||||
|                     txn.commit(); | ||||
|                     return noDuplicate; | ||||
|             }catch (Exception e) | ||||
|             { | ||||
|                   logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage()); | ||||
|                   s_logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage()); | ||||
|                   throw new CloudRuntimeException("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage(),e); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception e) | ||||
|         { | ||||
|             logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage()); | ||||
|             s_logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage()); | ||||
|             throw new CloudRuntimeException("checkDuplicateHostWithTheSameLocalStorage: Exception :" + e.getMessage(),e); | ||||
|         } | ||||
|         finally | ||||
| @ -137,7 +139,7 @@ public class DatabaseIntegrityChecker extends AdapterBase implements SystemInteg | ||||
|                 } | ||||
|             }catch(Exception e) | ||||
|             { | ||||
|                 logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception:"+ e.getMessage()); | ||||
|                 s_logger.error("checkDuplicateHostWithTheSameLocalStorage: Exception:"+ e.getMessage()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -150,7 +152,7 @@ public class DatabaseIntegrityChecker extends AdapterBase implements SystemInteg | ||||
|                 String tableName = rs.getString(1); | ||||
|                 if (tableName.equalsIgnoreCase("usage_event") || tableName.equalsIgnoreCase("usage_port_forwarding") || tableName.equalsIgnoreCase("usage_network_offering")) { | ||||
|                     num++; | ||||
|                     logger.debug("Checking 21to22PremiumUprage table " + tableName + " found"); | ||||
|                     s_logger.debug("Checking 21to22PremiumUprage table " + tableName + " found"); | ||||
|                 } | ||||
|                 if (num == 3) { | ||||
|                     return true; | ||||
| @ -166,7 +168,7 @@ public class DatabaseIntegrityChecker extends AdapterBase implements SystemInteg | ||||
|             boolean found = false; | ||||
|             while (rs.next()) { | ||||
|                 if (column.equalsIgnoreCase(rs.getString(1))) { | ||||
|                     logger.debug(String.format("Column %1$s.%2$s.%3$s found", dbName, tableName, column)); | ||||
|                     s_logger.debug(String.format("Column %1$s.%2$s.%3$s found", dbName, tableName, column)); | ||||
|                     found = true; | ||||
|                     break; | ||||
|                 } | ||||
| @ -223,33 +225,33 @@ public class DatabaseIntegrityChecker extends AdapterBase implements SystemInteg | ||||
|                     } | ||||
|                 } | ||||
|                 if (!hasUsage) { | ||||
|                     logger.debug("No cloud_usage found in database, no need to check missed premium upgrade"); | ||||
|                     s_logger.debug("No cloud_usage found in database, no need to check missed premium upgrade"); | ||||
|                     txn.commit(); | ||||
|                     return true; | ||||
|                 } | ||||
|                 if (!check21to22PremiumUprage(conn)) { | ||||
|                     logger.error("21to22 premium upgrade missed"); | ||||
|                     s_logger.error("21to22 premium upgrade missed"); | ||||
|                     txn.commit(); | ||||
|                     return false; | ||||
|                 } | ||||
|                 if (!check221to222PremiumUprage(conn)) { | ||||
|                     logger.error("221to222 premium upgrade missed"); | ||||
|                     s_logger.error("221to222 premium upgrade missed"); | ||||
|                     txn.commit(); | ||||
|                     return false; | ||||
|                 } | ||||
|                 if (!check222to224PremiumUpgrade(conn)) { | ||||
|                     logger.error("222to224 premium upgrade missed"); | ||||
|                     s_logger.error("222to224 premium upgrade missed"); | ||||
|                     txn.commit(); | ||||
|                     return false; | ||||
|                 } | ||||
|                 txn.commit(); | ||||
|                 return true; | ||||
|             } catch (Exception e) { | ||||
|                 logger.error("checkMissedPremiumUpgradeFor228: Exception:" + e.getMessage()); | ||||
|                 s_logger.error("checkMissedPremiumUpgradeFor228: Exception:" + e.getMessage()); | ||||
|                 throw new CloudRuntimeException("checkMissedPremiumUpgradeFor228: Exception:" + e.getMessage(), e); | ||||
|             } | ||||
|         }catch (Exception e) { | ||||
|             logger.error("checkMissedPremiumUpgradeFor228: Exception:"+ e.getMessage()); | ||||
|             s_logger.error("checkMissedPremiumUpgradeFor228: Exception:"+ e.getMessage()); | ||||
|             throw new CloudRuntimeException("checkMissedPremiumUpgradeFor228: Exception:" + e.getMessage(),e); | ||||
|         } | ||||
|         finally | ||||
| @ -260,7 +262,7 @@ public class DatabaseIntegrityChecker extends AdapterBase implements SystemInteg | ||||
|                 } | ||||
|             }catch(Exception e) | ||||
|             { | ||||
|                 logger.error("checkMissedPremiumUpgradeFor228: Exception:"+ e.getMessage()); | ||||
|                 s_logger.error("checkMissedPremiumUpgradeFor228: Exception:"+ e.getMessage()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -269,19 +271,19 @@ public class DatabaseIntegrityChecker extends AdapterBase implements SystemInteg | ||||
|     public void check() { | ||||
|         GlobalLock lock = GlobalLock.getInternLock("DatabaseIntegrity"); | ||||
|         try { | ||||
|             logger.info("Grabbing lock to check for database integrity."); | ||||
|             s_logger.info("Grabbing lock to check for database integrity."); | ||||
|             if (!lock.lock(20 * 60)) { | ||||
|                 throw new CloudRuntimeException("Unable to acquire lock to check for database integrity."); | ||||
|             } | ||||
| 
 | ||||
|             try { | ||||
|                 logger.info("Performing database integrity check"); | ||||
|                 s_logger.info("Performing database integrity check"); | ||||
|                 if (!checkDuplicateHostWithTheSameLocalStorage()) { | ||||
|                     throw new CloudRuntimeException("checkDuplicateHostWithTheSameLocalStorage detected error"); | ||||
|                 } | ||||
| 
 | ||||
|                 if (!checkMissedPremiumUpgradeFor228()) { | ||||
|                     logger.error("Your current database version is 2.2.8, management server detected some missed premium upgrade, please contact CloudStack support and attach log file. Thank you!"); | ||||
|                     s_logger.error("Your current database version is 2.2.8, management server detected some missed premium upgrade, please contact CloudStack support and attach log file. Thank you!"); | ||||
|                     throw new CloudRuntimeException("Detected missed premium upgrade"); | ||||
|                 } | ||||
|             } finally { | ||||
| @ -297,7 +299,7 @@ public class DatabaseIntegrityChecker extends AdapterBase implements SystemInteg | ||||
|         try { | ||||
|             check(); | ||||
|         } catch (Exception e) { | ||||
|             logger.error("System integrity check exception", e); | ||||
|             s_logger.error("System integrity check exception", e); | ||||
|             System.exit(1); | ||||
|         } | ||||
|         return true; | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.upgrade.dao.VersionVO.Step; | ||||
| @ -41,6 +42,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Local(value = VersionDao.class) | ||||
| @DB() | ||||
| public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements VersionDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(VersionDaoImpl.class); | ||||
| 
 | ||||
|     final GenericSearchBuilder<VersionVO, String> CurrentVersionSearch; | ||||
|     final SearchBuilder<VersionVO> AllFieldsSearch; | ||||
| @ -74,7 +76,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V | ||||
|     @DB | ||||
|     public String getCurrentVersion() { | ||||
|         try (Connection conn = TransactionLegacy.getStandaloneConnection();) { | ||||
|             logger.debug("Checking to see if the database is at a version before it was the version table is created"); | ||||
|             s_logger.debug("Checking to see if the database is at a version before it was the version table is created"); | ||||
| 
 | ||||
|             try ( | ||||
|                     PreparedStatement pstmt = conn.prepareStatement("SHOW TABLES LIKE 'version'"); | ||||
| @ -89,8 +91,8 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V | ||||
|                                 pstmt_domain.executeQuery(); | ||||
|                                 return "2.1.8"; | ||||
|                             } catch (final SQLException e) { | ||||
|                                 logger.debug("Assuming the exception means domain_id is not there."); | ||||
|                                 logger.debug("No version table and no nics table, returning 2.1.7"); | ||||
|                                 s_logger.debug("Assuming the exception means domain_id is not there."); | ||||
|                                 s_logger.debug("No version table and no nics table, returning 2.1.7"); | ||||
|                                 return "2.1.7"; | ||||
|                             } | ||||
|                         } else { | ||||
| @ -98,7 +100,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V | ||||
|                                  ResultSet rs_static_nat = pstmt_static_nat.executeQuery();){ | ||||
|                                 return "2.2.1"; | ||||
|                             } catch (final SQLException e) { | ||||
|                                 logger.debug("Assuming the exception means static_nat field doesn't exist in firewall_rules table, returning version 2.2.2"); | ||||
|                                 s_logger.debug("Assuming the exception means static_nat field doesn't exist in firewall_rules table, returning version 2.2.2"); | ||||
|                                 return "2.2.2"; | ||||
|                             } | ||||
|                         } | ||||
| @ -125,7 +127,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V | ||||
|                 } | ||||
| 
 | ||||
|                 // Use nics table information and is_static_nat field from firewall_rules table to determine version information | ||||
|                 logger.debug("Version table exists, but it's empty; have to confirm that version is 2.2.2"); | ||||
|                 s_logger.debug("Version table exists, but it's empty; have to confirm that version is 2.2.2"); | ||||
|                 try (PreparedStatement pstmt = conn.prepareStatement("SHOW TABLES LIKE 'nics'"); | ||||
|                      ResultSet rs = pstmt.executeQuery();){ | ||||
|                     if (!rs.next()) { | ||||
| @ -136,7 +138,7 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V | ||||
|                             throw new CloudRuntimeException("Unable to determine the current version, version table exists and empty, " + | ||||
|                                     "nics table doesn't exist, is_static_nat field exists in firewall_rules table"); | ||||
|                         } catch (final SQLException e) { | ||||
|                             logger.debug("Assuming the exception means static_nat field doesn't exist in firewall_rules table, returning version 2.2.2"); | ||||
|                             s_logger.debug("Assuming the exception means static_nat field doesn't exist in firewall_rules table, returning version 2.2.2"); | ||||
|                             return "2.2.2"; | ||||
|                         } | ||||
|                     } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import com.cloud.utils.db.GenericDaoBase; | ||||
| import com.cloud.utils.db.SearchCriteria; | ||||
| import com.cloud.utils.db.TransactionLegacy; | ||||
| import com.cloud.utils.exception.CloudRuntimeException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| @ -41,6 +42,7 @@ import java.util.TimeZone; | ||||
| @Component | ||||
| @Local(value = {UsageDao.class}) | ||||
| public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements UsageDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageDaoImpl.class.getName()); | ||||
|     private static final String DELETE_ALL = "DELETE FROM cloud_usage"; | ||||
|     private static final String DELETE_ALL_BY_ACCOUNTID = "DELETE FROM cloud_usage WHERE account_id = ?"; | ||||
|     private static final String DELETE_ALL_BY_INTERVAL = "DELETE FROM cloud_usage WHERE end_date < DATE_SUB(CURRENT_DATE(), INTERVAL ? DAY)"; | ||||
| @ -90,7 +92,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error retrieving usage vm instances for account id: " + accountId); | ||||
|             s_logger.error("error retrieving usage vm instances for account id: " + accountId); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -130,7 +132,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving account to cloud_usage db", ex); | ||||
|             s_logger.error("error saving account to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
|     } | ||||
| @ -160,7 +162,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving account to cloud_usage db", ex); | ||||
|             s_logger.error("error saving account to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
|     } | ||||
| @ -201,7 +203,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving user stats to cloud_usage db", ex); | ||||
|             s_logger.error("error saving user stats to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
|     } | ||||
| @ -228,7 +230,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving user stats to cloud_usage db", ex); | ||||
|             s_logger.error("error saving user stats to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
|     } | ||||
| @ -245,7 +247,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|                 return Long.valueOf(rs.getLong(1)); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting last account id", ex); | ||||
|             s_logger.error("error getting last account id", ex); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| @ -262,7 +264,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|                 return Long.valueOf(rs.getLong(1)); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting last user stats id", ex); | ||||
|             s_logger.error("error getting last user stats id", ex); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| @ -281,7 +283,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|                 templateList.add(Long.valueOf(rs.getLong(1))); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error listing public templates", ex); | ||||
|             s_logger.error("error listing public templates", ex); | ||||
|         } | ||||
|         return templateList; | ||||
|     } | ||||
| @ -298,7 +300,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|                 return Long.valueOf(rs.getLong(1)); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting last vm disk stats id", ex); | ||||
|             s_logger.error("error getting last vm disk stats id", ex); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| @ -331,7 +333,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving vm disk stats to cloud_usage db", ex); | ||||
|             s_logger.error("error saving vm disk stats to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
| 
 | ||||
| @ -377,7 +379,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving vm disk stats to cloud_usage db", ex); | ||||
|             s_logger.error("error saving vm disk stats to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
| 
 | ||||
| @ -444,7 +446,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving usage records to cloud_usage db", ex); | ||||
|             s_logger.error("error saving usage records to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
|     } | ||||
| @ -462,7 +464,7 @@ public class UsageDaoImpl extends GenericDaoBase<UsageVO, Long> implements Usage | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error removing old cloud_usage records for interval: " + days); | ||||
|             s_logger.error("error removing old cloud_usage records for interval: " + days); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import com.cloud.exception.CloudException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageIPAddressVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageIPAddressDao.class}) | ||||
| public class UsageIPAddressDaoImpl extends GenericDaoBase<UsageIPAddressVO, Long> implements UsageIPAddressDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageIPAddressDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String UPDATE_RELEASED = "UPDATE usage_ip_address SET released = ? WHERE account_id = ? AND public_ip_address = ? and released IS NULL"; | ||||
|     protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = | ||||
| @ -75,7 +77,7 @@ public class UsageIPAddressDaoImpl extends GenericDaoBase<UsageIPAddressVO, Long | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.error("Error updating usageIPAddressVO:"+e.getMessage(), e); | ||||
|             s_logger.error("Error updating usageIPAddressVO:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -140,7 +142,7 @@ public class UsageIPAddressDaoImpl extends GenericDaoBase<UsageIPAddressVO, Long | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records", e); | ||||
|             s_logger.warn("Error getting usage records", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -23,6 +23,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageJobVO; | ||||
| @ -35,6 +36,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {UsageJobDao.class}) | ||||
| public class UsageJobDaoImpl extends GenericDaoBase<UsageJobVO, Long> implements UsageJobDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(UsageJobDaoImpl.class.getName()); | ||||
| 
 | ||||
|     private static final String GET_LAST_JOB_SUCCESS_DATE_MILLIS = | ||||
|         "SELECT end_millis FROM cloud_usage.usage_job WHERE end_millis > 0 and success = 1 ORDER BY end_millis DESC LIMIT 1"; | ||||
| @ -51,7 +53,7 @@ public class UsageJobDaoImpl extends GenericDaoBase<UsageJobVO, Long> implements | ||||
|                 return rs.getLong(1); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting last usage job success date", ex); | ||||
|             s_logger.error("error getting last usage job success date", ex); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -77,7 +79,7 @@ public class UsageJobDaoImpl extends GenericDaoBase<UsageJobVO, Long> implements | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error updating job success date", ex); | ||||
|             s_logger.error("error updating job success date", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import com.cloud.exception.CloudException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageLoadBalancerPolicyVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageLoadBalancerPolicyDao.class}) | ||||
| public class UsageLoadBalancerPolicyDaoImpl extends GenericDaoBase<UsageLoadBalancerPolicyVO, Long> implements UsageLoadBalancerPolicyDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageLoadBalancerPolicyDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String REMOVE_BY_USERID_LBID = "DELETE FROM usage_load_balancer_policy WHERE account_id = ? AND id = ?"; | ||||
|     protected static final String UPDATE_DELETED = "UPDATE usage_load_balancer_policy SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL"; | ||||
| @ -64,7 +66,7 @@ public class UsageLoadBalancerPolicyDaoImpl extends GenericDaoBase<UsageLoadBala | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error removing UsageLoadBalancerPolicyVO", e); | ||||
|             s_logger.warn("Error removing UsageLoadBalancerPolicyVO", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -90,7 +92,7 @@ public class UsageLoadBalancerPolicyDaoImpl extends GenericDaoBase<UsageLoadBala | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error updating UsageLoadBalancerPolicyVO"+e.getMessage(), e); | ||||
|             s_logger.warn("Error updating UsageLoadBalancerPolicyVO"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -159,7 +161,7 @@ public class UsageLoadBalancerPolicyDaoImpl extends GenericDaoBase<UsageLoadBala | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records", e); | ||||
|             s_logger.warn("Error getting usage records", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.util.Map; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageNetworkVO; | ||||
| @ -34,6 +35,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {UsageNetworkDao.class}) | ||||
| public class UsageNetworkDaoImpl extends GenericDaoBase<UsageNetworkVO, Long> implements UsageNetworkDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(UsageVMInstanceDaoImpl.class.getName()); | ||||
|     private static final String SELECT_LATEST_STATS = | ||||
|         "SELECT u.account_id, u.zone_id, u.host_id, u.host_type, u.network_id, u.bytes_sent, u.bytes_received, u.agg_bytes_received, u.agg_bytes_sent, u.event_time_millis " | ||||
|             + "FROM cloud_usage.usage_network u INNER JOIN (SELECT netusage.account_id as acct_id, netusage.zone_id as z_id, max(netusage.event_time_millis) as max_date " | ||||
| @ -77,7 +79,7 @@ public class UsageNetworkDaoImpl extends GenericDaoBase<UsageNetworkVO, Long> im | ||||
|             } | ||||
|             return returnMap; | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting recent usage network stats", ex); | ||||
|             s_logger.error("error getting recent usage network stats", ex); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -97,7 +99,7 @@ public class UsageNetworkDaoImpl extends GenericDaoBase<UsageNetworkVO, Long> im | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error deleting old usage network stats", ex); | ||||
|             s_logger.error("error deleting old usage network stats", ex); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -126,7 +128,7 @@ public class UsageNetworkDaoImpl extends GenericDaoBase<UsageNetworkVO, Long> im | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving usage_network to cloud_usage db", ex); | ||||
|             s_logger.error("error saving usage_network to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import com.cloud.exception.CloudException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageNetworkOfferingVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageNetworkOfferingDao.class}) | ||||
| public class UsageNetworkOfferingDaoImpl extends GenericDaoBase<UsageNetworkOfferingVO, Long> implements UsageNetworkOfferingDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageNetworkOfferingDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String UPDATE_DELETED = | ||||
|         "UPDATE usage_network_offering SET deleted = ? WHERE account_id = ? AND vm_instance_id = ? AND network_offering_id = ? and deleted IS NULL"; | ||||
| @ -74,7 +76,7 @@ public class UsageNetworkOfferingDaoImpl extends GenericDaoBase<UsageNetworkOffe | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error updating UsageNetworkOfferingVO:"+e.getMessage(), e); | ||||
|             s_logger.warn("Error updating UsageNetworkOfferingVO:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -146,7 +148,7 @@ public class UsageNetworkOfferingDaoImpl extends GenericDaoBase<UsageNetworkOffe | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records", e); | ||||
|             s_logger.warn("Error getting usage records", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import com.cloud.exception.CloudException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsagePortForwardingRuleVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsagePortForwardingRuleDao.class}) | ||||
| public class UsagePortForwardingRuleDaoImpl extends GenericDaoBase<UsagePortForwardingRuleVO, Long> implements UsagePortForwardingRuleDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsagePortForwardingRuleDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String REMOVE_BY_USERID_PFID = "DELETE FROM usage_port_forwarding WHERE account_id = ? AND id = ?"; | ||||
|     protected static final String UPDATE_DELETED = "UPDATE usage_port_forwarding SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL"; | ||||
| @ -64,7 +66,7 @@ public class UsagePortForwardingRuleDaoImpl extends GenericDaoBase<UsagePortForw | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error removing UsagePortForwardingRuleVO", e); | ||||
|             s_logger.warn("Error removing UsagePortForwardingRuleVO", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -90,7 +92,7 @@ public class UsagePortForwardingRuleDaoImpl extends GenericDaoBase<UsagePortForw | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error updating UsagePortForwardingRuleVO:"+e.getMessage(), e); | ||||
|             s_logger.warn("Error updating UsagePortForwardingRuleVO:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -159,7 +161,7 @@ public class UsagePortForwardingRuleDaoImpl extends GenericDaoBase<UsagePortForw | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records", e); | ||||
|             s_logger.warn("Error getting usage records", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import com.cloud.exception.CloudException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageSecurityGroupVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageSecurityGroupDao.class}) | ||||
| public class UsageSecurityGroupDaoImpl extends GenericDaoBase<UsageSecurityGroupVO, Long> implements UsageSecurityGroupDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageSecurityGroupDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String UPDATE_DELETED = | ||||
|         "UPDATE usage_security_group SET deleted = ? WHERE account_id = ? AND vm_instance_id = ? AND security_group_id = ? and deleted IS NULL"; | ||||
| @ -74,7 +76,7 @@ public class UsageSecurityGroupDaoImpl extends GenericDaoBase<UsageSecurityGroup | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error updating UsageSecurityGroupVO:"+e.getMessage(), e); | ||||
|             s_logger.warn("Error updating UsageSecurityGroupVO:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -142,7 +144,7 @@ public class UsageSecurityGroupDaoImpl extends GenericDaoBase<UsageSecurityGroup | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records:"+e.getMessage(), e); | ||||
|             s_logger.warn("Error getting usage records:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import com.cloud.exception.CloudException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageStorageVO; | ||||
| @ -39,6 +40,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageStorageDao.class}) | ||||
| public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> implements UsageStorageDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageStorageDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String REMOVE_BY_USERID_STORAGEID = "DELETE FROM usage_storage WHERE account_id = ? AND id = ? AND storage_type = ?"; | ||||
|     protected static final String UPDATE_DELETED = "UPDATE usage_storage SET deleted = ? WHERE account_id = ? AND id = ? AND storage_type = ? and deleted IS NULL"; | ||||
| @ -106,7 +108,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> im | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.error("Error removing usageStorageVO", e); | ||||
|             s_logger.error("Error removing usageStorageVO", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -134,7 +136,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> im | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.error("Error updating UsageStorageVO:"+e.getMessage(), e); | ||||
|             s_logger.error("Error updating UsageStorageVO:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -208,7 +210,7 @@ public class UsageStorageDaoImpl extends GenericDaoBase<UsageStorageVO, Long> im | ||||
|             } | ||||
|         }catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.error("getUsageRecords:Exception:"+e.getMessage(), e); | ||||
|             s_logger.error("getUsageRecords:Exception:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.TimeZone; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageVMInstanceVO; | ||||
| @ -35,6 +36,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageVMInstanceDao.class}) | ||||
| public class UsageVMInstanceDaoImpl extends GenericDaoBase<UsageVMInstanceVO, Long> implements UsageVMInstanceDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageVMInstanceDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String UPDATE_USAGE_INSTANCE_SQL = "UPDATE usage_vm_instance SET end_date = ? " | ||||
|         + "WHERE account_id = ? and vm_instance_id = ? and usage_type = ? and end_date IS NULL"; | ||||
| @ -62,7 +64,7 @@ public class UsageVMInstanceDaoImpl extends GenericDaoBase<UsageVMInstanceVO, Lo | ||||
|             pstmt.executeUpdate(); | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             logger.warn(e); | ||||
|             s_logger.warn(e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -83,7 +85,7 @@ public class UsageVMInstanceDaoImpl extends GenericDaoBase<UsageVMInstanceVO, Lo | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error deleting usage vm instance with vmId: " + instance.getVmInstanceId() + ", for account with id: " + instance.getAccountId()); | ||||
|             s_logger.error("error deleting usage vm instance with vmId: " + instance.getVmInstanceId() + ", for account with id: " + instance.getAccountId()); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -141,7 +143,7 @@ public class UsageVMInstanceDaoImpl extends GenericDaoBase<UsageVMInstanceVO, Lo | ||||
|                 usageInstances.add(usageInstance); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error retrieving usage vm instances for account id: " + accountId, ex); | ||||
|             s_logger.error("error retrieving usage vm instances for account id: " + accountId, ex); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -26,6 +26,7 @@ import java.util.TimeZone; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageVMSnapshotVO; | ||||
| @ -36,6 +37,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageVMSnapshotDao.class}) | ||||
| public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Long> implements UsageVMSnapshotDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageVMSnapshotDaoImpl.class.getName()); | ||||
|     protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT id, zone_id, account_id, domain_id, vm_id, disk_offering_id, size, created, processed " | ||||
|         + " FROM usage_vmsnapshot" + " WHERE account_id = ? " + " AND ( (created BETWEEN ? AND ?) OR " | ||||
|         + "      (created < ? AND processed is NULL) ) ORDER BY created asc"; | ||||
| @ -60,7 +62,7 @@ public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Lo | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error updating UsageVMSnapshotVO", e); | ||||
|             s_logger.warn("Error updating UsageVMSnapshotVO", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -110,7 +112,7 @@ public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Lo | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records", e); | ||||
|             s_logger.warn("Error getting usage records", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -161,7 +163,7 @@ public class UsageVMSnapshotDaoImpl extends GenericDaoBase<UsageVMSnapshotVO, Lo | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records", e); | ||||
|             s_logger.warn("Error getting usage records", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import com.cloud.exception.CloudException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageVPNUserVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageVPNUserDao.class}) | ||||
| public class UsageVPNUserDaoImpl extends GenericDaoBase<UsageVPNUserVO, Long> implements UsageVPNUserDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageVPNUserDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String UPDATE_DELETED = "UPDATE usage_vpn_user SET deleted = ? WHERE account_id = ? AND user_id = ? and deleted IS NULL"; | ||||
|     protected static final String GET_USAGE_RECORDS_BY_ACCOUNT = "SELECT zone_id, account_id, domain_id, user_id, user_name, created, deleted " + "FROM usage_vpn_user " | ||||
| @ -69,7 +71,7 @@ public class UsageVPNUserDaoImpl extends GenericDaoBase<UsageVPNUserVO, Long> im | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.error("Error updating UsageVPNUserVO:"+e.getMessage(), e); | ||||
|             s_logger.error("Error updating UsageVPNUserVO:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -139,7 +141,7 @@ public class UsageVPNUserDaoImpl extends GenericDaoBase<UsageVPNUserVO, Long> im | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records", e); | ||||
|             s_logger.warn("Error getting usage records", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.util.Map; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageVmDiskVO; | ||||
| @ -34,6 +35,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {UsageVmDiskDao.class}) | ||||
| public class UsageVmDiskDaoImpl extends GenericDaoBase<UsageVmDiskVO, Long> implements UsageVmDiskDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(UsageVmDiskDaoImpl.class.getName()); | ||||
|     private static final String SELECT_LATEST_STATS = | ||||
|         "SELECT uvd.account_id, uvd.zone_id, uvd.vm_id, uvd.volume_id, uvd.io_read, uvd.io_write, uvd.agg_io_read, uvd.agg_io_write, " | ||||
|             + "uvd.bytes_read, uvd.bytes_write, uvd.agg_bytes_read, uvd.agg_bytes_write, uvd.event_time_millis " | ||||
| @ -81,7 +83,7 @@ public class UsageVmDiskDaoImpl extends GenericDaoBase<UsageVmDiskVO, Long> impl | ||||
|             } | ||||
|             return returnMap; | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error getting recent usage disk stats", ex); | ||||
|             s_logger.error("error getting recent usage disk stats", ex); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -101,7 +103,7 @@ public class UsageVmDiskDaoImpl extends GenericDaoBase<UsageVmDiskVO, Long> impl | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error deleting old usage disk stats", ex); | ||||
|             s_logger.error("error deleting old usage disk stats", ex); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -133,7 +135,7 @@ public class UsageVmDiskDaoImpl extends GenericDaoBase<UsageVmDiskVO, Long> impl | ||||
|             txn.commit(); | ||||
|         } catch (Exception ex) { | ||||
|             txn.rollback(); | ||||
|             logger.error("error saving usage_vm_disk to cloud_usage db", ex); | ||||
|             s_logger.error("error saving usage_vm_disk to cloud_usage db", ex); | ||||
|             throw new CloudRuntimeException(ex.getMessage()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -27,6 +27,7 @@ import java.util.TimeZone; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import com.cloud.exception.CloudException; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.usage.UsageVolumeVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UsageVolumeDao.class}) | ||||
| public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> implements UsageVolumeDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UsageVolumeDaoImpl.class.getName()); | ||||
| 
 | ||||
|     protected static final String REMOVE_BY_USERID_VOLID = "DELETE FROM usage_volume WHERE account_id = ? AND id = ?"; | ||||
|     protected static final String UPDATE_DELETED = "UPDATE usage_volume SET deleted = ? WHERE account_id = ? AND id = ? and deleted IS NULL"; | ||||
| @ -69,7 +71,7 @@ public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> impl | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error removing usageVolumeVO:"+e.getMessage(), e); | ||||
|             s_logger.warn("Error removing usageVolumeVO:"+e.getMessage(), e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -91,7 +93,7 @@ public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> impl | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error updating UsageVolumeVO", e); | ||||
|             s_logger.warn("Error updating UsageVolumeVO", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
| @ -169,7 +171,7 @@ public class UsageVolumeDaoImpl extends GenericDaoBase<UsageVolumeVO, Long> impl | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Error getting usage records", e); | ||||
|             s_logger.warn("Error getting usage records", e); | ||||
|         } finally { | ||||
|             txn.close(); | ||||
|         } | ||||
|  | ||||
| @ -23,6 +23,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.user.Account; | ||||
| @ -43,6 +44,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {AccountDao.class}) | ||||
| public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements AccountDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(AccountDaoImpl.class); | ||||
|     private static final String FIND_USER_ACCOUNT_BY_API_KEY = "SELECT u.id, u.username, u.account_id, u.secret_key, u.state, " | ||||
|         + "a.id, a.account_name, a.type, a.domain_id, a.state " + "FROM `cloud`.`user` u, `cloud`.`account` a " | ||||
|         + "WHERE u.account_id = a.id AND u.api_key = ? and u.removed IS NULL"; | ||||
| @ -146,7 +148,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A | ||||
|                 userAcctPair = new Pair<User, Account>(u, a); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Exception finding user/acct by api key: " + apiKey, e); | ||||
|             s_logger.warn("Exception finding user/acct by api key: " + apiKey, e); | ||||
|         } | ||||
|         return userAcctPair; | ||||
|     } | ||||
| @ -264,7 +266,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A | ||||
|         if (!account.getNeedsCleanup()) { | ||||
|             account.setNeedsCleanup(true); | ||||
|             if (!update(accountId, account)) { | ||||
|                 logger.warn("Failed to mark account id=" + accountId + " for cleanup"); | ||||
|                 s_logger.warn("Failed to mark account id=" + accountId + " for cleanup"); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -284,7 +286,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A | ||||
|             domain_id = account_vo.getDomainId(); | ||||
|         } | ||||
|         catch (Exception e) { | ||||
|             logger.warn("getDomainIdForGivenAccountId: Exception :" + e.getMessage()); | ||||
|             s_logger.warn("getDomainIdForGivenAccountId: Exception :" + e.getMessage()); | ||||
|         } | ||||
|         finally { | ||||
|             return domain_id; | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.TimeZone; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.user.UserStatisticsVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {UserStatisticsDao.class}) | ||||
| public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long> implements UserStatisticsDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(UserStatisticsDaoImpl.class); | ||||
|     private static final String ACTIVE_AND_RECENTLY_DELETED_SEARCH = | ||||
|         "SELECT us.id, us.data_center_id, us.account_id, us.public_ip_address, us.device_id, us.device_type, us.network_id, us.agg_bytes_received, us.agg_bytes_sent " | ||||
|             + "FROM user_statistics us, account a " + "WHERE us.account_id = a.id AND (a.removed IS NULL OR a.removed >= ?) " + "ORDER BY us.id"; | ||||
| @ -109,7 +111,7 @@ public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long | ||||
|                 userStats.add(toEntityBean(rs, false)); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error saving user stats to cloud_usage db", ex); | ||||
|             s_logger.error("error saving user stats to cloud_usage db", ex); | ||||
|         } | ||||
|         return userStats; | ||||
|     } | ||||
| @ -127,7 +129,7 @@ public class UserStatisticsDaoImpl extends GenericDaoBase<UserStatisticsVO, Long | ||||
|                 userStats.add(toEntityBean(rs, false)); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error lisitng updated user stats", ex); | ||||
|             s_logger.error("error lisitng updated user stats", ex); | ||||
|         } | ||||
|         return userStats; | ||||
|     } | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.TimeZone; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.user.VmDiskStatisticsVO; | ||||
| @ -37,6 +38,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Component | ||||
| @Local(value = {VmDiskStatisticsDao.class}) | ||||
| public class VmDiskStatisticsDaoImpl extends GenericDaoBase<VmDiskStatisticsVO, Long> implements VmDiskStatisticsDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(VmDiskStatisticsDaoImpl.class); | ||||
|     private static final String ACTIVE_AND_RECENTLY_DELETED_SEARCH = | ||||
|         "SELECT bcf.id, bcf.data_center_id, bcf.account_id, bcf.vm_id, bcf.volume_id, bcf.agg_io_read, bcf.agg_io_write, bcf.agg_bytes_read, bcf.agg_bytes_write " | ||||
|             + "FROM vm_disk_statistics bcf, account a " + "WHERE bcf.account_id = a.id AND (a.removed IS NULL OR a.removed >= ?) " + "ORDER BY bcf.id"; | ||||
| @ -104,7 +106,7 @@ public class VmDiskStatisticsDaoImpl extends GenericDaoBase<VmDiskStatisticsVO, | ||||
|                 vmDiskStats.add(toEntityBean(rs, false)); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error saving vm disk stats to cloud_usage db", ex); | ||||
|             s_logger.error("error saving vm disk stats to cloud_usage db", ex); | ||||
|         } | ||||
|         return vmDiskStats; | ||||
|     } | ||||
| @ -122,7 +124,7 @@ public class VmDiskStatisticsDaoImpl extends GenericDaoBase<VmDiskStatisticsVO, | ||||
|                 vmDiskStats.add(toEntityBean(rs, false)); | ||||
|             } | ||||
|         } catch (Exception ex) { | ||||
|             logger.error("error lisitng updated vm disk stats", ex); | ||||
|             s_logger.error("error lisitng updated vm disk stats", ex); | ||||
|         } | ||||
|         return vmDiskStats; | ||||
|     } | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.info.ConsoleProxyLoadInfo; | ||||
| @ -41,6 +42,7 @@ import com.cloud.vm.VirtualMachine.State; | ||||
| @Component | ||||
| @Local(value = {ConsoleProxyDao.class}) | ||||
| public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> implements ConsoleProxyDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(ConsoleProxyDaoImpl.class); | ||||
| 
 | ||||
|     // | ||||
|     // query SQL for returnning console proxy assignment info as following | ||||
| @ -215,7 +217,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im | ||||
|                 l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2))); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Caught SQLException: ", e); | ||||
|             s_logger.debug("Caught SQLException: ", e); | ||||
|         } | ||||
|         return l; | ||||
|     } | ||||
| @ -240,7 +242,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im | ||||
|                 l.add(new Pair<Long, Integer>(rs.getLong(1), rs.getInt(2))); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Caught SQLException: ", e); | ||||
|             s_logger.debug("Caught SQLException: ", e); | ||||
|         } | ||||
|         return l; | ||||
|     } | ||||
| @ -259,7 +261,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im | ||||
|                 return rs.getInt(1); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Caught SQLException: ", e); | ||||
|             s_logger.debug("Caught SQLException: ", e); | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
| @ -277,7 +279,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im | ||||
|                 return rs.getInt(1); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Caught SQLException: ", e); | ||||
|             s_logger.debug("Caught SQLException: ", e); | ||||
|         } | ||||
|         return 0; | ||||
|     } | ||||
| @ -299,7 +301,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im | ||||
|                 l.add(info); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Exception: ", e); | ||||
|             s_logger.debug("Exception: ", e); | ||||
|         } | ||||
|         return l; | ||||
|     } | ||||
| @ -321,7 +323,7 @@ public class ConsoleProxyDaoImpl extends GenericDaoBase<ConsoleProxyVO, Long> im | ||||
|                 l.add(rs.getLong(1)); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Caught SQLException: ", e); | ||||
|             s_logger.debug("Caught SQLException: ", e); | ||||
|         } | ||||
|         return l; | ||||
|     } | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.List; | ||||
| import javax.annotation.PostConstruct; | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.utils.db.DB; | ||||
| @ -34,6 +35,7 @@ import com.cloud.vm.UserVmCloneSettingVO; | ||||
| @Local(value = {UserVmCloneSettingDao.class}) | ||||
| @DB() | ||||
| public class UserVmCloneSettingDaoImpl extends GenericDaoBase<UserVmCloneSettingVO, Long> implements UserVmCloneSettingDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UserVmCloneSettingDaoImpl.class); | ||||
| 
 | ||||
|     protected SearchBuilder<UserVmCloneSettingVO> vmIdSearch; | ||||
|     protected SearchBuilder<UserVmCloneSettingVO> cloneTypeSearch; | ||||
|  | ||||
| @ -30,6 +30,7 @@ import javax.annotation.PostConstruct; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.server.ResourceTag.ResourceObjectType; | ||||
| import com.cloud.tags.dao.ResourceTagDao; | ||||
| @ -54,6 +55,7 @@ import com.cloud.vm.dao.UserVmData.SecurityGroupData; | ||||
| 
 | ||||
| @Local(value = {UserVmDao.class}) | ||||
| public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements UserVmDao { | ||||
|     public static final Logger s_logger = Logger.getLogger(UserVmDaoImpl.class); | ||||
| 
 | ||||
|     protected SearchBuilder<UserVmVO> AccountPodSearch; | ||||
|     protected SearchBuilder<UserVmVO> AccountDataCenterSearch; | ||||
| @ -376,13 +378,13 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use | ||||
|                 } | ||||
|             } | ||||
|             catch (Exception e) { | ||||
|                 logger.error("listPodIdsHavingVmsforAccount:Exception: " +  e.getMessage()); | ||||
|                 s_logger.error("listPodIdsHavingVmsforAccount:Exception: " +  e.getMessage()); | ||||
|                 throw new CloudRuntimeException("listPodIdsHavingVmsforAccount:Exception: " + e.getMessage(), e); | ||||
|             } | ||||
|             txn.commit(); | ||||
|             return result; | ||||
|         } catch (Exception e) { | ||||
|             logger.error("listPodIdsHavingVmsforAccount:Exception : " +  e.getMessage()); | ||||
|             s_logger.error("listPodIdsHavingVmsforAccount:Exception : " +  e.getMessage()); | ||||
|             throw new CloudRuntimeException("listPodIdsHavingVmsforAccount:Exception: " + e.getMessage(), e); | ||||
|         } | ||||
|         finally { | ||||
| @ -394,7 +396,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|                 s_logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -431,7 +433,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use | ||||
|                         } | ||||
|                         catch (Exception e) | ||||
|                         { | ||||
|                             logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|                             s_logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|                             throw new CloudRuntimeException("listVmDetails: Exception:" + e.getMessage(),e); | ||||
|                         } | ||||
|                         curr_index += VM_DETAILS_BATCH_SIZE; | ||||
| @ -439,7 +441,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use | ||||
|                 } | ||||
|                 catch (Exception e) | ||||
|                 { | ||||
|                     logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|                     s_logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|                     throw new CloudRuntimeException("listVmDetails: Exception:" + e.getMessage(),e); | ||||
|                 } | ||||
|             } | ||||
| @ -467,20 +469,20 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use | ||||
|                     } | ||||
|                     catch (Exception e) | ||||
|                     { | ||||
|                         logger.error("listVmDetails: Exception:" + e.getMessage()); | ||||
|                         s_logger.error("listVmDetails: Exception:" + e.getMessage()); | ||||
|                         throw new CloudRuntimeException("listVmDetails: Exception:" + e.getMessage(),e); | ||||
|                     } | ||||
|                 } | ||||
|                 catch (Exception e) | ||||
|                 { | ||||
|                     logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|                     s_logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|                     throw new CloudRuntimeException("listVmDetails: Exception:" + e.getMessage(),e); | ||||
|                 } | ||||
|             } | ||||
|             txn.commit(); | ||||
|             return userVmDataHash; | ||||
|         } catch (Exception e) { | ||||
|             logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|             s_logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|             throw new CloudRuntimeException("listVmDetails:Exception : ", e); | ||||
|         } | ||||
|         finally { | ||||
| @ -492,7 +494,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|                 s_logger.error("listVmDetails:Exception:" + e.getMessage()); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -654,7 +656,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use | ||||
|                 } | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.error("GetVmsDetailsByNames: Exception in sql: " + e.getMessage()); | ||||
|             s_logger.error("GetVmsDetailsByNames: Exception in sql: " + e.getMessage()); | ||||
|             throw new CloudRuntimeException("GetVmsDetailsByNames: Exception: " + e.getMessage()); | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -29,6 +29,7 @@ import javax.annotation.PostConstruct; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.host.HostVO; | ||||
| @ -65,6 +66,7 @@ import com.cloud.vm.VirtualMachine.Type; | ||||
| @Local(value = {VMInstanceDao.class}) | ||||
| public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implements VMInstanceDao { | ||||
| 
 | ||||
|     public static final Logger s_logger = Logger.getLogger(VMInstanceDaoImpl.class); | ||||
|     private static final int MAX_CONSECUTIVE_SAME_STATE_UPDATE_COUNT = 3; | ||||
| 
 | ||||
|     protected SearchBuilder<VMInstanceVO> VMClusterSearch; | ||||
| @ -437,8 +439,8 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem | ||||
|     @Override | ||||
|     public boolean updateState(State oldState, Event event, State newState, VirtualMachine vm, Object opaque) { | ||||
|         if (newState == null) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("There's no way to transition from old state: " + oldState.toString() + " event: " + event.toString()); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("There's no way to transition from old state: " + oldState.toString() + " event: " + event.toString()); | ||||
|             } | ||||
|             return false; | ||||
|         } | ||||
| @ -477,7 +479,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem | ||||
|         if (result == 0) { | ||||
|             VMInstanceVO vo = findByIdIncludingRemoved(vm.getId()); | ||||
| 
 | ||||
|             if (logger.isDebugEnabled()) { | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 if (vo != null) { | ||||
|                     StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
|                     str.append(": DB Data={Host=").append(vo.getHostId()).append("; State=").append(vo.getState().toString()).append("; updated=").append(vo.getUpdated()) | ||||
| @ -486,16 +488,16 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem | ||||
|                             .append("; time=").append(vo.getUpdateTime()); | ||||
|                     str.append("} Stale Data: {Host=").append(oldHostId).append("; State=").append(oldState).append("; updated=").append(oldUpdated).append("; time=") | ||||
|                             .append(oldUpdateDate).append("}"); | ||||
|                     logger.debug(str.toString()); | ||||
|                     s_logger.debug(str.toString()); | ||||
| 
 | ||||
|                 } else { | ||||
|                     logger.debug("Unable to update the vm id=" + vm.getId() + "; the vm either doesn't exist or already removed"); | ||||
|                     s_logger.debug("Unable to update the vm id=" + vm.getId() + "; the vm either doesn't exist or already removed"); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (vo != null && vo.getState() == newState) { | ||||
|                 // allow for concurrent update if target state has already been matched | ||||
|                 logger.debug("VM " + vo.getInstanceName() + " state has been already been updated to " + newState); | ||||
|                 s_logger.debug("VM " + vo.getInstanceName() + " state has been already been updated to " + newState); | ||||
|                 return true; | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -22,6 +22,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.utils.db.GenericDaoBase; | ||||
| @ -37,6 +38,7 @@ import com.cloud.vm.snapshot.VMSnapshotVO; | ||||
| @Component | ||||
| @Local(value = {VMSnapshotDao.class}) | ||||
| public class VMSnapshotDaoImpl extends GenericDaoBase<VMSnapshotVO, Long> implements VMSnapshotDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(VMSnapshotDaoImpl.class); | ||||
|     private final SearchBuilder<VMSnapshotVO> SnapshotSearch; | ||||
|     private final SearchBuilder<VMSnapshotVO> ExpungingSnapshotSearch; | ||||
|     private final SearchBuilder<VMSnapshotVO> SnapshotStatusSearch; | ||||
| @ -143,7 +145,7 @@ public class VMSnapshotDaoImpl extends GenericDaoBase<VMSnapshotVO, Long> implem | ||||
|         builder.set(vo, "updated", new Date()); | ||||
| 
 | ||||
|         int rows = update((VMSnapshotVO)vo, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             VMSnapshotVO dbVol = findByIdIncludingRemoved(vo.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -176,7 +178,7 @@ public class VMSnapshotDaoImpl extends GenericDaoBase<VMSnapshotVO, Long> implem | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update VM snapshot: id=" + vo.getId() + ", as there is no such snapshot exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update VM snapshot: id=" + vo.getId() + ", as there is no such snapshot exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
| @ -23,6 +23,7 @@ import javax.annotation.PostConstruct; | ||||
| import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO; | ||||
| @ -38,6 +39,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| @Local(value = {VMEntityDao.class}) | ||||
| public class VMEntityDaoImpl extends GenericDaoBase<VMEntityVO, Long> implements VMEntityDao { | ||||
| 
 | ||||
|     public static final Logger s_logger = Logger.getLogger(VMEntityDaoImpl.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     protected VMReservationDao _vmReservationDao; | ||||
|  | ||||
| @ -18,6 +18,7 @@ package org.apache.cloudstack.region.dao; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.region.RegionVO; | ||||
| @ -29,6 +30,7 @@ import com.cloud.utils.db.SearchCriteria; | ||||
| @Component | ||||
| @Local(value = {RegionDao.class}) | ||||
| public class RegionDaoImpl extends GenericDaoBase<RegionVO, Integer> implements RegionDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(RegionDaoImpl.class); | ||||
|     protected SearchBuilder<RegionVO> NameSearch; | ||||
|     protected SearchBuilder<RegionVO> AllFieldsSearch; | ||||
| 
 | ||||
|  | ||||
| @ -26,6 +26,7 @@ import java.util.Map; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.agent.AgentManager; | ||||
| import com.cloud.agent.Listener; | ||||
| @ -59,6 +60,7 @@ import com.cloud.utils.fsm.NoTransitionException; | ||||
| import com.cloud.utils.fsm.StateMachine2; | ||||
| 
 | ||||
| public class DirectAgentManagerSimpleImpl extends ManagerBase implements AgentManager { | ||||
|     private static final Logger logger = Logger.getLogger(DirectAgentManagerSimpleImpl.class); | ||||
|     private final Map<Long, ServerResource> hostResourcesMap = new HashMap<Long, ServerResource>(); | ||||
|     @Inject | ||||
|     HostDao hostDao; | ||||
|  | ||||
| @ -24,6 +24,7 @@ import java.util.Map; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority; | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions; | ||||
| @ -70,6 +71,7 @@ import com.cloud.vm.snapshot.VMSnapshotVO; | ||||
| import com.cloud.vm.snapshot.dao.VMSnapshotDao; | ||||
| 
 | ||||
| public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshotStrategy { | ||||
|     private static final Logger s_logger = Logger.getLogger(DefaultVMSnapshotStrategy.class); | ||||
|     @Inject | ||||
|     VMSnapshotHelper vmSnapshotHelper; | ||||
|     @Inject | ||||
| @ -146,7 +148,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot | ||||
|             answer = (CreateVMSnapshotAnswer)agentMgr.send(hostId, ccmd); | ||||
|             if (answer != null && answer.getResult()) { | ||||
|                 processAnswer(vmSnapshotVO, userVm, answer, hostId); | ||||
|                 logger.debug("Create vm snapshot " + vmSnapshot.getName() + " succeeded for vm: " + userVm.getInstanceName()); | ||||
|                 s_logger.debug("Create vm snapshot " + vmSnapshot.getName() + " succeeded for vm: " + userVm.getInstanceName()); | ||||
|                 result = true; | ||||
| 
 | ||||
|                 for (VolumeObjectTO volumeTo : answer.getVolumeTOs()) { | ||||
| @ -157,21 +159,21 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot | ||||
|                 String errMsg = "Creating VM snapshot: " + vmSnapshot.getName() + " failed"; | ||||
|                 if (answer != null && answer.getDetails() != null) | ||||
|                     errMsg = errMsg + " due to " + answer.getDetails(); | ||||
|                 logger.error(errMsg); | ||||
|                 s_logger.error(errMsg); | ||||
|                 throw new CloudRuntimeException(errMsg); | ||||
|             } | ||||
|         } catch (OperationTimedoutException e) { | ||||
|             logger.debug("Creating VM snapshot: " + vmSnapshot.getName() + " failed: " + e.toString()); | ||||
|             s_logger.debug("Creating VM snapshot: " + vmSnapshot.getName() + " failed: " + e.toString()); | ||||
|             throw new CloudRuntimeException("Creating VM snapshot: " + vmSnapshot.getName() + " failed: " + e.toString()); | ||||
|         } catch (AgentUnavailableException e) { | ||||
|             logger.debug("Creating VM snapshot: " + vmSnapshot.getName() + " failed", e); | ||||
|             s_logger.debug("Creating VM snapshot: " + vmSnapshot.getName() + " failed", e); | ||||
|             throw new CloudRuntimeException("Creating VM snapshot: " + vmSnapshot.getName() + " failed: " + e.toString()); | ||||
|         } finally { | ||||
|             if (!result) { | ||||
|                 try { | ||||
|                     vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.OperationFailed); | ||||
|                 } catch (NoTransitionException e1) { | ||||
|                     logger.error("Cannot set vm snapshot state due to: " + e1.getMessage()); | ||||
|                     s_logger.error("Cannot set vm snapshot state due to: " + e1.getMessage()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -184,7 +186,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot | ||||
|         try { | ||||
|             vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.ExpungeRequested); | ||||
|         } catch (NoTransitionException e) { | ||||
|             logger.debug("Failed to change vm snapshot state with event ExpungeRequested"); | ||||
|             s_logger.debug("Failed to change vm snapshot state with event ExpungeRequested"); | ||||
|             throw new CloudRuntimeException("Failed to change vm snapshot state with event ExpungeRequested: " + e.getMessage()); | ||||
|         } | ||||
| 
 | ||||
| @ -212,7 +214,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot | ||||
|                 return true; | ||||
|             } else { | ||||
|                 String errMsg = (answer == null) ? null : answer.getDetails(); | ||||
|                 logger.error("Delete vm snapshot " + vmSnapshot.getName() + " of vm " + userVm.getInstanceName() + " failed due to " + errMsg); | ||||
|                 s_logger.error("Delete vm snapshot " + vmSnapshot.getName() + " of vm " + userVm.getInstanceName() + " failed due to " + errMsg); | ||||
|                 throw new CloudRuntimeException("Delete vm snapshot " + vmSnapshot.getName() + " of vm " + userVm.getInstanceName() + " failed due to " + errMsg); | ||||
|             } | ||||
|         } catch (OperationTimedoutException e) { | ||||
| @ -245,7 +247,7 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot | ||||
|             }); | ||||
|         } catch (Exception e) { | ||||
|             String errMsg = "Error while process answer: " + as.getClass() + " due to " + e.getMessage(); | ||||
|             logger.error(errMsg, e); | ||||
|             s_logger.error(errMsg, e); | ||||
|             throw new CloudRuntimeException(errMsg); | ||||
|         } | ||||
|     } | ||||
| @ -365,21 +367,21 @@ public class DefaultVMSnapshotStrategy extends ManagerBase implements VMSnapshot | ||||
|                 String errMsg = "Revert VM: " + userVm.getInstanceName() + " to snapshot: " + vmSnapshotVO.getName() + " failed"; | ||||
|                 if (answer != null && answer.getDetails() != null) | ||||
|                     errMsg = errMsg + " due to " + answer.getDetails(); | ||||
|                 logger.error(errMsg); | ||||
|                 s_logger.error(errMsg); | ||||
|                 throw new CloudRuntimeException(errMsg); | ||||
|             } | ||||
|         } catch (OperationTimedoutException e) { | ||||
|             logger.debug("Failed to revert vm snapshot", e); | ||||
|             s_logger.debug("Failed to revert vm snapshot", e); | ||||
|             throw new CloudRuntimeException(e.getMessage()); | ||||
|         } catch (AgentUnavailableException e) { | ||||
|             logger.debug("Failed to revert vm snapshot", e); | ||||
|             s_logger.debug("Failed to revert vm snapshot", e); | ||||
|             throw new CloudRuntimeException(e.getMessage()); | ||||
|         } finally { | ||||
|             if (!result) { | ||||
|                 try { | ||||
|                     vmSnapshotHelper.vmSnapshotStateTransitTo(vmSnapshot, VMSnapshot.Event.OperationFailed); | ||||
|                 } catch (NoTransitionException e1) { | ||||
|                     logger.error("Cannot set vm snapshot state due to: " + e1.getMessage()); | ||||
|                     s_logger.error("Cannot set vm snapshot state due to: " + e1.getMessage()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @ -28,6 +28,7 @@ import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import com.cloud.storage.Storage; | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; | ||||
| @ -53,6 +54,7 @@ import com.cloud.vm.DiskProfile; | ||||
| import com.cloud.vm.VirtualMachineProfile; | ||||
| 
 | ||||
| public abstract class AbstractStoragePoolAllocator extends AdapterBase implements StoragePoolAllocator { | ||||
|     private static final Logger s_logger = Logger.getLogger(AbstractStoragePoolAllocator.class); | ||||
|     @Inject | ||||
|     StorageManager storageMgr; | ||||
|     protected @Inject | ||||
| @ -114,8 +116,8 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement | ||||
|         } | ||||
| 
 | ||||
|         List<Long> poolIdsByCapacity = _capacityDao.orderHostsByFreeCapacity(clusterId, capacityType); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("List of pools in descending order of free capacity: "+ poolIdsByCapacity); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("List of pools in descending order of free capacity: "+ poolIdsByCapacity); | ||||
|         } | ||||
| 
 | ||||
|       //now filter the given list of Pools by this ordered list | ||||
| @ -144,8 +146,8 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement | ||||
|         Long clusterId = plan.getClusterId(); | ||||
| 
 | ||||
|         List<Long> poolIdsByVolCount = _volumeDao.listPoolIdsByVolumeCount(dcId, podId, clusterId, account.getAccountId()); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("List of pools in ascending order of number of volumes for account id: " + account.getAccountId() + " is: " + poolIdsByVolCount); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("List of pools in ascending order of number of volumes for account id: " + account.getAccountId() + " is: " + poolIdsByVolCount); | ||||
|         } | ||||
| 
 | ||||
|         // now filter the given list of Pools by this ordered list | ||||
| @ -187,12 +189,12 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement | ||||
| 
 | ||||
|     protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh, DeploymentPlan plan) { | ||||
| 
 | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Checking if storage pool is suitable, name: " + pool.getName() + " ,poolId: " + pool.getId()); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Checking if storage pool is suitable, name: " + pool.getName() + " ,poolId: " + pool.getId()); | ||||
|         } | ||||
|         if (avoid.shouldAvoid(pool)) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("StoragePool is in avoid set, skipping this pool"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("StoragePool is in avoid set, skipping this pool"); | ||||
|             } | ||||
|             return false; | ||||
|         } | ||||
| @ -201,14 +203,14 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement | ||||
|         if (clusterId != null) { | ||||
|             ClusterVO cluster = _clusterDao.findById(clusterId); | ||||
|             if (!(cluster.getHypervisorType() == dskCh.getHypervisorType())) { | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("StoragePool's Cluster does not have required hypervisorType, skipping this pool"); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("StoragePool's Cluster does not have required hypervisorType, skipping this pool"); | ||||
|                 } | ||||
|                 return false; | ||||
|             } | ||||
|         } else if (pool.getHypervisor() != null && !pool.getHypervisor().equals(HypervisorType.Any) && !(pool.getHypervisor() == dskCh.getHypervisorType())) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("StoragePool does not have required hypervisorType, skipping this pool"); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("StoragePool does not have required hypervisorType, skipping this pool"); | ||||
|             } | ||||
|             return false; | ||||
|         } | ||||
| @ -233,13 +235,13 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement | ||||
|                 //LXC ROOT disks supports NFS and local storage pools only | ||||
|                 if(!(Storage.StoragePoolType.NetworkFilesystem.equals(poolType) || | ||||
|                         Storage.StoragePoolType.Filesystem.equals(poolType)) ){ | ||||
|                     logger.debug("StoragePool does not support LXC ROOT disk, skipping this pool"); | ||||
|                     s_logger.debug("StoragePool does not support LXC ROOT disk, skipping this pool"); | ||||
|                     return false; | ||||
|                 } | ||||
|             } else if (Volume.Type.DATADISK.equals(volType)){ | ||||
|                 //LXC DATA disks supports RBD storage pool only | ||||
|                 if(!Storage.StoragePoolType.RBD.equals(poolType)){ | ||||
|                     logger.debug("StoragePool does not support LXC DATA disk, skipping this pool"); | ||||
|                     s_logger.debug("StoragePool does not support LXC DATA disk, skipping this pool"); | ||||
|                     return false; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @ -23,6 +23,7 @@ import javax.ejb.Local; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; | ||||
| import org.apache.cloudstack.framework.config.dao.ConfigurationDao; | ||||
| @ -37,6 +38,7 @@ import com.cloud.vm.VirtualMachineProfile; | ||||
| 
 | ||||
| @Local(value = StoragePoolAllocator.class) | ||||
| public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAllocator { | ||||
|     private static final Logger s_logger = Logger.getLogger(GarbageCollectingStoragePoolAllocator.class); | ||||
| 
 | ||||
|     StoragePoolAllocator _firstFitStoragePoolAllocator; | ||||
|     StoragePoolAllocator _localStoragePoolAllocator; | ||||
| @ -48,9 +50,9 @@ public class GarbageCollectingStoragePoolAllocator extends AbstractStoragePoolAl | ||||
| 
 | ||||
|     @Override | ||||
|     public List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { | ||||
|         logger.debug("GarbageCollectingStoragePoolAllocator looking for storage pool"); | ||||
|         s_logger.debug("GarbageCollectingStoragePoolAllocator looking for storage pool"); | ||||
|         if (!_storagePoolCleanupEnabled) { | ||||
|             logger.debug("Storage pool cleanup is not enabled, so GarbageCollectingStoragePoolAllocator is being skipped."); | ||||
|             s_logger.debug("Storage pool cleanup is not enabled, so GarbageCollectingStoragePoolAllocator is being skipped."); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -28,6 +28,7 @@ import javax.naming.ConfigurationException; | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; | ||||
| import org.apache.cloudstack.framework.config.dao.ConfigurationDao; | ||||
| import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.capacity.dao.CapacityDao; | ||||
| @ -46,6 +47,7 @@ import com.cloud.vm.dao.VMInstanceDao; | ||||
| @Component | ||||
| @Local(value = StoragePoolAllocator.class) | ||||
| public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator { | ||||
|     private static final Logger s_logger = Logger.getLogger(LocalStoragePoolAllocator.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     StoragePoolHostDao _poolHostDao; | ||||
| @ -62,18 +64,18 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator { | ||||
| 
 | ||||
|     @Override | ||||
|     protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { | ||||
|         logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the vm"); | ||||
|         s_logger.debug("LocalStoragePoolAllocator trying to find storage pool to fit the vm"); | ||||
| 
 | ||||
|         if (!dskCh.useLocalStorage()) { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isTraceEnabled()) { | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             // Log the pools details that are ignored because they are in disabled state | ||||
|             List<StoragePoolVO> disabledPools = _storagePoolDao.findDisabledPoolsByScope(plan.getDataCenterId(), plan.getPodId(), plan.getClusterId(), ScopeType.HOST); | ||||
|             if (disabledPools != null && !disabledPools.isEmpty()) { | ||||
|                 for (StoragePoolVO pool : disabledPools) { | ||||
|                     logger.trace("Ignoring pool " + pool + " as it is in disabled state."); | ||||
|                     s_logger.trace("Ignoring pool " + pool + " as it is in disabled state."); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -87,7 +89,7 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator { | ||||
|                 if (pool != null && pool.isLocal()) { | ||||
|                     StoragePool storagePool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId()); | ||||
|                     if (filter(avoid, storagePool, dskCh, plan)) { | ||||
|                         logger.debug("Found suitable local storage pool " + pool.getId() + ", adding to list"); | ||||
|                         s_logger.debug("Found suitable local storage pool " + pool.getId() + ", adding to list"); | ||||
|                         suitablePools.add(storagePool); | ||||
|                     } else { | ||||
|                         avoid.addPool(pool.getId()); | ||||
| @ -126,8 +128,8 @@ public class LocalStoragePoolAllocator extends AbstractStoragePoolAllocator { | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("LocalStoragePoolAllocator returning " + suitablePools.size() + " suitable storage pools"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("LocalStoragePoolAllocator returning " + suitablePools.size() + " suitable storage pools"); | ||||
|         } | ||||
| 
 | ||||
|         return suitablePools; | ||||
|  | ||||
| @ -23,6 +23,7 @@ import java.util.Map; | ||||
| 
 | ||||
| import javax.inject.Inject; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; | ||||
| @ -40,6 +41,7 @@ import com.cloud.vm.VirtualMachineProfile; | ||||
| 
 | ||||
| @Component | ||||
| public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator { | ||||
|     private static final Logger s_logger = Logger.getLogger(ZoneWideStoragePoolAllocator.class); | ||||
|     @Inject | ||||
|     PrimaryDataStoreDao _storagePoolDao; | ||||
|     @Inject | ||||
| @ -48,18 +50,18 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator { | ||||
| 
 | ||||
|     @Override | ||||
|     protected List<StoragePool> select(DiskProfile dskCh, VirtualMachineProfile vmProfile, DeploymentPlan plan, ExcludeList avoid, int returnUpTo) { | ||||
|         logger.debug("ZoneWideStoragePoolAllocator to find storage pool"); | ||||
|         s_logger.debug("ZoneWideStoragePoolAllocator to find storage pool"); | ||||
| 
 | ||||
|         if (dskCh.useLocalStorage()) { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isTraceEnabled()) { | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             // Log the pools details that are ignored because they are in disabled state | ||||
|             List<StoragePoolVO> disabledPools = _storagePoolDao.findDisabledPoolsByScope(plan.getDataCenterId(), null, null, ScopeType.ZONE); | ||||
|             if (disabledPools != null && !disabledPools.isEmpty()) { | ||||
|                 for (StoragePoolVO pool : disabledPools) { | ||||
|                     logger.trace("Ignoring pool " + pool + " as it is in disabled state."); | ||||
|                     s_logger.trace("Ignoring pool " + pool + " as it is in disabled state."); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -112,8 +114,8 @@ public class ZoneWideStoragePoolAllocator extends AbstractStoragePoolAllocator { | ||||
|         long dcId = plan.getDataCenterId(); | ||||
| 
 | ||||
|         List<Long> poolIdsByVolCount = _volumeDao.listZoneWidePoolIdsByVolumeCount(dcId, account.getAccountId()); | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("List of pools in ascending order of number of volumes for account id: " + account.getAccountId() + " is: " + poolIdsByVolCount); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("List of pools in ascending order of number of volumes for account id: " + account.getAccountId() + " is: " + poolIdsByVolCount); | ||||
|         } | ||||
| 
 | ||||
|         // now filter the given list of Pools by this ordered list | ||||
|  | ||||
| @ -30,6 +30,7 @@ import java.util.concurrent.CopyOnWriteArrayList; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.api.response.StorageProviderResponse; | ||||
| @ -47,6 +48,7 @@ import com.cloud.utils.component.Registry; | ||||
| 
 | ||||
| @Component | ||||
| public class DataStoreProviderManagerImpl extends ManagerBase implements DataStoreProviderManager, Registry<DataStoreProvider> { | ||||
|     private static final Logger s_logger = Logger.getLogger(DataStoreProviderManagerImpl.class); | ||||
| 
 | ||||
|     List<DataStoreProvider> providers; | ||||
|     protected Map<String, DataStoreProvider> providerMap = new ConcurrentHashMap<String, DataStoreProvider>(); | ||||
| @ -121,18 +123,18 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto | ||||
| 
 | ||||
|         String providerName = provider.getName(); | ||||
|         if (providerMap.get(providerName) != null) { | ||||
|             logger.debug("Did not register data store provider, provider name: " + providerName + " is not unique"); | ||||
|             s_logger.debug("Did not register data store provider, provider name: " + providerName + " is not unique"); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
|         logger.debug("registering data store provider:" + provider.getName()); | ||||
|         s_logger.debug("registering data store provider:" + provider.getName()); | ||||
| 
 | ||||
|         providerMap.put(providerName, provider); | ||||
|         try { | ||||
|             boolean registrationResult = provider.configure(copyParams); | ||||
|             if (!registrationResult) { | ||||
|                 providerMap.remove(providerName); | ||||
|                 logger.debug("Failed to register data store provider: " + providerName); | ||||
|                 s_logger.debug("Failed to register data store provider: " + providerName); | ||||
|                 return false; | ||||
|             } | ||||
| 
 | ||||
| @ -144,7 +146,7 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto | ||||
|                 imageStoreProviderMgr.registerDriver(provider.getName(), (ImageStoreDriver)provider.getDataStoreDriver()); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.debug("configure provider failed", e); | ||||
|             s_logger.debug("configure provider failed", e); | ||||
|             providerMap.remove(providerName); | ||||
|             return false; | ||||
|         } | ||||
|  | ||||
| @ -21,6 +21,7 @@ import java.util.Map; | ||||
| 
 | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; | ||||
| @ -35,6 +36,7 @@ import com.cloud.utils.db.UpdateBuilder; | ||||
| 
 | ||||
| @Component | ||||
| public class ObjectInDataStoreDaoImpl extends GenericDaoBase<ObjectInDataStoreVO, Long> implements ObjectInDataStoreDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(ObjectInDataStoreDaoImpl.class); | ||||
|     private SearchBuilder<ObjectInDataStoreVO> updateStateSearch; | ||||
| 
 | ||||
|     @Override | ||||
| @ -67,7 +69,7 @@ public class ObjectInDataStoreDaoImpl extends GenericDaoBase<ObjectInDataStoreVO | ||||
|         builder.set(vo, "updated", new Date()); | ||||
| 
 | ||||
|         int rows = update(vo, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             ObjectInDataStoreVO dbVol = findByIdIncludingRemoved(vo.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -100,7 +102,7 @@ public class ObjectInDataStoreDaoImpl extends GenericDaoBase<ObjectInDataStoreVO | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update objectIndatastore: id=" + vo.getId() + ", as there is no such object exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update objectIndatastore: id=" + vo.getId() + ", as there is no such object exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.Map; | ||||
| 
 | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; | ||||
| @ -45,6 +46,7 @@ import com.cloud.utils.db.UpdateBuilder; | ||||
| 
 | ||||
| @Component | ||||
| public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO, Long> implements SnapshotDataStoreDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(SnapshotDataStoreDaoImpl.class); | ||||
|     private SearchBuilder<SnapshotDataStoreVO> updateStateSearch; | ||||
|     private SearchBuilder<SnapshotDataStoreVO> storeSearch; | ||||
|     private SearchBuilder<SnapshotDataStoreVO> destroyedSearch; | ||||
| @ -138,7 +140,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO | ||||
|         builder.set(dataObj, "updated", new Date()); | ||||
| 
 | ||||
|         int rows = update(dataObj, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             SnapshotDataStoreVO dbVol = findByIdIncludingRemoved(dataObj.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(dataObj.toString()); | ||||
| @ -171,7 +173,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update objectIndatastore: id=" + dataObj.getId() + ", as there is no such object exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update objectIndatastore: id=" + dataObj.getId() + ", as there is no such object exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
| @ -232,7 +234,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO | ||||
|                 } | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Failed to find latest snapshot for volume: " + volumeId + " due to: "  + e.toString()); | ||||
|             s_logger.debug("Failed to find latest snapshot for volume: " + volumeId + " due to: "  + e.toString()); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| @ -253,7 +255,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO | ||||
|                 } | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Failed to find oldest snapshot for volume: " + volumeId + " due to: "  + e.toString()); | ||||
|             s_logger.debug("Failed to find oldest snapshot for volume: " + volumeId + " due to: "  + e.toString()); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| @ -276,7 +278,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO | ||||
|                 } | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|             logger.debug("Failed to find parent snapshot: " + e.toString()); | ||||
|             s_logger.debug("Failed to find parent snapshot: " + e.toString()); | ||||
|         } | ||||
|         return null; | ||||
|     } | ||||
| @ -324,14 +326,14 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO | ||||
|         List<SnapshotDataStoreVO> snapshots = listBy(sc); | ||||
|         // create an entry for each record, but with empty install path since the content is not yet on region-wide store yet | ||||
|         if (snapshots != null) { | ||||
|             logger.info("Duplicate " + snapshots.size() + " snapshot cache store records to region store"); | ||||
|             s_logger.info("Duplicate " + snapshots.size() + " snapshot cache store records to region store"); | ||||
|             for (SnapshotDataStoreVO snap : snapshots) { | ||||
|                 SnapshotDataStoreVO snapStore = findByStoreSnapshot(DataStoreRole.Image, storeId, snap.getSnapshotId()); | ||||
|                 if (snapStore != null) { | ||||
|                     logger.info("There is already entry for snapshot " + snap.getSnapshotId() + " on region store " + storeId); | ||||
|                     s_logger.info("There is already entry for snapshot " + snap.getSnapshotId() + " on region store " + storeId); | ||||
|                     continue; | ||||
|                 } | ||||
|                 logger.info("Persisting an entry for snapshot " + snap.getSnapshotId() + " on region store " + storeId); | ||||
|                 s_logger.info("Persisting an entry for snapshot " + snap.getSnapshotId() + " on region store " + storeId); | ||||
|                 SnapshotDataStoreVO ss = new SnapshotDataStoreVO(); | ||||
|                 ss.setSnapshotId(snap.getSnapshotId()); | ||||
|                 ss.setDataStoreId(storeId); | ||||
| @ -375,7 +377,7 @@ public class SnapshotDataStoreDaoImpl extends GenericDaoBase<SnapshotDataStoreVO | ||||
|         sc.setParameters("destroyed", false); | ||||
|         List<SnapshotDataStoreVO> snaps = listBy(sc); | ||||
|         if (snaps != null) { | ||||
|             logger.info("Update to cache store role for " + snaps.size() + " entries in snapshot_store_ref"); | ||||
|             s_logger.info("Update to cache store role for " + snaps.size() + " entries in snapshot_store_ref"); | ||||
|             for (SnapshotDataStoreVO snap : snaps) { | ||||
|                 snap.setRole(DataStoreRole.ImageCache); | ||||
|                 update(snap.getId(), snap); | ||||
|  | ||||
| @ -26,6 +26,7 @@ import java.util.Map; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; | ||||
| @ -55,6 +56,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| 
 | ||||
| @Component | ||||
| public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO, Long> implements TemplateDataStoreDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(TemplateDataStoreDaoImpl.class); | ||||
|     private SearchBuilder<TemplateDataStoreVO> updateStateSearch; | ||||
|     private SearchBuilder<TemplateDataStoreVO> storeSearch; | ||||
|     private SearchBuilder<TemplateDataStoreVO> cacheSearch; | ||||
| @ -172,7 +174,7 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO | ||||
|         } | ||||
| 
 | ||||
|         int rows = update(dataObj, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             TemplateDataStoreVO dbVol = findByIdIncludingRemoved(dataObj.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(dataObj.toString()); | ||||
| @ -205,7 +207,7 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update objectIndatastore: id=" + dataObj.getId() + ", as there is no such object exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update objectIndatastore: id=" + dataObj.getId() + ", as there is no such object exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
| @ -455,7 +457,7 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO | ||||
|         List<TemplateDataStoreVO> tmpls = listBy(sc); | ||||
|         // create an entry for each template record, but with empty install path since the content is not yet on region-wide store yet | ||||
|         if (tmpls != null) { | ||||
|             logger.info("Duplicate " + tmpls.size() + " template cache store records to region store"); | ||||
|             s_logger.info("Duplicate " + tmpls.size() + " template cache store records to region store"); | ||||
|             for (TemplateDataStoreVO tmpl : tmpls) { | ||||
|                 long templateId = tmpl.getTemplateId(); | ||||
|                 VMTemplateVO template = _tmpltDao.findById(templateId); | ||||
| @ -463,15 +465,15 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO | ||||
|                     throw new CloudRuntimeException("No template is found for template id: " + templateId); | ||||
|                 } | ||||
|                 if (template.getTemplateType() == TemplateType.SYSTEM) { | ||||
|                     logger.info("No need to duplicate system template since it will be automatically downloaded while adding region store"); | ||||
|                     s_logger.info("No need to duplicate system template since it will be automatically downloaded while adding region store"); | ||||
|                     continue; | ||||
|                 } | ||||
|                 TemplateDataStoreVO tmpStore = findByStoreTemplate(storeId, tmpl.getTemplateId()); | ||||
|                 if (tmpStore != null) { | ||||
|                     logger.info("There is already entry for template " + tmpl.getTemplateId() + " on region store " + storeId); | ||||
|                     s_logger.info("There is already entry for template " + tmpl.getTemplateId() + " on region store " + storeId); | ||||
|                     continue; | ||||
|                 } | ||||
|                 logger.info("Persisting an entry for template " + tmpl.getTemplateId() + " on region store " + storeId); | ||||
|                 s_logger.info("Persisting an entry for template " + tmpl.getTemplateId() + " on region store " + storeId); | ||||
|                 TemplateDataStoreVO ts = new TemplateDataStoreVO(); | ||||
|                 ts.setTemplateId(tmpl.getTemplateId()); | ||||
|                 ts.setDataStoreId(storeId); | ||||
| @ -506,7 +508,7 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO | ||||
|         sc.setParameters("destroyed", false); | ||||
|         List<TemplateDataStoreVO> tmpls = listBy(sc); | ||||
|         if (tmpls != null) { | ||||
|             logger.info("Update to cache store role for " + tmpls.size() + " entries in template_store_ref"); | ||||
|             s_logger.info("Update to cache store role for " + tmpls.size() + " entries in template_store_ref"); | ||||
|             for (TemplateDataStoreVO tmpl : tmpls) { | ||||
|                 tmpl.setDataStoreRole(DataStoreRole.ImageCache); | ||||
|                 update(tmpl.getId(), tmpl); | ||||
| @ -535,7 +537,7 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Failed expiring download urls for dcId: " + dcId, e); | ||||
|             s_logger.warn("Failed expiring download urls for dcId: " + dcId, e); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
|  | ||||
| @ -25,6 +25,7 @@ import java.util.Map; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; | ||||
| @ -47,6 +48,7 @@ import com.cloud.utils.db.UpdateBuilder; | ||||
| 
 | ||||
| @Component | ||||
| public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Long> implements VolumeDataStoreDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(VolumeDataStoreDaoImpl.class); | ||||
|     private SearchBuilder<VolumeDataStoreVO> updateStateSearch; | ||||
|     private SearchBuilder<VolumeDataStoreVO> volumeSearch; | ||||
|     private SearchBuilder<VolumeDataStoreVO> storeSearch; | ||||
| @ -139,7 +141,7 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo | ||||
|         } | ||||
| 
 | ||||
|         int rows = update(dataObj, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             VolumeDataStoreVO dbVol = findByIdIncludingRemoved(dataObj.getId()); | ||||
|             if (dbVol != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(dataObj.toString()); | ||||
| @ -172,7 +174,7 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update objectIndatastore: id=" + dataObj.getId() + ", as there is no such object exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update objectIndatastore: id=" + dataObj.getId() + ", as there is no such object exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
| @ -279,14 +281,14 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo | ||||
|         } | ||||
|         // create an entry for each record, but with empty install path since the content is not yet on region-wide store yet | ||||
|         if (vols != null) { | ||||
|             logger.info("Duplicate " + vols.size() + " volume cache store records to region store"); | ||||
|             s_logger.info("Duplicate " + vols.size() + " volume cache store records to region store"); | ||||
|             for (VolumeDataStoreVO vol : vols) { | ||||
|                 VolumeDataStoreVO volStore = findByStoreVolume(storeId, vol.getVolumeId()); | ||||
|                 if (volStore != null) { | ||||
|                     logger.info("There is already entry for volume " + vol.getVolumeId() + " on region store " + storeId); | ||||
|                     s_logger.info("There is already entry for volume " + vol.getVolumeId() + " on region store " + storeId); | ||||
|                     continue; | ||||
|                 } | ||||
|                 logger.info("Persisting an entry for volume " + vol.getVolumeId() + " on region store " + storeId); | ||||
|                 s_logger.info("Persisting an entry for volume " + vol.getVolumeId() + " on region store " + storeId); | ||||
|                 VolumeDataStoreVO vs = new VolumeDataStoreVO(); | ||||
|                 vs.setVolumeId(vol.getVolumeId()); | ||||
|                 vs.setDataStoreId(storeId); | ||||
| @ -335,7 +337,7 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             txn.rollback(); | ||||
|             logger.warn("Failed expiring download urls for dcId: " + dcId, e); | ||||
|             s_logger.warn("Failed expiring download urls for dcId: " + dcId, e); | ||||
|         } | ||||
| 
 | ||||
|     } | ||||
|  | ||||
| @ -20,6 +20,7 @@ package org.apache.cloudstack.storage.volume.db; | ||||
| 
 | ||||
| import java.util.Date; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; | ||||
| @ -35,6 +36,7 @@ import com.cloud.utils.db.UpdateBuilder; | ||||
| 
 | ||||
| @Component | ||||
| public class TemplatePrimaryDataStoreDaoImpl extends GenericDaoBase<TemplatePrimaryDataStoreVO, Long> implements TemplatePrimaryDataStoreDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(TemplatePrimaryDataStoreDaoImpl.class); | ||||
|     protected final SearchBuilder<TemplatePrimaryDataStoreVO> updateSearchBuilder; | ||||
| 
 | ||||
|     public TemplatePrimaryDataStoreDaoImpl() { | ||||
| @ -79,7 +81,7 @@ public class TemplatePrimaryDataStoreDaoImpl extends GenericDaoBase<TemplatePrim | ||||
|         builder.set(vo, "lastUpdated", new Date()); | ||||
| 
 | ||||
|         int rows = update(vo, sc); | ||||
|         if (rows == 0 && logger.isDebugEnabled()) { | ||||
|         if (rows == 0 && s_logger.isDebugEnabled()) { | ||||
|             TemplatePrimaryDataStoreVO template = findByIdIncludingRemoved(vo.getId()); | ||||
|             if (template != null) { | ||||
|                 StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString()); | ||||
| @ -112,7 +114,7 @@ public class TemplatePrimaryDataStoreDaoImpl extends GenericDaoBase<TemplatePrim | ||||
|                     .append("; updatedTime=") | ||||
|                     .append(oldUpdatedTime); | ||||
|             } else { | ||||
|                 logger.debug("Unable to update template: id=" + vo.getId() + ", as there is no such template exists in the database anymore"); | ||||
|                 s_logger.debug("Unable to update template: id=" + vo.getId() + ", as there is no such template exists in the database anymore"); | ||||
|             } | ||||
|         } | ||||
|         return rows > 0; | ||||
|  | ||||
| @ -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 com.cloud.utils.component.ManagerBase; | ||||
| @ -30,6 +31,7 @@ import com.cloud.utils.component.ManagerBase; | ||||
| @Component | ||||
| @Local(value = {ClusterFenceManager.class}) | ||||
| public class ClusterFenceManagerImpl extends ManagerBase implements ClusterFenceManager, ClusterManagerListener { | ||||
|     private static final Logger s_logger = Logger.getLogger(ClusterFenceManagerImpl.class); | ||||
| 
 | ||||
|     @Inject | ||||
|     ClusterManager _clusterMgr; | ||||
| @ -50,7 +52,7 @@ public class ClusterFenceManagerImpl extends ManagerBase implements ClusterFence | ||||
| 
 | ||||
|     @Override | ||||
|     public void onManagementNodeIsolated() { | ||||
|         logger.error("Received node isolation notification, will perform self-fencing and shut myself down"); | ||||
|         s_logger.error("Received node isolation notification, will perform self-fencing and shut myself down"); | ||||
|         System.exit(SELF_FENCING_EXIT_CODE); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -46,6 +46,7 @@ import org.apache.cloudstack.framework.config.ConfigKey; | ||||
| import org.apache.cloudstack.framework.config.Configurable; | ||||
| import org.apache.cloudstack.managed.context.ManagedContextRunnable; | ||||
| import org.apache.cloudstack.utils.identity.ManagementServerNode; | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.cluster.dao.ManagementServerHostDao; | ||||
| import com.cloud.cluster.dao.ManagementServerHostPeerDao; | ||||
| @ -69,6 +70,7 @@ import com.cloud.utils.net.NetUtils; | ||||
| 
 | ||||
| @Local(value = {ClusterManager.class}) | ||||
| public class ClusterManagerImpl extends ManagerBase implements ClusterManager, Configurable { | ||||
|     private static final Logger s_logger = Logger.getLogger(ClusterManagerImpl.class); | ||||
| 
 | ||||
|     private static final int EXECUTOR_SHUTDOWN_TIMEOUT = 1000; // 1 second | ||||
|     private static final int DEFAULT_OUTGOING_WORKERS = 5; | ||||
| @ -165,7 +167,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         } | ||||
| 
 | ||||
|         for (final ClusterServiceRequestPdu pdu : candidates) { | ||||
|             logger.warn("Cancel cluster request PDU to peer: " + strPeer + ", pdu: " + pdu.getJsonPackage()); | ||||
|             s_logger.warn("Cancel cluster request PDU to peer: " + strPeer + ", pdu: " + pdu.getJsonPackage()); | ||||
|             synchronized (pdu) { | ||||
|                 pdu.notifyAll(); | ||||
|             } | ||||
| @ -249,13 +251,13 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                     try { | ||||
|                         peerService = getPeerService(pdu.getDestPeer()); | ||||
|                     } catch (final RemoteException e) { | ||||
|                         logger.error("Unable to get cluster service on peer : " + pdu.getDestPeer()); | ||||
|                         s_logger.error("Unable to get cluster service on peer : " + pdu.getDestPeer()); | ||||
|                     } | ||||
| 
 | ||||
|                     if (peerService != null) { | ||||
|                         try { | ||||
|                             if (logger.isDebugEnabled()) { | ||||
|                                 logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + ". agent: " + pdu.getAgentId() + ", pdu seq: " + | ||||
|                             if (s_logger.isDebugEnabled()) { | ||||
|                                 s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + ". agent: " + pdu.getAgentId() + ", pdu seq: " + | ||||
|                                         pdu.getSequenceId() + ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage()); | ||||
|                             } | ||||
| 
 | ||||
| @ -265,8 +267,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                             final String strResult = peerService.execute(pdu); | ||||
|                             profiler.stop(); | ||||
| 
 | ||||
|                             if (logger.isDebugEnabled()) { | ||||
|                                 logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + " completed. time: " + | ||||
|                             if (s_logger.isDebugEnabled()) { | ||||
|                                 s_logger.debug("Cluster PDU " + getSelfPeerName() + " -> " + pdu.getDestPeer() + " completed. time: " + | ||||
|                                         profiler.getDurationInMillis() + "ms. agent: " + pdu.getAgentId() + ", pdu seq: " + pdu.getSequenceId() + | ||||
|                                         ", pdu ack seq: " + pdu.getAckSequenceId() + ", json: " + pdu.getJsonPackage()); | ||||
|                             } | ||||
| @ -277,15 +279,15 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
| 
 | ||||
|                         } catch (final RemoteException e) { | ||||
|                             invalidatePeerService(pdu.getDestPeer()); | ||||
|                             if (logger.isInfoEnabled()) { | ||||
|                                 logger.info("Exception on remote execution, peer: " + pdu.getDestPeer() + ", iteration: " + i + ", exception message :" + | ||||
|                             if (s_logger.isInfoEnabled()) { | ||||
|                                 s_logger.info("Exception on remote execution, peer: " + pdu.getDestPeer() + ", iteration: " + i + ", exception message :" + | ||||
|                                         e.getMessage()); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } catch (final Throwable e) { | ||||
|                 logger.error("Unexcpeted exception: ", e); | ||||
|                 s_logger.error("Unexcpeted exception: ", e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -309,7 +311,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                                     requestPdu.notifyAll(); | ||||
|                                 } | ||||
|                             } else { | ||||
|                                 logger.warn("Original request has already been cancelled. pdu: " + pdu.getJsonPackage()); | ||||
|                                 s_logger.warn("Original request has already been cancelled. pdu: " + pdu.getJsonPackage()); | ||||
|                             } | ||||
|                         } else { | ||||
|                             String result = _dispatcher.dispatch(pdu); | ||||
| @ -331,7 +333,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                     } | ||||
|                 }); | ||||
|             } catch (final Throwable e) { | ||||
|                 logger.error("Unexcpeted exception: ", e); | ||||
|                 s_logger.error("Unexcpeted exception: ", e); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -364,12 +366,12 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                 continue; // Skip myself. | ||||
|             } | ||||
|             try { | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Forwarding " + cmds + " to " + peer.getMsid()); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Forwarding " + cmds + " to " + peer.getMsid()); | ||||
|                 } | ||||
|                 executeAsync(peerName, agentId, cmds, true); | ||||
|             } catch (final Exception e) { | ||||
|                 logger.warn("Caught exception while talkign to " + peer.getMsid()); | ||||
|                 s_logger.warn("Caught exception while talkign to " + peer.getMsid()); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| @ -386,8 +388,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
| 
 | ||||
|     @Override | ||||
|     public String execute(final String strPeer, final long agentId, final String cmds, final boolean stopOnError) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug(getSelfPeerName() + " -> " + strPeer + "." + agentId + " " + cmds); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug(getSelfPeerName() + " -> " + strPeer + "." + agentId + " " + cmds); | ||||
|         } | ||||
| 
 | ||||
|         final ClusterServiceRequestPdu pdu = new ClusterServiceRequestPdu(); | ||||
| @ -406,8 +408,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug(getSelfPeerName() + " -> " + strPeer + "." + agentId + " completed. result: " + pdu.getResponseResult()); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug(getSelfPeerName() + " -> " + strPeer + "." + agentId + " completed. result: " + pdu.getResponseResult()); | ||||
|         } | ||||
| 
 | ||||
|         if (pdu.getResponseResult() != null && pdu.getResponseResult().length() > 0) { | ||||
| @ -436,7 +438,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         // Note : we don't check duplicates | ||||
|         synchronized (_listeners) { | ||||
| 
 | ||||
|             logger.info("register cluster listener " + listener.getClass()); | ||||
|             s_logger.info("register cluster listener " + listener.getClass()); | ||||
| 
 | ||||
|             _listeners.add(listener); | ||||
|         } | ||||
| @ -445,18 +447,18 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|     @Override | ||||
|     public void unregisterListener(final ClusterManagerListener listener) { | ||||
|         synchronized (_listeners) { | ||||
|             logger.info("unregister cluster listener " + listener.getClass()); | ||||
|             s_logger.info("unregister cluster listener " + listener.getClass()); | ||||
| 
 | ||||
|             _listeners.remove(listener); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void notifyNodeJoined(final List<ManagementServerHostVO> nodeList) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Notify management server node join to listeners."); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Notify management server node join to listeners."); | ||||
| 
 | ||||
|             for (final ManagementServerHostVO mshost : nodeList) { | ||||
|                 logger.debug("Joining node, IP: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid()); | ||||
|                 s_logger.debug("Joining node, IP: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid()); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -470,13 +472,13 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|     } | ||||
| 
 | ||||
|     public void notifyNodeLeft(final List<ManagementServerHostVO> nodeList) { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Notify management server node left to listeners."); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Notify management server node left to listeners."); | ||||
|         } | ||||
| 
 | ||||
|         for (final ManagementServerHostVO mshost : nodeList) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Leaving node, IP: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid()); | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Leaving node, IP: " + mshost.getServiceIP() + ", msid: " + mshost.getMsid()); | ||||
|             } | ||||
|             cancelClusterRequestToPeer(String.valueOf(mshost.getMsid())); | ||||
|         } | ||||
| @ -491,8 +493,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|     } | ||||
| 
 | ||||
|     public void notifyNodeIsolated() { | ||||
|         if (logger.isDebugEnabled()) { | ||||
|             logger.debug("Notify management server node isolation to listeners"); | ||||
|         if (s_logger.isDebugEnabled()) { | ||||
|             s_logger.debug("Notify management server node isolation to listeners"); | ||||
|         } | ||||
| 
 | ||||
|         synchronized (_listeners) { | ||||
| @ -547,16 +549,16 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
| 
 | ||||
|                         profilerHeartbeatUpdate.start(); | ||||
|                         txn.transitToUserManagedConnection(getHeartbeatConnection()); | ||||
|                         if (logger.isTraceEnabled()) { | ||||
|                             logger.trace("Cluster manager heartbeat update, id:" + _mshostId); | ||||
|                         if (s_logger.isTraceEnabled()) { | ||||
|                             s_logger.trace("Cluster manager heartbeat update, id:" + _mshostId); | ||||
|                         } | ||||
| 
 | ||||
|                         _mshostDao.update(_mshostId, _runId, DateUtil.currentGMTTime()); | ||||
|                         profilerHeartbeatUpdate.stop(); | ||||
| 
 | ||||
|                         profilerPeerScan.start(); | ||||
|                         if (logger.isTraceEnabled()) { | ||||
|                             logger.trace("Cluster manager peer-scan, id:" + _mshostId); | ||||
|                         if (s_logger.isTraceEnabled()) { | ||||
|                             s_logger.trace("Cluster manager peer-scan, id:" + _mshostId); | ||||
|                         } | ||||
| 
 | ||||
|                         if (!_peerScanInited) { | ||||
| @ -571,18 +573,18 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                         profiler.stop(); | ||||
| 
 | ||||
|                         if (profiler.getDurationInMillis() >= HeartbeatInterval.value()) { | ||||
|                             if (logger.isDebugEnabled()) { | ||||
|                                 logger.debug("Management server heartbeat takes too long to finish. profiler: " + profiler.toString() + ", profilerHeartbeatUpdate: " + | ||||
|                             if (s_logger.isDebugEnabled()) { | ||||
|                                 s_logger.debug("Management server heartbeat takes too long to finish. profiler: " + profiler.toString() + ", profilerHeartbeatUpdate: " + | ||||
|                                         profilerHeartbeatUpdate.toString() + ", profilerPeerScan: " + profilerPeerScan.toString()); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
|                 } catch (final CloudRuntimeException e) { | ||||
|                     logger.error("Runtime DB exception ", e.getCause()); | ||||
|                     s_logger.error("Runtime DB exception ", e.getCause()); | ||||
| 
 | ||||
|                     if (e.getCause() instanceof ClusterInvalidSessionException) { | ||||
|                         logger.error("Invalid cluster session found, fence it"); | ||||
|                         s_logger.error("Invalid cluster session found, fence it"); | ||||
|                         queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeIsolated)); | ||||
|                     } | ||||
| 
 | ||||
| @ -592,7 +594,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                 } catch (final ActiveFencingException e) { | ||||
|                     queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeIsolated)); | ||||
|                 } catch (final Throwable e) { | ||||
|                     logger.error("Unexpected exception in cluster heartbeat", e); | ||||
|                     s_logger.error("Unexpected exception in cluster heartbeat", e); | ||||
|                     if (isRootCauseConnectionRelated(e.getCause())) { | ||||
|                         invalidHeartbeatConnection(); | ||||
|                     } | ||||
| @ -631,7 +633,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|             if (conn != null) { | ||||
|                 _heartbeatConnection.reset(conn); | ||||
|             } else { | ||||
|                 logger.error("DB communication problem detected, fence it"); | ||||
|                 s_logger.error("DB communication problem detected, fence it"); | ||||
|                 queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeIsolated)); | ||||
|             } | ||||
|             // The stand-alone connection does not have to be closed here because there will be another reference to it. | ||||
| @ -664,11 +666,11 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
| 
 | ||||
|                                     profiler.stop(); | ||||
|                                     if (profiler.getDurationInMillis() > 1000) { | ||||
|                                         if (logger.isDebugEnabled()) { | ||||
|                                             logger.debug("Notifying management server join event took " + profiler.getDurationInMillis() + " ms"); | ||||
|                                         if (s_logger.isDebugEnabled()) { | ||||
|                                             s_logger.debug("Notifying management server join event took " + profiler.getDurationInMillis() + " ms"); | ||||
|                                         } | ||||
|                                     } else { | ||||
|                                         logger.warn("Notifying management server join event took " + profiler.getDurationInMillis() + " ms"); | ||||
|                                         s_logger.warn("Notifying management server join event took " + profiler.getDurationInMillis() + " ms"); | ||||
|                                     } | ||||
|                                 } | ||||
|                                 break; | ||||
| @ -682,11 +684,11 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
| 
 | ||||
|                                     profiler.stop(); | ||||
|                                     if (profiler.getDurationInMillis() > 1000) { | ||||
|                                         if (logger.isDebugEnabled()) { | ||||
|                                             logger.debug("Notifying management server leave event took " + profiler.getDurationInMillis() + " ms"); | ||||
|                                         if (s_logger.isDebugEnabled()) { | ||||
|                                             s_logger.debug("Notifying management server leave event took " + profiler.getDurationInMillis() + " ms"); | ||||
|                                         } | ||||
|                                     } else { | ||||
|                                         logger.warn("Notifying management server leave event took " + profiler.getDurationInMillis() + " ms"); | ||||
|                                         s_logger.warn("Notifying management server leave event took " + profiler.getDurationInMillis() + " ms"); | ||||
|                                     } | ||||
|                                 } | ||||
|                                 break; | ||||
| @ -701,7 +703,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                             } | ||||
| 
 | ||||
|                         } catch (final Throwable e) { | ||||
|                             logger.warn("Unexpected exception during cluster notification. ", e); | ||||
|                             s_logger.warn("Unexpected exception during cluster notification. ", e); | ||||
|                         } | ||||
|                     } | ||||
| 
 | ||||
| @ -768,18 +770,18 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         if (orphanList.size() > 0) { | ||||
|             for (final Long orphanMsid : orphanList) { | ||||
|                 // construct fake ManagementServerHostVO based on orphan MSID | ||||
|                 logger.info("Add orphan management server msid found in host table to initial clustering notification, orphan msid: " + orphanMsid); | ||||
|                 s_logger.info("Add orphan management server msid found in host table to initial clustering notification, orphan msid: " + orphanMsid); | ||||
|                 inactiveList.add(new ManagementServerHostVO(orphanMsid, 0, "orphan", 0, new Date())); | ||||
|             } | ||||
|         } else { | ||||
|             logger.info("We are good, no orphan management server msid in host table is found"); | ||||
|             s_logger.info("We are good, no orphan management server msid in host table is found"); | ||||
|         } | ||||
| 
 | ||||
|         if (inactiveList.size() > 0) { | ||||
|             if (logger.isInfoEnabled()) { | ||||
|                 logger.info("Found " + inactiveList.size() + " inactive management server node based on timestamp"); | ||||
|             if (s_logger.isInfoEnabled()) { | ||||
|                 s_logger.info("Found " + inactiveList.size() + " inactive management server node based on timestamp"); | ||||
|                 for (final ManagementServerHostVO host : inactiveList) { | ||||
|                     logger.info("management server node msid: " + host.getMsid() + ", name: " + host.getName() + ", service ip: " + host.getServiceIP() + | ||||
|                     s_logger.info("management server node msid: " + host.getMsid() + ", name: " + host.getName() + ", service ip: " + host.getServiceIP() + | ||||
|                             ", version: " + host.getVersion()); | ||||
|                 } | ||||
|             } | ||||
| @ -787,7 +789,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|             final List<ManagementServerHostVO> downHostList = new ArrayList<ManagementServerHostVO>(); | ||||
|             for (final ManagementServerHostVO host : inactiveList) { | ||||
|                 if (!pingManagementNode(host)) { | ||||
|                     logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and also not pingable"); | ||||
|                     s_logger.warn("Management node " + host.getId() + " is detected inactive by timestamp and also not pingable"); | ||||
|                     downHostList.add(host); | ||||
|                 } | ||||
|             } | ||||
| @ -796,7 +798,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                 queueNotification(new ClusterManagerMessage(ClusterManagerMessage.MessageType.nodeRemoved, downHostList)); | ||||
|             } | ||||
|         } else { | ||||
|             logger.info("No inactive management server node found"); | ||||
|             s_logger.info("No inactive management server node found"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| @ -821,7 +823,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|             if (_mshostPeerDao.countStateSeenInPeers(_mshostId, _runId, ManagementServerHost.State.Down) > 0) { | ||||
|                 final String msg = | ||||
|                         "We have detected that at least one management server peer reports that this management server is down, perform active fencing to avoid split-brain situation"; | ||||
|                 logger.error(msg); | ||||
|                 s_logger.error(msg); | ||||
|                 throw new ActiveFencingException(msg); | ||||
|             } | ||||
| 
 | ||||
| @ -831,24 +833,24 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                 final ManagementServerHostVO current = getInListById(entry.getKey(), currentList); | ||||
|                 if (current == null) { | ||||
|                     if (entry.getKey().longValue() != _mshostId.longValue()) { | ||||
|                         if (logger.isDebugEnabled()) { | ||||
|                             logger.debug("Detected management node left, id:" + entry.getKey() + ", nodeIP:" + entry.getValue().getServiceIP()); | ||||
|                         if (s_logger.isDebugEnabled()) { | ||||
|                             s_logger.debug("Detected management node left, id:" + entry.getKey() + ", nodeIP:" + entry.getValue().getServiceIP()); | ||||
|                         } | ||||
|                         removedNodeList.add(entry.getValue()); | ||||
|                     } | ||||
|                 } else { | ||||
|                     if (current.getRunid() == 0) { | ||||
|                         if (entry.getKey().longValue() != _mshostId.longValue()) { | ||||
|                             if (logger.isDebugEnabled()) { | ||||
|                                 logger.debug("Detected management node left because of invalidated session, id:" + entry.getKey() + ", nodeIP:" + | ||||
|                             if (s_logger.isDebugEnabled()) { | ||||
|                                 s_logger.debug("Detected management node left because of invalidated session, id:" + entry.getKey() + ", nodeIP:" + | ||||
|                                         entry.getValue().getServiceIP()); | ||||
|                             } | ||||
|                             invalidatedNodeList.add(entry.getValue()); | ||||
|                         } | ||||
|                     } else { | ||||
|                         if (entry.getValue().getRunid() != current.getRunid()) { | ||||
|                             if (logger.isDebugEnabled()) { | ||||
|                                 logger.debug("Detected management node left and rejoined quickly, id:" + entry.getKey() + ", nodeIP:" + entry.getValue().getServiceIP()); | ||||
|                             if (s_logger.isDebugEnabled()) { | ||||
|                                 s_logger.debug("Detected management node left and rejoined quickly, id:" + entry.getKey() + ", nodeIP:" + entry.getValue().getServiceIP()); | ||||
|                             } | ||||
| 
 | ||||
|                             entry.getValue().setRunid(current.getRunid()); | ||||
| @ -868,7 +870,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                 try { | ||||
|                     JmxUtil.unregisterMBean("ClusterManager", "Node " + mshost.getId()); | ||||
|                 } catch (final Exception e) { | ||||
|                     logger.warn("Unable to deregiester cluster node from JMX monitoring due to exception " + e.toString()); | ||||
|                     s_logger.warn("Unable to deregiester cluster node from JMX monitoring due to exception " + e.toString()); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
| @ -883,15 +885,15 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         while (it.hasNext()) { | ||||
|             final ManagementServerHostVO mshost = it.next(); | ||||
|             if (!pingManagementNode(mshost)) { | ||||
|                 logger.warn("Management node " + mshost.getId() + " is detected inactive by timestamp and also not pingable"); | ||||
|                 s_logger.warn("Management node " + mshost.getId() + " is detected inactive by timestamp and also not pingable"); | ||||
|                 _activePeers.remove(mshost.getId()); | ||||
|                 try { | ||||
|                     JmxUtil.unregisterMBean("ClusterManager", "Node " + mshost.getId()); | ||||
|                 } catch (final Exception e) { | ||||
|                     logger.warn("Unable to deregiester cluster node from JMX monitoring due to exception " + e.toString()); | ||||
|                     s_logger.warn("Unable to deregiester cluster node from JMX monitoring due to exception " + e.toString()); | ||||
|                 } | ||||
|             } else { | ||||
|                 logger.info("Management node " + mshost.getId() + " is detected inactive by timestamp but is pingable"); | ||||
|                 s_logger.info("Management node " + mshost.getId() + " is detected inactive by timestamp but is pingable"); | ||||
|                 it.remove(); | ||||
|             } | ||||
|         } | ||||
| @ -906,15 +908,15 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|             if (!_activePeers.containsKey(mshost.getId())) { | ||||
|                 _activePeers.put(mshost.getId(), mshost); | ||||
| 
 | ||||
|                 if (logger.isDebugEnabled()) { | ||||
|                     logger.debug("Detected management node joined, id:" + mshost.getId() + ", nodeIP:" + mshost.getServiceIP()); | ||||
|                 if (s_logger.isDebugEnabled()) { | ||||
|                     s_logger.debug("Detected management node joined, id:" + mshost.getId() + ", nodeIP:" + mshost.getServiceIP()); | ||||
|                 } | ||||
|                 newNodeList.add(mshost); | ||||
| 
 | ||||
|                 try { | ||||
|                     JmxUtil.registerMBean("ClusterManager", "Node " + mshost.getId(), new ClusterManagerMBeanImpl(this, mshost)); | ||||
|                 } catch (final Exception e) { | ||||
|                     logger.warn("Unable to regiester cluster node into JMX monitoring due to exception " + ExceptionUtil.toString(e)); | ||||
|                     s_logger.warn("Unable to regiester cluster node into JMX monitoring due to exception " + ExceptionUtil.toString(e)); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -926,8 +928,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         profiler.stop(); | ||||
| 
 | ||||
|         if (profiler.getDurationInMillis() >= HeartbeatInterval.value()) { | ||||
|             if (logger.isDebugEnabled()) { | ||||
|                 logger.debug("Peer scan takes too long to finish. profiler: " + profiler.toString() + ", profilerQueryActiveList: " + | ||||
|             if (s_logger.isDebugEnabled()) { | ||||
|                 s_logger.debug("Peer scan takes too long to finish. profiler: " + profiler.toString() + ", profilerQueryActiveList: " + | ||||
|                         profilerQueryActiveList.toString() + ", profilerSyncClusterInfo: " + profilerSyncClusterInfo.toString() + ", profilerInvalidatedNodeList: " + | ||||
|                         profilerInvalidatedNodeList.toString() + ", profilerRemovedList: " + profilerRemovedList.toString()); | ||||
|             } | ||||
| @ -946,8 +948,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|     @Override | ||||
|     @DB | ||||
|     public boolean start() { | ||||
|         if (logger.isInfoEnabled()) { | ||||
|             logger.info("Starting Cluster manager, msid : " + _msId); | ||||
|         if (s_logger.isInfoEnabled()) { | ||||
|             s_logger.info("Starting Cluster manager, msid : " + _msId); | ||||
|         } | ||||
| 
 | ||||
|         final ManagementServerHostVO mshost = Transaction.execute(new TransactionCallback<ManagementServerHostVO>() { | ||||
| @ -971,14 +973,14 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                     mshost.setAlertCount(0); | ||||
|                     mshost.setState(ManagementServerHost.State.Up); | ||||
|                     _mshostDao.persist(mshost); | ||||
|                     if (logger.isInfoEnabled()) { | ||||
|                         logger.info("New instance of management server msid " + _msId + ", runId " + _runId + " is being started"); | ||||
|                     if (s_logger.isInfoEnabled()) { | ||||
|                         s_logger.info("New instance of management server msid " + _msId + ", runId " + _runId + " is being started"); | ||||
|                     } | ||||
|                 } else { | ||||
|                     _mshostDao.update(mshost.getId(), _runId, NetUtils.getHostName(), version, _clusterNodeIP, _currentServiceAdapter.getServicePort(), | ||||
|                             DateUtil.currentGMTTime()); | ||||
|                     if (logger.isInfoEnabled()) { | ||||
|                         logger.info("Management server " + _msId + ", runId " + _runId + " is being started"); | ||||
|                     if (s_logger.isInfoEnabled()) { | ||||
|                         s_logger.info("Management server " + _msId + ", runId " + _runId + " is being started"); | ||||
|                     } | ||||
|                 } | ||||
| 
 | ||||
| @ -987,8 +989,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         }); | ||||
| 
 | ||||
|         _mshostId = mshost.getId(); | ||||
|         if (logger.isInfoEnabled()) { | ||||
|             logger.info("Management server (host id : " + _mshostId + ") is being started at " + _clusterNodeIP + ":" + _currentServiceAdapter.getServicePort()); | ||||
|         if (s_logger.isInfoEnabled()) { | ||||
|             s_logger.info("Management server (host id : " + _mshostId + ") is being started at " + _clusterNodeIP + ":" + _currentServiceAdapter.getServicePort()); | ||||
|         } | ||||
| 
 | ||||
|         _mshostPeerDao.clearPeerInfo(_mshostId); | ||||
| @ -997,8 +999,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         _heartbeatScheduler.scheduleAtFixedRate(getHeartbeatTask(), HeartbeatInterval.value(), HeartbeatInterval.value(), TimeUnit.MILLISECONDS); | ||||
|         _notificationExecutor.submit(getNotificationTask()); | ||||
| 
 | ||||
|         if (logger.isInfoEnabled()) { | ||||
|             logger.info("Cluster manager was started successfully"); | ||||
|         if (s_logger.isInfoEnabled()) { | ||||
|             s_logger.info("Cluster manager was started successfully"); | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
| @ -1007,8 +1009,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|     @Override | ||||
|     @DB | ||||
|     public boolean stop() { | ||||
|         if (logger.isInfoEnabled()) { | ||||
|             logger.info("Stopping Cluster manager, msid : " + _msId); | ||||
|         if (s_logger.isInfoEnabled()) { | ||||
|             s_logger.info("Stopping Cluster manager, msid : " + _msId); | ||||
|         } | ||||
| 
 | ||||
|         if (_mshostId != null) { | ||||
| @ -1026,8 +1028,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         } catch (final InterruptedException e) { | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isInfoEnabled()) { | ||||
|             logger.info("Cluster manager is stopped"); | ||||
|         if (s_logger.isInfoEnabled()) { | ||||
|             s_logger.info("Cluster manager is stopped"); | ||||
|         } | ||||
| 
 | ||||
|         return true; | ||||
| @ -1035,8 +1037,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
| 
 | ||||
|     @Override | ||||
|     public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException { | ||||
|         if (logger.isInfoEnabled()) { | ||||
|             logger.info("Start configuring cluster manager : " + name); | ||||
|         if (s_logger.isInfoEnabled()) { | ||||
|             s_logger.info("Start configuring cluster manager : " + name); | ||||
|         } | ||||
| 
 | ||||
|         final Properties dbProps = DbProperties.getDbProperties(); | ||||
| @ -1046,8 +1048,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         } | ||||
|         _clusterNodeIP = _clusterNodeIP.trim(); | ||||
| 
 | ||||
|         if (logger.isInfoEnabled()) { | ||||
|             logger.info("Cluster node IP : " + _clusterNodeIP); | ||||
|         if (s_logger.isInfoEnabled()) { | ||||
|             s_logger.info("Cluster node IP : " + _clusterNodeIP); | ||||
|         } | ||||
| 
 | ||||
|         if (!NetUtils.isLocalAddress(_clusterNodeIP)) { | ||||
| @ -1072,8 +1074,8 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
| 
 | ||||
|         checkConflicts(); | ||||
| 
 | ||||
|         if (logger.isInfoEnabled()) { | ||||
|             logger.info("Cluster manager is configured."); | ||||
|         if (s_logger.isInfoEnabled()) { | ||||
|             s_logger.info("Cluster manager is configured."); | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
| @ -1131,7 +1133,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
| 
 | ||||
|         final String targetIp = mshost.getServiceIP(); | ||||
|         if ("127.0.0.1".equals(targetIp) || "0.0.0.0".equals(targetIp)) { | ||||
|             logger.info("ping management node cluster service can not be performed on self"); | ||||
|             s_logger.info("ping management node cluster service can not be performed on self"); | ||||
|             return false; | ||||
|         } | ||||
| 
 | ||||
| @ -1139,7 +1141,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|         while (--retry > 0) { | ||||
|             SocketChannel sch = null; | ||||
|             try { | ||||
|                 logger.info("Trying to connect to " + targetIp); | ||||
|                 s_logger.info("Trying to connect to " + targetIp); | ||||
|                 sch = SocketChannel.open(); | ||||
|                 sch.configureBlocking(true); | ||||
|                 sch.socket().setSoTimeout(5000); | ||||
| @ -1149,7 +1151,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                 return true; | ||||
|             } catch (final IOException e) { | ||||
|                 if (e instanceof ConnectException) { | ||||
|                     logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " due to ConnectException", e); | ||||
|                     s_logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " due to ConnectException", e); | ||||
|                     return false; | ||||
|                 } | ||||
|             } finally { | ||||
| @ -1167,7 +1169,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " after retries"); | ||||
|         s_logger.error("Unable to ping management server at " + targetIp + ":" + mshost.getServicePort() + " after retries"); | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
| @ -1184,25 +1186,25 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C | ||||
|                 if ("127.0.0.1".equals(_clusterNodeIP)) { | ||||
|                     if (pingManagementNode(peer.getMsid())) { | ||||
|                         final String msg = "Detected another management node with localhost IP is already running, please check your cluster configuration"; | ||||
|                         logger.error(msg); | ||||
|                         s_logger.error(msg); | ||||
|                         throw new ConfigurationException(msg); | ||||
|                     } else { | ||||
|                         final String msg = | ||||
|                                 "Detected another management node with localhost IP is considered as running in DB, however it is not pingable, we will continue cluster initialization with this management server node"; | ||||
|                         logger.info(msg); | ||||
|                         s_logger.info(msg); | ||||
|                     } | ||||
|                 } else { | ||||
|                     if (pingManagementNode(peer.getMsid())) { | ||||
|                         final String msg = | ||||
|                                 "Detected that another management node with the same IP " + peer.getServiceIP() + | ||||
|                                 " is already running, please check your cluster configuration"; | ||||
|                         logger.error(msg); | ||||
|                         s_logger.error(msg); | ||||
|                         throw new ConfigurationException(msg); | ||||
|                     } else { | ||||
|                         final String msg = | ||||
|                                 "Detected that another management node with the same IP " + peer.getServiceIP() + | ||||
|                                 " is considered as running in DB, however it is not pingable, we will continue cluster initialization with this management server node"; | ||||
|                         logger.info(msg); | ||||
|                         s_logger.info(msg); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @ -23,6 +23,7 @@ import java.util.Properties; | ||||
| import javax.inject.Inject; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| import org.apache.cloudstack.framework.config.ConfigDepot; | ||||
| 
 | ||||
| import com.cloud.cluster.dao.ManagementServerHostDao; | ||||
| @ -33,6 +34,7 @@ import com.cloud.utils.db.DbProperties; | ||||
| 
 | ||||
| public class ClusterServiceServletAdapter extends AdapterBase implements ClusterServiceAdapter { | ||||
| 
 | ||||
|     private static final Logger s_logger = Logger.getLogger(ClusterServiceServletAdapter.class); | ||||
|     private static final int DEFAULT_SERVICE_PORT = 9090; | ||||
|     private static final int DEFAULT_REQUEST_TIMEOUT = 300;            // 300 seconds | ||||
| 
 | ||||
| @ -57,7 +59,7 @@ public class ClusterServiceServletAdapter extends AdapterBase implements Cluster | ||||
|         try { | ||||
|             init(); | ||||
|         } catch (ConfigurationException e) { | ||||
|             logger.error("Unable to init ClusterServiceServletAdapter"); | ||||
|             s_logger.error("Unable to init ClusterServiceServletAdapter"); | ||||
|             throw new RemoteException("Unable to init ClusterServiceServletAdapter"); | ||||
|         } | ||||
| 
 | ||||
| @ -73,7 +75,7 @@ public class ClusterServiceServletAdapter extends AdapterBase implements Cluster | ||||
|         try { | ||||
|             init(); | ||||
|         } catch (ConfigurationException e) { | ||||
|             logger.error("Unable to init ClusterServiceServletAdapter"); | ||||
|             s_logger.error("Unable to init ClusterServiceServletAdapter"); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
| @ -124,7 +126,7 @@ public class ClusterServiceServletAdapter extends AdapterBase implements Cluster | ||||
|         Properties dbProps = DbProperties.getDbProperties(); | ||||
| 
 | ||||
|         _clusterServicePort = NumbersUtil.parseInt(dbProps.getProperty("cluster.servlet.port"), DEFAULT_SERVICE_PORT); | ||||
|         if (logger.isInfoEnabled()) | ||||
|             logger.info("Cluster servlet port : " + _clusterServicePort); | ||||
|         if (s_logger.isInfoEnabled()) | ||||
|             s_logger.info("Cluster servlet port : " + _clusterServicePort); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -26,6 +26,7 @@ import java.util.TimeZone; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.cluster.ClusterInvalidSessionException; | ||||
| import com.cloud.cluster.ManagementServerHost; | ||||
| @ -42,6 +43,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| 
 | ||||
| @Local(value = {ManagementServerHostDao.class}) | ||||
| public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServerHostVO, Long> implements ManagementServerHostDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(ManagementServerHostDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<ManagementServerHostVO> MsIdSearch; | ||||
|     private final SearchBuilder<ManagementServerHostVO> ActiveSearch; | ||||
| @ -98,7 +100,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer | ||||
|             pstmt.executeUpdate(); | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unexpected exception, ", e); | ||||
|             s_logger.warn("Unexpected exception, ", e); | ||||
|             throw new RuntimeException(e.getMessage(), e); | ||||
|         } | ||||
|     } | ||||
| @ -118,7 +120,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer | ||||
|             txn.commit(); | ||||
|             return true; | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unexpected exception, ", e); | ||||
|             s_logger.warn("Unexpected exception, ", e); | ||||
|             throw new RuntimeException(e.getMessage(), e); | ||||
|         } | ||||
|     } | ||||
| @ -140,11 +142,11 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer | ||||
|             txn.commit(); | ||||
| 
 | ||||
|             if (count < 1) { | ||||
|                 logger.info("Invalid cluster session detected, runId " + runid + " is no longer valid"); | ||||
|                 s_logger.info("Invalid cluster session detected, runId " + runid + " is no longer valid"); | ||||
|                 throw new CloudRuntimeException("Invalid cluster session detected, runId " + runid + " is no longer valid", new ClusterInvalidSessionException("runId " + runid + " is no longer valid")); | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unexpected exception, ", e); | ||||
|             s_logger.warn("Unexpected exception, ", e); | ||||
|             throw new RuntimeException(e.getMessage(), e); | ||||
|         } | ||||
|     } | ||||
| @ -180,7 +182,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer | ||||
|             changedRows = pstmt.executeUpdate(); | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unexpected exception, ", e); | ||||
|             s_logger.warn("Unexpected exception, ", e); | ||||
|             throw new RuntimeException(e.getMessage(), e); | ||||
|         } | ||||
| 
 | ||||
| @ -221,7 +223,7 @@ public class ManagementServerHostDaoImpl extends GenericDaoBase<ManagementServer | ||||
|             int count = pstmt.executeUpdate(); | ||||
| 
 | ||||
|             if (count < 1) { | ||||
|                 logger.info("Invalid cluster session detected, runId " + runId + " is no longer valid"); | ||||
|                 s_logger.info("Invalid cluster session detected, runId " + runId + " is no longer valid"); | ||||
|                 throw new CloudRuntimeException("Invalid cluster session detected, runId " + runId + " is no longer valid", new ClusterInvalidSessionException("runId " + runId + " is no longer valid")); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|  | ||||
| @ -20,6 +20,7 @@ import java.util.List; | ||||
| 
 | ||||
| import javax.ejb.Local; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.cluster.ManagementServerHost; | ||||
| import com.cloud.cluster.ManagementServerHostPeerVO; | ||||
| @ -31,6 +32,7 @@ import com.cloud.utils.db.TransactionLegacy; | ||||
| 
 | ||||
| @Local(value = {ManagementServerHostPeerDao.class}) | ||||
| public class ManagementServerHostPeerDaoImpl extends GenericDaoBase<ManagementServerHostPeerVO, Long> implements ManagementServerHostPeerDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(ManagementServerHostPeerDaoImpl.class); | ||||
| 
 | ||||
|     private final SearchBuilder<ManagementServerHostPeerVO> ClearPeerSearch; | ||||
|     private final SearchBuilder<ManagementServerHostPeerVO> FindForUpdateSearch; | ||||
| @ -85,7 +87,7 @@ public class ManagementServerHostPeerDaoImpl extends GenericDaoBase<ManagementSe | ||||
|             } | ||||
|             txn.commit(); | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unexpected exception, ", e); | ||||
|             s_logger.warn("Unexpected exception, ", e); | ||||
|             txn.rollback(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -26,6 +26,7 @@ import javax.ejb.Local; | ||||
| import javax.naming.ConfigurationException; | ||||
| 
 | ||||
| import org.apache.cloudstack.framework.config.impl.ConfigurationVO; | ||||
| import org.apache.log4j.Logger; | ||||
| import org.springframework.stereotype.Component; | ||||
| 
 | ||||
| import com.cloud.utils.component.ComponentLifecycle; | ||||
| @ -40,6 +41,7 @@ import com.cloud.utils.exception.CloudRuntimeException; | ||||
| @Component | ||||
| @Local(value = {ConfigurationDao.class}) | ||||
| public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String> implements ConfigurationDao { | ||||
|     private static final Logger s_logger = Logger.getLogger(ConfigurationDaoImpl.class); | ||||
|     private Map<String, String> _configs = null; | ||||
|     private boolean _premium; | ||||
| 
 | ||||
| @ -146,7 +148,7 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String | ||||
|             stmt.executeUpdate(); | ||||
|             return true; | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unable to update Configuration Value", e); | ||||
|             s_logger.warn("Unable to update Configuration Value", e); | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| @ -163,7 +165,7 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String | ||||
|                 return true; | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unable to update Configuration Value", e); | ||||
|             s_logger.warn("Unable to update Configuration Value", e); | ||||
|         } | ||||
|         return false; | ||||
|     } | ||||
| @ -197,7 +199,7 @@ public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String | ||||
|             } | ||||
|             return returnValue; | ||||
|         } catch (Exception e) { | ||||
|             logger.warn("Unable to update Configuration Value", e); | ||||
|             s_logger.warn("Unable to update Configuration Value", e); | ||||
|             throw new CloudRuntimeException("Unable to initialize configuration variable: " + name); | ||||
| 
 | ||||
|         } | ||||
|  | ||||
| @ -65,6 +65,7 @@ import net.sf.ehcache.Cache; | ||||
| import net.sf.ehcache.CacheManager; | ||||
| import net.sf.ehcache.Element; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.utils.DateUtil; | ||||
| import com.cloud.utils.NumbersUtil; | ||||
| @ -114,6 +115,7 @@ import com.cloud.utils.net.NetUtils; | ||||
|  **/ | ||||
| @DB | ||||
| public abstract class GenericDaoBase<T, ID extends Serializable> extends ComponentLifecycleBase implements GenericDao<T, ID>, ComponentMethodInterceptable { | ||||
|     private final static Logger s_logger = Logger.getLogger(GenericDaoBase.class); | ||||
| 
 | ||||
|     protected final static TimeZone s_gmtTimeZone = TimeZone.getTimeZone("GMT"); | ||||
| 
 | ||||
| @ -253,26 +255,26 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone | ||||
|         _searchEnhancer.setSuperclass(_entityBeanType); | ||||
|         _searchEnhancer.setCallback(new UpdateBuilder(this)); | ||||
| 
 | ||||
|         if (logger.isTraceEnabled()) { | ||||
|             logger.trace("Select SQL: " + _partialSelectSql.first().toString()); | ||||
|             logger.trace("Remove SQL: " + (_removeSql != null ? _removeSql.first() : "No remove sql")); | ||||
|             logger.trace("Select by Id SQL: " + _selectByIdSql); | ||||
|             logger.trace("Table References: " + _tables); | ||||
|             logger.trace("Insert SQLs:"); | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             s_logger.trace("Select SQL: " + _partialSelectSql.first().toString()); | ||||
|             s_logger.trace("Remove SQL: " + (_removeSql != null ? _removeSql.first() : "No remove sql")); | ||||
|             s_logger.trace("Select by Id SQL: " + _selectByIdSql); | ||||
|             s_logger.trace("Table References: " + _tables); | ||||
|             s_logger.trace("Insert SQLs:"); | ||||
|             for (final Pair<String, Attribute[]> insertSql : _insertSqls) { | ||||
|                 logger.trace(insertSql.first()); | ||||
|                 s_logger.trace(insertSql.first()); | ||||
|             } | ||||
| 
 | ||||
|             logger.trace("Delete SQLs"); | ||||
|             s_logger.trace("Delete SQLs"); | ||||
|             for (final Pair<String, Attribute[]> deletSql : _deleteSqls) { | ||||
|                 logger.trace(deletSql.first()); | ||||
|                 s_logger.trace(deletSql.first()); | ||||
|             } | ||||
| 
 | ||||
|             logger.trace("Collection SQLs"); | ||||
|             s_logger.trace("Collection SQLs"); | ||||
|             for (Attribute attr : _ecAttributes) { | ||||
|                 EcInfo info = (EcInfo)attr.attache; | ||||
|                 logger.trace(info.insertSql); | ||||
|                 logger.trace(info.selectSql); | ||||
|                 s_logger.trace(info.insertSql); | ||||
|                 s_logger.trace(info.selectSql); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -411,7 +413,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             if (logger.isDebugEnabled() && lock != null) { | ||||
|             if (s_logger.isDebugEnabled() && lock != null) { | ||||
|                 txn.registerLock(pstmt.toString()); | ||||
|             } | ||||
|             final ResultSet rs = pstmt.executeQuery(); | ||||
| @ -776,8 +778,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if (logger.isTraceEnabled()) { | ||||
|             logger.trace("join search statement is " + pstmt); | ||||
|         if (s_logger.isTraceEnabled()) { | ||||
|             s_logger.trace("join search statement is " + pstmt); | ||||
|         } | ||||
|         return count; | ||||
|     } | ||||
| @ -1595,7 +1597,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone | ||||
|             try { | ||||
|                 _cache.put(new Element(_idField.get(entity), entity)); | ||||
|             } catch (final Exception e) { | ||||
|                 logger.debug("Can't put it in the cache", e); | ||||
|                 s_logger.debug("Can't put it in the cache", e); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -1617,7 +1619,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone | ||||
|             try { | ||||
|                 _cache.put(new Element(_idField.get(entity), entity)); | ||||
|             } catch (final Exception e) { | ||||
|                 logger.debug("Can't put it in the cache", e); | ||||
|                 s_logger.debug("Can't put it in the cache", e); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
| @ -1796,7 +1798,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone | ||||
|             final int idle = NumbersUtil.parseInt((String)params.get("cache.time.to.idle"), 300); | ||||
|             _cache = new Cache(getName(), maxElements, false, live == -1, live == -1 ? Integer.MAX_VALUE : live, idle); | ||||
|             cm.addCache(_cache); | ||||
|             logger.info("Cache created: " + _cache.toString()); | ||||
|             s_logger.info("Cache created: " + _cache.toString()); | ||||
|         } else { | ||||
|             _cache = null; | ||||
|         } | ||||
|  | ||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user