The standard BatchListener action called by QueryBatcher.
499456
@Override
  public void processEvent(QueryBatch batch) {
    try {
      batch.getClient().newDocumentManager().delete( batch.getItems() );
    } catch (Throwable t) {
      for ( BatchFailureListener<Batch<String>> listener : failureListeners ) {
        try {
          listener.processFailure(batch, t);
        } catch (Throwable t2) {
          logger.error("Exception thrown by an onBatchFailure listener", t2);
        }
      }
      for ( BatchFailureListener<QueryBatch> queryBatchFailureListener : queryBatchFailureListeners ) {
        try {
          queryBatchFailureListener.processFailure(batch, t);
        } catch (Throwable t2) {
          logger.error("Exception thrown by an onFailure listener", t2);
        }
      }
    }
  }
146645
public void compileBatch(String []files)
    throws IOException, ClassNotFoundException
  {
    if (_compileParent) {
      try {
        if (_loader instanceof Make)
          ((Make) _loader).make();
      } catch (Exception e) {
        throw new IOException(e);
      }
    }

    if (files.length == 0)
      return;

    // only batch a number of files at a time

    int batchCount = _maxBatch;
    if (batchCount < 0)
      batchCount = Integer.MAX_VALUE / 2;
    else if (batchCount == 0)
      batchCount = 1;

    IOException exn = null;

    ArrayList<String> uniqueFiles = new ArrayList<String>();
    for (int i = 0; i < files.length; i++) {
      if (! uniqueFiles.contains(files[i]))
        uniqueFiles.add(files[i]);
    }
    files = new String[uniqueFiles.size()];
    uniqueFiles.toArray(files);

    LineMap lineMap = null;
    
    _compilerService.compile(this, files, lineMap);

    /*
    synchronized (LOCK) {
      for (int i = 0; i < files.length; i += batchCount) {
        int len = files.length - i;

        len = Math.min(len, batchCount);

        String []batchFiles = new String[len];

        System.arraycopy(files, i, batchFiles, 0, len);

        Arrays.sort(batchFiles);

        try {
          compileInt(batchFiles, null);
        } catch (IOException e) {
          if (exn == null)
            exn = e;
          else
            log.log(Level.WARNING, e.toString(), e);
        }
      }
    }

    if (exn != null)
      throw exn;
      */
  }
426666
@Override
    public int executeBatch()
    {
        BulkRequestBuilder bulkRequest = txClient.prepareBulk().setRefresh(isRefreshIndexes());

        try
        {
            for (Node node : nodes)
            {
                if (node.isDirty())
                {
                    node.handlePreEvent();
                    Object entity = node.getData();
                    Object id = node.getEntityId();
                    EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                            node.getDataClass());

                    MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                            .getMetamodel(metadata.getPersistenceUnit());

                    EntityType entityType = metaModel.entity(metadata.getEntityClazz());

                    String key = getKeyAsString(id, metadata, metaModel);

                    if (node.isInState(RemovedState.class))
                    {
                        // create a delete request.

                        DeleteRequest request = new DeleteRequest(metadata.getSchema().toLowerCase(),
                                metadata.getTableName(), key);
                        bulkRequest.add(request);

                    }
                    else if (node.isUpdate())
                    {
                        Map<String, Object> values = new HashMap<String, Object>();
                        List<RelationHolder> relationHolders = getRelationHolders(node);

                        addSource(entity, values, entityType);

                        addRelations(relationHolders, values);

                        UpdateRequest request = new UpdateRequest(metadata.getSchema().toLowerCase(),
                                metadata.getTableName(), key).doc(values);
                        bulkRequest.add(request);
                    }
                    else
                    {
                        // create an insert request.
                        Map<String, Object> values = new HashMap<String, Object>();
                        List<RelationHolder> relationHolders = getRelationHolders(node);

                        addSource(entity, values, entityType);

                        addRelations(relationHolders, values);

                        IndexRequest request = new IndexRequest(metadata.getSchema().toLowerCase(),
                                metadata.getTableName(), key).source(values);
                        bulkRequest.add(request);

                    }

                }
            }

            BulkResponse response = null;
            if (nodes != null && !nodes.isEmpty())
            {
                // bulkRequest.setRefresh(true);
                response = bulkRequest.execute().actionGet();
            }
            return response != null ? response.getItems().length : 0;
        }
        finally
        {
            clear();
        }

    }
370473
def do_batch(resource_root, elements):
  
  return call(resource_root.post, BATCH_PATH, ApiBatchResponseList,
      data=elements, api_version=6)
