Class ElasticsearchWatermarkStore
java.lang.Object
org.alfresco.elasticsearch.batchindexing.ElasticsearchWatermarkStore
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 Summary
ConstructorsConstructorDescriptionElasticsearchWatermarkStore(org.opensearch.client.opensearch.OpenSearchClient openSearchClient, String indexName, int maxRetries, long retryDelayMs) -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsures the watermark index exists.read()Reads the full watermark document from Elasticsearch.voidwrite(WatermarkDocument document) Writes the watermark document after a reindexing cycle.
-
Constructor Details
-
ElasticsearchWatermarkStore
public ElasticsearchWatermarkStore(org.opensearch.client.opensearch.OpenSearchClient openSearchClient, String indexName, int maxRetries, long retryDelayMs)
-
-
Method Details
-
ensureIndexExists
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_noand_primary_termare captured.- Returns:
- the watermark document, or empty if no watermark has been written yet
- Throws:
WatermarkAccessException- if Elasticsearch is unreachable
-
write
Writes the watermark document after a reindexing cycle.Retries up to
maxRetriestimes.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)
-