[Swift-commit] cog r3784

swift at ci.uchicago.edu swift at ci.uchicago.edu
Mon Sep 16 01:35:02 CDT 2013


------------------------------------------------------------------------
r3784 | hategan | 2013-09-16 01:34:38 -0500 (Mon, 16 Sep 2013) | 1 line

merged r3778 from trunk (bulk old proxy delete operations)
------------------------------------------------------------------------
Index: modules/provider-ssh/.classpath
===================================================================
--- modules/provider-ssh/.classpath	(revision 3783)
+++ modules/provider-ssh/.classpath	(working copy)
@@ -12,7 +12,7 @@
 	<classpathentry kind="lib" path="lib/j2ssh-common-0.2.2.jar"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/jglobus"/>
 	<classpathentry kind="lib" path="lib/j2ssh-core-0.2.2-patch-b.jar"/>
-	<classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/>
 	<classpathentry kind="src" path="/abstraction-provider-local"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/log4j"/>
 	<classpathentry kind="output" path=".build"/>
 </classpath>
Index: modules/provider-ssh/src/org/globus/cog/abstraction/impl/sshcl/execution/SSHCLProxyForwarder.java
===================================================================
--- modules/provider-ssh/src/org/globus/cog/abstraction/impl/sshcl/execution/SSHCLProxyForwarder.java	(revision 3783)
+++ modules/provider-ssh/src/org/globus/cog/abstraction/impl/sshcl/execution/SSHCLProxyForwarder.java	(working copy)
@@ -44,6 +44,8 @@
 public class SSHCLProxyForwarder extends ProxyForwarder {
     public static final Logger logger = Logger.getLogger(SSHCLProxyForwarder.class);
     
+    public static final int DELETE_BULK_SIZE = 10;
+    
     private String host;
     private int port;
     private Properties properties;
@@ -150,6 +152,7 @@
             logger.info("Cleaning up old proxies");
             String output = runSSH(new String[] {"ls", "-1", globusDir + "/ssh*-*-*"});
             String[] files = output.split("\\n");
+            List<String> deleteQueue = new ArrayList<String>();
             long nowSecs = System.currentTimeMillis() / 1000;
             for (String f : files) {
                 f = f.substring(f.lastIndexOf('/') + 1);
@@ -157,11 +160,16 @@
                 if (m.matches()) {
                     long expirationTime = Long.parseLong(m.group(3));
                     if (expirationTime < nowSecs) {
-                        logger.info("Removing " + f);
-                        runSSH(new String[] {"rm", "-f", globusDir + "/" + f});
+                        deleteQueue.add(globusDir + "/" + f);
+                        if (deleteQueue.size() == DELETE_BULK_SIZE) {
+                            deleteFiles(deleteQueue);
+                        }
                     }
                 }
             }
+            // delete remaining files
+            deleteFiles(deleteQueue);
+            
         }
         catch (IOException e) {
             if (e.getMessage() == null 
@@ -175,6 +183,21 @@
         }
     }
 
+    private void deleteFiles(List<String> l) throws IOException {
+        if (l.isEmpty()) {
+            return;
+        }
+        
+        logger.info("Removing " + l);
+        String[] cmdline = new String[l.size() + 2];
+        cmdline[0] = "rm";
+        cmdline[1] = "-f";
+        for (int i = 0; i < l.size(); i++) {
+            cmdline[i + 2] = l.get(i);
+        }
+        runSSH(cmdline);
+    }
+
     private String makeGlobusDir() throws IOException {
         String h = runSSH(new String[] {"mkdir", "-p", "~/.globus", ";", "ls", "-d", "~"});
         return h.trim() + "/.globus";



More information about the Swift-commit mailing list