Search in sources :

Example 1 with AsyncTask

use of org.apache.jena.fuseki.async.AsyncTask in project jena by apache.

the class Async method execASyncTask.

public static AsyncTask execASyncTask(HttpAction action, AsyncPool asyncPool, String displayName, Runnable runnable) {
    AsyncTask atask = Async.asyncTask(asyncPool, displayName, action.getDataService(), runnable, action.id);
    Async.setLocationHeader(action, atask);
    return atask;
}
Also used : AsyncTask(org.apache.jena.fuseki.async.AsyncTask)

Example 2 with AsyncTask

use of org.apache.jena.fuseki.async.AsyncTask in project jena by apache.

the class ActionAsyncTask method execPostItem.

@Override
protected final JsonValue execPostItem(HttpAction action) {
    Runnable task = createRunnable(action);
    AsyncTask aTask = Async.execASyncTask(action, AsyncPool.get(), "backup", task);
    Async.setLocationHeader(action, aTask);
    return Async.asJson(aTask);
}
Also used : AsyncTask(org.apache.jena.fuseki.async.AsyncTask)

Example 3 with AsyncTask

use of org.apache.jena.fuseki.async.AsyncTask in project jena by apache.

the class ActionSleep method perform.

@Override
protected void perform(HttpAction action) {
    Runnable task = createRunnable(action);
    AsyncTask aTask = Async.execASyncTask(action, AsyncPool.get(), "sleep", task);
    JsonValue v = Async.asJson(aTask);
    Async.setLocationHeader(action, aTask);
    ServletOps.sendJsonReponse(action, v);
}
Also used : AsyncTask(org.apache.jena.fuseki.async.AsyncTask) JsonValue(org.apache.jena.atlas.json.JsonValue)

Example 4 with AsyncTask

use of org.apache.jena.fuseki.async.AsyncTask in project jena by apache.

the class ActionTasks method execGet.

private void execGet(HttpAction action, String name) {
    if (name == null)
        log.info(format("[%d] Tasks", action.id));
    else
        log.info(format("[%d] Task %s", action.id, name));
    JsonValue responseBody = null;
    if (name == null) {
        JsonBuilder builder = new JsonBuilder();
        builder.startArray();
        for (AsyncPool pool : pools) {
            for (AsyncTask aTask : pool.tasks()) {
                //builder.value(aTask.getTaskId()) ;
                descOneTask(builder, aTask);
            }
        }
        builder.finishArray();
        responseBody = builder.build();
    } else {
        for (AsyncPool pool : pools) {
            // Assumes first is only.
            AsyncTask aTask = pool.getTask(name);
            if (aTask != null) {
                JsonBuilder builder = new JsonBuilder();
                descOneTask(builder, aTask);
                responseBody = builder.build();
            }
        }
    }
    if (responseBody == null)
        ServletOps.errorNotFound("Task '" + name + "' not found");
    ServletOps.setNoCache(action);
    ServletOps.sendJsonReponse(action, responseBody);
}
Also used : JsonBuilder(org.apache.jena.atlas.json.JsonBuilder) JsonValue(org.apache.jena.atlas.json.JsonValue) AsyncTask(org.apache.jena.fuseki.async.AsyncTask) AsyncPool(org.apache.jena.fuseki.async.AsyncPool)

Aggregations

AsyncTask (org.apache.jena.fuseki.async.AsyncTask)4 JsonValue (org.apache.jena.atlas.json.JsonValue)2 JsonBuilder (org.apache.jena.atlas.json.JsonBuilder)1 AsyncPool (org.apache.jena.fuseki.async.AsyncPool)1