@Override
  public void execute(FunctionContext context) {
    RegionFunctionContext ctx = (RegionFunctionContext) context;
    ResultSender<Boolean> resultSender = ctx.getResultSender();

    Region region = ctx.getDataSet();
    Cache cache = region.getCache();
    WaitUntilFlushedFunctionContext arg = (WaitUntilFlushedFunctionContext) ctx.getArguments();
    if (arg == null) {
      return;
    }
    String indexName = arg.getIndexName();
    if (indexName == null) {
      throw new IllegalArgumentException("Missing index name");
    }
    long timeout = arg.getTimeout();
    TimeUnit unit = arg.getTimeunit();

    boolean result = false;
    String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, region.getFullPath());
    AsyncEventQueueImpl queue = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId);
    if (queue != null) {
      try {
        result = queue.waitUntilFlushed(timeout, unit);
      } catch (InterruptedException ignored) {
      }

    } else {
      throw new IllegalStateException(
          "The AEQ does not exist for the index " + indexName + " region " + region.getFullPath());
    }
    resultSender.lastResult(result);
  }
{@link WaitUntilFlushedFunction} will check all the members with index to wait until the events
in current AEQs are flushed into index. This function enables an accessor and client to call to
make sure the current events are processed.
geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/distributed/WaitUntilFlushedFunction.java