use of org.apache.jena.atlas.RuntimeIOException in project jena by apache.
the class SPARQL_ServletBase method doCommon.
// Common framework for handling HTTP requests
/**
* Handles GET and POST requests.
* @param request HTTP request
* @param response HTTP response
*/
protected void doCommon(HttpServletRequest request, HttpServletResponse response) //throws ServletException, IOException
{
try {
long id = allocRequestId(request, response);
// Lifecycle
HttpAction action = allocHttpAction(id, request, response);
// then add to doCommonWorker
// work with HttpServletResponseTracker
printRequest(action);
action.setStartTime();
response = action.response;
initResponse(request, response);
Context cxt = ARQ.getContext();
try {
execCommonWorker(action);
} catch (QueryCancelledException ex) {
// Also need the per query info ...
String message = String.format("The query timed out (restricted to %s ms)", cxt.get(ARQ.queryTimeout));
// Possibility :: response.setHeader("Retry-after", "600") ; // 5 minutes
responseSendError(response, HttpSC.SERVICE_UNAVAILABLE_503, message);
} catch (ActionErrorException ex) {
if (ex.exception != null)
ex.exception.printStackTrace(System.err);
// Log message done by printResponse in a moment.
if (ex.message != null)
responseSendError(response, ex.rc, ex.message);
else
responseSendError(response, ex.rc);
} catch (RuntimeIOException ex) {
log.warn(format("[%d] Runtime IO Exception (client left?) RC = %d", id, HttpSC.INTERNAL_SERVER_ERROR_500));
responseSendError(response, HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage());
} catch (Throwable ex) {
// This should not happen.
//ex.printStackTrace(System.err) ;
log.warn(format("[%d] RC = %d : %s", id, HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage()), ex);
responseSendError(response, HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage());
}
action.setFinishTime();
printResponse(action);
archiveHttpAction(action);
} catch (Throwable th) {
log.error("Internal error", th);
}
}
use of org.apache.jena.atlas.RuntimeIOException in project jena by apache.
the class BinaryDataFileRandomAccess method open.
@Override
public void open() {
if (file != null)
throw new RuntimeIOException("Already open");
try {
file = new RandomAccessFile(filename, "rw");
writePosition = file.length();
readPosition = 0;
readMode = true;
} catch (IOException e) {
IO.exception(e);
}
}
use of org.apache.jena.atlas.RuntimeIOException in project jena by apache.
the class BinaryDataFileMem method open.
@Override
public synchronized void open() {
if (storage != null)
throw new RuntimeIOException("Already open");
storage = new SegmentedMemBuffer();
readMode = true;
}
use of org.apache.jena.atlas.RuntimeIOException in project jena by apache.
the class TransBinaryDataFile method truncate.
/**
* Truncate only supported for an abort - this transactional version of
* {@link BinaryDataFile} will not truncate to earlier than the committed length.
*/
@Override
public void truncate(long size) {
requireWriteTxn();
TxnBinFile state = getDataState();
if (size < state.length)
throw new RuntimeIOException("truncate(" + size + ") to smaller than commited length " + state.length);
binFile.truncate(size);
}
use of org.apache.jena.atlas.RuntimeIOException in project jena by apache.
the class ActionService method executeLifecycle.
/**
* Add counters to the validate-execute lifecycle.
*/
@Override
protected void executeLifecycle(HttpAction action) {
// And also HTTP counter
CounterSet csService = (action.getDataService() == null) ? null : action.getDataService().getCounters();
CounterSet csOperation = null;
if (action.getEndpoint() != null)
// Direct naming GSP does not have an "endpoint".
csOperation = action.getEndpoint().getCounters();
incCounter(csService, Requests);
incCounter(csOperation, Requests);
// or in execution in perform.
try {
validate(action);
} catch (ActionErrorException ex) {
incCounter(csOperation, RequestsBad);
incCounter(csService, RequestsBad);
throw ex;
}
try {
execute(action);
// Success
incCounter(csOperation, RequestsGood);
incCounter(csService, RequestsGood);
} catch (ActionErrorException | QueryCancelledException | RuntimeIOException ex) {
incCounter(csOperation, RequestsBad);
incCounter(csService, RequestsBad);
throw ex;
}
}
Aggregations