Prevents further mutations and waits for all outstanding mutations to complete.

@throws BulkMutationFailure If any mutations failed.
@throws InterruptedException If interrupted.
@throws TimeoutException If the outstanding requests don't finish in time.
353390
public void close(Duration duration) throws InterruptedException, TimeoutException {
    closed = true;
    long deadlineMs = System.currentTimeMillis() + duration.toMillis();

    synchronized (lock) {
      while (numOutstanding.get() > 0) {
        long waitMs = deadlineMs - System.currentTimeMillis();
        if (waitMs <= 0) {
          throw new TimeoutException("Timed out waiting outstanding mutations to finish");
        }
        lock.wait(waitMs);
      }

      // numFailures can only be checked after numOutstanding is zero.
      if (numFailures > 0) {
        throw new BulkMutationFailure(numFailures);
      }
    }
  }
935116
public void stop() throws Exception {
		synchronized (this.lock) {
			if (this.nephele != null) {
				this.nephele.stop();
				this.nephele = null;
			} else {
				throw new IllegalStateException("The local executor was not started.");
			}
		}
	}
21777
public ApiFuture<Void> add(final RowMutation rowMutation) {
    Preconditions.checkState(!closed, "BulkMutations has been closed");
    numOutstanding.incrementAndGet();

    ApiFuture<Void> future = callable.futureCall(rowMutation);

    ApiFutures.addCallback(
        future,
        new ApiFutureCallback<Void>() {
          @Override
          public void onFailure(Throwable throwable) {
            onMutationComplete(false);
          }

          @Override
          public void onSuccess(Void aVoid) {
            onMutationComplete(true);
          }
        },
        MoreExecutors.directExecutor());

    return future;
  }
984713
private void waitUntilReconstitutionIsCompleted()
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "waitUntilReconstitutionISCompleted");

        // gracefully shutdown the pool
        _reconstituteThreadpool.shutdown();

        //awaitTermination() is a blocking call and caller thread will be blocked
        //until all tasks in pool have completed execution after a shutdown request
        try
        {
            _reconstituteThreadpool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e)
        {
            // No FFDC code needed
            SibTr.exception(tc, e);
        }

        //Destroy the thread pool
        _reconstituteThreadpool = null;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "waitUntilReconstitutionISCompleted");
    }
885381
private static void waitForAll(Iterable<? extends Future<?>> futures) throws InterruptedException, ExecutionException {
		for(Future<?> future : futures) {
			future.get();
		}
	}
678943
@Override
  public CompletableFuture<Void> mutate(final Mutation mutation) {
    return toCompletableFuture(helper.mutate(mutation))
        .thenApply(r -> null);
  }
1048177
@Override
	public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
		int counts = rejectCounts.incrementAndGet();
		if(logger.isWarnEnabled()) {
			int t = counts % 100;
			if (t == 0) {
					logger.warn(new StringBuilder().append("Task[").append(message).append("] blocked ").append(counts).append(" times.").toString());
			}
		}
//
		try {
			if(sliceScrollBlockedWaitTimeout <= 0) {
				executor.getQueue().put(r);
			}
			else {
				boolean result = executor.getQueue().offer(r, this.sliceScrollBlockedWaitTimeout, TimeUnit.MILLISECONDS);
				if(!result){
					throw new RejectedExecutionException(new StringBuilder().append("Task[").append(message).append("] rejected: wait timeout after ")
							.append(sliceScrollBlockedWaitTimeout).append(" MILLISECONDS.").toString());
				}
			}
		} catch (InterruptedException e1) {
			throw new RejectedExecutionException(e1);
		}
	}
515674
@Override
    public void release() throws Exception {
        if (!locksToDelete.isEmpty() || lockColumn != null) {
            MutationBatch m = keyspace.prepareMutationBatch().setConsistencyLevel(consistencyLevel);
            fillReleaseMutation(m, false);
            m.execute();
        }
    }
441988
protected void handleMutation() {

        if (m_unregistered) {
            removeObserver();
            return;
        }

        int maxHeight = getState().getMaxHeight();
        if (m_currentHeight > 0) {
            removeObserver(); // prevent 'recursive' call of handleMutation (it's not actually recursive since it's async, but would still lead to an infinite number of calls)
            JavaScriptObject scrollPositionData = saveScrollPositions(m_widget.getElement());
            String classToAdd = "o-measuring-height";
            m_widget.addStyleName(classToAdd);
            m_widget.getElement().getStyle().clearHeight();
            int computedHeight = m_widget.getOffsetHeight();
            m_widget.removeStyleName(classToAdd);
            if ((computedHeight + 10) < m_currentHeight) {
                m_currentHeight = -1;
                m_rpc.fixHeight(m_currentHeight);
            } else {
                m_widget.getElement().getStyle().setHeight(m_currentHeight, Unit.PX);
            }
            restoreScrollPositions(scrollPositionData);
            addMutationObserver(m_widget.getElement());
        } else if ((maxHeight > 0) && (m_widget.getOffsetHeight() > maxHeight)) {
            m_currentHeight = maxHeight;
            m_rpc.fixHeight(m_currentHeight);
        }
    }
