Marks a query as completed with the given HTTP code with exception and moves it from the running map to the cache, updating the cache if it already existed. @param response The HTTP response to log @param exception The exception thrown
(final HttpResponseStatus response,
final Throwable exception)
| 339 | * @param exception The exception thrown |
| 340 | */ |
| 341 | public void markSerialized(final HttpResponseStatus response, |
| 342 | final Throwable exception) { |
| 343 | this.exception = exception; |
| 344 | this.response = response; |
| 345 | |
| 346 | query_completed_ts = DateTime.currentTimeMillis(); |
| 347 | overall_stats.put(QueryStat.PROCESSING_PRE_WRITE_TIME, DateTime.nanoTime() - query_start_ns); |
| 348 | synchronized (running_queries) { |
| 349 | if (!running_queries.containsKey(this.hashCode())) { |
| 350 | if (!ENABLE_DUPLICATES) { |
| 351 | LOG.warn("Query was already marked as complete: " + this); |
| 352 | } |
| 353 | } |
| 354 | running_queries.remove(hashCode()); |
| 355 | if (LOG.isDebugEnabled()) { |
| 356 | LOG.debug("Removed completed query " + remote_address + " with hash " + |
| 357 | hashCode() + " on thread " + Thread.currentThread().getId()); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | aggQueryStats(); |
| 362 | |
| 363 | final int cache_hash = this.hashCode() ^ response.toString().hashCode(); |
| 364 | synchronized (completed_queries) { |
| 365 | final QueryStats old_query = completed_queries.getIfPresent(cache_hash); |
| 366 | if (old_query == null) { |
| 367 | completed_queries.put(cache_hash, this); |
| 368 | } else { |
| 369 | old_query.executed++; |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * Marks the query as complete and logs it to the proper logs. This is called |