@Override public void abort() { aborted = true; if(decoratee != null) { decoratee.abort(); } }
@Override public void abort() { decoratee.abort(); }
/** * Stop in mid execution. * This method can be called in parallel with other methods on the * QueryExecution object. * There is no guarantee that the concrete implementation actual * will stop or that it will do so immediately. * No operations on the query execution or any associated * result set are permitted after this call and may cause exceptions to be thrown. */ @Override public void abort() { try { a.abort(); } finally { b.abort(); } }
@Override public void run() { try { queryExecution.abort(); } catch (Exception e) { logger.warn("Exception while aborting a QueryExecution that has reached its execution timeout", e); } //throw new RuntimeException("Query execution has reached its time limit."); } };
@Override public boolean cancel(boolean mayInterruptIfRunning) { qe.abort();System.out.println("Aborting..."); return super.cancel(mayInterruptIfRunning); }
private void shutdownAll(ExecutorService threadPool, int position){ for (int j = 0; j < decoratees.size(); j++) { if(j != position){ System.out.println("Cancelling " + (j+1) + ". query execution."); decoratees.get(j).abort(); } } threadPool.shutdownNow(); }
@Override public void onDisconnect(AsyncResponse disconnect) { logger.debug("Client disconnected"); qeAndType.getQueryExecution().abort(); // if(true) { // disconnect.resume( // Response.status(Response.Status.SERVICE_UNAVAILABLE) // .entity("Connection Callback").build()); // } else { // disconnect.cancel(); // } } });
public static void abortAfterFirstRow(QueryExecution qe) { Query query = qe.getQuery(); assert query != null : "QueryExecution did not tell us which query it is bound to - query was null"; int queryType = query.getQueryType(); try { switch (queryType) { case Query.QueryTypeAsk: qe.execAsk(); break; case Query.QueryTypeConstruct: Iterator<Triple> itC = qe.execConstructTriples(); itC.hasNext(); break; case Query.QueryTypeDescribe: Iterator<Triple> itD = qe.execDescribeTriples(); itD.hasNext(); break; case Query.QueryTypeSelect: ResultSet rs = qe.execSelect(); rs.hasNext(); break; default: throw new RuntimeException("Unknown query type - should not happen: queryType = " + queryType); } } finally { qe.abort(); } }
@Test public void test_Cancel_API_3() throws InterruptedException { // Don't qExec.close on this thread. QueryExecution qExec = makeQExec("PREFIX ex: <" + ns + "> SELECT * { ?s ?p ?o . FILTER ex:wait(100) }") ; CancelThreadRunner thread = new CancelThreadRunner(qExec); thread.start(); synchronized (qExec) { qExec.wait() ; } synchronized (qExec) { qExec.abort() ;} synchronized (qExec) { qExec.notify() ; } assertEquals (1, thread.getCount()) ; }
@Test public void test_Cancel_API_4() throws InterruptedException { // Don't qExec.close on this thread. QueryExecution qExec = makeQExec("PREFIX ex: <" + ns + "> SELECT * { ?s ?p ?o } ORDER BY ex:wait(100)") ; CancelThreadRunner thread = new CancelThreadRunner(qExec); thread.start(); synchronized (qExec) { qExec.wait() ; } synchronized (qExec) { qExec.abort(); } synchronized (qExec) { qExec.notify() ; } assertEquals (1, thread.getCount()) ; }
@Test public void timeout_03() { String qs = prefix + "SELECT * { ?s ?p ?o }" ; @SuppressWarnings("resource") QueryExecution qExec = QueryExecutionFactory.create(qs, ds) ; qExec.setTimeout(100, TimeUnit.MILLISECONDS) ; ResultSet rs = qExec.execSelect() ; ResultSetFormatter.consume(rs) ; qExec.close() ; qExec.abort() ; }
@Test(expected=QueryCancelledException.class) public void test_Cancel_API_1() { try(QueryExecution qExec = makeQExec("SELECT * {?s ?p ?o}")) { ResultSet rs = qExec.execSelect() ; assertTrue(rs.hasNext()) ; qExec.abort(); assertTrue(rs.hasNext()) ; rs.nextSolution(); assertFalse("Results not expected after cancel.", rs.hasNext()) ; } }
@Test(expected=QueryCancelledException.class) public void test_Cancel_API_2() { try(QueryExecution qExec = makeQExec("PREFIX ex: <" + ns + "> SELECT * {?s ?p ?o . FILTER ex:wait(100) }")) { ResultSet rs = qExec.execSelect() ; assertTrue(rs.hasNext()) ; qExec.abort(); assertTrue(rs.hasNext()) ; rs.nextSolution(); assertFalse("Results not expected after cancel.", rs.hasNext()) ; } }
QueryExecution qExec = QueryExecutionFactory.create(query, getModStore().getDataset()) ; qExec.abort();