[Swift-commit] cog r3778
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Fri Sep 6 17:00:05 CDT 2013
------------------------------------------------------------------------
r3778 | hategan | 2013-09-06 16:55:40 -0500 (Fri, 06 Sep 2013) | 1 line
bulk old proxy delete operations
------------------------------------------------------------------------
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 3777)
+++ 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