771542
private String batchExecute(String indexName,String indexType,int batchsize,String refreshOption){
		int count = 0;
		StringBuilder builder = new StringBuilder();
		BBossStringWriter writer = new BBossStringWriter(builder);
		String ret = null;
		int taskNo = 0;
		Exception exception = null;
		Object lastValue = null;
		long start = System.currentTimeMillis();
		long istart = 0;
		long end = 0;
		long totalCount = 0;
		try {
			istart = start;
			while (jdbcResultSet.next()) {
				lastValue = jdbcResultSet.getLastValue();
				Context context = evalBuilk(writer, indexName, indexType, jdbcResultSet, "index",clientInterface.isVersionUpper7());
				if(context.isDrop())
					continue;
				count++;
				if (count == batchsize) {
					writer.flush();
					String datas = builder.toString();
					builder.setLength(0);
					writer.close();
					writer = new BBossStringWriter(builder);
					count = 0;
					taskNo ++;

					ret = TaskCall.call(refreshOption,clientInterface,datas,jdbcResultSet);
					jdbcResultSet.flushLastValue(lastValue);


					if(isPrintTaskLog())  {
						end = System.currentTimeMillis();
						logger.info(new StringBuilder().append("Task[").append(taskNo).append("] complete,take time:").append((end - istart)).append("ms")
								.append(",import ").append(batchsize).append(" records.").toString());
						istart = end;
					}
					totalCount += batchsize;


				}

			}
			if (count > 0) {
				writer.flush();
				String datas = builder.toString();
				taskNo ++;
				ret = TaskCall.call(refreshOption,clientInterface,datas,jdbcResultSet);
				jdbcResultSet.flushLastValue(lastValue);
				if(isPrintTaskLog())  {
					end = System.currentTimeMillis();
					logger.info(new StringBuilder().append("Task[").append(taskNo).append("] complete,take time:").append((end - istart)).append("ms")
							.append(",import ").append(count).append(" records.").toString());

				}
				totalCount += count;
			}
			if(isPrintTaskLog()) {
				end = System.currentTimeMillis();
				logger.info(new StringBuilder().append("Execute Tasks:").append(taskNo).append(",All Take time:").append((end - start)).append("ms")
						.append(",Import total ").append(totalCount).append(" records.").toString());

			}
		} catch (SQLException e) {
			exception = e;
			throw new ElasticSearchException(e);

		} catch (ElasticSearchException e) {
			exception = e;
			throw e;
		} catch (Exception e) {
			exception = e;
			throw new ElasticSearchException(e);
		}
		finally {
			if(exception != null && !getESJDBC().isContinueOnError()){
				getESJDBC().stop();
			}
			try {
				writer.close();
			} catch (Exception e) {

			}
		}

		return ret;
	}
418666
public JSONObject batch(List<JSONObject> actions) throws AlgoliaException {
    return postBatch(actions, RequestOptions.empty);
  }
954022
private void initBatcher(String appenderName) {
        MessageProcessor<LoggingEvent> messageProcessor = new MessageProcessor<LoggingEvent>() {
            @Override
            public void process(List<LoggingEvent> objects) {
                processLoggingEvents(objects);
            }
        };
        String batcherName = this.getClass().getName() + BATCHER_NAME_LIMITER
                + appenderName;
        batcher = BatcherFactory.createBatcher(batcherName, messageProcessor);
        batcher.setTarget(messageProcessor);

    }
623631
@Override
  public void initializeListener(QueryBatcher queryBatcher) {
    HostAvailabilityListener hostAvailabilityListener = HostAvailabilityListener.getInstance(queryBatcher);
    if ( hostAvailabilityListener != null ) {
      BatchFailureListener<QueryBatch> retryListener = hostAvailabilityListener.initializeRetryListener(this);
      if( retryListener != null )  onFailure(retryListener);
    }
  }
132216
public JSONObject batch(JSONArray actions, RequestOptions requestOptions) throws AlgoliaException {
    return postBatch(actions, requestOptions);
  }
1056012
private void doBatchWork(BatchBackend backend) throws InterruptedException {
		ExecutorService executor = Executors.newFixedThreadPool( typesToIndexInParallel, "BatchIndexingWorkspace" );
		for ( IndexedTypeIdentifier indexedTypeIdentifier : rootIndexedTypes ) {
			executor.execute( new BatchIndexingWorkspace( gridDialect, searchFactoryImplementor, sessionFactory, indexedTypeIdentifier,
					cacheMode, endAllSignal, monitor, backend, tenantId ) );
		}
		executor.shutdown();
		endAllSignal.await(); // waits for the executor to finish
	}
420120
@Override
	public final void addBatch(String s) throws SQLException {
		batchSql.add(s);

		stmt.addBatch(s);
	}
350793
def do_batch(args):
    
    if args.subcommand == 'list':
        do_batch_list(args)

    if args.subcommand == 'show':
        do_batch_show(args)

    if args.subcommand == 'status':
        do_batch_status(args)

    if args.subcommand == 'submit':
        do_batch_submit(args)
