[Swift-commit] cog r3911

swift at ci.uchicago.edu swift at ci.uchicago.edu
Tue Jun 10 00:55:09 CDT 2014


------------------------------------------------------------------------
r3911 | hategan | 2014-06-10 00:53:56 -0500 (Tue, 10 Jun 2014) | 1 line

added a name property to task handlers and make the AbstractionFactory set this property to the value of the requested provider
------------------------------------------------------------------------
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/TaskHandlerImpl.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/TaskHandlerImpl.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/file/TaskHandlerImpl.java	(working copy)
@@ -526,4 +526,8 @@
     protected FileResource getResource() {
         return this.fileResource;
     }
+    
+    public String getName() {
+        return "FileOperationTaskHandler";
+    }
 }
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractionFactory.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractionFactory.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractionFactory.java	(working copy)
@@ -74,7 +74,9 @@
             throws InvalidProviderException, ProviderMethodException {
         AbstractionProperties providerProps = AbstractionProperties
                 .getProperties(provider);
-        return (TaskHandler) newObject(provider, type);
+        TaskHandler th = (TaskHandler) newObject(provider, type);
+        th.setName(provider);
+        return th;
     }
 
     /**
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/TaskHandlerSkeleton.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/TaskHandlerSkeleton.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/TaskHandlerSkeleton.java	(working copy)
@@ -17,7 +17,7 @@
 public abstract class TaskHandlerSkeleton implements TaskHandler {
 
     private int type;
-
+    
     public void cancel(Task task) throws InvalidSecurityContextException,
             TaskSubmissionException {
         cancel(task, null);
@@ -30,4 +30,12 @@
     public int getType() {
     	return type;
     }
+    
+    public String toString() {
+        return "TaskHandler(type = " + getType() + ", provider = " + getName() + ")";
+    }
+    
+    public void setName(String name) {
+        // ignored
+    }
 }
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/FileTransferTaskHandler.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/FileTransferTaskHandler.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/FileTransferTaskHandler.java	(working copy)
@@ -17,7 +17,7 @@
         setType(TaskHandler.FILE_TRANSFER);
     }
     
-    protected String getName() {
+    public String getName() {
         return "FileTransferTaskHandler";
     }
 
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/FileOperationTaskHandler.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/FileOperationTaskHandler.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/FileOperationTaskHandler.java	(working copy)
@@ -9,7 +9,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.globus.cog.abstraction.impl.common.AbstractionFactory;
@@ -21,10 +20,10 @@
 import org.globus.cog.abstraction.interfaces.TaskHandler;
 
 public class FileOperationTaskHandler extends MultiplexingTaskHandler {
-    private Map mapping;
+    private Map<String, TaskHandler> mapping;
 
     public FileOperationTaskHandler() {
-        this.mapping = new HashMap();
+        this.mapping = new HashMap<String, TaskHandler>();
         setType(TaskHandler.FILE_OPERATION);
     }
 
@@ -36,7 +35,7 @@
         String provider = task.getService(0).getProvider().toLowerCase();
         TaskHandler th = null;
         synchronized (this.mapping) {
-            th = (TaskHandler) this.mapping.get(provider);
+            th = this.mapping.get(provider);
         }
         if (th == null) {
             throw new TaskSubmissionException("Provider " + provider
@@ -55,7 +54,7 @@
         }
         String provider = task.getService(0).getProvider().toLowerCase();
         synchronized (this.mapping) {
-            TaskHandler th = (TaskHandler) this.mapping.get(provider);
+            TaskHandler th = this.mapping.get(provider);
             if (th == null) {
                 th = createTaskHandler(task);
             }
@@ -99,18 +98,16 @@
 
     public void remove(Task task) throws ActiveTaskException {
         String provider = task.getService(0).getProvider().toLowerCase();
-        TaskHandler taskHandler = (TaskHandler) this.mapping.get(provider);
+        TaskHandler taskHandler = this.mapping.get(provider);
         if (taskHandler != null) {
             taskHandler.remove(task);
         }
     }
     
-    protected Collection getTasks(final TaskCollector collector) {
+    protected Collection<Task> getTasks(final TaskCollector collector) {
         // extract tasks from various TaskHandlers
-        ArrayList list = new ArrayList();
-        Iterator i = this.mapping.values().iterator();
-        while (i.hasNext()) {
-            TaskHandler handler = (TaskHandler) i.next();
+        ArrayList<Task> list = new ArrayList<Task>();
+        for (TaskHandler handler : mapping.values()) {
             list.addAll(collector.collect(handler));
         }
         return list;
@@ -132,4 +129,9 @@
         this.mapping.put(provider.toLowerCase(), taskHandler);
         return taskHandler;
     }
+
+    @Override
+    public String getName() {
+        return "FileOperationTaskHandler";
+    }
 }
\ No newline at end of file
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/ExecutionTaskHandler.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/ExecutionTaskHandler.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/ExecutionTaskHandler.java	(working copy)
@@ -185,7 +185,7 @@
         return getTasksWithStatus(Status.CANCELED);
     }
     
-    public String toString() {
+    public String getName() {
         return "ExecutionTaskHandler"; 
     }
 }
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/GenericTaskHandler.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/GenericTaskHandler.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/task/GenericTaskHandler.java	(working copy)
@@ -122,4 +122,8 @@
         list.addAll(collector.collect(fileHandler));
         return list;
     }
+    
+    public String getName() {
+        return "GenericTaskHandler";
+    }
 }
\ No newline at end of file
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/execution/TaskHandlerImpl.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/execution/TaskHandlerImpl.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/execution/TaskHandlerImpl.java	(working copy)
@@ -26,4 +26,8 @@
 	}
 
 	protected abstract DelegatedTaskHandler newDelegatedTaskHandler();
+	
+	public String toString() {
+        return "ExecutionTaskHandler(provider = " + getName() + ")";
+    }
 }
Index: modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractTaskHandler.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractTaskHandler.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/impl/common/AbstractTaskHandler.java	(working copy)
@@ -47,7 +47,11 @@
 
 	protected abstract DelegatedTaskHandler newDelegatedTaskHandler(int type) throws TaskSubmissionException;
 
-	protected abstract String getName();
+	public abstract String getName();
+	
+	public void setName(String name) {
+	    // ignored for most handlers
+	}
 
 	public void suspend(Task task) throws InvalidSecurityContextException, TaskSubmissionException {
 		DelegatedTaskHandler dth = this.handleMap.get(task);
Index: modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/TaskHandler.java
===================================================================
--- modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/TaskHandler.java	(revision 3910)
+++ modules/abstraction-common/src/org/globus/cog/abstraction/interfaces/TaskHandler.java	(working copy)
@@ -65,6 +65,10 @@
      * Returns the type of tasks handled by this <code>TaskHandler</code>
      */
     public int getType();
+    
+    public String getName();
+    
+    public void setName(String provider);
 
     /**
      * Submits the given {@link Task}for execuiton. The <code>Task</code> is



More information about the Swift-commit mailing list