geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r1022386 - in /geronimo/devtools/eclipse-plugin/trunk/plugins: org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/ org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/ o...
Date Thu, 14 Oct 2010 06:43:12 GMT
Author: delos
Date: Thu Oct 14 06:43:12 2010
New Revision: 1022386

URL: http://svn.apache.org/viewvc?rev=1022386&view=rev
Log:
GERONIMODEVTOOLS-608 reduce time-consuming in DependencyHelper with cache. Thanks Boes and
Chris for the patch

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v22.core/META-INF/MANIFEST.MF
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/DependencyHelper.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java?rev=1022386&r1=1022385&r2=1022386&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java
Thu Oct 14 06:43:12 2010
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.xml.bind.JAXBElement;
 
@@ -67,6 +68,8 @@ public class DependencyHelper {
     private List<JAXBElement> inputJAXBElements = new ArrayList();
     private List<JAXBElement> reorderedJAXBElements = new ArrayList();
 
+    //provide a cache
+    private ConcurrentHashMap<IModule, EnvironmentType> environmentCache = new ConcurrentHashMap<IModule,
EnvironmentType>();
 
     /**
      * Reorder the publish order of the modules based on any discovered dependencies
@@ -78,6 +81,9 @@ public class DependencyHelper {
      */
     public List reorderModules(IServer server, List modules, List deltaKind ) {
         Trace.tracePoint("Entry", "DependencyHelper.reorderModules", modules, deltaKind);
+        
+        //provide a cache
+        ConcurrentHashMap<String,Boolean> verifiedModules = new ConcurrentHashMap<String,Boolean>();
 
         if (modules.size() == 0) {
             List reorderedLists = new ArrayList(2);
@@ -125,8 +131,23 @@ public class DependencyHelper {
 	                            if (dep.getType()!=null)
 	                            	configId.append(dep.getType());
 	                            
-	                            if (!DeploymentUtils.isInstalledModule(server,configId.toString()))
-	                               	dm.addDependency( child, parent );
+	                            //get install flag from the cache
+								Boolean isInstalledModule = verifiedModules
+										.get(configId.toString());
+								if (isInstalledModule == null) {
+									// not in the cache, invoke
+									// isInstalledModule() method
+									isInstalledModule = DeploymentUtils
+											.isInstalledModule(server,
+													configId.toString());
+									// put install flag into the cache for next
+									// retrieve
+									verifiedModules.put(configId.toString(),
+											isInstalledModule);
+								}
+
+								if (!isInstalledModule)
+                                    dm.addDependency( child, parent );
 	                        }
 	                    }
 	                }
@@ -375,6 +396,12 @@ public class DependencyHelper {
     private EnvironmentType getEnvironment(IModule module) {
         Trace.tracePoint("Enter", "DependencyHelper.getEnvironment", module);
 
+        // if module's environment is in the cache, get it from the cache
+        if(environmentCache.containsKey(module)) {
+             return environmentCache.get(module);
+        }
+
+        
         EnvironmentType environment = null;
         if (GeronimoUtils.isWebModule(module)) {
             if (getWebDeploymentPlan(module) != null) {
@@ -411,6 +438,9 @@ public class DependencyHelper {
             }
         }
 
+        //put module's environment into the cache for next retrieve
+        environmentCache.put(module, environment);
+        
         Trace.tracePoint("Exit ", "DependencyHelper.getEnvironment", environment);
         return environment;
     }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java?rev=1022386&r1=1022385&r2=1022386&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java
Thu Oct 14 06:43:12 2010
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.xml.bind.JAXBElement;
 
@@ -67,6 +68,9 @@ public class DependencyHelper {
     private List<JAXBElement> inputJAXBElements = new ArrayList();
     private List<JAXBElement> reorderedJAXBElements = new ArrayList();
 
+    
+    //provide a cache
+    private ConcurrentHashMap<IModule, Environment> environmentCache = new ConcurrentHashMap<IModule,
Environment>();
 
     /**
      * Reorder the publish order of the modules based on any discovered dependencies
@@ -78,6 +82,10 @@ public class DependencyHelper {
      */
     public List reorderModules(IServer server, List modules, List deltaKind ) {
         Trace.tracePoint("Entry", "DependencyHelper.reorderModules", modules, deltaKind);
+        
+        //provide a cache
+        ConcurrentHashMap<String,Boolean> verifiedModules = new ConcurrentHashMap<String,Boolean>();
+
 
         if (modules.size() == 0) {
             List reorderedLists = new ArrayList(2);
@@ -125,8 +133,23 @@ public class DependencyHelper {
 	                            if (dep.getType()!=null)
 	                            	configId.append(dep.getType());
 	                            
-	                            if (!DeploymentUtils.isInstalledModule(server,configId.toString()))
-	                               	dm.addDependency( child, parent );
+	                            //get install flag from the cache
+								Boolean isInstalledModule = verifiedModules
+										.get(configId.toString());
+								if (isInstalledModule == null) {
+									// not in the cache, invoke
+									// isInstalledModule() method
+									isInstalledModule = DeploymentUtils
+											.isInstalledModule(server,
+													configId.toString());
+									// put install flag into the cache for next
+									// retrieve
+									verifiedModules.put(configId.toString(),
+											isInstalledModule);
+								}
+
+								if (!isInstalledModule)
+                                    dm.addDependency( child, parent );
 	                        }
 	                    }
 	                }
@@ -374,6 +397,11 @@ public class DependencyHelper {
      */
     private Environment getEnvironment(IModule module) {
         Trace.tracePoint("Enter", "DependencyHelper.getEnvironment", module);
+        
+        // if module's environment is in the cache, get it from the cache
+        if(environmentCache.containsKey(module)) {
+             return environmentCache.get(module);
+        }
 
         Environment environment = null;
         if (GeronimoUtils.isWebModule(module)) {
@@ -410,6 +438,9 @@ public class DependencyHelper {
                     environment = plan.getServerEnvironment();
             }
         }
+        
+        //put module's environment into the cache for next retrieve
+        environmentCache.put(module, environment);
 
         Trace.tracePoint("Exit ", "DependencyHelper.getEnvironment", environment);
         return environment;

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v22.core/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v22.core/META-INF/MANIFEST.MF?rev=1022386&r1=1022385&r2=1022386&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v22.core/META-INF/MANIFEST.MF
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v22.core/META-INF/MANIFEST.MF
Thu Oct 14 06:43:12 2010
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.apache.geronimo.st.v22.core;singleton:=true
 Bundle-Version: 3.0.0
-Bundle-Activator: org.apache.geronimo.st.v21.core.Activator
+Bundle-Activator: org.apache.geronimo.st.v22.core.Activator
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
 Require-Bundle: org.apache.geronimo.runtime.v22,

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/DependencyHelper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/DependencyHelper.java?rev=1022386&r1=1022385&r2=1022386&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/DependencyHelper.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/DependencyHelper.java
Thu Oct 14 06:43:12 2010
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.xml.bind.JAXBElement;
 
@@ -66,6 +67,9 @@ public class DependencyHelper {
     private List reorderedKinds  = new ArrayList();
     private List<JAXBElement> inputJAXBElements = new ArrayList();
     private List<JAXBElement> reorderedJAXBElements = new ArrayList();
+    
+    //provide a cache
+    private ConcurrentHashMap<IModule, Environment> environmentCache = new ConcurrentHashMap<IModule,
Environment>();
 
 
     /**
@@ -78,6 +82,9 @@ public class DependencyHelper {
      */
     public List reorderModules(IServer server, List modules, List deltaKind ) {
         Trace.tracePoint("Entry", "DependencyHelper.reorderModules", modules, deltaKind);
+        
+        //provide a cache
+        ConcurrentHashMap<String,Boolean> verifiedModules = new ConcurrentHashMap<String,Boolean>();
 
         if (modules.size() == 0) {
             List reorderedLists = new ArrayList(2);
@@ -125,7 +132,22 @@ public class DependencyHelper {
                                 if (dep.getType()!=null)
                                     configId.append(dep.getType());
                                 
-                                if (!DeploymentUtils.isInstalledModule(server,configId.toString()))
+                                //get install flag from the cache
+								Boolean isInstalledModule = verifiedModules
+										.get(configId.toString());
+								if (isInstalledModule == null) {
+									// not in the cache, invoke
+									// isInstalledModule() method
+									isInstalledModule = DeploymentUtils
+											.isInstalledModule(server,
+													configId.toString());
+									// put install flag into the cache for next
+									// retrieve
+									verifiedModules.put(configId.toString(),
+											isInstalledModule);
+								}
+
+								if (!isInstalledModule)
                                     dm.addDependency( child, parent );
                             }
                         }
@@ -374,6 +396,11 @@ public class DependencyHelper {
      */
     private Environment getEnvironment(IModule module) {
         Trace.tracePoint("Enter", "DependencyHelper.getEnvironment", module);
+        
+        // if module's environment is in the cache, get it from the cache
+        if(environmentCache.containsKey(module)) {
+             return environmentCache.get(module);
+        }
 
         Environment environment = null;
         if (GeronimoUtils.isWebModule(module)) {
@@ -411,6 +438,9 @@ public class DependencyHelper {
             }
         }
 
+        //put module's environment into the cache for next retrieve
+        environmentCache.put(module, environment);
+        
         Trace.tracePoint("Exit ", "DependencyHelper.getEnvironment", environment);
         return environment;
     }



Mime
View raw message