use of org.exist.xquery.XQueryWatchDog in project exist by eXist-db.
the class ProcessMonitor method killAll.
public void killAll(final long waitTime) {
synchronized (runningQueries) {
for (final XQueryWatchDog watchdog : runningQueries) {
LOG.debug("Killing query: {}", ExpressionDumper.dump(watchdog.getContext().getRootExpression()));
watchdog.kill(waitTime);
}
}
}
use of org.exist.xquery.XQueryWatchDog in project exist by eXist-db.
the class ProcessReport method getRunningQueries.
@Override
public List<RunningQuery> getRunningQueries() {
final List<RunningQuery> queries = new ArrayList<>();
final XQueryWatchDog[] watchdogs = processMonitor.getRunningXQueries();
for (final XQueryWatchDog watchdog : watchdogs) {
String requestURI = null;
if (processMonitor.getTrackRequestURI()) {
requestURI = ProcessMonitor.getRequestURI(watchdog);
}
queries.add(new RunningQuery(watchdog, requestURI));
}
return queries;
}
use of org.exist.xquery.XQueryWatchDog in project exist by eXist-db.
the class GetRunningXQueries method getRunningXQueries.
private Sequence getRunningXQueries() throws XPathException {
Sequence xmlResponse = null;
context.pushDocumentContext();
try {
final MemTreeBuilder builder = context.getDocumentBuilder();
builder.startDocument();
builder.startElement(new QName("xqueries", NAMESPACE_URI, PREFIX), null);
// Add all the running xqueries
final XQueryWatchDog[] watchdogs = getContext().getBroker().getBrokerPool().getProcessMonitor().getRunningXQueries();
for (XQueryWatchDog watchdog : watchdogs) {
final XQueryContext context = watchdog.getContext();
getRunningXQuery(builder, context, watchdog);
}
builder.endElement();
xmlResponse = (NodeValue) builder.getDocument().getDocumentElement();
return (xmlResponse);
} finally {
context.popDocumentContext();
}
}
use of org.exist.xquery.XQueryWatchDog in project exist by eXist-db.
the class KillRunningXQuery method killXQuery.
private void killXQuery(Sequence[] args) throws XPathException {
int id = 0;
long waittime = 0;
// determine the query id to kill
if (args.length == 1) {
if (!args[0].isEmpty()) {
id = ((NumericValue) args[0].itemAt(0)).getInt();
}
}
// determine the wait time
if (args.length == 2) {
if (!args[1].isEmpty()) {
waittime = ((NumericValue) args[1].itemAt(0)).getLong();
}
}
if (id != 0) {
final XQueryWatchDog[] watchdogs = getContext().getBroker().getBrokerPool().getProcessMonitor().getRunningXQueries();
for (XQueryWatchDog watchdog : watchdogs) {
final XQueryContext context = watchdog.getContext();
if (id == context.hashCode()) {
if (!watchdog.isTerminating()) {
watchdog.kill(waittime);
}
break;
}
}
}
}
Aggregations