[Swift-commit] r4738 - in trunk/src/org/griphyn/vdl: karajan karajan/lib karajan/lib/swiftscript mapping mapping/file
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Sat Jul 2 21:08:41 CDT 2011
Author: hategan
Date: 2011-07-02 21:08:41 -0500 (Sat, 02 Jul 2011)
New Revision: 4738
Added:
trunk/src/org/griphyn/vdl/karajan/FutureTracker.java
trunk/src/org/griphyn/vdl/karajan/FutureWrapper.java
Removed:
trunk/src/org/griphyn/vdl/karajan/WrapperMap.java
Modified:
trunk/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java
trunk/src/org/griphyn/vdl/karajan/DSHandleFutureWrapper.java
trunk/src/org/griphyn/vdl/karajan/HangChecker.java
trunk/src/org/griphyn/vdl/karajan/Monitor.java
trunk/src/org/griphyn/vdl/karajan/lib/CloseDataset.java
trunk/src/org/griphyn/vdl/karajan/lib/CreateArray.java
trunk/src/org/griphyn/vdl/karajan/lib/FringePaths.java
trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java
trunk/src/org/griphyn/vdl/karajan/lib/GetFieldSubscript.java
trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java
trunk/src/org/griphyn/vdl/karajan/lib/IsDone.java
trunk/src/org/griphyn/vdl/karajan/lib/Mark.java
trunk/src/org/griphyn/vdl/karajan/lib/New.java
trunk/src/org/griphyn/vdl/karajan/lib/Range.java
trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
trunk/src/org/griphyn/vdl/karajan/lib/SetFutureFault.java
trunk/src/org/griphyn/vdl/karajan/lib/SiteProfile.java
trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java
trunk/src/org/griphyn/vdl/karajan/lib/Stagein.java
trunk/src/org/griphyn/vdl/karajan/lib/Stageout.java
trunk/src/org/griphyn/vdl/karajan/lib/SwiftArg.java
trunk/src/org/griphyn/vdl/karajan/lib/UnwrapClosedList.java
trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
trunk/src/org/griphyn/vdl/karajan/lib/WaitFieldValue.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Java.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java
trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
trunk/src/org/griphyn/vdl/mapping/ArrayDataNode.java
trunk/src/org/griphyn/vdl/mapping/DSHandle.java
trunk/src/org/griphyn/vdl/mapping/ExternalDataNode.java
trunk/src/org/griphyn/vdl/mapping/MappingParam.java
trunk/src/org/griphyn/vdl/mapping/RootArrayDataNode.java
trunk/src/org/griphyn/vdl/mapping/RootDataNode.java
trunk/src/org/griphyn/vdl/mapping/file/ArrayFileMapper.java
Log:
got rid of the wrapper map
Modified: trunk/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/ArrayIndexFutureList.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -5,6 +5,8 @@
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -16,40 +18,34 @@
import org.globus.cog.karajan.workflow.futures.FutureListener;
import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.globus.cog.karajan.workflow.futures.ListenerStackPair;
-import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.DSHandleListener;
+import org.griphyn.vdl.mapping.ArrayDataNode;
-public class ArrayIndexFutureList implements FutureList, DSHandleListener {
+public class ArrayIndexFutureList implements FutureList, FutureWrapper {
private ArrayList<Object> keys;
private Map<?, ?> values;
- private boolean closed;
- private ArrayList<ListenerStackPair> listeners;
- private FutureEvaluationException exception;
+ private List<ListenerStackPair> listeners;
+ private ArrayDataNode node;
- public ArrayIndexFutureList(DSHandle handle, Map<?, ?> values) {
+ public ArrayIndexFutureList(ArrayDataNode node, Map<?, ?> values) {
+ this.node = node;
this.values = values;
keys = new ArrayList<Object>();
- handle.addListener(this);
}
- private RuntimeException notYetAvailable() {
- if (exception != null) {
- return exception;
- }
- return new FutureNotYetAvailable(this);
- }
-
public Object get(int index) {
- if (exception != null) {
- throw exception;
+ synchronized(node) {
+ Object v = node.getValue();
+ if (v instanceof RuntimeException) {
+ throw (RuntimeException) v;
+ }
+ if (!node.isClosed() && index >= keys.size()) {
+ throw new FutureNotYetAvailable(this);
+ }
+ else {
+ Object key = keys.get(index);
+ return new Pair(key, values.get(key));
+ }
}
- if (!closed && index >= keys.size()) {
- throw notYetAvailable();
- }
- else {
- Object key = keys.get(index);
- return new Pair(key, values.get(key));
- }
}
public int available() {
@@ -70,43 +66,47 @@
}
public void close() {
- synchronized(this) {
- closed = true;
- Set<Object> allkeys = new HashSet<Object>(values.keySet());
- allkeys.removeAll(keys);
- // remaining keys must be added
- keys.addAll(allkeys);
+ synchronized(node) {
+ purge();
}
notifyListeners();
}
- public synchronized boolean isClosed() {
- return closed;
+ private void purge() {
+ Set<Object> allkeys = new HashSet<Object>(values.keySet());
+ allkeys.removeAll(keys);
+ // remaining keys must be added
+ keys.addAll(allkeys);
}
+ public boolean isClosed() {
+ synchronized(node) {
+ return node.isClosed();
+ }
+ }
+
public Object getValue() {
return this;
}
- public void addModificationAction(FutureListener target,
- VariableStack stack) {
- synchronized(this) {
+ public void addModificationAction(FutureListener target, VariableStack stack) {
+ synchronized(node) {
if (listeners == null) {
- listeners = new ArrayList<ListenerStackPair>();
+ listeners = new LinkedList<ListenerStackPair>();
}
-
listeners.add(new ListenerStackPair(target, stack));
- if (!closed) {
+ WaitingThreadsMonitor.addThread(stack);
+ if (!node.isClosed()) {
return;
}
}
- // closed
+ // closed == true;
notifyListeners();
}
- private void notifyListeners() {
- ArrayList<ListenerStackPair> l;
- synchronized (this) {
+ public void notifyListeners() {
+ List<ListenerStackPair> l;
+ synchronized(node) {
if (listeners == null) {
return;
}
@@ -114,23 +114,36 @@
l = listeners;
listeners = null;
}
-
+
for (ListenerStackPair lsp : l) {
+ WaitingThreadsMonitor.removeThread(lsp.stack);
lsp.listener.futureModified(this, lsp.stack);
}
}
public EventTargetPair[] getListenerEvents() {
- return listeners.toArray(new EventTargetPair[0]);
+ synchronized(node) {
+ if (listeners != null) {
+ return listeners.toArray(new EventTargetPair[0]);
+ }
+ else {
+ return null;
+ }
+ }
}
public int size() {
- if (closed) {
- return keys.size();
+ synchronized(node) {
+ if (node.isClosed()) {
+ if (node.getValue() instanceof RuntimeException) {
+ throw (RuntimeException) node.getValue();
+ }
+ return keys.size();
+ }
+ else {
+ throw new FutureNotYetAvailable(this);
+ }
}
- else {
- throw notYetAvailable();
- }
}
public String toString() {
@@ -141,7 +154,7 @@
else {
l = listeners.size() + " listeners";
}
- if (!closed) {
+ if (!isClosed()) {
return "Open, " + keys.size() + " elements, " + l;
}
else {
@@ -153,15 +166,31 @@
}
public void fail(FutureEvaluationException e) {
- this.exception = e;
- notifyListeners();
+ synchronized(node) {
+ node.setValue(e);
+ }
}
public FutureEvaluationException getException() {
- return exception;
+ synchronized(node) {
+ Object v = node.getValue();
+ if (v instanceof FutureEvaluationException) {
+ return (FutureEvaluationException) v;
+ }
+ else {
+ return null;
+ }
+ }
}
- public void handleClosed(DSHandle handle) {
- close();
+ public int listenerCount() {
+ synchronized(node) {
+ if (listeners == null) {
+ return 0;
+ }
+ else {
+ return listeners.size();
+ }
+ }
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/DSHandleFutureWrapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/DSHandleFutureWrapper.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/DSHandleFutureWrapper.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -8,120 +8,104 @@
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.events.EventTargetPair;
-import org.globus.cog.karajan.workflow.futures.Future;
import org.globus.cog.karajan.workflow.futures.FutureEvaluationException;
import org.globus.cog.karajan.workflow.futures.FutureListener;
import org.globus.cog.karajan.workflow.futures.ListenerStackPair;
-import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.DSHandleListener;
+import org.griphyn.vdl.mapping.AbstractDataNode;
-public class DSHandleFutureWrapper implements Future, DSHandleListener {
- private DSHandle handle;
- private LinkedList<ListenerStackPair> listeners;
+public class DSHandleFutureWrapper implements FutureWrapper {
+ private LinkedList<ListenerStackPair> listeners;
+ private AbstractDataNode node;
+
+ public DSHandleFutureWrapper(AbstractDataNode node) {
+ this.node = node;
+ }
+
+ public void addModificationAction(FutureListener target, VariableStack stack) {
+ /**
+ * TODO So, the strategy is the following: getValue() or something else
+ * throws a future exception; then some entity catches that and calls
+ * this method. There is no way to ensure that the future was not closed
+ * in the mean time. What has to be done is that this method should
+ * check if the future was closed or modified at the time of the call of
+ * this method and call notifyListeners().
+ */
+ synchronized(node) {
+ if (listeners == null) {
+ listeners = new LinkedList<ListenerStackPair>();
+ }
+ listeners.add(new ListenerStackPair(target, stack));
+ WaitingThreadsMonitor.addThread(stack);
+ if (!node.isClosed()) {
+ return;
+ }
+ }
+ // closed == true;
+ notifyListeners();
+ }
- public DSHandleFutureWrapper(DSHandle handle) {
- this.handle = handle;
- handle.addListener(this);
- }
+ public void notifyListeners() {
+ List<ListenerStackPair> l;
+ synchronized(node) {
+ if (listeners == null) {
+ return;
+ }
+
+ l = listeners;
+ listeners = null;
+ }
+
+ for (ListenerStackPair lsp : l) {
+ WaitingThreadsMonitor.removeThread(lsp.stack);
+ lsp.listener.futureModified(this, lsp.stack);
+ }
+ }
- public synchronized void close() {
- handle.closeShallow();
- }
+ public void close() {
+ node.closeShallow();
+ }
+
+ public boolean isClosed() {
+ return node.isClosed();
+ }
- public synchronized boolean isClosed() {
- return handle.isClosed();
- }
+ public Object getValue() {
+ Object v = node.getValue();
+ if (v instanceof RuntimeException) {
+ throw (RuntimeException) v;
+ }
+ return v;
+ }
- public synchronized Object getValue() {
- Object value = handle.getValue();
- if (value instanceof RuntimeException) {
- throw (RuntimeException) value;
- }
- else {
- return value;
- }
- }
-
- public void addModificationAction(FutureListener target, VariableStack stack) {
- /**
- * TODO So, the strategy is the following: getValue() or something else
- * throws a future exception; then some entity catches that and calls
- * this method. There is no way to ensure that the future was not closed
- * in the mean time. What has to be done is that this method should
- * check if the future was closed or modified at the time of the call of
- * this method and call notifyListeners().
- */
- synchronized(this) {
+ public void fail(FutureEvaluationException e) {
+ node.setValue(e);
+ }
+
+ public int listenerCount() {
+ synchronized(node) {
if (listeners == null) {
- listeners = new LinkedList<ListenerStackPair>();
+ return 0;
}
- listeners.add(new ListenerStackPair(target, stack));
- WaitingThreadsMonitor.addThread(stack);
- if (!handle.isClosed()) {
- return;
+ else {
+ return listeners.size();
}
}
- // handle.isClosed();
- notifyListeners();
}
+
+ private static final EventTargetPair[] EVENT_ARRAY = new EventTargetPair[0];
- private void notifyListeners() {
- List<ListenerStackPair> l;
- synchronized(this) {
- if (listeners == null) {
- return;
- }
-
- l = listeners;
- listeners = null;
+ public EventTargetPair[] getListenerEvents() {
+ synchronized(node) {
+ if (listeners != null) {
+ return listeners.toArray(EVENT_ARRAY);
+ }
+ else {
+ return null;
+ }
}
-
- for (ListenerStackPair lsp : l) {
- WaitingThreadsMonitor.removeThread(lsp.stack);
- lsp.listener.futureModified(DSHandleFutureWrapper.this, lsp.stack);
- }
}
- public synchronized int listenerCount() {
- if (listeners == null) {
- return 0;
- }
- else {
- return listeners.size();
- }
- }
-
- public synchronized EventTargetPair[] getListenerEvents() {
- if (listeners != null) {
- return (EventTargetPair[]) listeners.toArray(new EventTargetPair[0]);
- }
- else {
- return null;
- }
- }
-
public String toString() {
- String l;
- if (listeners == null) {
- l = "no listeners";
- }
- else {
- l = listeners.size() + " listeners";
- }
- if (!isClosed()) {
- return "Open, " + l;
- }
- else {
- return "Closed, " + l;
- }
+ return "F/" + node;
}
-
- public void fail(FutureEvaluationException e) {
- handle.setValue(e);
- handle.closeShallow();
- }
-
- public void handleClosed(DSHandle handle) {
- notifyListeners();
- }
}
Added: trunk/src/org/griphyn/vdl/karajan/FutureTracker.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/FutureTracker.java (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/FutureTracker.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -0,0 +1,49 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 1, 2011
+ */
+package org.griphyn.vdl.karajan;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.workflow.futures.Future;
+import org.griphyn.vdl.mapping.DSHandle;
+
+public class FutureTracker {
+ public static final String VAR_NAME = "#swift:futureTracker";
+
+ public static FutureTracker get(VariableStack stack) {
+ return (FutureTracker) stack.firstFrame().getVar(VAR_NAME);
+ }
+
+ private static final FutureTracker ft = new FutureTracker();
+
+ public static FutureTracker get() {
+ return ft;
+ }
+
+ private Map<DSHandle, Future> futures;
+
+ public FutureTracker() {
+ futures = new HashMap<DSHandle, Future>();
+ }
+
+ public synchronized void add(DSHandle h, Future f) {
+ futures.put(h, f);
+ }
+
+ public synchronized void remove(DSHandle h) {
+ futures.remove(h);
+ }
+
+ public Map<DSHandle, Future> getMap() {
+ return futures;
+ }
+}
Added: trunk/src/org/griphyn/vdl/karajan/FutureWrapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/FutureWrapper.java (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/FutureWrapper.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -0,0 +1,21 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 1, 2011
+ */
+package org.griphyn.vdl.karajan;
+
+import org.globus.cog.karajan.workflow.events.EventTargetPair;
+import org.globus.cog.karajan.workflow.futures.Future;
+
+public interface FutureWrapper extends Future {
+ void notifyListeners();
+
+ int listenerCount();
+
+ EventTargetPair[] getListenerEvents();
+}
Modified: trunk/src/org/griphyn/vdl/karajan/HangChecker.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/HangChecker.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/HangChecker.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -28,12 +28,10 @@
public static final int CHECK_INTERVAL = 10000;
private Timer timer;
private long lastEventCount;
- private WrapperMap map;
private VariableStack stack;
public HangChecker(VariableStack stack) throws ExecutionException {
this.stack = stack;
- map = VDLFunction.getFutureWrapperMap(stack);
}
public void start() {
@@ -51,7 +49,7 @@
logger.warn("No events in " + (CHECK_INTERVAL / 1000) + "s.");
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
- Monitor.dumpVariables(map, ps);
+ Monitor.dumpVariables(ps);
Monitor.dumpThreads(ps);
logger.warn(os.toString());
ps.close();
Modified: trunk/src/org/griphyn/vdl/karajan/Monitor.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/Monitor.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/Monitor.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -39,7 +39,6 @@
import org.globus.cog.karajan.util.ThreadingContext;
import org.globus.cog.karajan.workflow.events.EventTargetPair;
import org.globus.cog.karajan.workflow.futures.Future;
-import org.griphyn.vdl.karajan.WrapperMap.FutureWrappers;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.ArrayDataNode;
import org.griphyn.vdl.mapping.DSHandle;
@@ -55,10 +54,7 @@
private List wr, wt;
private int crtdisp;
- private WrapperMap map;
-
- public Monitor(WrapperMap map) {
- this.map = map;
+ public Monitor() {
Service s = new Service();
new Thread(s, "network debugger").start();
}
@@ -99,20 +95,12 @@
crtdisp = VARS;
ArrayList al = new ArrayList();
wr = new ArrayList();
+ Map<DSHandle, Future> map = FutureTracker.get().getMap();
synchronized (map) {
- Iterator i = map.entrySet().iterator();
- while (i.hasNext()) {
+ for (Map.Entry<DSHandle, Future> en : map.entrySet()) {
List entry = new ArrayList();
- Map.Entry en = (Map.Entry) i.next();
- FutureWrappers fw = (FutureWrappers) en.getValue();
- Future f = null;
- if (fw.nodeWrapper != null) {
- f = fw.nodeWrapper;
- }
- else if (fw.arrayWrapper != null) {
- f = fw.arrayWrapper;
- }
- DSHandle handle = (DSHandle) en.getKey();
+ Future f = en.getValue();
+ DSHandle handle = en.getKey();
String value = "-";
Object v;
try {
@@ -143,8 +131,8 @@
entry.add(f.isClosed() ? "Closed" : "Open");
entry.add(sz);
String fs;
- if (f instanceof DSHandleFutureWrapper) {
- fs = String.valueOf(((DSHandleFutureWrapper) f).listenerCount());
+ if (f instanceof FutureWrapper) {
+ fs = String.valueOf(((FutureWrapper) f).listenerCount());
}
else {
fs = f.toString();
@@ -209,25 +197,13 @@
public void dumpVariables() {
dumpVariables(System.out);
}
-
- public void dumpVariables(PrintStream ps) {
- dumpVariables(map, ps);
- }
- public static void dumpVariables(WrapperMap map, PrintStream ps) {
+ public static void dumpVariables(PrintStream ps) {
ps.println("\nRegistered futures:");
+ Map<DSHandle, Future> map = FutureTracker.get().getMap();
synchronized (map) {
- Iterator i = map.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry en = (Map.Entry) i.next();
- FutureWrappers fw = (FutureWrappers) en.getValue();
- Future f = null;
- if (fw.nodeWrapper != null) {
- f = fw.nodeWrapper;
- }
- else if (fw.arrayWrapper != null) {
- f = fw.arrayWrapper;
- }
+ for (Map.Entry<DSHandle, Future> en : map.entrySet()) {
+ Future f = en.getValue();
AbstractDataNode handle = (AbstractDataNode) en.getKey();
String value = "-";
try {
@@ -395,13 +371,12 @@
public EventTargetPair[] getListeners(int wrindex) {
Object o = wr.get(wrindex);
- if (o instanceof DSHandleFutureWrapper) {
- return ((DSHandleFutureWrapper) o).getListenerEvents();
+ if (o instanceof FutureWrapper) {
+ return ((FutureWrapper) o).getListenerEvents();
}
- else if (o instanceof ArrayIndexFutureList) {
- return ((ArrayIndexFutureList) o).getListenerEvents();
+ else {
+ return null;
}
- return null;
}
public void mousePressed(MouseEvent e) {
Deleted: trunk/src/org/griphyn/vdl/karajan/WrapperMap.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/WrapperMap.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/WrapperMap.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -1,104 +0,0 @@
-/*
- * Created on Jul 6, 2006
- */
-package org.griphyn.vdl.karajan;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.griphyn.vdl.mapping.DSHandle;
-
-public class WrapperMap {
- private Map<DSHandle, FutureWrappers> map;
-
- public WrapperMap() {
- this.map = new HashMap<DSHandle, FutureWrappers>();
- }
-
- public static class FutureWrappers {
- public DSHandleFutureWrapper nodeWrapper;
- public ArrayIndexFutureList arrayWrapper;
- }
-
- public void close(DSHandle handle) {
- DSHandleFutureWrapper nodeWrapper;
- ArrayIndexFutureList arrayWrapper;
- synchronized(this) {
- FutureWrappers fw = map.get(handle);
- if (fw == null) {
- return;
- }
- nodeWrapper = fw.nodeWrapper;
- arrayWrapper = fw.arrayWrapper;
- }
- if (nodeWrapper != null) {
- nodeWrapper.close();
- }
- if (arrayWrapper != null) {
- arrayWrapper.close();
- }
- }
-
- public boolean isClosed(DSHandle handle) {
- DSHandleFutureWrapper nodeWrapper;
- ArrayIndexFutureList arrayWrapper;
- synchronized(this) {
- FutureWrappers fw = map.get(handle);
- if (fw == null) {
- return false;
- }
- nodeWrapper = fw.nodeWrapper;
- arrayWrapper = fw.arrayWrapper;
- }
- if (nodeWrapper != null) {
- return nodeWrapper.isClosed();
- }
- else if (arrayWrapper != null) {
- return arrayWrapper.isClosed();
- }
- else {
- return false;
- }
- }
-
- public synchronized DSHandleFutureWrapper addNodeListener(DSHandle handle) {
- FutureWrappers fw = map.get(handle);
- if (fw == null) {
- map.put(handle, fw = new FutureWrappers());
- }
- if (fw.nodeWrapper == null) {
- assert Thread.holdsLock(handle.getRoot()); // TODO should be on root or on handle?
- fw.nodeWrapper = new DSHandleFutureWrapper(handle);
- }
- return fw.nodeWrapper;
- }
-
- public synchronized ArrayIndexFutureList addFutureListListener(DSHandle handle, Map<?, ?> value) {
- FutureWrappers fw = map.get(handle);
- if (fw == null) {
- map.put(handle, fw = new FutureWrappers());
- }
- if (fw.arrayWrapper == null) {
- assert Thread.holdsLock(handle.getRoot()); // TODO should be on root or on handle?
- fw.arrayWrapper = new ArrayIndexFutureList(handle, value);
- }
- return fw.arrayWrapper;
- }
-
- public synchronized void mergeListeners(DSHandle destination, DSHandle source) {
- // TODO
- throw new RuntimeException("not implemented");
- }
-
- public synchronized void markAsAvailable(DSHandle handle, Object key) {
- FutureWrappers fw = map.get(handle);
- if (fw != null && fw.arrayWrapper != null) {
- fw.arrayWrapper.addKey(key);
- }
- }
-
- public Set<Map.Entry<DSHandle, FutureWrappers>> entrySet() {
- return map.entrySet();
- }
-}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/CloseDataset.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/CloseDataset.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/CloseDataset.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -8,6 +8,7 @@
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.util.TypeUtil;
import org.globus.cog.karajan.workflow.ExecutionException;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
@@ -31,10 +32,10 @@
var = var.getField(path);
if (TypeUtil.toBoolean(OA_CHILDREN_ONLY.getValue(stack))) {
- closeChildren(stack, var);
+ closeChildren(stack, (AbstractDataNode) var);
}
else {
- closeDeep(stack, var);
+ var.closeDeep();
}
}
catch (InvalidPathException e) {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/CreateArray.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/CreateArray.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/CreateArray.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -75,7 +75,7 @@
logger.info("CREATEARRAY MEMBER array="+handle.getIdentifier()+" index="+index+" member="+n.getIdentifier());
index++;
}
- closeShallow(stack, handle);
+ handle.closeShallow();
logger.info("CREATEARRAY COMPLETED array="+handle.getIdentifier());
return handle;
@@ -84,5 +84,4 @@
throw new ExecutionException(e);
}
}
-
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/FringePaths.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/FringePaths.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/FringePaths.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -8,6 +8,7 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
+import org.globus.cog.karajan.workflow.futures.Future;
import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.HandleOpenException;
@@ -34,9 +35,7 @@
throw new ExecutionException(e);
}
catch (HandleOpenException e) {
- synchronized(root) {
- throw new FutureNotYetAvailable(addFutureListener(stack, e.getSource()));
- }
+ throw new FutureNotYetAvailable((Future) e.getSource());
}
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetArrayIterator.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -1,12 +1,11 @@
package org.griphyn.vdl.karajan.lib;
-import java.util.Map;
-
import org.apache.log4j.Logger;
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
import org.griphyn.vdl.karajan.PairIterator;
+import org.griphyn.vdl.mapping.ArrayDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
@@ -34,18 +33,16 @@
}
else {
var = var.getField(path);
- if (var.getType().isArray()) {
- Map value = var.getArrayValue();
+ if (!var.getType().isArray()) {
+ throw new RuntimeException("Cannot get array iterator for non-array");
+ }
+ synchronized(var) {
if (var.isClosed()) {
- return new PairIterator(value);
+ return new PairIterator(var.getArrayValue());
}
else {
- synchronized(var.getRoot()) {
- return addFutureListListener(stack, var, value);
- }
+ return ((ArrayDataNode) var).getFutureList().futureIterator();
}
- } else {
- throw new RuntimeException("Cannot get array iterator for non-array");
}
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetFieldSubscript.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetFieldSubscript.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetFieldSubscript.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -28,20 +28,23 @@
Object index = PA_SUBSCRIPT.getValue(stack);
try {
-// TODO this is inefficient, but should expose the right semantics
-// so can be fixed up later
Path path;
- if(index instanceof String)
- path = parsePath("["+index+"]", stack);
- else if(index instanceof Double)
- path = parsePath("["+((Double)index).intValue()+"]", stack);
- else
- throw new RuntimeException("Cannot handle array index of Java type "+index.getClass());
+ if (index instanceof String) {
+ path = Path.EMPTY_PATH.addFirst((String) index, true);
+ }
+ else if (index instanceof Double) {
+ path = Path.EMPTY_PATH.addFirst(String.valueOf(((Double) index).intValue()), true);
+ }
+ else {
+ throw new RuntimeException("Cannot handle array index of Java type " + index.getClass());
+ }
Collection<DSHandle> fields = var.getFields(path);
- if(fields.size() == 1)
+ if (fields.size() == 1) {
return fields.iterator().next();
- else
+ }
+ else {
return fields;
+ }
}
catch (InvalidPathException e) {
throw new ExecutionException(e);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetFieldValue.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -7,10 +7,9 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
+import org.globus.cog.karajan.workflow.futures.FutureFault;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.HandleOpenException;
-import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
public class GetFieldValue extends VDLFunction {
@@ -29,41 +28,27 @@
if (!(var1 instanceof DSHandle)) {
return var1;
}
- DSHandle var = (DSHandle) var1;
- DSHandle root = var.getRoot();
- synchronized(root) {
- try {
- Path path = parsePath(OA_PATH.getValue(stack), stack);
- if (path.hasWildcards()) {
- try {
- return var.getFields(path).toArray();
- }
- catch (HandleOpenException e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Waiting for var=" + var + " path=" + path);
- }
- throw new FutureNotYetAvailable(addFutureListener(stack, e.getSource()));
- }
+ AbstractDataNode var = (AbstractDataNode) var1;
+
+ try {
+ Path path = parsePath(OA_PATH.getValue(stack), stack);
+ if (path.hasWildcards()) {
+ return var.getFields(path).toArray();
+ }
+ else {
+ var = (AbstractDataNode) var.getField(path);
+ if (var.getType().isArray()) {
+ throw new RuntimeException("Getting value for array " + var + " which is not permitted.");
}
- else {
- var = var.getField(path);
- if (var.getType().isArray()) {
- throw new RuntimeException("Getting value for array "+var+" which is not permitted.");
- }
- if (!var.isClosed()) {
- if (logger.isDebugEnabled()) {
- logger.debug("Waiting for " + var);
- }
- throw new FutureNotYetAvailable(addFutureListener(stack, var));
- }
- else {
- return var.getValue();
- }
- }
+ var.waitFor();
+ return var.getValue();
}
- catch (InvalidPathException e) {
- throw new ExecutionException(e);
- }
}
+ catch (FutureFault f) {
+ throw f;
+ }
+ catch (Exception e) {
+ throw new ExecutionException(e);
+ }
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/IsDone.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/IsDone.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/IsDone.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -21,8 +21,7 @@
}
@Override
- protected Object function(VariableStack stack) throws ExecutionException,
- HandleOpenException {
+ protected Object function(VariableStack stack) throws ExecutionException {
List files = TypeUtil.toList(STAGEOUT.getValue(stack));
for (Object f : files) {
List pv = TypeUtil.toList(f);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Mark.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Mark.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Mark.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -25,8 +25,7 @@
}
@Override
- protected Object function(VariableStack stack) throws ExecutionException,
- HandleOpenException {
+ protected Object function(VariableStack stack) throws ExecutionException {
try {
if (TypeUtil.toBoolean(ERR.getValue(stack))) {
boolean mapping = TypeUtil.toBoolean(MAPPING.getValue(stack));
@@ -43,7 +42,7 @@
else {
leaf.setValue(new DataDependentException(leaf, null));
}
- closeShallow(stack, leaf);
+ leaf.closeShallow();
}
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/New.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/New.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/New.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -114,7 +114,7 @@
index++;
}
}
- closeShallow(stack, handle);
+ handle.closeShallow();
}
handle.init(mapping);
@@ -127,7 +127,6 @@
handle.init(mapping);
if (value != null) {
handle.setValue(internalValue(type, value));
- closeShallow(stack, handle);
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Range.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Range.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Range.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -47,13 +47,17 @@
handle = new RootArrayDataNode(type.arrayType()) {
final DSHandle h = this;
- public Collection getFields(Path path)
- throws InvalidPathException, HandleOpenException {
+ {
+ closeShallow();
+ }
+
+ public Collection<DSHandle> getFields(Path path)
+ throws InvalidPathException {
if (path.size() > 1) {
throw new InvalidPathException(path, this);
}
else if (path.equals(Path.EMPTY_PATH)) {
- return Collections.singletonList(this);
+ return Collections.singletonList((DSHandle) this);
}
else {
int index = Integer.parseInt(path.getFirst());
@@ -65,12 +69,12 @@
}
}
- public Map getArrayValue() {
- return new AbstractMap() {
- public Set entrySet() {
- return new AbstractSet() {
- public Iterator iterator() {
- return new Iterator() {
+ public Map<Comparable<?>, DSHandle> getArrayValue() {
+ return new AbstractMap<Comparable<?>, DSHandle>() {
+ public Set<Map.Entry<Comparable<?>, DSHandle>> entrySet() {
+ return new AbstractSet<Map.Entry<Comparable<?>, DSHandle>>() {
+ public Iterator<Map.Entry<Comparable<?>, DSHandle>> iterator() {
+ return new Iterator<Map.Entry<Comparable<?>, DSHandle>>() {
private double crt = start;
private int index = 0;
@@ -78,9 +82,9 @@
return crt <= stop;
}
- public Object next() {
+ public Map.Entry<Comparable<?>, DSHandle> next() {
try {
- Map.Entry e = new Map.Entry() {
+ Map.Entry<Comparable<?>, DSHandle> e = new Map.Entry<Comparable<?>, DSHandle>() {
private DSHandle value;
private int key;
@@ -92,22 +96,22 @@
key = index;
}
- public Object getKey() {
+ public Comparable<?> getKey() {
return new Double(key);
}
- public Object getValue() {
+ public DSHandle getValue() {
return value;
}
- public Object setValue(Object value) {
+ public DSHandle setValue(DSHandle value) {
throw new UnsupportedOperationException();
}
};
index++;
crt += incr;
if (crt > stop) {
- VDLFunction.closeShallow(stack, h);
+ h.closeShallow();
}
return e;
}
@@ -128,17 +132,7 @@
};
}
};
- }
-
- public boolean isClosed() {
- //the need for this lie arises from:
- //1. adding fields to a truly closed array throws an exception
- //2. this is a lazy array not a future array. Consequently, we
- // want the consumer(s) of this array to think that all values
- // in the array are available
- return true;
- }
-
+ }
};
return handle;
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -10,10 +10,10 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
+import org.globus.cog.karajan.workflow.futures.FutureFault;
import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.griphyn.vdl.karajan.Pair;
import org.griphyn.vdl.karajan.PairIterator;
-import org.griphyn.vdl.karajan.VDL2FutureException;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.InvalidPathException;
@@ -33,7 +33,7 @@
try {
Path path = parsePath(OA_PATH.getValue(stack), stack);
DSHandle leaf = var.getField(path);
- DSHandle value = (DSHandle) PA_VALUE.getValue(stack);
+ AbstractDataNode value = (AbstractDataNode) PA_VALUE.getValue(stack);
log(leaf, value);
@@ -42,27 +42,14 @@
// is a DSHandle. There is no need (I think? maybe numerical casting?)
// for type conversion here; but would be useful to have
// type checking.
- synchronized (value.getRoot()) {
- if (!value.isClosed()) {
- throw new FutureNotYetAvailable(addFutureListener(stack, value));
- }
- }
- try {
- synchronized (var.getRoot()) {
- deepCopy(leaf, value, stack);
- if (var.getParent() != null && var.getParent().getType().isArray()) {
- markAsAvailable(stack, leaf.getParent(), leaf.getPathFromRoot().getLast());
- }
- }
- }
- catch (VDL2FutureException e) {
- throw new FutureNotYetAvailable(addFutureListener(stack, e.getHandle()));
- }
+ value.waitFor();
+ deepCopy(leaf, value, stack);
+
return null;
}
- catch (FutureNotYetAvailable fnya) {
- throw fnya;
+ catch (FutureFault f) {
+ throw f;
}
catch (Exception e) { // TODO tighten this
throw new ExecutionException(e);
@@ -144,7 +131,7 @@
}
deepCopy(field, rhs, stack);
}
- closeShallow(stack, dest);
+ dest.closeShallow();
}
else if (!source.getType().isComposite()) {
Path dpath = dest.getPathFromRoot();
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SetFutureFault.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SetFutureFault.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SetFutureFault.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -40,7 +40,6 @@
else {
leaf.setValue(new DataDependentException(leaf, (Exception) value));
}
- closeShallow(stack, leaf);
}
}
catch (Exception e) {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SiteProfile.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SiteProfile.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SiteProfile.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -5,25 +5,16 @@
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
-import org.globus.cog.abstraction.impl.common.execution.WallTime;
import org.globus.cog.karajan.arguments.Arg;
-import org.globus.cog.karajan.arguments.ArgUtil;
-import org.globus.cog.karajan.arguments.NamedArguments;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.util.BoundContact;
import org.globus.cog.karajan.util.TypeUtil;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.nodes.grid.GridExec;
-import org.globus.swift.catalog.TCEntry;
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;
public class SiteProfile extends VDLFunction {
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -6,10 +6,9 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
-
import org.griphyn.vdl.karajan.Pair;
import org.griphyn.vdl.karajan.PairIterator;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
@@ -47,12 +46,8 @@
if(var1 instanceof DSHandle) {
try {
- DSHandle sourceArray = (DSHandle) var1;
- synchronized(sourceArray.getRoot()) {
- if(!sourceArray.isClosed()) {
- throw new FutureNotYetAvailable(VDLFunction.addFutureListener(stack, sourceArray));
- }
- }
+ AbstractDataNode sourceArray = (AbstractDataNode) var1;
+ sourceArray.waitFor();
Type sourceType = sourceArray.getType();
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Stagein.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Stagein.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Stagein.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -7,17 +7,15 @@
import org.apache.log4j.Logger;
import org.globus.cog.karajan.arguments.Arg;
+import org.globus.cog.karajan.arguments.Arg.Channel;
import org.globus.cog.karajan.arguments.ArgUtil;
import org.globus.cog.karajan.arguments.NamedArguments;
-import org.globus.cog.karajan.arguments.Arg.Channel;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
+import org.globus.cog.karajan.workflow.futures.FutureFault;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.DependentException;
-import org.griphyn.vdl.mapping.HandleOpenException;
-import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.MappingDependentException;
import org.griphyn.vdl.mapping.Path;
@@ -37,31 +35,8 @@
.isPrimitive());
}
- private void waitFor(DSHandle var, VariableStack stack)
- throws ExecutionException {
- synchronized (var) {
- if (!var.isClosed()) {
- if (logger.isDebugEnabled()) {
- logger.debug("Waiting for " + var);
- }
- throw new FutureNotYetAvailable(addFutureListener(stack, var));
- }
- else {
- Object v = var.getValue();
- if (logger.isDebugEnabled()) {
- logger.debug("Do not need to wait for " +
- var + " as it is closed and has value " + v +
- (v != null ? " with class " + v.getClass() : ""));
- }
- if (v != null && v instanceof RuntimeException) {
- throw (RuntimeException) v;
- }
- }
- }
- }
-
protected Object function(VariableStack stack) throws ExecutionException {
- DSHandle var = (DSHandle) VAR.getValue(stack);
+ AbstractDataNode var = (AbstractDataNode) VAR.getValue(stack);
if (!isPrimitive(var)) {
boolean deperr = false;
boolean mdeperr = false;
@@ -69,7 +44,7 @@
Collection<Path> fp = var.getFringePaths();
try {
for (Path p : fp) {
- waitFor(var.getField(p), stack);
+ ((AbstractDataNode) var.getField(p)).waitFor();
}
}
catch (DependentException e) {
@@ -79,15 +54,15 @@
STAGEIN.ret(stack, filename(stack, var.getField(p))[0]);
}
}
+ catch (FutureFault f) {
+ throw f;
+ }
catch (MappingDependentException e) {
logger.debug(e);
deperr = true;
mdeperr = true;
}
- catch (HandleOpenException e) {
- throw new FutureNotYetAvailable(addFutureListener(stack, e.getSource()));
- }
- catch (InvalidPathException e) {
+ catch (Exception e) {
throw new ExecutionException(e);
}
if (deperr || mdeperr) {
@@ -98,7 +73,7 @@
}
else {
// we still wait until the primitive value is there
- waitFor(var, stack);
+ var.waitFor();
}
return null;
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/Stageout.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Stageout.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Stageout.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -14,10 +14,9 @@
import org.globus.cog.karajan.arguments.NamedArguments;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.HandleOpenException;
+import org.griphyn.vdl.mapping.DataNode;
import org.griphyn.vdl.mapping.MappingDependentException;
import org.griphyn.vdl.mapping.Path;
@@ -46,7 +45,7 @@
}
protected Object function(VariableStack stack) throws ExecutionException {
- DSHandle var = (DSHandle) VAR.getValue(stack);
+ AbstractDataNode var = (AbstractDataNode) VAR.getValue(stack);
boolean deperr = false;
boolean mdeperr = false;
// currently only static arrays are supported as app returns
@@ -55,12 +54,7 @@
// race conditions (e.g. if this array's mapper had some parameter
// dependencies that weren't closed at the time the app was started).
if (var.getType().isArray()) {
- if (!var.isClosed()) {
- if (logger.isDebugEnabled()) {
- logger.debug("Waiting for array size from " + var);
- }
- throw new FutureNotYetAvailable(addFutureListener(stack, var));
- }
+ var.waitFor();
}
try {
if (!isPrimitive(var)) {
@@ -90,9 +84,8 @@
channel.ret(stack, list(p, var));
}
}
- catch (HandleOpenException e) {
- throw new FutureNotYetAvailable(addFutureListener(stack, e
- .getSource()));
+ catch (Exception e) {
+ throw new ExecutionException(e);
}
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/SwiftArg.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SwiftArg.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SwiftArg.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -6,7 +6,6 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.apache.log4j.Logger;
import org.globus.cog.karajan.arguments.Arg;
@@ -14,9 +13,10 @@
import org.globus.cog.karajan.arguments.VariableArguments;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
-import org.griphyn.vdl.karajan.PairIterator;
+import org.griphyn.vdl.mapping.AbstractDataNode;
+import org.griphyn.vdl.mapping.ArrayDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataNode;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -33,32 +33,17 @@
protected Object unwrap(VariableStack stack, Object val) throws ExecutionException {
if (val instanceof DSHandle) {
- DSHandle handle = (DSHandle) val;
+ AbstractDataNode handle = (AbstractDataNode) val;
+ if (logger.isDebugEnabled()) {
+ logger.debug("SwiftArg.getValue(" + handle + ")");
+ }
if (handle.getType().isArray()) {
- Map value = handle.getArrayValue();
- synchronized(handle.getRoot()) {
- if (handle.isClosed()) {
- return new PairIterator(value);
- }
- else {
- return VDLFunction.addFutureListListener(stack, handle, value);
- }
- }
+ return handle;
}
- if (logger.isDebugEnabled()) {
- logger.debug("SwiftArg.getValue(" + handle + ")");
+ else {
+ handle.waitFor();
+ return handle.getValue();
}
- synchronized (handle.getRoot()) {
- if (!handle.isClosed()) {
- if (logger.isDebugEnabled()) {
- logger.debug("Waiting for " + handle);
- }
- throw new FutureNotYetAvailable(VDLFunction.addFutureListener(stack, handle));
- }
- else {
- return handle.getValue();
- }
- }
}
else {
throw new ExecutionException("Expected Swift data, but got some primitive type (" + val
@@ -187,6 +172,15 @@
}
return ret;
}
+
+ public AbstractDataNode[] asDataNodeArray(VariableStack stack) throws ExecutionException {
+ VariableArguments args = get(stack);
+ AbstractDataNode[] ret = new AbstractDataNode[args.size()];
+ for (int i = 0; i < ret.length; i++) {
+ ret[i] = (AbstractDataNode) args.get(i);
+ }
+ return ret;
+ }
public List asList(VariableStack stack) throws ExecutionException {
VariableArguments args = get(stack);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/UnwrapClosedList.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/UnwrapClosedList.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/UnwrapClosedList.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -30,7 +30,7 @@
for (DSHandle h : l) {
if (h.getType().isArray()) {
- Map<String, DSHandle> m = h.getArrayValue();
+ Map<?, DSHandle> m = h.getArrayValue();
for (DSHandle h2 : m.values()) {
r.add(h2.getValue());
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -5,7 +5,6 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -24,9 +23,6 @@
import org.globus.cog.karajan.util.TypeUtil;
import org.globus.cog.karajan.workflow.ExecutionException;
import org.globus.cog.karajan.workflow.KarajanRuntimeException;
-import org.globus.cog.karajan.workflow.futures.Future;
-import org.globus.cog.karajan.workflow.futures.FutureIterator;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.globus.cog.karajan.workflow.nodes.SequentialWithArguments;
import org.globus.cog.karajan.workflow.nodes.restartLog.RestartLog;
import org.globus.swift.catalog.TCEntry;
@@ -35,10 +31,9 @@
import org.griphyn.vdl.karajan.AssertFailedException;
import org.griphyn.vdl.karajan.Loader;
import org.griphyn.vdl.karajan.TCCache;
-import org.griphyn.vdl.karajan.VDL2FutureException;
-import org.griphyn.vdl.karajan.WrapperMap;
import org.griphyn.vdl.karajan.functions.ConfigProperty;
import org.griphyn.vdl.mapping.AbsFile;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.GeneralizedFileFormat;
@@ -74,9 +69,6 @@
logger.fatal("swift: assert failed: " + e.getMessage());
stack.getExecutionContext().failedQuietly(stack, e);
}
- catch (HandleOpenException e) {
- throw new FutureNotYetAvailable(VDLFunction.addFutureListener(stack, e.getSource()));
- }
catch (DependentException e) {
// This would not be the primal fault so in non-lazy errors mode it
// should not matter
@@ -104,8 +96,7 @@
}
}
- protected abstract Object function(VariableStack stack) throws ExecutionException,
- HandleOpenException;
+ protected abstract Object function(VariableStack stack) throws ExecutionException;
/*
* This will likely break if the engine changes in fundamental ways. It also
@@ -115,11 +106,11 @@
public static String getThreadPrefix(VariableStack stack) throws ExecutionException {
stack = stack.copy();
ThreadingContext last = ThreadingContext.get(stack);
- Stack s = new Stack();
+ Stack<Object> s = new Stack<Object>();
while (stack.frameCount() > 1) {
StackFrame frame = stack.currentFrame();
if (frame.isDefined("$")) {
- List itv = (List) frame.getVar("$");
+ List<?> itv = (List<?>) frame.getVar("$");
s.push(itv.get(0));
stack.leave();
last = ThreadingContext.get(stack);
@@ -168,9 +159,6 @@
else if (Types.BOOLEAN.equals(type)) {
return new Boolean(TypeUtil.toBoolean(value));
}
- else if (value instanceof String) {
- return (String) value;
- }
else {
return value;
}
@@ -184,18 +172,10 @@
}
public static String[] filename(VariableStack stack, DSHandle handle) throws ExecutionException {
- try {
- return filename(handle);
- }
- catch(VDL2FutureException ve) {
- throw new FutureNotYetAvailable(addFutureListener(stack, ve.getHandle()));
- }
- catch (HandleOpenException e) {
- throw new FutureNotYetAvailable(addFutureListener(stack, e.getSource()));
- }
+ return filename(handle);
}
- public static String[] filename(DSHandle var) throws ExecutionException, HandleOpenException {
+ public static String[] filename(DSHandle var) throws ExecutionException {
try {
if (var.getType().isArray()) {
return leavesFileNames(var);
@@ -210,6 +190,9 @@
catch (DependentException e) {
return new String[0];
}
+ catch (HandleOpenException e) {
+ throw new ExecutionException("The current implementation should not throw this exception", e);
+ }
}
private static String[] leavesFileNames(DSHandle var) throws ExecutionException, HandleOpenException {
@@ -217,34 +200,30 @@
synchronized (var.getRoot()) {
mapper = var.getMapper();
}
- List l = new ArrayList();
- Iterator i;
+ List<String> l = new ArrayList<String>();
try {
- Collection fp = var.getFringePaths();
- List src;
+ Collection<Path> fp = var.getFringePaths();
+ List<Path> src;
if (fp instanceof List) {
- src = (List) fp;
+ src = (List<Path>) fp;
}
else {
- src = new ArrayList(fp);
+ src = new ArrayList<Path>(fp);
}
Collections.sort(src, new PathComparator());
- i = src.iterator();
- while (i.hasNext()) {
- Path p = (Path) i.next();
+
+ for (Path p : src) {
l.add(leafFileName(var.getField(p), mapper));
}
}
catch (InvalidPathException e) {
throw new ExecutionException("DSHandle is lying about its fringe paths");
}
- return (String[]) l.toArray(EMPTY_STRING_ARRAY);
+ return l.toArray(EMPTY_STRING_ARRAY);
}
- private static class PathComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- Path p1 = (Path) o1;
- Path p2 = (Path) o2;
+ private static class PathComparator implements Comparator<Path> {
+ public int compare(Path p1, Path p2) {
for (int i = 0; i < Math.min(p1.size(), p2.size()); i++) {
int d;
d = indexOrder(p1.isArrayIndex(i), p2.isArrayIndex(i));
@@ -288,11 +267,7 @@
}
private static String leafFileName(DSHandle var) throws ExecutionException {
- Mapper mapper;
- synchronized (var.getRoot()) {
- mapper = var.getMapper();
- }
- return leafFileName(var, mapper);
+ return leafFileName(var, var.getMapper());
}
private static String leafFileName(DSHandle var, Mapper mapper) throws ExecutionException {
@@ -377,20 +352,6 @@
}
}
- public static final String VDL_FUTURE_WRAPPER_MAP = "#vdl:futureWrapperMap";
-
- public static WrapperMap getFutureWrapperMap(VariableStack stack) throws ExecutionException {
- synchronized (stack.getExecutionContext()) {
- WrapperMap hash = (WrapperMap) stack.firstFrame().getVar(VDL_FUTURE_WRAPPER_MAP);
- if (hash == null) {
- hash = new WrapperMap();
- stack.firstFrame().setVar(VDL_FUTURE_WRAPPER_MAP, hash);
- //InHook.install(new Monitor(hash));
- }
- return hash;
- }
- }
-
protected static Map getLogData(VariableStack stack) throws ExecutionException {
try {
return (Map) stack.getDeepVar(RestartLog.LOG_DATA);
@@ -426,114 +387,26 @@
}
}
- protected void closeChildren(VariableStack stack, DSHandle handle) throws ExecutionException,
+ protected void closeChildren(VariableStack stack, AbstractDataNode handle) throws ExecutionException,
InvalidPathException {
- WrapperMap hash = getFutureWrapperMap(stack);
// Close the future
- boolean closed;
- synchronized(handle.getRoot()) {
- closed = handle.isClosed();
- if (!closed) {
- handle.closeShallow();
- hash.close(handle);
- }
+ handle.closeShallow();
+ // Mark all leaves
+ for (DSHandle child : handle.getFields(Path.CHILDREN)) {
+ child.closeShallow();
}
- try {
- // Mark all leaves
- Iterator it = handle.getFields(Path.CHILDREN).iterator();
- while (it.hasNext()) {
- DSHandle child = (DSHandle) it.next();
- child.closeShallow();
- hash.close(child);
- }
- }
- catch (HandleOpenException e) {
- throw new ExecutionException("Handle open in closeChildren",e);
- }
-
- if (!closed) {
- markToRoot(stack, handle);
- }
}
-
- protected void closeDeep(VariableStack stack, DSHandle handle)
- throws ExecutionException, InvalidPathException {
- synchronized(handle.getRoot()) {
- closeDeep(stack, handle, getFutureWrapperMap(stack));
- }
- }
+
+ public static AbstractDataNode[] waitForAllVargs(VariableStack stack) throws ExecutionException {
+ AbstractDataNode[] args = SwiftArg.VARGS.asDataNodeArray(stack);
- private void closeDeep(VariableStack stack, DSHandle handle,
- WrapperMap wrapperMap)
- throws InvalidPathException, ExecutionException {
- handle.closeShallow();
- wrapperMap.close(handle);
- try {
- // Mark all children
- for (DSHandle child : handle.getFields(Path.CHILDREN))
- closeDeep(stack, child, wrapperMap);
+ for (int i = 0; i < args.length; i++) {
+ args[i].waitFor();
}
- catch (HandleOpenException e) {
- throw new ExecutionException("Handle open in closeChildren", e);
- }
- }
-
- private void markToRoot(VariableStack stack, DSHandle handle) throws ExecutionException {
- // Also mark all arrays from root
- Path fullPath = handle.getPathFromRoot();
- DSHandle root = handle.getRoot();
- synchronized(root) {
- for (int i = 0; i < fullPath.size(); i++) {
- if (fullPath.isArrayIndex(i)) {
- try {
- markAsAvailable(stack, root.getField(fullPath.subPath(0, i)),
- fullPath.getElement(i));
- }
- catch (InvalidPathException e) {
- e.printStackTrace();
- }
- }
- }
- }
+
+ return args;
}
- /** Returns the DSHandle that it is passed, but ensuring that it
- is closed. If the handle is not closed, then execution will
- be deferred/retried until it is.
- */
- static public DSHandle waitFor(VariableStack stack, DSHandle handle) throws ExecutionException {
- synchronized(handle.getRoot()) {
- if (!handle.isClosed()) {
- throw new FutureNotYetAvailable(addFutureListener(stack, handle));
- }
- }
- return handle;
- }
-
- protected static void closeShallow(VariableStack stack, DSHandle handle) throws ExecutionException {
- synchronized (handle.getRoot()) {
- handle.closeShallow();
- getFutureWrapperMap(stack).close(handle);
- }
- }
-
- public static Future addFutureListener(VariableStack stack, DSHandle handle)
- throws ExecutionException {
- assert Thread.holdsLock(handle.getRoot());
- return getFutureWrapperMap(stack).addNodeListener(handle);
- }
-
- protected static FutureIterator addFutureListListener(VariableStack stack, DSHandle handle,
- Map value) throws ExecutionException {
- assert Thread.holdsLock(handle.getRoot());
- return getFutureWrapperMap(stack).addFutureListListener(handle, value).futureIterator(stack);
- }
-
- protected void markAsAvailable(VariableStack stack, DSHandle handle, Object key)
- throws ExecutionException {
- getFutureWrapperMap(stack).markAsAvailable(handle, key);
- }
-
public static Path parsePath(Object o, VariableStack stack) throws ExecutionException {
Path q = Path.EMPTY_PATH;
Path p;
Modified: trunk/src/org/griphyn/vdl/karajan/lib/WaitFieldValue.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/WaitFieldValue.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/WaitFieldValue.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -4,8 +4,7 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
-import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
@@ -21,29 +20,12 @@
* path. Path can contain wildcards, in which case an array is returned.
*/
public Object function(VariableStack stack) throws ExecutionException {
- Object var1 = PA_VAR.getValue(stack);
- if (!(var1 instanceof DSHandle)) {
- throw new RuntimeException("Can only wait for DSHandles - was supplied "+var1.getClass());
- }
- DSHandle var = (DSHandle) var1;
+ AbstractDataNode var = (AbstractDataNode) PA_VAR.getValue(stack);
try {
Path path = parsePath(OA_PATH.getValue(stack), stack);
- var = var.getField(path);
- synchronized (var.getRoot()) {
- if (!var.isClosed()) {
- logger.debug("Waiting for " + var);
- throw new FutureNotYetAvailable(addFutureListener(stack, var));
- }
- else {
- Object v = var.getValue();
- logger.debug("Do not need to wait for " + var+" as it is closed and has value "+v + (v!=null ? " with class "+v.getClass() : "" ));
- if(v !=null && v instanceof RuntimeException) {
- throw (RuntimeException)v;
- } else {
- return null;
- }
- }
- }
+ var = (AbstractDataNode) var.getField(path);
+ var.waitFor();
+ return null;
}
catch (InvalidPathException e) {
throw new ExecutionException(e);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -5,8 +5,8 @@
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
import org.griphyn.vdl.karajan.AssertFailedException;
-import org.griphyn.vdl.karajan.lib.SwiftArg;
import org.griphyn.vdl.karajan.lib.VDLFunction;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.type.Types;
@@ -26,14 +26,9 @@
@Override
protected Object function(VariableStack stack)
throws ExecutionException {
- DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
+ AbstractDataNode[] args = waitForAllVargs(stack);
String message = "";
- for (int i = 0; i < args.length; i++) {
- DSHandle handle = args[i];
- VDLFunction.waitFor(stack, handle);
- }
-
if (args.length == 2)
if (args[1].getType() == Types.STRING)
message = args[1].toString();
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -8,10 +8,9 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.griphyn.vdl.karajan.lib.VDLFunction;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.HandleOpenException;
import org.griphyn.vdl.mapping.RootDataNode;
import org.griphyn.vdl.type.Types;
@@ -21,26 +20,23 @@
setArguments(ExtractInt.class, new Arg[] { PA_VAR });
}
- public Object function(VariableStack stack) throws ExecutionException, HandleOpenException {
- DSHandle handle = null;
+ public Object function(VariableStack stack) throws ExecutionException {
+ AbstractDataNode handle = null;
try {
- handle = (DSHandle) PA_VAR.getValue(stack);
- synchronized(handle.getRoot()) {
- if (!handle.isClosed()) {
- throw new FutureNotYetAvailable(addFutureListener(stack, handle));
- }
- String fn = argList(filename(handle), true);
- Reader freader = new FileReader(fn);
- BufferedReader breader = new BufferedReader(freader);
- String str = breader.readLine();
- freader.close();
- Double i = new Double(str);
- DSHandle result = RootDataNode.newNode(Types.FLOAT, i);
- int provid = VDLFunction.nextProvenanceID();
- VDLFunction.logProvenanceResult(provid, result, "extractint");
- VDLFunction.logProvenanceParameter(provid, handle, "filename");
- return result;
- }
+ handle = (AbstractDataNode) PA_VAR.getValue(stack);
+ handle.waitFor();
+
+ String fn = argList(filename(handle), true);
+ Reader freader = new FileReader(fn);
+ BufferedReader breader = new BufferedReader(freader);
+ String str = breader.readLine();
+ freader.close();
+ Double i = new Double(str);
+ DSHandle result = RootDataNode.newNode(Types.FLOAT, i);
+ int provid = VDLFunction.nextProvenanceID();
+ VDLFunction.logProvenanceResult(provid, result, "extractint");
+ VDLFunction.logProvenanceParameter(provid, handle, "filename");
+ return result;
}
catch (IOException ioe) {
throw new ExecutionException("Reading integer content of file", ioe);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -3,8 +3,6 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
-import org.griphyn.vdl.karajan.VDL2FutureException;
import org.griphyn.vdl.karajan.lib.VDLFunction;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.RootDataNode;
@@ -16,17 +14,11 @@
}
public Object function(VariableStack stack) throws ExecutionException {
- try {
- String s = argList(filename(stack), true);
- DSHandle result = RootDataNode.newNode(Types.STRING, s);
- int provid = VDLFunction.nextProvenanceID();
- //VDLFunction.logProvenanceParameter(provid, (DSHandle) PA_VAR.getValue(stack), "input");
- //VDLFunction.logProvenanceResult(provid, result, "filename");
- return result;
- } catch(VDL2FutureException ve) {
- synchronized(ve.getHandle().getRoot()) {
- throw new FutureNotYetAvailable(addFutureListener(stack, ve.getHandle()));
- }
- }
+ String s = argList(filename(stack), true);
+ DSHandle result = RootDataNode.newNode(Types.STRING, s);
+ int provid = VDLFunction.nextProvenanceID();
+ //VDLFunction.logProvenanceParameter(provid, (DSHandle) PA_VAR.getValue(stack), "input");
+ //VDLFunction.logProvenanceResult(provid, result, "filename");
+ return result;
}
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -8,8 +8,8 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.griphyn.vdl.karajan.lib.SwiftArg;
import org.griphyn.vdl.karajan.lib.VDLFunction;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.type.Types;
@@ -35,13 +35,8 @@
@Override
protected Object function(VariableStack stack)
throws ExecutionException {
- DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
-
- for (int i = 0; i < args.length; i++) {
- DSHandle handle = args[i];
- VDLFunction.waitFor(stack, handle);
- }
-
+ AbstractDataNode[] args = waitForAllVargs(stack);
+
check(args);
String filename = args[0].toString();
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Java.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Java.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Java.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -5,13 +5,11 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.griphyn.vdl.karajan.lib.SwiftArg;
import org.griphyn.vdl.karajan.lib.VDLFunction;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.HandleOpenException;
-import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.RootDataNode;
-import org.griphyn.vdl.type.NoSuchTypeException;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -21,14 +19,8 @@
setArguments(Java.class, new Arg[] { Arg.VARGS });
}
- protected Object function(VariableStack stack) throws ExecutionException,
- HandleOpenException {
- DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
-
- for (int i = 0; i < args.length; i++) {
- DSHandle handle = args[i];
- VDLFunction.waitFor(stack, handle);
- }
+ protected Object function(VariableStack stack) throws ExecutionException {
+ AbstractDataNode[] args = waitForAllVargs(stack);
Method method = getMethod(args);
Object[] p = convertInputs(method, args);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -1,7 +1,6 @@
package org.griphyn.vdl.karajan.lib.swiftscript;
import java.io.IOException;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -13,8 +12,10 @@
import org.globus.cog.karajan.workflow.nodes.functions.FunctionsCollection;
import org.griphyn.vdl.karajan.lib.SwiftArg;
import org.griphyn.vdl.karajan.lib.VDLFunction;
+import org.griphyn.vdl.mapping.AbsFile;
+import org.griphyn.vdl.mapping.AbstractDataNode;
+import org.griphyn.vdl.mapping.ArrayDataNode;
import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.HandleOpenException;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.RootArrayDataNode;
@@ -22,11 +23,6 @@
import org.griphyn.vdl.type.Types;
import org.griphyn.vdl.util.VDL2Config;
-import org.griphyn.vdl.mapping.AbsFile;
-import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
-
-import org.griphyn.vdl.mapping.ArrayDataNode;
-
public class Misc extends FunctionsCollection {
private static final Logger logger = Logger.getLogger(Misc.class);
@@ -34,6 +30,8 @@
public static final SwiftArg PA_INPUT = new SwiftArg.Positional("input");
public static final SwiftArg PA_PATTERN = new SwiftArg.Positional("regexp");
public static final SwiftArg PA_TRANSFORM = new SwiftArg.Positional("transform");
+ public static final SwiftArg PA_FILE = new SwiftArg.Positional("file");
+ public static final SwiftArg PA_ARRAY = new SwiftArg.Positional("array");
static {
setArguments("swiftscript_trace", new Arg[] { Arg.VARGS });
@@ -48,9 +46,9 @@
setArguments("swiftscript_format", new Arg[] { PA_INPUT, PA_TRANSFORM });
setArguments("swiftscript_pad", new Arg[] { PA_INPUT, PA_TRANSFORM });
setArguments("swiftscript_tostring", new Arg[] { PA_INPUT });
- setArguments("swiftscript_dirname", new Arg[] { Arg.VARGS });
- setArguments("swiftscript_length", new Arg[] { Arg.VARGS });
- setArguments("swiftscript_existsfile", new Arg[] { Arg.VARGS });
+ setArguments("swiftscript_dirname", new Arg[] { PA_FILE });
+ setArguments("swiftscript_length", new Arg[] { PA_ARRAY });
+ setArguments("swiftscript_existsfile", new Arg[] { PA_FILE });
}
private static final Logger traceLogger =
@@ -58,24 +56,37 @@
public DSHandle swiftscript_trace(VariableStack stack)
throws ExecutionException {
- DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
+ AbstractDataNode[] args = VDLFunction.waitForAllVargs(stack);
StringBuffer buf = new StringBuffer();
buf.append("SwiftScript trace: ");
for (int i = 0; i < args.length; i++) {
DSHandle handle = args[i];
- VDLFunction.waitFor(stack, handle);
if (i != 0) {
buf.append(", ");
}
Object v = args[i].getValue();
- buf.append(v == null ? args[i] : v);
+ //buf.append(v == null ? args[i] : v);
+ prettyPrint(buf, args[i]);
}
traceLogger.warn(buf);
return null;
}
- public DSHandle swiftscript_strcat(VariableStack stack) throws ExecutionException {
+ private void prettyPrint(StringBuffer buf, DSHandle h) {
+ Object o = h.getValue();
+ if (o == null) {
+ buf.append(h);
+ }
+ else {
+ if (h.getType().isPrimitive()) {
+ buf.append(o);
+ }
+
+ }
+ }
+
+ public DSHandle swiftscript_strcat(VariableStack stack) throws ExecutionException {
if (logger.isDebugEnabled()) {
logger.debug(stack);
}
@@ -344,30 +355,18 @@
throws ExecutionException {
Object input = PA_INPUT.getValue(stack);
DSHandle handle = new RootDataNode(Types.STRING);
- handle.setValue(""+input);
+ handle.setValue(String.valueOf(input));
handle.closeShallow();
return handle;
}
public DSHandle swiftscript_dirname(VariableStack stack)
throws ExecutionException {
- DSHandle handle;
- try
- {
- DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
- DSHandle arg = args[0];
- String[] input = VDLFunction.filename(arg);
- String name = input[0];
- String result = new AbsFile(name).getDir();
- handle = new RootDataNode(Types.STRING);
- handle.setValue(result);
- handle.closeShallow();
- }
- catch (HandleOpenException e) {
- throw new FutureNotYetAvailable
- (VDLFunction.addFutureListener(stack, e.getSource()));
- }
- return handle;
+ AbstractDataNode n = (AbstractDataNode) PA_FILE.getValue(stack);
+ n.waitFor();
+ String name = VDLFunction.filename(n)[0];
+ String result = new AbsFile(name).getDir();
+ return RootDataNode.newNode(Types.STRING, result);
}
/*
@@ -379,23 +378,11 @@
*/
public DSHandle swiftscript_length(VariableStack stack)
throws ExecutionException {
- DSHandle handle;
- DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
- DSHandle arg = args[0];
- ArrayDataNode adn = (ArrayDataNode)arg;
+ AbstractDataNode n = (AbstractDataNode) PA_ARRAY.getValue(stack);
+ n.waitFor();
+ ArrayDataNode adn = (ArrayDataNode) n;
- if( !( adn.isClosed() ) )
- {
- throw new FutureNotYetAvailable
- (VDLFunction.addFutureListener(stack, adn));
- }
-
- int result = adn.size();
- handle = new RootDataNode(Types.INT);
- handle.setValue(result);
- handle.closeShallow();
-
- return handle;
+ return RootDataNode.newNode(Types.INT, Integer.valueOf(adn.size()));
}
public DSHandle swiftscript_existsfile(VariableStack stack)
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -17,6 +17,7 @@
import org.globus.cog.karajan.workflow.ExecutionException;
import org.griphyn.vdl.karajan.lib.VDLFunction;
import org.griphyn.vdl.mapping.AbsFile;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.HandleOpenException;
import org.griphyn.vdl.mapping.InvalidPathException;
@@ -36,10 +37,10 @@
setArguments(ReadData.class, new Arg[] { DEST, SRC });
}
- protected Object function(VariableStack stack) throws ExecutionException, HandleOpenException {
+ protected Object function(VariableStack stack) throws ExecutionException {
DSHandle dest = (DSHandle) DEST.getValue(stack);
- DSHandle src = (DSHandle) SRC.getValue(stack);
- waitFor(stack, src);
+ AbstractDataNode src = (AbstractDataNode) SRC.getValue(stack);
+ src.waitFor();
if (src.getType().equals(Types.STRING)) {
readData(dest, (String) src.getValue());
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -14,6 +14,7 @@
import org.globus.cog.karajan.workflow.ExecutionException;
import org.griphyn.vdl.karajan.lib.VDLFunction;
import org.griphyn.vdl.mapping.AbsFile;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.HandleOpenException;
import org.griphyn.vdl.mapping.Path;
@@ -31,10 +32,10 @@
setArguments(ReadStructured.class, new Arg[] { DEST, SRC });
}
- protected Object function(VariableStack stack) throws ExecutionException, HandleOpenException {
+ protected Object function(VariableStack stack) throws ExecutionException {
DSHandle dest = (DSHandle) DEST.getValue(stack);
- DSHandle src = (DSHandle) SRC.getValue(stack);
- waitFor(stack, src);
+ AbstractDataNode src = (AbstractDataNode) SRC.getValue(stack);
+ src.waitFor();
if (src.getType().equals(Types.STRING)) {
readData(dest, (String) src.getValue());
}
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Sprintf.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -4,8 +4,8 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.griphyn.vdl.karajan.lib.SwiftArg;
import org.griphyn.vdl.karajan.lib.VDLFunction;
+import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.ArrayDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.Path;
@@ -41,12 +41,8 @@
@Override
protected Object function(VariableStack stack)
throws ExecutionException {
- DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
-
- for (int i = 0; i < args.length; i++) {
- DSHandle handle = args[i];
- VDLFunction.waitFor(stack, handle);
- }
+ AbstractDataNode[] args = waitForAllVargs(stack);
+
String msg = format(args);
logger.debug("generated: " + msg);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -4,9 +4,8 @@
import org.globus.cog.karajan.arguments.Arg;
import org.globus.cog.karajan.stack.VariableStack;
import org.globus.cog.karajan.workflow.ExecutionException;
-import org.griphyn.vdl.karajan.lib.SwiftArg;
import org.griphyn.vdl.karajan.lib.VDLFunction;
-import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.AbstractDataNode;
/**
Formatted trace output. <br>
@@ -30,13 +29,8 @@
@Override
protected Object function(VariableStack stack)
throws ExecutionException {
- DSHandle[] args = SwiftArg.VARGS.asDSHandleArray(stack);
+ AbstractDataNode[] args = waitForAllVargs(stack);
- for (int i = 0; i < args.length; i++) {
- DSHandle handle = args[i];
- VDLFunction.waitFor(stack, handle);
- }
-
String msg = Sprintf.format(args);
logger.info(msg);
System.out.print(msg);
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -5,7 +5,6 @@
import java.io.FileWriter;
import java.io.IOException;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
@@ -36,14 +35,14 @@
setArguments(WriteData.class, new Arg[] { DEST, SRC });
}
- protected Object function(VariableStack stack) throws ExecutionException, HandleOpenException {
+ protected Object function(VariableStack stack) throws ExecutionException {
// dest needs to be mapped to a file, or a string
DSHandle dest = (DSHandle) DEST.getValue(stack);
// src can be any of several forms of value
- DSHandle src = (DSHandle) SRC.getValue(stack);
+ AbstractDataNode src = (AbstractDataNode) SRC.getValue(stack);
- waitFor(stack, src);
+ src.waitFor();
if (dest.getType().equals(Types.STRING)) {
writeData((String)dest.getValue(), src);
@@ -113,8 +112,9 @@
private void writePrimitiveArray(BufferedWriter br, DSHandle src) throws IOException,
ExecutionException {
- Map<String, DSHandle> m = ((AbstractDataNode) src).getArrayValue();
- Map<String, DSHandle> c = new TreeMap<String, DSHandle>(new ArrayIndexComparator());
+ // this scheme currently only works properly if the keys are strings
+ Map<Comparable<?>, DSHandle> m = ((AbstractDataNode) src).getArrayValue();
+ Map<Comparable<?>, DSHandle> c = new TreeMap<Comparable<?>, DSHandle>(new ArrayIndexComparator());
c.putAll(m);
for (DSHandle h : c.values()) {
br.write(h.getValue().toString());
@@ -125,8 +125,8 @@
private void writeStructArray(BufferedWriter br, DSHandle src) throws IOException,
ExecutionException {
writeStructHeader(src.getType().itemType(), br);
- Map<String, DSHandle> m = ((AbstractDataNode) src).getArrayValue();
- Map<String, DSHandle> c = new TreeMap<String, DSHandle>(new ArrayIndexComparator());
+ Map<Comparable<?>, DSHandle> m = ((AbstractDataNode) src).getArrayValue();
+ Map<Comparable<?>, DSHandle> c = new TreeMap<Comparable<?>, DSHandle>(new ArrayIndexComparator());
c.putAll(m);
for (DSHandle h : c.values()) {
writeStruct(br, h);
@@ -156,10 +156,10 @@
}
}
- class ArrayIndexComparator implements Comparator<String> {
- public int compare(String o1, String o2) {
- int i1 = Integer.parseInt(o1);
- int i2 = Integer.parseInt(o2);
+ class ArrayIndexComparator implements Comparator<Comparable<?>> {
+ public int compare(Comparable<?> o1, Comparable<?> o2) {
+ int i1 = Integer.parseInt(String.valueOf(o1));
+ int i2 = Integer.parseInt(String.valueOf(o2));
if(i1 < i2) return -1;
if(i1 > i2) return 1;
return 0;
Modified: trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -10,8 +10,13 @@
import java.util.Map;
import org.apache.log4j.Logger;
+import org.globus.cog.karajan.workflow.futures.Future;
+import org.globus.cog.karajan.workflow.futures.FutureFault;
+import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
+import org.griphyn.vdl.karajan.DSHandleFutureWrapper;
+import org.griphyn.vdl.karajan.FutureTracker;
+import org.griphyn.vdl.karajan.FutureWrapper;
import org.griphyn.vdl.karajan.Loader;
-import org.griphyn.vdl.karajan.VDL2FutureException;
import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.util.VDL2Config;
@@ -46,19 +51,21 @@
private static final String datasetIDPartialID = Loader.getUUID();
private Field field;
- private Map<String,DSHandle> handles;
+ private Map<Comparable<?>, DSHandle> handles;
private Object value;
private boolean closed;
- private List<DSHandleListener> listeners;
final String identifierURI = makeIdentifierURIString();
private Path pathFromRoot;
+
+ protected FutureWrapper wrapper;
protected AbstractDataNode(Field field) {
this.field = field;
- handles = new HashMap<String,DSHandle>();
+ handles = new HashMap<Comparable<?>, DSHandle>();
}
- public void init(Map<String,Object> params) {
+ public void init(Map<String, Object> params) {
+ throw new UnsupportedOperationException();
}
public Type getType() {
@@ -191,15 +198,13 @@
}
}
- public Collection<DSHandle> getFields(Path path)
- throws InvalidPathException, HandleOpenException {
+ public Collection<DSHandle> getFields(Path path) throws InvalidPathException {
List<DSHandle> fields = new ArrayList<DSHandle>();
getFields(fields, path);
return fields;
}
- private void getFields(List<DSHandle> fields, Path path)
- throws InvalidPathException, HandleOpenException {
+ protected void getFields(List<DSHandle> fields, Path path) throws InvalidPathException {
if (path.isEmpty()) {
fields.add(this);
}
@@ -207,7 +212,7 @@
Path rest = path.butFirst();
if (path.isWildcard(0)) {
if (isArray() && !closed) {
- throw new HandleOpenException(this);
+ throw new FutureNotYetAvailable(getFutureWrapper());
}
for (DSHandle handle : handles.values()) {
((AbstractDataNode) handle).getFields(fields, rest);
@@ -324,11 +329,10 @@
return value;
}
- public Map<String, DSHandle> getArrayValue() {
+ public Map<Comparable<?>, DSHandle> getArrayValue() {
checkDataException();
if (!field.getType().isArray()) {
- throw new RuntimeException
- ("getArrayValue called on a struct: " + this);
+ throw new RuntimeException("getArrayValue called on a non-array: " + this);
}
return handles;
}
@@ -448,7 +452,7 @@
try {
m = this.getMapper();
}
- catch (VDL2FutureException fe) {
+ catch (FutureFault fe) {
m = null; // no mapping info if mapper isn't initialised yet
}
if (m != null) {
@@ -562,55 +566,59 @@
return ((AbstractDataNode) getRoot()).getMapper();
}
- protected Map<String,DSHandle> getHandles() {
+ protected Map<Comparable<?>, DSHandle> getHandles() {
return handles;
}
+
+ public String getIdentifier() {
+ return identifierURI;
+ }
- public void addListener(DSHandleListener listener) {
- if (logger.isDebugEnabled()) {
- logger.debug("Adding handle listener \"" + listener +
- "\" to \"" + getIdentifyingString() + "\"");
- }
- synchronized(this) {
- if (listeners == null) {
- listeners = new ArrayList<DSHandleListener>();
- }
- listeners.add(listener);
- if (!closed) {
- return;
- }
- }
- // listeners != null, closed
- notifyListeners();
+ String makeIdentifierURIString() {
+ datasetIDCounter++;
+ return DATASET_URI_PREFIX + datasetIDPartialID + ":" + datasetIDCounter;
}
-
- protected void notifyListeners() {
- List<DSHandleListener> l;
-
- synchronized(this) {
- if (listeners == null) {
- return;
+
+ public synchronized void waitFor() {
+ if (!closed) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Waiting for " + this);
}
-
- l = listeners;
- listeners = null;
+ throw new FutureNotYetAvailable(getFutureWrapper());
}
-
- for (DSHandleListener listener : l) {
+ else {
if (logger.isDebugEnabled()) {
- logger.debug("Notifying listener \"" + listener
- + "\" about \"" + getIdentifyingString() + "\"");
+ logger.debug("Do not need to wait for " + this);
}
- listener.handleClosed(this);
+ if (value instanceof RuntimeException) {
+ throw (RuntimeException) value;
+ }
}
}
-
- public String getIdentifier() {
- return identifierURI;
+
+ public void addListener(DSHandleListener listener) {
+ throw new UnsupportedOperationException();
}
-
- String makeIdentifierURIString() {
- datasetIDCounter++;
- return DATASET_URI_PREFIX + datasetIDPartialID + ":" + datasetIDCounter;
+
+ protected synchronized Future getFutureWrapper() {
+ if (wrapper == null) {
+ wrapper = new DSHandleFutureWrapper(this);
+ FutureTracker.get().add(this, wrapper);
+ }
+ return wrapper;
}
+
+ protected void notifyListeners() {
+ FutureWrapper wrapper;
+ synchronized(this) {
+ wrapper = this.wrapper;
+ if (closed) {
+ FutureTracker.get().remove(this);
+ this.wrapper = null;
+ }
+ }
+ if (wrapper != null) {
+ wrapper.notifyListeners();
+ }
+ }
}
Modified: trunk/src/org/griphyn/vdl/mapping/ArrayDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/ArrayDataNode.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/mapping/ArrayDataNode.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -3,10 +3,14 @@
*/
package org.griphyn.vdl.mapping;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.globus.cog.karajan.workflow.futures.Future;
+import org.globus.cog.karajan.workflow.futures.FutureList;
+import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
+import org.griphyn.vdl.karajan.ArrayIndexFutureList;
+import org.griphyn.vdl.karajan.FutureTracker;
import org.griphyn.vdl.type.Field;
public class ArrayDataNode extends DataNode {
@@ -14,18 +18,16 @@
super(field, root, parent);
}
- public void getFringePaths(List list, Path parentPath) throws HandleOpenException {
+ public void getFringePaths(List<Path> list, Path parentPath) throws HandleOpenException {
checkMappingException();
if (!isClosed()) {
- throw new HandleOpenException(this);
+ throw new FutureNotYetAvailable(getFutureWrapper());
}
- Map<String,DSHandle> handles = getHandles();
+ Map<Comparable<?>, DSHandle> handles = getHandles();
synchronized (handles) {
- Iterator i = handles.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry e = (Map.Entry) i.next();
+ for (Map.Entry<Comparable<?>, DSHandle> e : handles.entrySet()) {
AbstractDataNode mapper = (AbstractDataNode) e.getValue();
- Path fullPath = parentPath.addLast((String) e.getKey(), getType().isArray());
+ Path fullPath = parentPath.addLast(e.getKey().toString(), getType().isArray());
if (!mapper.isHandlesEmpty()) {
mapper.getFringePaths(list, fullPath);
}
@@ -40,14 +42,10 @@
types. */
public void closeDeep() {
assert(this.getType().isArray());
- if (!this.isClosed()) {
- closeShallow();
- }
- Map handles = getHandles();
+ closeShallow();
+ Map<Comparable<?>, DSHandle> handles = getHandles();
synchronized (handles) {
- Iterator i = handles.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry e = (Map.Entry) i.next();
+ for (Map.Entry<Comparable<?>, DSHandle> e : handles.entrySet()) {
AbstractDataNode child = (AbstractDataNode) e.getValue();
child.closeDeep();
}
@@ -62,4 +60,39 @@
public int size() {
return getHandles().size();
}
+
+ @Override
+ protected void setField(String name, DSHandle handle) {
+ super.setField(name, handle);
+ addKey(name);
+ }
+
+ private void addKey(String name) {
+ synchronized(this) {
+ if (wrapper != null) {
+ ((ArrayIndexFutureList) wrapper).addKey(name);
+ }
+ }
+ }
+
+ @Override
+ public DSHandle createDSHandle(String fieldName)
+ throws NoSuchFieldException {
+ DSHandle h = super.createDSHandle(fieldName);
+ addKey(fieldName);
+ return h;
+ }
+
+ @Override
+ protected synchronized Future getFutureWrapper() {
+ if (wrapper == null) {
+ wrapper = new ArrayIndexFutureList(this, this.getArrayValue());
+ FutureTracker.get().add(this, wrapper);
+ }
+ return wrapper;
+ }
+
+ public FutureList getFutureList() {
+ return (FutureList) getFutureWrapper();
+ }
}
Modified: trunk/src/org/griphyn/vdl/mapping/DSHandle.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/DSHandle.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/mapping/DSHandle.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -67,7 +67,7 @@
public Collection<Path> getFringePaths() throws HandleOpenException;
- public Map<String, DSHandle> getArrayValue();
+ public Map<Comparable<?>, DSHandle> getArrayValue();
public Path getPathFromRoot();
Modified: trunk/src/org/griphyn/vdl/mapping/ExternalDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/ExternalDataNode.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/mapping/ExternalDataNode.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -1,223 +1,80 @@
package org.griphyn.vdl.mapping;
-import org.griphyn.vdl.karajan.Loader;
-
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
-import org.griphyn.vdl.type.NoSuchTypeException;
-import org.griphyn.vdl.type.Type;
+import org.griphyn.vdl.karajan.Loader;
import org.griphyn.vdl.type.Types;
+import org.griphyn.vdl.type.impl.FieldImpl;
-public class ExternalDataNode implements DSHandle {
+public class ExternalDataNode extends AbstractDataNode {
- private Map params;
-
- public void init(Map params) {
- this.params = params;
- }
-
static final String DATASET_URI_PREFIX = "dataset:external:";
public static final Logger logger = Logger.getLogger(ExternalDataNode.class);
public static final MappingParam PARAM_PREFIX = new MappingParam("prefix", null);
- /** Datasets are identified within a run by this sequence number and the
- partial ID field.
- The initial value is chosen to aid human recognition of sequence
- numbers in the wild. There is no requirement that it start at this
- (or any other) particular value. Note that this introduces a
- maximum on the number of datasets which can be dealt with in any
- run to be about 2^62. */
private static long datasetIDCounter = 850000000000l;
- /** This is used to provide a (hopefully) globally unique identifier for
- each time the datasetIDCounter is reset (whenever this class is
- loaded, which will usually happen once per JVM). No meaning should be
- inferred from this value - it exists purely for making unique URIs. */
private static final String datasetIDPartialID = Loader.getUUID();
+
+ private Map<String, Object> params;
- private Map handles;
- private Object value;
- private boolean closed;
- private List listeners;
- final String identifierURI = makeIdentifierURIString();
-
public ExternalDataNode() {
+ super(new FieldImpl("", Types.EXTERNAL));
}
- public Type getType() {
- try {
- return Types.getType("external");
- } catch(NoSuchTypeException te) {
- throw new RuntimeException(te);
- }
- }
+ @Override
+ public void init(Map<String, Object> params) {
+ this.params = params;
+ }
- public boolean isPrimitive() {
- return false;
- }
-
- public boolean isRestartable() {
+ public boolean isRestartable() {
return true;
}
- /**
- * create a String representation of this node. If the node has a value,
- * then uses the String representation of that value. Otherwise, generates a
- * text description.
- */
- public String toString() {
- String prefix = this.getClass().getName();
-
- prefix = prefix + " identifier "+this.getIdentifier();
-
- prefix = prefix + " with no value at dataset=";
-
- prefix = prefix + getDisplayableName();
-
- if (!Path.EMPTY_PATH.equals(getPathFromRoot())) {
- prefix = prefix + " path="+ getPathFromRoot().toString();
- }
-
- if(closed) {
- prefix = prefix + " (closed)";
- }
- else {
- prefix = prefix + " (not closed)";
- }
-
- return prefix;
- }
-
- public String getIdentifyingString() {
- return toString();
- }
-
public DSHandle getRoot() {
return this;
}
- protected String getDisplayableName() {
- String prefix = getRoot().getParam("dbgname");
- if (prefix == null) {
- prefix = getRoot().getParam("prefix");
- }
- if (prefix == null) {
- prefix = "unnamed SwiftScript value";
- }
- return prefix;
- }
-
public DSHandle getField(Path path) throws InvalidPathException {
if (path.isEmpty()) {
return this;
- } else {
+ }
+ else {
throw new InvalidPathException(path, this);
}
}
-
- public Collection getFields(Path path) throws InvalidPathException, HandleOpenException {
- List fields = new ArrayList();
- return fields;
+
+ protected void getFields(List<DSHandle> fields, Path path) throws InvalidPathException {
+ // nothing
}
public void set(DSHandle handle) {
- throw new IllegalArgumentException(this.getDisplayableName() + " is an external dataset and cannot be set");
+ throw new UnsupportedOperationException(this.getDisplayableName() + " is an external dataset and cannot be set");
}
- protected void setField(String name, DSHandle handle) {
- synchronized (handles) {
- handles.put(name, handle);
- }
- }
-
- protected DSHandle getHandle(String name) {
- synchronized (handles) {
- return (DSHandle) handles.get(name);
- }
- }
-
- protected boolean isHandlesEmpty() {
- synchronized (handles) {
- return handles.isEmpty();
- }
- }
-
- protected void checkDataException() {
- if (value instanceof DependentException) {
- throw (DependentException) value;
- }
- }
-
- protected void checkMappingException() {
- if (value instanceof MappingDependentException) {
- throw (MappingDependentException) value;
- }
- }
-
public Object getValue() {
-logger.warn("getValue called in an external dataset");
-return value;
-// throw new RuntimeException("cannot get value of external dataset");
+ logger.warn("getValue called on an external dataset");
+ return null;
}
- public Map getArrayValue() {
-throw new RuntimeException("cannot get value of external dataset");
+ public Map<Comparable<?>, DSHandle> getArrayValue() {
+ throw new UnsupportedOperationException("cannot get value of external dataset");
}
public boolean isArray() {
return false;
}
- public void setValue(Object value) {
- if (this.closed) {
- throw new IllegalArgumentException(this.getDisplayableName()
- + " is closed with a value of "+this.value);
- }
- if (this.value != null) {
- throw new IllegalArgumentException(this.getDisplayableName()
- + " is already assigned with a value of " + this.value);
- }
- this.value = value;
+ public Collection<Path> getFringePaths() throws HandleOpenException {
+ return Collections.singletonList(Path.EMPTY_PATH);
}
- public Collection getFringePaths() throws HandleOpenException {
- ArrayList list = new ArrayList();
- list.add(Path.EMPTY_PATH);
- return list;
- }
-
- public synchronized void closeShallow() {
- this.closed = true;
- notifyListeners();
- logger.info("closed "+this.getIdentifier());
- }
-
- public boolean isClosed() {
- return closed;
- }
-
- public void closeDeep() {
- if (!this.closed) {
- closeShallow();
- }
- synchronized (handles) {
- Iterator i = handles.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry e = (Map.Entry) i.next();
- AbstractDataNode mapper = (AbstractDataNode) e.getValue();
- mapper.closeDeep();
- }
- }
- }
-
public Path getPathFromRoot() {
return Path.EMPTY_PATH;
}
@@ -226,59 +83,24 @@
return null;
}
- protected Map getHandles() {
- return handles;
+ protected String makeIdentifierURIString() {
+ datasetIDCounter++;
+ return DATASET_URI_PREFIX + datasetIDPartialID + ":" + datasetIDCounter;
}
- public synchronized void addListener(DSHandleListener listener) {
- if (logger.isInfoEnabled()) {
- logger.info("Adding handle listener \"" + listener + "\" to \"" + this + "\"");
- }
- if (listeners == null) {
- listeners = new LinkedList();
- }
- listeners.add(listener);
- if (closed) {
- notifyListeners();
- }
+ public DSHandle createDSHandle(String fieldName) {
+ throw new UnsupportedOperationException("cannot create new field in external dataset");
}
- protected synchronized void notifyListeners() {
- if (listeners != null) {
- Iterator i = listeners.iterator();
- while (i.hasNext()) {
- DSHandleListener listener = (DSHandleListener) i.next();
- i.remove();
- if (logger.isInfoEnabled()) {
- logger.info("Notifying listener \"" + listener + "\" about \"" + this + "\"");
- }
- listener.handleClosed(this);
- }
- listeners = null;
- }
+ public DSHandle getParent() {
+ return null;
}
- public String getIdentifier() {
- return identifierURI;
- }
-
- String makeIdentifierURIString() {
- datasetIDCounter++;
- return DATASET_URI_PREFIX + datasetIDPartialID + ":" + datasetIDCounter;
- }
-
- public String getParam(String name) {
- if (params == null) {
- return null;
- }
- return (String) params.get(name);
+ @Override
+ public String getParam(String name) {
+ if (params == null) {
+ return null;
}
-
- public DSHandle createDSHandle(String fieldName) {
-throw new RuntimeException("cannot create new field in external dataset");
- }
-
- public DSHandle getParent() {
- return null;
- }
+ return (String) params.get(name);
+ }
}
Modified: trunk/src/org/griphyn/vdl/mapping/MappingParam.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/MappingParam.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/mapping/MappingParam.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -2,7 +2,6 @@
import java.util.Map;
-import org.griphyn.vdl.karajan.VDL2FutureException;
import org.griphyn.vdl.type.Types;
/** The MappingParam class provides helper methods to deal with
@@ -42,9 +41,9 @@
*/
public Object getValue(Mapper mapper) {
Object value = mapper.getParam(name);
- if (value instanceof DSHandle) {
- DSHandle handle = (DSHandle) value;
- checkHandle(handle);
+ if (value instanceof AbstractDataNode) {
+ AbstractDataNode handle = (AbstractDataNode) value;
+ handle.waitFor();
if (handle.getType().equals(Types.INT)) {
return Integer.valueOf(((Number) handle.getValue()).intValue());
}
@@ -66,11 +65,11 @@
}
}
- public Object getValue(Map params) {
+ public Object getValue(Map<String, Object> params) {
Object value = params.get(name);
- if (value instanceof DSHandle) {
- DSHandle handle = (DSHandle) value;
- checkHandle(handle);
+ if (value instanceof AbstractDataNode) {
+ AbstractDataNode handle = (AbstractDataNode) value;
+ handle.waitFor();
return handle.getValue().toString();
}
else if (value == null) {
@@ -95,15 +94,6 @@
return mapper.getParam(name);
}
-
- private void checkHandle(DSHandle handle) {
- if (!handle.isClosed()) {
- throw new VDL2FutureException(handle);
- }
- handle.getValue();
- // try to get value, so that the appropriate exceptions are thrown for futures
- }
-
/** Returns the mapper parameter as a String. Other data types will be
converted to a String as appropriate. */
public String getStringValue(Mapper mapper) {
Modified: trunk/src/org/griphyn/vdl/mapping/RootArrayDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/RootArrayDataNode.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/mapping/RootArrayDataNode.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -1,21 +1,23 @@
package org.griphyn.vdl.mapping;
-import java.util.Iterator;
import java.util.Map;
import org.apache.log4j.Logger;
-import org.griphyn.vdl.karajan.VDL2FutureException;
+import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.workflow.futures.Future;
+import org.globus.cog.karajan.workflow.futures.FutureListener;
+import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Type;
-public class RootArrayDataNode extends ArrayDataNode implements DSHandleListener {
+public class RootArrayDataNode extends ArrayDataNode implements FutureListener {
Logger logger = Logger.getLogger(RootArrayDataNode.class);
private boolean initialized = false;
private Mapper mapper;
private Map<String, Object> params;
- private DSHandle waitingMapperParam;
+ private AbstractDataNode waitingMapperParam;
/**
* Instantiate a root array data node with specified type.
@@ -37,13 +39,12 @@
private synchronized void innerInit() {
logger.debug("innerInit: " + this);
- Iterator i = params.entrySet().iterator();
- while(i.hasNext()) {
- Map.Entry entry = (Map.Entry) i.next();
+
+ for (Map.Entry<String, Object> entry : params.entrySet()) {
Object v = entry.getValue();
- if (v instanceof DSHandle && !((DSHandle) v).isClosed()) {
- waitingMapperParam = (DSHandle) v;
- waitingMapperParam.addListener(this);
+ if (v instanceof AbstractDataNode && !((AbstractDataNode) v).isClosed()) {
+ waitingMapperParam = (AbstractDataNode) v;
+ waitingMapperParam.getFutureWrapper().addModificationAction(this, null);
return;
}
}
@@ -70,19 +71,16 @@
try {
RootDataNode.checkInputs(params, mapper, this);
}
- catch (VDL2FutureException e) {
- e.getHandle().addListener(this);
- }
catch (DependentException e) {
setValue(new MappingDependentException(this, e));
closeShallow();
}
}
+
+ public void futureModified(Future f, VariableStack stack) {
+ innerInit();
+ }
- public void handleClosed(DSHandle handle) {
- innerInit();
- }
-
public String getParam(String name) {
if (params == null) {
return null;
@@ -103,7 +101,7 @@
return mapper;
}
assert(waitingMapperParam != null);
- throw new VDL2FutureException(waitingMapperParam);
+ throw new FutureNotYetAvailable(waitingMapperParam.getFutureWrapper());
}
public boolean isArray() {
@@ -115,7 +113,8 @@
initialized();
}
- private void initialized() {
+ private synchronized void initialized() {
initialized = true;
+ waitingMapperParam = null;
}
}
Modified: trunk/src/org/griphyn/vdl/mapping/RootDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/RootDataNode.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/mapping/RootDataNode.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -3,22 +3,24 @@
*/
package org.griphyn.vdl.mapping;
-import java.util.Iterator;
import java.util.Map;
import org.apache.log4j.Logger;
-import org.griphyn.vdl.karajan.VDL2FutureException;
+import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.workflow.futures.Future;
+import org.globus.cog.karajan.workflow.futures.FutureListener;
+import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
import org.griphyn.vdl.type.Field;
import org.griphyn.vdl.type.Type;
-public class RootDataNode extends AbstractDataNode implements DSHandleListener {
+public class RootDataNode extends AbstractDataNode implements FutureListener {
static Logger logger = Logger.getLogger(RootDataNode.class);
private boolean initialized=false;
private Mapper mapper;
private Map<String, Object> params;
- private DSHandle waitingMapperParam;
+ private AbstractDataNode waitingMapperParam;
public static DSHandle newNode(Type type, Object value) {
DSHandle handle = new RootDataNode(type);
@@ -45,12 +47,13 @@
/** must have this.params set to the appropriate parameters before
being called. */
private synchronized void innerInit() {
- logger.debug("innerInit: " + this);
for (Object v : params.values()) {
- if(v instanceof DSHandle && !((DSHandle) v).isClosed()) {
- logger.debug("addListener: " + this + " " + v);
- waitingMapperParam = (DSHandle) v;
- waitingMapperParam.addListener(this);
+ if(v instanceof AbstractDataNode && !((AbstractDataNode) v).isClosed()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("addListener: " + this + " " + v);
+ }
+ waitingMapperParam = (AbstractDataNode) v;
+ waitingMapperParam.getFutureWrapper().addModificationAction(this, null);
return;
}
}
@@ -82,10 +85,6 @@
try {
checkInputs(params, mapper, this);
}
- catch (VDL2FutureException e) {
- logger.warn("Unexpected VDL2FutureException checking inputs for dataset "+this);
- throw new RuntimeException("Got a VDL2FutureException but all parameters should have their values",e);
- }
catch (DependentException e) {
setValue(new MappingDependentException(this, e));
closeShallow();
@@ -93,17 +92,15 @@
}
}
- public void handleClosed(DSHandle handle) {
+ public void futureModified(Future f, VariableStack stack) {
innerInit();
}
- static protected void checkInputs(Map params, Mapper mapper, AbstractDataNode root) {
+ static protected void checkInputs(Map<String, Object> params, Mapper mapper, AbstractDataNode root) {
String input = (String) params.get("input");
if (input != null && Boolean.valueOf(input.trim()).booleanValue()) {
- Iterator i = mapper.existing().iterator();
- while (i.hasNext()) {
- Path p = (Path) i.next();
+ for (Path p : mapper.existing()) {
try {
DSHandle field = root.getField(p);
field.closeShallow();
@@ -112,8 +109,8 @@
}
}
catch (InvalidPathException e) {
- throw new IllegalStateException("mapper.existing() returned a path " + p
- + " that it cannot subsequently map");
+ throw new IllegalStateException("Structure of mapped data is " +
+ "incompatible with the mapped variable type: " + e.getMessage());
}
}
root.closeDeep();
@@ -155,9 +152,7 @@
if (handle.getType().isArray()) {
// any number of indices is ok
try {
- Iterator i = handle.getFields(Path.CHILDREN).iterator();
- while (i.hasNext()) {
- DSHandle dh = (DSHandle) i.next();
+ for (DSHandle dh : handle.getFields(Path.CHILDREN)) {
Path path = dh.getPathFromRoot();
String index = path.getElement(path.size() - 1);
try {
@@ -182,9 +177,7 @@
else {
// all fields must be present
Type type = handle.getType();
- Iterator i = type.getFieldNames().iterator();
- while (i.hasNext()) {
- String fieldName = (String) i.next();
+ for (String fieldName : type.getFieldNames()) {
Path fieldPath = Path.parse(fieldName);
try {
checkConsistency(handle.getField(fieldPath));
@@ -213,12 +206,12 @@
return null;
}
- public Mapper getMapper() {
+ public synchronized Mapper getMapper() {
if (initialized) {
return mapper;
}
assert (waitingMapperParam != null);
- throw new VDL2FutureException(waitingMapperParam);
+ throw new FutureNotYetAvailable(waitingMapperParam.getFutureWrapper());
}
public boolean isArray() {
@@ -230,7 +223,7 @@
initialized();
}
- private void initialized() {
+ private synchronized void initialized() {
initialized = true;
waitingMapperParam = null;
}
Modified: trunk/src/org/griphyn/vdl/mapping/file/ArrayFileMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/ArrayFileMapper.java 2011-07-03 01:57:32 UTC (rev 4737)
+++ trunk/src/org/griphyn/vdl/mapping/file/ArrayFileMapper.java 2011-07-03 02:08:41 UTC (rev 4738)
@@ -27,12 +27,12 @@
if (dn == null) {
throw new RuntimeException("Missing 'files' mapper attribute");
}
- Map<String,DSHandle> m = dn.getArrayValue();
- Set<String> s = m.keySet();
- Iterator<String> i = s.iterator();
+ Map<?, DSHandle> m = dn.getArrayValue();
+ Set<?> s = m.keySet();
+ Iterator<?> i = s.iterator();
while(i.hasNext()) {
String nextKey = i.next().toString();
- l.add(Path.EMPTY_PATH.addLast(nextKey,true));
+ l.add(Path.EMPTY_PATH.addLast(nextKey, true));
}
return l;
}
More information about the Swift-commit
mailing list