use of com.revolsys.parallel.tools.ScriptExecutorRunnable in project com.revolsys.open by revolsys.
the class ScriptExecutorBoundingBoxTaskSplitter method execute.
@Override
public void execute(final BoundingBox boundingBox) {
this.outsideBoundaryObjects.expandBoundary(boundingBox.toGeometry());
final ScriptExecutorRunnable executor = new ScriptExecutorRunnable(this.scriptName, this.attributes);
executor.setLogScriptInfo(isLogScriptInfo());
executor.addBean("boundingBox", boundingBox);
final Set<Record> objects = this.outsideBoundaryObjects.getAndClearObjects();
executor.addBean("outsideBoundaryObjects", objects);
executor.addBeans(this.beans);
executor.addBeans(this.inChannels);
executor.addBeans(this.outChannels);
executor.run();
}
use of com.revolsys.parallel.tools.ScriptExecutorRunnable in project com.revolsys.open by revolsys.
the class ScriptExecutorProcess method executeScript.
private void executeScript(final Record record) {
try {
final JexlContext context = new HashMapContext();
final Map<String, Object> vars = new HashMap<>(this.attributes);
vars.putAll(record);
context.setVars(vars);
final Map<String, Object> scriptParams = new HashMap<>();
scriptParams.putAll(this.attributes);
for (final Entry<String, Expression> param : this.expressions.entrySet()) {
final String key = param.getKey();
final Expression expression = param.getValue();
final Object value = JexlUtil.evaluateExpression(context, expression);
scriptParams.put(key, value);
}
final ScriptExecutorRunnable scriptRunner = new ScriptExecutorRunnable(this.script, scriptParams);
if (this.executor == null) {
scriptRunner.run();
} else {
while (this.tasks.size() >= this.maxConcurrentScripts) {
try {
synchronized (this) {
ThreadUtil.pause(1000);
for (final Iterator<Future<?>> taskIter = this.tasks.iterator(); taskIter.hasNext(); ) {
final Future<?> task = taskIter.next();
if (task.isDone()) {
taskIter.remove();
}
}
}
} catch (final ThreadInterruptedException e) {
throw new ClosedException(e);
}
}
final Future<?> future = this.executor.submit(scriptRunner);
this.tasks.add(future);
}
} catch (final ThreadDeath e) {
throw e;
} catch (final Throwable t) {
Logs.error(this, t);
}
}
Aggregations