From b4a7d2031990c3c2e326efcd1bed8a7c5079ad3c Mon Sep 17 00:00:00 2001 From: Kelven Yang Date: Sat, 17 Aug 2013 23:06:42 -0700 Subject: [PATCH] CLOUDSTACK-4357: don't cache ServiceContent and rootFolder in memory, the cache semantics break session keep-alive mechanism --- .../hypervisor/vmware/util/VmwareClient.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java index c822265221a..d4e4256ebde 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java @@ -108,10 +108,8 @@ public class VmwareClient { private ManagedObjectReference SVC_INST_REF = new ManagedObjectReference(); private ManagedObjectReference propCollectorRef; - private ManagedObjectReference rootRef; private static VimService vimService; private VimPortType vimPort; - private ServiceContent serviceContent; private String serviceCookie; private final String SVC_INST_NAME = "ServiceInstance"; @@ -139,7 +137,7 @@ public class VmwareClient { ctxt.put("com.sun.xml.internal.ws.request.timeout", 600000); ctxt.put("com.sun.xml.internal.ws.connect.timeout", 600000); - serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF); + ServiceContent serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF); // Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles Map> headers = (Map>) ((BindingProvider) vimPort) @@ -155,7 +153,6 @@ public class VmwareClient { isConnected = true; propCollectorRef = serviceContent.getPropertyCollector(); - rootRef = serviceContent.getRootFolder(); } /** @@ -165,7 +162,7 @@ public class VmwareClient { */ public void disconnect() throws Exception { if (isConnected) { - vimPort.logout(serviceContent.getSessionManager()); + vimPort.logout(getServiceContent().getSessionManager()); } isConnected = false; } @@ -181,7 +178,12 @@ public class VmwareClient { * @return Service instance content */ public ServiceContent getServiceContent() { - return serviceContent; + + try { + return vimPort.retrieveServiceContent(SVC_INST_REF); + } catch (RuntimeFaultFaultMsg e) { + } + return null; } /** @@ -202,7 +204,7 @@ public class VmwareClient { * @return Root folder */ public ManagedObjectReference getRootFolder() { - return rootRef; + return getServiceContent().getRootFolder(); } /**