Search in sources :

Example 1 with XQueryWatchDog

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);
        }
    }
}
Also used : XQueryWatchDog(org.exist.xquery.XQueryWatchDog)

Example 2 with XQueryWatchDog

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;
}
Also used : ArrayList(java.util.ArrayList) XQueryWatchDog(org.exist.xquery.XQueryWatchDog)

Example 3 with XQueryWatchDog

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();
    }
}
Also used : MemTreeBuilder(org.exist.dom.memtree.MemTreeBuilder) QName(org.exist.dom.QName) XQueryContext(org.exist.xquery.XQueryContext) Sequence(org.exist.xquery.value.Sequence) XQueryWatchDog(org.exist.xquery.XQueryWatchDog)

Example 4 with XQueryWatchDog

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;
            }
        }
    }
}
Also used : XQueryContext(org.exist.xquery.XQueryContext) XQueryWatchDog(org.exist.xquery.XQueryWatchDog)

Aggregations

XQueryWatchDog (org.exist.xquery.XQueryWatchDog)4 XQueryContext (org.exist.xquery.XQueryContext)2 ArrayList (java.util.ArrayList)1 QName (org.exist.dom.QName)1 MemTreeBuilder (org.exist.dom.memtree.MemTreeBuilder)1 Sequence (org.exist.xquery.value.Sequence)1