590516
@Override
  public void initializeListener(QueryBatcher queryBatcher) {
    HostAvailabilityListener hostAvailabilityListener = HostAvailabilityListener.getInstance(queryBatcher);
    if ( hostAvailabilityListener != null ) {
      BatchFailureListener<QueryBatch> retryListener = hostAvailabilityListener.initializeRetryListener(this);
      if ( retryListener != null )  onFailure(retryListener);
    }
    NoResponseListener noResponseListener = NoResponseListener.getInstance(queryBatcher);
    if ( noResponseListener != null ) {
      BatchFailureListener<QueryBatch> noResponseRetryListener = noResponseListener.initializeRetryListener(this);
      if ( noResponseRetryListener != null )  onFailure(noResponseRetryListener);
    }
  }
508502
private void signalBatch() {
        writer.execute(new Runnable() {
            @Override
            public void run() {
                // Wait for other threads writing on the same journal to finish:
                while (writing.compareAndSet(false, true) == false) {
                    try {
                        Thread.sleep(SPIN_BACKOFF);
                    } catch (Exception ex) {
                    }
                }
                // TODO: Improve by employing different spinning strategies?
                WriteBatch wb = batchQueue.poll();
                try {
                    while (wb != null) {
                        if (!wb.isEmpty()) {
                            boolean newOrRotated = lastAppendDataFile != wb.getDataFile();
                            if (newOrRotated) {
                                if (lastAppendRaf != null) {
                                    lastAppendRaf.close();
                                }
                                lastAppendDataFile = wb.getDataFile();
                                lastAppendRaf = lastAppendDataFile.openRandomAccessFile();
                            }

                            // Perform batch:
                            Location batchLocation = wb.perform(lastAppendRaf, journal.isChecksum(), journal.isPhysicalSync(), journal.getReplicationTarget());

                            // Add batch location as hint:
                            journal.getHints().put(batchLocation, batchLocation.getThisFilePosition());

                            // Adjust journal length:
                            journal.addToTotalLength(wb.getSize());

                            // Now that the data is on disk, notify callbacks and remove the writes from the in-flight cache:
                            for (WriteCommand current : wb.getWrites()) {
                                try {
                                    current.getLocation().getWriteCallback().onSync(current.getLocation());
                                } catch (Throwable ex) {
                                    warn(ex, ex.getMessage());
                                }
                                journal.getInflightWrites().remove(current.getLocation());
                            }

                            // Finally signal any waiting threads that the write is on disk.
                            wb.getLatch().countDown();
                        }
                        // Poll next batch:
                        wb = batchQueue.poll();
                    }
                } catch (Exception ex) {
                    // Put back latest batch:
                    batchQueue.offer(wb);
                    // Notify error to all locations of all batches, and signal waiting threads:
                    for (WriteBatch currentBatch : batchQueue) {
                        for (WriteCommand currentWrite : currentBatch.getWrites()) {
                            try {
                                currentWrite.getLocation().getWriteCallback().onError(currentWrite.getLocation(), ex);
                            } catch (Throwable innerEx) {
                                warn(innerEx, innerEx.getMessage());
                            }
                        }
                        currentBatch.getLatch().countDown();
                    }
                    // Propagate exception:
                    asyncException.compareAndSet(null, ex);
                } finally {
                    writing.set(false);
                }
            }
        });
    }
1131979
@Override
	public void execute() {
		if (this.batches.isEmpty())
			return;
		
		// Reset the collection before making the call to eliminate callback chatter when
		// the batches call back to the master.
		List<Batch> old = this.batches;
		
		// Reset our batches
		this.batches = new ArrayList<Batch>();
		this.queryBatch = null;
		
		for (Batch batch: old) {
			batch.execute();
		}
	}
1253413
void batchReady(String batch) {
    if (log.isDebugEnabled()) {
      log.debug(String.format("%s - Batch ready: Batch[batch=%s]", this, batch));
    }
    eventBus.send(outAddress, new JsonObject().putString("action", "batch").putString("batch", batch));
  }
891809
private boolean updateBatch(DBObjectBatch dbObjBatch, BatchResult batchResult) throws IOException {
        Map<String, Map<String, String>> objCurrScalarMap = getCurrentScalars(dbObjBatch);
        Map<String, Map<String, Integer>> targObjShardNos = getLinkTargetShardNumbers(dbObjBatch);
        for (DBObject dbObj : dbObjBatch.getObjects()) {
            checkCommit();
            Map<String, String> currScalarMap = objCurrScalarMap.get(dbObj.getObjectID());
            ObjectResult objResult = updateObject(dbObj, currScalarMap, targObjShardNos);
            batchResult.addObjectResult(objResult);
        }
        commitTransaction();
        return batchResult.hasUpdates();
    }