protected final void stopThreads(Exception cause) { // There is no need to stop threads if all threads have already completed. if (done.compareAndSet(false, true)) { exception = cause; // Send stop signal to threads. for (QueryThread thread : threads) { thread.stop(); } sendCancel(); } }
private final void threadCompleted() { int finished = completedCount.incrementAndGet(); if (finished < threads.length) { int nextThread = finished + maxConcurrentNodes - 1; // Determine if a new thread needs to be started. if (nextThread < threads.length && ! done.get()) { // Start new thread. threadPool.execute(threads[nextThread]); } } else { // All threads complete. Tell RecordSet thread to return complete to user // if an exception has not already occurred. if (done.compareAndSet(false, true)) { sendCompleted(); } } }
/** * Close query. */ public final void close() { valid = false; // Check if more records are available. if (record != END && queue.poll() != END) { // Some query threads may still be running. Stop these threads. executor.stopThreads(new AerospikeException.QueryTerminated()); } }
protected final void initializeThreads() { // Detect cluster migrations when performing scan. long clusterKey = policy.failOnClusterChange ? QueryValidate.validateBegin(nodes[0], statement.namespace) : 0; boolean first = true; // Initialize threads. for (int i = 0; i < nodes.length; i++) { MultiCommand command = createCommand(clusterKey, first); threads[i] = new QueryThread(nodes[i], command); first = false; } }
/** * Retrieve next record. This method will block until a record is retrieved * or the query is cancelled. * * @return whether record exists - if false, no more records are available */ public final boolean next() throws AerospikeException { if (! valid) { executor.checkForException(); return false; } try { record = queue.take(); } catch (InterruptedException ie) { valid = false; if (Log.debugEnabled()) { Log.debug("RecordSet " + executor.statement.taskId + " take interrupted"); } return false; } if (record == END) { valid = false; executor.checkForException(); return false; } return true; }
protected final void initializeThreads() { // Detect cluster migrations when performing scan. long clusterKey = policy.failOnClusterChange ? QueryValidate.validateBegin(nodes[0], statement.namespace) : 0; boolean first = true; // Initialize threads. for (int i = 0; i < nodes.length; i++) { MultiCommand command = createCommand(clusterKey, first); threads[i] = new QueryThread(nodes[i], command); first = false; } }
/** * Retrieve next record. This method will block until a record is retrieved * or the query is cancelled. * * @return whether record exists - if false, no more records are available */ public final boolean next() throws AerospikeException { if (! valid) { executor.checkForException(); return false; } try { record = queue.take(); } catch (InterruptedException ie) { valid = false; if (Log.debugEnabled()) { Log.debug("RecordSet " + executor.statement.taskId + " take interrupted"); } return false; } if (record == END) { valid = false; executor.checkForException(); return false; } return true; }
/** * Close query. */ public final void close() { valid = false; // Check if more records are available. if (record != END && queue.poll() != END) { // Some query threads may still be running. Stop these threads. executor.stopThreads(new AerospikeException.QueryTerminated()); } }
protected final void stopThreads(Exception cause) { // There is no need to stop threads if all threads have already completed. if (done.compareAndSet(false, true)) { exception = cause; // Send stop signal to threads. for (QueryThread thread : threads) { thread.stop(); } sendCancel(); } }
private final void threadCompleted() { int finished = completedCount.incrementAndGet(); if (finished < threads.length) { int nextThread = finished + maxConcurrentNodes - 1; // Determine if a new thread needs to be started. if (nextThread < threads.length && ! done.get()) { // Start new thread. threadPool.execute(threads[nextThread]); } } else { // All threads complete. Tell RecordSet thread to return complete to user // if an exception has not already occurred. if (done.compareAndSet(false, true)) { sendCompleted(); } } }
public void run() { try { if (command.isValid()) { command.execute(cluster, policy, node); } threadCompleted(); } catch (Exception e) { // Terminate other query threads. stopThreads(e); } }
public void run() { try { runThreads(); } catch (Exception e) { super.stopThreads(e); } finally { LuaCache.putInstance(lua); } }
public void run() { try { runThreads(); } catch (Exception e) { super.stopThreads(e); } finally { LuaCache.putInstance(lua); } }
public void run() { try { if (command.isValid()) { command.execute(cluster, policy, node); } threadCompleted(); } catch (Exception e) { // Terminate other query threads. stopThreads(e); } }