Updated Branches:
  refs/heads/4.2 e3a6657c9 -> e6d7cdf70

CLOUDSTACK-4357: don't cache ServiceContent and rootFolder in memory, the cache 
semantics break session keep-alive mechanism


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

Branch: refs/heads/4.2
Commit: e6d7cdf70f1566b881c461f5881803660e116238
Parents: e3a6657
Author: Kelven Yang <[email protected]>
Authored: Sat Aug 17 23:06:42 2013 -0700
Committer: Kelven Yang <[email protected]>
Committed: Sat Aug 17 23:06:42 2013 -0700

----------------------------------------------------------------------
 .../cloud/hypervisor/vmware/util/VmwareClient.java  | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e6d7cdf7/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
----------------------------------------------------------------------
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 5df2608..6ab9700 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
@@ -110,10 +110,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";
 
@@ -141,7 +139,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<String, List<String>> headers = (Map<String, List<String>>) 
((BindingProvider) vimPort)
@@ -157,7 +155,6 @@ public class VmwareClient {
         isConnected = true;
 
         propCollectorRef = serviceContent.getPropertyCollector();
-        rootRef = serviceContent.getRootFolder();
     }
 
     /**
@@ -167,7 +164,7 @@ public class VmwareClient {
      */
     public void disconnect() throws Exception {
         if (isConnected) {
-            vimPort.logout(serviceContent.getSessionManager());
+            vimPort.logout(getServiceContent().getSessionManager());
         }
         isConnected = false;
     }
@@ -183,7 +180,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;
     }
 
     /**
@@ -204,7 +206,7 @@ public class VmwareClient {
      * @return Root folder
      */
     public ManagedObjectReference getRootFolder() {
-        return rootRef;
+        return getServiceContent().getRootFolder();
     }
 
     /**

Reply via email to