/** * Persists all {@link PendingStoreRequest} currently in the queue with the given writer. */ void persist(StoreRequestWriter<?> writer) { // Capture all current events. // The reason for capturing instead of using a live iterator is to avoid the possible case of infinite write // time. E.g. while generating the entry to write to the storage table, a new store request get enqueued. // The number of requests in the queue is bounded by the number of threads that call this method. // Since this method is expected to be called (indirectly) from a http handler thread, that is bounded by // the thread pool size used by the http service. inflightRequests.clear(); PendingStoreRequest request = writeQueue.poll(); while (request != null) { inflightRequests.add(request); request = writeQueue.poll(); } metricsCollector.gauge("persist.queue.size", inflightRequests.size()); try { writer.write(inflightRequests.iterator()); completeAll(null); } catch (Throwable t) { completeAll(t); } }
/** * Persists all {@link PendingStoreRequest} currently in the queue with the given writer. */ void persist(StoreRequestWriter<?> writer) { // Capture all current events. // The reason for capturing instead of using a live iterator is to avoid the possible case of infinite write // time. E.g. while generating the entry to write to the storage table, a new store request get enqueued. // The number of requests in the queue is bounded by the number of threads that call this method. // Since this method is expected to be called (indirectly) from a http handler thread, that is bounded by // the thread pool size used by the http service. inflightRequests.clear(); PendingStoreRequest request = writeQueue.poll(); while (request != null) { inflightRequests.add(request); request = writeQueue.poll(); } metricsCollector.gauge("persist.queue.size", inflightRequests.size()); try { writer.write(inflightRequests.iterator()); completeAll(null); } catch (Throwable t) { completeAll(t); } }