diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2012-07-12 14:52:36 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2012-07-12 14:52:36 +0200 |
| commit | 20c81748688547c1b13686f15c65fbb1d60d81a0 (patch) | |
| tree | 59dc2b94c47ed30b8bc93c07cab42e96904d1146 /src/main/java/com/c2kernel/process/UserCodeProcess.java | |
| parent | 61559eef9369dbdbb027bec7c571d7f770b2e7a3 (diff) | |
Suspend transition now can carry an optional 'Errors' outcome where
client processes can record the reason for the suspension. Errors XML is
marshalled ErrorInfo. UserCodeProcess automatically sends fatal
ErrorInfos through suspend jobs.
Job API added to to support all this.
fixes #23
Diffstat (limited to 'src/main/java/com/c2kernel/process/UserCodeProcess.java')
| -rw-r--r-- | src/main/java/com/c2kernel/process/UserCodeProcess.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/com/c2kernel/process/UserCodeProcess.java b/src/main/java/com/c2kernel/process/UserCodeProcess.java index 7779802..2f508bc 100644 --- a/src/main/java/com/c2kernel/process/UserCodeProcess.java +++ b/src/main/java/com/c2kernel/process/UserCodeProcess.java @@ -14,6 +14,8 @@ import com.c2kernel.entity.proxy.EntityProxyObserver; import com.c2kernel.entity.proxy.MemberSubscription;
import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.scripting.ErrorInfo;
+import com.c2kernel.scripting.ScriptErrorException;
import com.c2kernel.utils.Logger;
/**************************************************************************
@@ -28,6 +30,7 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv protected AgentProxy agent;
static boolean active = true;
ArrayList<String> ignoredPaths = new ArrayList<String>();
+ HashMap<String, ErrorInfo> errors = new HashMap<String, ErrorInfo>();
HashMap<String, C2KLocalObject> jobs;
public UserCodeProcess(String agentName, String agentPass) {
@@ -96,18 +99,31 @@ public class UserCodeProcess extends StandardClient implements EntityProxyObserv ignoredPaths.remove(jobKey);
}
else if (thisJob.getPossibleTransition()==Transitions.SUSPEND) {
- if (ignoredPaths.contains(jobKey))
+ if (ignoredPaths.contains(jobKey)) {
+ if (errors.containsKey(jobKey)) {
+ thisJob.setOutcome(Gateway.getMarshaller().marshall(errors.get(jobKey)));
+ errors.remove(jobKey);
+ }
agent.execute(thisJob);
+ }
}
else if (thisJob.getPossibleTransition()==Transitions.RESUME) {
if (!ignoredPaths.contains(jobKey))
agent.execute(thisJob);
}
+ } catch (ScriptErrorException ex) {
+ errors.put(jobKey, ex.getErrors());
+ ignoredPaths.add(jobKey);
} catch (InvalidTransitionException ex) {
// must have already been done by someone else - ignore
} catch (Throwable ex) {
Logger.error("Error executing "+Transitions.getTransitionName(thisJob.getPossibleTransition())+" job:");
Logger.error(ex);
+ ErrorInfo ei = new ErrorInfo();
+ ei.setFatal();
+ ei.addError(ex.getClass().getSimpleName());
+ ei.addError(ex.getMessage());
+ errors.put(jobKey, ei);
ignoredPaths.add(jobKey);
}
}
|