1218661
public void flush() {
        BulkResponse bulk = tryFlush();
        if (!bulk.getDocumentErrors().isEmpty()) {
            int maxErrors = 5;
            String header = String.format("Could not write all entries for bulk operation [%s/%s]. Error " +
                    "sample (first [%s] error messages):\n", bulk.getDocumentErrors().size(), bulk.getTotalDocs(), maxErrors);
            StringBuilder message = new StringBuilder(header);
            int i = 0;
            for (BulkResponse.BulkError errors : bulk.getDocumentErrors()) {
                if (i >=maxErrors ) {
                    break;
                }
                message.append("\t");
                appendError(message, errors.getError());
                message.append("\n");
                message.append("\t")
                	.append(errors.getDocument().toString())
                	.append("\n");
                i++;
            }
            message.append("Bailing out...");
            throw new EsHadoopException(message.toString());
        }
    }
960665
final void internalWait(long timeout) {
    int s;
    if ((s = status) >= 0 && // force completer to issue notify
        U.compareAndSwapInt(this, STATUS, s, s | SIGNAL)) {
      synchronized (this) {
        if (status >= 0)
          try {
            wait(timeout);
          } catch (InterruptedException ie) {
          }
        else
          notifyAll();
      }
    }
  }
1242342
@POST
    @Path("/retry")
    @ApiOperation("Retry the last failed task for each workflow from the list")
    public BulkResponse retry(List<String> workflowIds) {
       return  workflowBulkService.retry(workflowIds);
    }
581713
public void finish() throws Exception {
        assertTrue(format("Did you call finish() from outside @%s test?", Specification.class.getSimpleName()),
                !latch.isInInitState());

        // wait for script to finish
        latch.notifyStartable();

        latch.awaitFinished();
    }
148681
public void waitForCompletion() throws InterruptedException {
        try {
            waitForCompletion(0L);
        } catch (AsyncTimeoutException ate) {
            // cannot happen since arg of 0L means wait forever
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Unexpected timeout on blocking wait call, exception: " + ate.getMessage());
            }
            FFDCFilter.processException(ate,
                                        getClass().getName() + ".waitForCompletion", "268", this);
            InterruptedException ie = new InterruptedException("Unexpected timeout");
            ie.initCause(ate);
            throw ie;
        }
    }
142533
def trigger(self):
        '''
        
        '''
        assert(self.controller)
        self._trigger()
        self.logger.debug('Waiting for mutation response. (timeout = %d)'
                          % self.mutation_server_timeout)
        res = self.response_sent_event.wait(self.mutation_server_timeout)
        if not res:
            # mark the controller's report as failed since we did not get a response from the stack
            # self.controller.report.add('failed', False) ## so it will not appear in the UI
            # self.controller.report.add('failure_reason', 'trigger timed out')
            # raise Exception('[%s] Error: trigger timed out (%d)'
            #                 % (self.name, self.mutation_server_timeout))
            self.report.error('trigger timed out')
            self.logger.error('Failure: trigger timed out')
        else:
            time.sleep(self.post_fuzz_delay)
        self.response_sent_event.clear()
434489
@CanIgnoreReturnValue
  @Override
  public <T> T callWithTimeout(
      Callable<T> callable, long timeoutDuration, TimeUnit timeoutUnit, boolean amInterruptible)
      throws Exception {
    checkNotNull(callable);
    checkNotNull(timeoutUnit);
    checkArgument(timeoutDuration > 0, "timeout must be positive: %s", timeoutDuration);
    Future<T> future = executor.submit(callable);
    try {
      if (amInterruptible) {
        try {
          return future.get(timeoutDuration, timeoutUnit);
        } catch (InterruptedException e) {
          future.cancel(true);
          throw e;
        }
      } else {
        return Uninterruptibles.getUninterruptibly(future, timeoutDuration, timeoutUnit);
      }
    } catch (ExecutionException e) {
      throw throwCause(e, true);
    } catch (TimeoutException e) {
      future.cancel(true);
      throw new UncheckedTimeoutException(e);
    }
  }
954882
@Override
  public void execute(TxScope scope, Runnable runnable) {
    methodCalls.add(MethodCall.of("bulkUpdate").with("scope", scope, "runnable", runnable));
    delegate.execute(scope, runnable);
  }