/** * Check to see if the query execution got canceled. The query gets canceled by the QueryMonitor * if it takes more than the max query execution time or low memory situations */ public boolean isCanceled() { return getQueryCanceledException() != null; }
/** * This method attempts to reintrepret a {@link QueryExecutionCanceledException} using the * the value returned by {@link #getQueryCanceledException} (set by the {@link QueryMonitor}). * * @throws if {@link #getQueryCanceledException} doesn't return {@code null} then throw that * {@link CacheRuntimeException}, otherwise throw {@link QueryExecutionCanceledException} */ private Object reinterpretQueryExecutionCanceledException() { final CacheRuntimeException queryCanceledException = getQueryCanceledException(); if (queryCanceledException != null) { throw queryCanceledException; } else { throw new QueryExecutionCanceledException( "Query was canceled. It may be due to low memory or the query was running longer than the MAX_QUERY_EXECUTION_TIME."); } }
private void checkIfQueryShouldBeCancelled() { if (QueryMonitor.isLowMemory()) { String reason = "Query execution canceled due to low memory while gathering results from partitioned regions"; query.setQueryCanceledException(new QueryExecutionLowMemoryException(reason)); if (DefaultQuery.testHook != null) { DefaultQuery.testHook .doTestHook(DefaultQuery.TestHook.SPOTS.BEFORE_THROW_QUERY_CANCELED_EXCEPTION, null); } throw query.getQueryCanceledException(); } else if (query.isCanceled()) { throw query.getQueryCanceledException(); } }
if (logger.isDebugEnabled()) { logger.debug("query cancelled while gathering results, aborting due to exception " + query.getQueryCanceledException());
throw query.getQueryCanceledException();
throw new QueryExecutionLowMemoryException(reason); } else if (query.isCanceled()) { throw query.getQueryCanceledException();
e = new QueryException(defaultQuery.getQueryCanceledException().getMessage(), e.getCause());