cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [10/27] git commit: updated refs/heads/master to ae23144
Date Wed, 04 Sep 2013 22:42:19 GMT
CLOUDSTACK-3568: finalize logging in the refactored code on new vCenter API management facility


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d361cb52
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d361cb52
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d361cb52

Branch: refs/heads/master
Commit: d361cb5282c2314da7e7131544585259b5b8ce7d
Parents: 0becde9
Author: Kelven Yang <kelveny@gmail.com>
Authored: Mon Aug 12 18:26:05 2013 -0700
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Wed Sep 4 14:49:45 2013 -0700

----------------------------------------------------------------------
 .../hypervisor/vmware/util/VmwareContext.java   | 17 ++++++++++++
 .../vmware/util/VmwareContextPool.java          | 29 ++++++++++++++------
 2 files changed, 37 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d361cb52/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
index 95553fd..5944582 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java
@@ -68,6 +68,8 @@ public class VmwareContext {
 
 	private VmwareContextPool _pool;
 	private String _poolKey;
+	
+	private static volatile int s_outstandingCount = 0;
 
 	static {
 		try {
@@ -87,6 +89,8 @@ public class VmwareContext {
 
 		_vimClient = client;
 		_serverAddress = address;
+		
+		registerOutstandingContext();
 	}
 
 	public void registerStockObject(String name, Object obj) {
@@ -154,6 +158,18 @@ public class VmwareContext {
 	public void idleCheck() throws Exception {
 		getRootFolder();
 	}
+	
+	public static int getOutstandingContextCount() {
+		return s_outstandingCount;
+	}
+	
+	public static void registerOutstandingContext() {
+		s_outstandingCount++;
+	}
+	
+	public static void unregisterOutstandingContext() {
+		s_outstandingCount--;
+	}
 
 	public ManagedObjectReference getHostMorByPath(String inventoryPath) throws Exception {
 		assert(inventoryPath != null);
@@ -614,6 +630,7 @@ public class VmwareContext {
 		} catch(Exception e) {
 			s_logger.warn("Unexpected exception: ", e);
 		}
+		unregisterOutstandingContext();
 	}
 
 	public static class TrustAllManager implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager
{

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d361cb52/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java
index 3bac028..4647ab9 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java
@@ -63,15 +63,17 @@ public class VmwareContextPool {
 
 			if(l.size() > 0) {
 				if(s_logger.isTraceEnabled())
-					s_logger.trace("Return a VmwareContext from the pool.");
+					s_logger.trace("Return a VmwareContext from the idle pool: " + poolKey + ". current
pool size: " + l.size() + ", outstanding count: " + VmwareContext.getOutstandingContextCount());
 				
 				VmwareContext context = l.remove(0);
 				context.setPoolInfo(this, poolKey);
 				return context;
 			}
 			
-			if(s_logger.isInfoEnabled())
-				s_logger.info("No VmwareContext is available from the idle pool, create a new one");
+			if(s_logger.isTraceEnabled())
+				s_logger.trace("No VmwareContext is available from the idle pool: " + poolKey + ", create
a new one and current outstanding count is: " + VmwareContext.getOutstandingContextCount());
+			
+			// TODO, we need to control the maximum number of outstanding VmwareContext object in
the future
 			return null;
 		}
 	}
@@ -89,9 +91,13 @@ public class VmwareContextPool {
 			if(l.size() < _maxIdleQueueLength) {
 				context.clearStockObjects();
 				l.add(context);
+				
+				if(s_logger.isTraceEnabled())
+					s_logger.trace("Recycle VmwareContext into idle pool: " + context.getPoolKey() + ",
current idle pool size: " 
+						+ l.size() + ", outstanding count: " + VmwareContext.getOutstandingContextCount());
 			} else {
-				if(s_logger.isInfoEnabled())
-					s_logger.info("VmwareContextPool queue exceeds limits, queue size: " + l.size());
+				if(s_logger.isTraceEnabled())
+					s_logger.trace("VmwareContextPool queue exceeds limits, queue size: " + l.size());
 				context.close();
 			}
 		}
@@ -99,11 +105,13 @@ public class VmwareContextPool {
 	
 	private void getIdleCheckContexts(List<VmwareContext> l, int batchSize) {
 		synchronized(_pool) {
-			for(List<VmwareContext> entryList : _pool.values()) {
-				if(entryList != null) {
+			for(Map.Entry<String, List<VmwareContext>> entry : _pool.entrySet()) {
+				if(entry.getValue() != null) {
 					int count = 0;
-					while(entryList.size() > 0 && count < batchSize) {
-						l.add(entryList.remove(0));
+					while(entry.getValue().size() > 0 && count < batchSize) {
+						VmwareContext context = entry.getValue().remove(0);
+						context.setPoolInfo(this, entry.getKey());
+						l.add(context);
 						count++;
 					}
 				}
@@ -132,6 +140,9 @@ public class VmwareContextPool {
 		for(VmwareContext context : l) {
 			try {
 				context.idleCheck();
+				
+				if(s_logger.isTraceEnabled())
+					s_logger.trace("Recyle context after idle check");
 				returnContext(context);
 			} catch(Throwable e) {
 				s_logger.warn("Exception caught during VmwareContext idle check, close and discard the
context", e);


Mime
View raw message