use of net.sourceforge.processdash.data.compiler.ExecutionException in project processdash by dtuma.
the class CompiledFunction method recalc.
protected void recalc() {
if (isDisposed())
// we have been disposed. Don't try to recalc.
return;
Set calcNameSet = (Set) CURRENTLY_CALCULATING.get();
if (calcNameSet.contains(name)) {
logger.warning("Encountered recursively defined data " + "when calculating " + name + " - ABORTING");
// break out of infinite loops.
return;
}
SimpleData oldValue = value;
SimpleData newValue = null;
String newAlias = null;
SubscribingExpressionContext context = null;
// attempt to perform the calculation up to 10 times. (This should
// be more than generous - even one retry should be rare.)
int retryCount = 10;
while (retryCount-- > 0 && extChanges.isDirty()) {
context = new SubscribingExpressionContext(data, prefix, this, name, currentSubscriptions);
ListStack stack = new ListStack();
int changeCount = -1;
try {
calcNameSet.add(name);
changeCount = extChanges.getUnhandledChangeCount();
script.run(stack, context);
newAlias = (String) stack.peekDescriptor();
newValue = (SimpleData) stack.pop();
if (newValue != null && newAlias == null)
newValue = (SimpleData) newValue.getEditable(false);
} catch (ExecutionException e) {
logger.warning("Error executing " + name + ": " + e);
newValue = null;
} finally {
calcNameSet.remove(name);
}
if (extChanges.maybeClearDirty(changeCount, newValue, newAlias))
break;
else if (retryCount > 0)
logger.finer("Retrying calculating " + name);
}
if (context == null)
// of the loop above. Nothing needs to be done.
return;
if (retryCount <= 0)
logger.warning("Ran out of retries while calculating " + name);
context.removeOldSubscriptions();
currentSubscriptions.trimToSize();
if (oldValue != VALUE_NEVER_QUERIED && !eq(oldValue, value))
data.valueRecalculated(name, this);
}
use of net.sourceforge.processdash.data.compiler.ExecutionException in project processdash by dtuma.
the class Eval method call.
/** Perform a procedure call.
*
* This method <b>must</b> be thread-safe.
*/
public Object call(List arguments, ExpressionContext context) {
String expression = asString(getArg(arguments, 0));
if (expression == null || expression.length() == 0)
return null;
String prefix = asString(getArg(arguments, 1));
CompiledScript script = Compiler.compile(expression);
try {
Stack stack = new ListStack();
if (prefix != null)
context = new RelativeExpressionContext(context, prefix);
script.run(stack, context);
return stack.pop();
} catch (ExecutionException ee) {
return null;
}
}
Aggregations