/*
(non-Javadoc)

@see
com.netflix.blitz4j.BlitzConfig#shouldRejectWhenAllBatcherThreadsUsed
(java.lang.String)
501614
@Override
    public boolean shouldRejectWhenAllBatcherThreadsUsed(String batcherName) {
        return CONFIGURATION.getBooleanProperty(
                batcherName + ".rejectWhenFull",
                Boolean.valueOf(this.getPropertyValue(batcherName
                        + ".rejectWhenFull", "false"))).get();
    }
751460
public ValidatorContext<D, O> handleWith(final ResultHandler<O>... resultHandlers) {
        if (resultHandlers != null) {
            Collections.addAll(registeredResultHandlers, resultHandlers);
        }
        return this;
    }
869328
@Override
	public void executeBatch(OperationsQueue queue) {
		if ( batchableGridDialect != null ) {
			batchableGridDialect.executeBatch( queue );
		}
		else if ( groupingByEntityGridDialect != null ) {
			groupingByEntityGridDialect.executeBatch( queue );
		}
	}
804447
@Service
    public List<Task> batchPoll(String taskType, String workerId, String domain, Integer count, Integer timeout) {
        List<Task> polledTasks = executionService.poll(taskType, workerId, domain, count, timeout);
        LOGGER.debug("The Tasks {} being returned for /tasks/poll/{}?{}&{}",
                polledTasks.stream()
                        .map(Task::getTaskId)
                        .collect(Collectors.toList()), taskType, workerId, domain);
        Monitors.recordTaskPollCount(taskType, domain, polledTasks.size());
        return polledTasks;
    }
78189
@Override
    public boolean holdbackActiveBatch(String name) {
        if(activeBatch == null) {
            return false;
        }

        if(batches.containsKey(name)) {
            return false;
        }

        if(batches.isEmpty()) {
            batches = new HashMap<String, DefaultBatch>();
        }
        batches.put(name, activeBatch);
        activeBatch = null;
        return true;
    }
518701
public void executeBatch() throws OJBBatchUpdateException
    {
        if (batchCon != null)
        {
            try
            {
                batchCon.executeBatch();
            }
            catch (Throwable th)
            {
                throw new OJBBatchUpdateException(th);
            }
        }
    }
427443
protected void writeBatchEntry(StringBuilder sb, ExecutionInfo execInfo, List<QueryInfo> queryInfoList) {
        sb.append("\"batch\":");
        sb.append(execInfo.isBatch() ? "true" : "false");
        sb.append(", ");
    }
1193221
private function checkReadContext()
    {
        if ($this->type === self::TYPE_SINGLE_USE && $this->context === SessionPoolInterface::CONTEXT_READWRITE) {
            throw new \BadMethodCallException('Cannot use a single-use read-write transaction for read or execute.');
        }
    }
580070
private void doBatchMessage(final JsonObject message) {
    String batchID = message.getString("batch");
    if (currentBatch != null && currentBatch.id().equals(batchID)) {
      Object value = deserializer.deserialize(message);
      if (value != null) {
        if (log.isDebugEnabled()) {
          log.debug(String.format("%s - Batch received: Batch[batch=%s, id=%d, message=%s]", this, batchID, message.getLong("id"), value));
        }
        currentBatch.handleMessage(value);
      }
    }
  }
436354
private FailedBatch doBatchWriteItemWithRetry(
            Map<String, List<WriteRequest>> batch,
            BatchWriteRetryStrategy batchWriteRetryStrategy) {

        BatchWriteItemResult result = null;
        int retries = 0;
        int maxRetries = batchWriteRetryStrategy
                .getMaxRetryOnUnprocessedItems(Collections
                        .unmodifiableMap(batch));

        FailedBatch failedBatch = null;
        Map<String, List<WriteRequest>> pendingItems = batch;

        while (true) {
            try {
                result = db.batchWriteItem(applyBatchOperationUserAgent(
                        new BatchWriteItemRequest().withRequestItems(pendingItems)));
            } catch (Exception e) {
                failedBatch = new FailedBatch();
                failedBatch.setUnprocessedItems(pendingItems);
                failedBatch.setException(e);
                return failedBatch;
            }
            pendingItems = result.getUnprocessedItems();

            if (pendingItems.size() > 0) {

                // return pendingItems as a FailedBatch if we have exceeded max retry
                if (maxRetries >= 0 && retries >= maxRetries) {
                    failedBatch = new FailedBatch();
                    failedBatch.setUnprocessedItems(pendingItems);
                    failedBatch.setException(null);
                    return failedBatch;
                }

                pause(batchWriteRetryStrategy.getDelayBeforeRetryUnprocessedItems(
                        Collections.unmodifiableMap(pendingItems), retries));
                retries++;
            } else {
                break;
            }
        }
        return failedBatch;
    }
874887
@Override
    public java.util.concurrent.Future<SendMessageBatchResult> sendMessageBatchAsync(String queueUrl, java.util.List<SendMessageBatchRequestEntry> entries,
            com.amazonaws.handlers.AsyncHandler<SendMessageBatchRequest, SendMessageBatchResult> asyncHandler) {

        return sendMessageBatchAsync(new SendMessageBatchRequest().withQueueUrl(queueUrl).withEntries(entries), asyncHandler);
    }
559962
static void failOnUnknownContextTypes(HashSet<String> unknown, ArrayList<ThreadContextProvider> contextProviders) {
        Set<String> known = new TreeSet<>(); // alphabetize for readability of message
        known.addAll(Arrays.asList(ThreadContext.ALL_REMAINING, ThreadContext.APPLICATION, ThreadContext.CDI, ThreadContext.SECURITY, ThreadContext.TRANSACTION));
        for (ThreadContextProvider provider : contextProviders) {
            String contextType = provider.getThreadContextType();
            known.add(contextType);
        }

        throw new IllegalStateException(Tr.formatMessage(tc, "CWWKC1155.unknown.context", new TreeSet<String>(unknown), known));
    }
1332232
private void doBatchStart(final JsonObject message) {
    if (currentBatch != null) {
      currentBatch.handleEnd(null);
    }
    String batchID = message.getString("batch");
    Object args = deserializer.deserialize(message);
    if (log.isDebugEnabled()) {
      log.debug(String.format("%s - Batch started: Batch[batch=%s, args=%s]", this, batchID, args));
    }
    currentBatch = new DefaultConnectionInputBatch(batchID, this);
    if (batchHandler != null) {
      batchHandler.handle(currentBatch);
    }
    currentBatch.handleStart(args);
  }
372417
private static <T> void batchReject(T[] array, int start, int end, FastListRejectProcedure<T> castProcedure)
    {
        for (int i = start; i < end; i++)
        {
            castProcedure.value(array[i]);
        }
    }
986012
@Override
    public IterationBuilderVar as(Class<? extends WindupVertexFrame> varType, String var)
    {
        setPayloadManager(new TypedNamedIterationPayloadManager(varType, var));
        return this;
    }
1137529
private void checkThread() {
        if (Thread.currentThread() != thread) {
            throw new IllegalStateException("Don't cross-thread using the "
                    + Context.class.getName() + " object, it's thread-local only. context thread: "
                    + thread.getName() + ", current thread: " + Thread.currentThread().getName());
        }
    }
15246
@Override
    public java.util.concurrent.Future<SendMessageBatchResult> sendMessageBatchAsync(String queueUrl, java.util.List<SendMessageBatchRequestEntry> entries) {

        return sendMessageBatchAsync(new SendMessageBatchRequest().withQueueUrl(queueUrl).withEntries(entries));
    }