[Swift-commit] r3232 - in trunk/src/org/globus/swift/data: . policy
noreply at svn.ci.uchicago.edu
noreply at svn.ci.uchicago.edu
Tue Feb 9 15:40:26 CST 2010
Author: wozniak
Date: 2010-02-09 15:40:25 -0600 (Tue, 09 Feb 2010)
New Revision: 3232
Added:
trunk/src/org/globus/swift/data/policy/Gather.java
Modified:
trunk/src/org/globus/swift/data/Director.java
trunk/src/org/globus/swift/data/policy/Policy.java
Log:
Support for CDM properties and the GATHER policy.
Modified: trunk/src/org/globus/swift/data/Director.java
===================================================================
--- trunk/src/org/globus/swift/data/Director.java 2010-02-05 23:02:18 UTC (rev 3231)
+++ trunk/src/org/globus/swift/data/Director.java 2010-02-09 21:40:25 UTC (rev 3232)
@@ -4,6 +4,7 @@
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -32,9 +33,14 @@
static File policyFile;
/**
- Maps from Patterns to Policies
+ Maps from Patterns to Policies for fs.data rules
*/
- static Map map = new LinkedHashMap();
+ static Map<Pattern,Policy> map = new LinkedHashMap();
+
+ /**
+ Maps from String names to String values for fs.data properties
+ */
+ static Map<String,String> properties = new HashMap();
/**
Remember the files we have broadcasted
@@ -54,19 +60,43 @@
static void addLine(String s) {
String[] tokens = LineReader.tokenize(s);
- Pattern pattern = Pattern.compile(tokens[0]);
- Policy policy = Policy.valueOf(tokens[1]);
+ String type = tokens[0];
+ if (type.equals("rule")) {
+ addRule(tokens);
+ }
+ else if (type.equals("property")) {
+ addProperty(tokens);
+ }
+
+ }
+
+ static void addRule(String[] tokens) {
+ Pattern pattern = Pattern.compile(tokens[1]);
+ Policy policy = Policy.valueOf(tokens[2]);
List<String> tokenList = Arrays.asList(tokens);
- policy.settings(tokenList.subList(2,tokenList.size()));
+ policy.settings(tokenList.subList(3,tokenList.size()));
map.put(pattern, policy);
}
-
+
+ static void addProperty(String[] tokens) {
+ String name = tokens[1];
+ String value = concat(tokens, 2);
+ properties.put(name, value);
+ }
+
+ static String concat(String[] tokens, int start) {
+ StringBuilder result = new StringBuilder();
+ for (int i = start; i < tokens.length; i++) {
+ result.append(tokens[i]);
+ }
+ return result.toString();
+ }
+
public static Policy lookup(String file) {
- for (Iterator it = map.keySet().iterator(); it.hasNext(); ) {
- Pattern pattern = (Pattern) it.next();
+ for (Pattern pattern : map.keySet()) {
Matcher matcher = pattern.matcher(file);
if (matcher.matches())
- return (Policy) map.get(pattern);
+ return map.get(pattern);
}
return Policy.DEFAULT;
}
Added: trunk/src/org/globus/swift/data/policy/Gather.java
===================================================================
--- trunk/src/org/globus/swift/data/policy/Gather.java (rev 0)
+++ trunk/src/org/globus/swift/data/policy/Gather.java 2010-02-09 21:40:25 UTC (rev 3232)
@@ -0,0 +1,14 @@
+package org.globus.swift.data.policy;
+
+import java.util.List;
+
+public class Gather extends Policy {
+
+ public String toString() {
+ return "GATHER";
+ }
+
+ @Override
+ public void settings(List<String> tokens) {
+ }
+}
Modified: trunk/src/org/globus/swift/data/policy/Policy.java
===================================================================
--- trunk/src/org/globus/swift/data/policy/Policy.java 2010-02-05 23:02:18 UTC (rev 3231)
+++ trunk/src/org/globus/swift/data/policy/Policy.java 2010-02-09 21:40:25 UTC (rev 3232)
@@ -19,6 +19,8 @@
return new Direct();
else if (token.compareToIgnoreCase("broadcast") == 0)
return new Broadcast();
+ else if (token.compareToIgnoreCase("gather") == 0)
+ return new Gather();
return null;
}
}
More information about the Swift-commit
mailing list