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;
}
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);
}
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);
}
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);
}
Aggregations