[Swift-commit] r3672 - in trunk/src/org: globus/swift/catalog globus/swift/catalog/util griphyn/vdl/karajan/lib

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Fri Oct 8 12:00:17 CDT 2010


Author: wozniak
Date: 2010-10-08 12:00:17 -0500 (Fri, 08 Oct 2010)
New Revision: 3672

Modified:
   trunk/src/org/globus/swift/catalog/TransformationCatalogEntry.java
   trunk/src/org/globus/swift/catalog/util/Profile.java
   trunk/src/org/griphyn/vdl/karajan/lib/TCProfile.java
Log:
Minor changes: cleanups and generics


Modified: trunk/src/org/globus/swift/catalog/TransformationCatalogEntry.java
===================================================================
--- trunk/src/org/globus/swift/catalog/TransformationCatalogEntry.java	2010-10-08 16:59:09 UTC (rev 3671)
+++ trunk/src/org/globus/swift/catalog/TransformationCatalogEntry.java	2010-10-08 17:00:17 UTC (rev 3672)
@@ -68,7 +68,7 @@
     /**
      * The profiles associated with the transformation;
      */
-    private List profiles;
+    private List<Profile> profiles;
 
     /**
      * The System Info for the transformation.
@@ -121,7 +121,7 @@
     public TransformationCatalogEntry( String namespace, String name,
         String version,
         String resourceid, String physicalname, TCType type,
-        List profiles,
+        List<Profile> profiles,
         SysInfo sysinfo ) {
         this.namespace = namespace;
         this.version = version;
@@ -162,13 +162,10 @@
             "\n SysInfo           : " + ((this.sysinfo == null) ? "" : this.sysinfo.toString()) +
             "\n TYPE              : " + ((this.type == null) ? "" : type.toString());
         if(profiles != null){
-            for (Iterator i = profiles.listIterator(); i.hasNext(); ) {
-                st = st +
-                    "\n Profile           : " + ( (Profile) i.next()).toString();
-            }
+            for (Profile p : profiles)
+                st = st + "\n Profile           : " + p.toString();
         }
         return st;
-
     }
 
     /**
@@ -201,10 +198,8 @@
             + " sysinfo=\"" + this.getSysInfo() + "\"";
         if ( this.profiles != null ) {
             xml += " >\n";
-            for ( Iterator iter = this.profiles.iterator(); iter.hasNext(); ) {
-                Profile profile = ( Profile ) iter.next();
-                xml += "\t\t\t" + profile.toXML() + "\n";
-            }
+            for (Profile p : profiles)
+                xml += "\t\t\t" + p.toXML() + "\n";
             xml += "\t\t</pfn>\n";
         } else {
             xml += " />\n";
@@ -301,7 +296,7 @@
     public void setProfile( Profile profile ) {
         if ( profile != null ) {
             if ( this.profiles == null ) {
-                this.profiles = new ArrayList( 5 );
+                this.profiles = new ArrayList<Profile>( 5 );
             }
             this.profiles.add( profile );
         }
@@ -311,10 +306,11 @@
      * Allows you to add multiple profiles to the transformation.
      * @param profiles List of Profile objects containing the profile information.
      */
