Class ElasticsearchWatermarkStore

java.lang.Object
org.alfresco.elasticsearch.batchindexing.ElasticsearchWatermarkStore

public class ElasticsearchWatermarkStore extends Object
Persists the reindexing watermark as a typed WatermarkDocument in a dedicated Elasticsearch index.

The document contains both the trusted anchor (lastSuccessfulToTimeEpochMs) and audit fields for the most recent run (status, counts, time range) so operators can diagnose degraded runs directly from Elasticsearch without grepping logs.

  • Constructor Details

    • ElasticsearchWatermarkStore

      public ElasticsearchWatermarkStore(org.opensearch.client.opensearch.OpenSearchClient openSearchClient, String indexName, int maxRetries, long retryDelayMs)
  • Method Details

    • ensureIndexExists

      public void ensureIndexExists() throws WatermarkAccessException
      Ensures the watermark index exists. Called once on startup. Retries with exponential backoff if Elasticsearch is unreachable.
      Throws:
      WatermarkAccessException - if the index cannot be created or verified after all retry attempts
    • read

      Reads the full watermark document from Elasticsearch.

      On success the response's _seq_no and _primary_term are captured.

      Returns:
      the watermark document, or empty if no watermark has been written yet
      Throws:
      WatermarkAccessException - if Elasticsearch is unreachable
    • write

      public void write(WatermarkDocument document) throws WatermarkConflictException
      Writes the watermark document after a reindexing cycle.

      Retries up to maxRetries times.

      If all retries fail, logs an error but does NOT throw — the next cycle will simply re-scan the same window (safe, because ES writes are idempotent upserts).

      Parameters:
      document - the fully populated watermark document to persist
      Throws:
      WatermarkConflictException - if another instance has concurrently updated the watermark (HTTP 409)