Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22773101A1 for ; Wed, 4 Sep 2013 22:42:15 +0000 (UTC) Received: (qmail 43482 invoked by uid 500); 4 Sep 2013 22:42:11 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 43385 invoked by uid 500); 4 Sep 2013 22:42:11 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 43096 invoked by uid 99); 4 Sep 2013 22:42:11 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 04 Sep 2013 22:42:11 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D69D5900820; Wed, 4 Sep 2013 22:42:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kelveny@apache.org To: commits@cloudstack.apache.org Date: Wed, 04 Sep 2013 22:42:19 -0000 Message-Id: <9517adfc624e4aa787034bd63003f0d2@git.apache.org> In-Reply-To: <2120af6f82154b6dad8445eadc5c6cc2@git.apache.org> References: <2120af6f82154b6dad8445eadc5c6cc2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [10/27] git commit: updated refs/heads/master to ae23144 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 Authored: Mon Aug 12 18:26:05 2013 -0700 Committer: Kelven Yang 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 l, int batchSize) { synchronized(_pool) { - for(List entryList : _pool.values()) { - if(entryList != null) { + for(Map.Entry> 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);