-    public void setProfiles( List profiles ) {
+    public void setProfiles( List<Profile> profiles ) {
         if ( profiles != null ) {
             if ( this.profiles == null ) {
-                this.profiles = new ArrayList( profiles.size() );
+                this.profiles = 
+                    new ArrayList<Profile>( profiles.size() );
             }
             this.profiles.addAll( profiles );
         }
@@ -388,7 +384,7 @@
      * Returns the list of profiles associated with the transformation.
      * @return List Returns null if no profiles associated.
      */
-    public List getProfiles() {
+    public List<Profile> getProfiles() {
         return this.profiles;
     }
 
@@ -397,14 +393,13 @@
      * @param namespace String The namespace of the profile
      * @return List   List of Profile objects. returns null if none are found.
      */
-    public List getProfiles( String namespace ) {
-        List results = null;
+    public List<Profile> getProfiles( String namespace ) {
+        List<Profile> results = null;
         if ( profiles != null ) {
-            for ( Iterator i = profiles.iterator(); i.hasNext(); ) {
-                Profile p = ( Profile ) i.next();
+            for ( Profile p : profiles ) {
                 if ( p.getProfileNamespace().equalsIgnoreCase( namespace ) ) {
                     if ( results == null ) {
-                        results = new ArrayList();
+                        results = new ArrayList<Profile>();
                     }
                     results.add( p );
                 }

Modified: trunk/src/org/globus/swift/catalog/util/Profile.java
===================================================================
--- trunk/src/org/globus/swift/catalog/util/Profile.java	2010-10-08 16:59:09 UTC (rev 3671)
+++ trunk/src/org/globus/swift/catalog/util/Profile.java	2010-10-08 17:00:17 UTC (rev 3672)
@@ -122,8 +122,8 @@
      * Returns the Profile (namespace, value and key);
      * @return ArrayList
      */
-    public List getProfile() {
-        ArrayList m_profile = new ArrayList( 3 );
+    public List<String> getProfile() {
+        List<String> m_profile = new ArrayList<String>( 3 );
         m_profile.add( mNamespace );
         m_profile.add( mKey );
         m_profile.add( mValue );

Modified: trunk/src/org/griphyn/vdl/karajan/lib/TCProfile.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/TCProfile.java	2010-10-08 16:59:09 UTC (rev 3671)
+++ trunk/src/org/griphyn/vdl/karajan/lib/TCProfile.java	2010-10-08 17:00:17 UTC (rev 3672)
@@ -5,7 +5,6 @@
 
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -21,7 +20,6 @@
 import org.globus.cog.karajan.workflow.ExecutionException;
 import org.globus.cog.karajan.workflow.nodes.grid.GridExec;
 import org.globus.swift.catalog.TransformationCatalogEntry;
-import org.globus.swift.catalog.types.Os;
 import org.globus.swift.catalog.util.Profile;
 import org.griphyn.vdl.karajan.TCCache;
 import org.griphyn.vdl.util.FQN;
@@ -36,10 +34,10 @@
 		setArguments(TCProfile.class, new Arg[] { PA_HOST, OA_TR });
 	}
 
-	private static Map PROFILE_T;
+	private static Map<String, Arg> PROFILE_T;
 
 	static {
-		PROFILE_T = new HashMap();
+		PROFILE_T = new HashMap<String, Arg>();
 		PROFILE_T.put("count", GridExec.A_COUNT);
 		PROFILE_T.put("jobtype", GridExec.A_JOBTYPE);
 		PROFILE_T.put("maxcputime", GridExec.A_MAXCPUTIME);
@@ -60,7 +58,7 @@
 		BoundContact bc = (BoundContact) PA_HOST.getValue(stack);
 		
 		NamedArguments named = ArgUtil.getNamedReturn(stack);
-		Map attrs = null;
+		Map<String,Object> attrs = null;
 		
 		attrs = attributesFromHost(bc, attrs, named);
 
@@ -69,7 +67,7 @@
 		    tce = getTCE(tc, new FQN(tr), bc);
 		}
 		
-		Map env = new HashMap();
+		Map<String,String> env = new HashMap<String,String>();
 		if (tce != null) {
 			addEnvironment(env, tce);
 			addEnvironment(env, bc);
@@ -104,7 +102,8 @@
         }
 	}
 	
-	private static final Set warnedAboutWalltime = new HashSet();
+	private static final Set<String> warnedAboutWalltime = 
+	    new HashSet<String>();
 	
 	private void warn(String tr, String message) {
         synchronized (warnedAboutWalltime) {
@@ -114,24 +113,23 @@
         }
     }
 
-	private void addEnvironment(Map m, TransformationCatalogEntry tce) {
-		List l = tce.getProfiles(Profile.ENV);
-		if (l != null) {
-			Iterator i = l.iterator();
-			while (i.hasNext()) {
-				Profile p = (Profile) i.next();
+	private void addEnvironment(Map<String,String> m, 
+	                            TransformationCatalogEntry tce) {
+		List<Profile> list = tce.getProfiles(Profile.ENV);
+		if (list != null) {
+			for (Profile p : list) {
 				m.put(p.getProfileKey(), p.getProfileValue());
 			}
 		}
 	}
 
-	public static final String PROFILE_GLOBUS_PREFIX = (Profile.GLOBUS + "::").toLowerCase();
+	public static final String PROFILE_GLOBUS_PREFIX = 
+	    (Profile.GLOBUS + "::").toLowerCase();
 
-	private void addEnvironment(Map m, BoundContact bc) {
-		Map props = bc.getProperties();
-		Iterator i = props.entrySet().iterator();
-		while (i.hasNext()) {
-			Map.Entry e = (Map.Entry) i.next();
+	private void addEnvironment(Map<String,String> m, 
+	                            BoundContact bc) {
+		Map<String,Object> props = bc.getProperties();
+		for (Map.Entry<String,Object> e : props.entrySet()) {
 			String name = (String) e.getKey();
 			FQN fqn = new FQN(name); 
 			String value = (String) e.getValue();
@@ -141,7 +139,8 @@
 		}
 	}
 	
-	private void addAttributes(NamedArguments named, Map attrs) {
+	private void addAttributes(NamedArguments named, 
+	                           Map<String,Object> attrs) {
 	    if (logger.isDebugEnabled()) {
 	        logger.debug("Attributes: " + attrs);
 	    }
@@ -151,16 +150,17 @@
 	    named.add(GridExec.A_ATTRIBUTES, attrs);
 	}
 
-	private Map attributesFromTC(TransformationCatalogEntry tce, Map attrs, NamedArguments named) {
-		List l = tce.getProfiles(Profile.GLOBUS);
-		if (l != null) {
-			Iterator i = l.iterator();
-			while (i.hasNext()) {
-				Profile p = (Profile) i.next();
-				Arg a = (Arg) PROFILE_T.get(p.getProfileKey());
+	private Map<String,Object> 
+	attributesFromTC(TransformationCatalogEntry tce, 
+	                 Map<String,Object> attrs, 
+	                 NamedArguments named) {
+	    List<Profile> list = tce.getProfiles(Profile.GLOBUS);
+		if (list != null) {
+			for (Profile p : list) {
+				Arg a = PROFILE_T.get(p.getProfileKey());
 				if (a == null) {
 				    if (attrs == null) {
-				        attrs = new HashMap();
+				        attrs = new HashMap<String,Object>();
 				    }
 				    attrs.put(p.getProfileKey(), p.getProfileValue());
 				}
@@ -172,18 +172,19 @@
 		return attrs;
 	}
 	
-	private Map attributesFromHost(BoundContact bc, Map attrs, NamedArguments named) {
-		Map props = bc.getProperties();
+	private Map<String,Object> 
+	attributesFromHost(BoundContact bc, 
+	                   Map<String,Object> attrs, 
+	                   NamedArguments named) {
+		Map<String,Object> props = bc.getProperties();
 		if (props != null) {
-		    Iterator i = props.entrySet().iterator();
-		    while (i.hasNext()) {
-		        Map.Entry e = (Map.Entry) i.next();
+		    for (Map.Entry<String,Object> e : props.entrySet()) {
 		        FQN fqn = new FQN((String) e.getKey());
 		        if (Profile.GLOBUS.equalsIgnoreCase(fqn.getNamespace())) {
 		            Arg a = (Arg) PROFILE_T.get(fqn.getName());
 		            if (a == null) {
 		                if (attrs == null) {
-		                    attrs = new HashMap();
+		                    attrs = new HashMap<String,Object>();
 		                }
 		                attrs.put(fqn.getName(), e.getValue());
 		            }




More information about the Swift-commit mailing list