use of it.unibo.arces.wot.sepa.engine.processing.endpoint.SPARQLEndpoint in project SEPA by arces-wot.
the class QueryProcessor method process.
public Response process(InternalQueryRequest req) throws SEPASecurityException, IOException {
// Build the request
QueryRequest request;
request = new QueryRequest(properties.getQueryMethod(), properties.getProtocolScheme(), properties.getHost(), properties.getPort(), properties.getQueryPath(), req.getSparql(), req.getDefaultGraphUri(), req.getNamedGraphUri(), req.getBasicAuthorizationHeader(), req.getInternetMediaType(), QueryProcessorBeans.getTimeout(), 0);
int n = 0;
Response ret;
do {
long start = Timings.getTime();
SPARQLEndpoint endpoint;
if (properties.getProtocolScheme().equals("jena-api") && properties.getHost().equals("in-memory"))
endpoint = new JenaInMemoryEndpoint();
else
endpoint = new RemoteEndpoint();
ret = endpoint.query(request);
endpoint.close();
long stop = Timings.getTime();
UpdateProcessorBeans.timings(start, stop);
logger.trace("Response: " + ret.toString());
Timings.log("QUERY_PROCESSING_TIME", start, stop);
n++;
if (ret.isTimeoutError()) {
QueryProcessorBeans.timedOutRequest();
logger.error("*** TIMEOUT *** (" + n + "/" + QueryProcessorBeans.getTimeoutNRetry() + ") " + req);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.warn("Failed to sleep...");
}
}
} while (ret.isTimeoutError() && n < QueryProcessorBeans.getTimeoutNRetry());
// Request ABORTED
if (ret.isTimeoutError()) {
logger.error("*** REQUEST ABORTED *** " + request);
QueryProcessorBeans.abortedRequest();
}
return ret;
}
use of it.unibo.arces.wot.sepa.engine.processing.endpoint.SPARQLEndpoint in project SEPA by arces-wot.
the class UpdateProcessor method process.
public Response process(InternalUpdateRequest req) throws SEPASecurityException, IOException {
// ENDPOINT UPDATE (set timeout and set retry = 0)
UpdateRequest request = new UpdateRequest(properties.getUpdateMethod(), properties.getProtocolScheme(), properties.getHost(), properties.getPort(), properties.getUpdatePath(), req.getSparql(), req.getDefaultGraphUri(), req.getNamedGraphUri(), req.getBasicAuthorizationHeader(), UpdateProcessorBeans.getTimeout(), 0);
logger.trace(request);
Response ret;
int n = 0;
do {
long start = Timings.getTime();
SPARQLEndpoint endpoint;
if (properties.getProtocolScheme().equals("jena-api") && properties.getHost().equals("in-memory"))
endpoint = new JenaInMemoryEndpoint();
else
endpoint = new RemoteEndpoint();
ret = endpoint.update(request);
endpoint.close();
long stop = Timings.getTime();
UpdateProcessorBeans.timings(start, stop);
logger.trace("Response: " + ret.toString());
Timings.log("UPDATE_PROCESSING_TIME", start, stop);
n++;
if (ret.isTimeoutError()) {
UpdateProcessorBeans.timedOutRequest();
logger.error("*TIMEOUT* (" + n + "/" + UpdateProcessorBeans.getTimeoutNRetry() + ") " + req);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.warn("Failed to sleep...");
}
}
} while (ret.isTimeoutError() && n < UpdateProcessorBeans.getTimeoutNRetry());
if (ret.isTimeoutError()) {
logger.error("*** REQUEST ABORTED *** " + request);
UpdateProcessorBeans.abortedRequest();
}
return ret;
}
Aggregations