Skip to content

Commit

Permalink
Add java doc for OpenSearchUpdater class
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chu <[email protected]>
  • Loading branch information
noCharger committed Feb 19, 2024
1 parent f73ebcd commit efda5f2
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
import static org.opensearch.flint.core.metrics.MetricConstants.REQUEST_METADATA_READ_METRIC_PREFIX;
import static org.opensearch.flint.core.metrics.MetricConstants.REQUEST_METADATA_WRITE_METRIC_PREFIX;

/**
* Provides functionality for updating and upserting documents in an OpenSearch index.
* This class utilizes FlintClient for managing connections to OpenSearch and performs
* document updates and upserts with optional optimistic concurrency control.
*/
public class OpenSearchUpdater {
private static final Logger LOG = Logger.getLogger(OpenSearchUpdater.class.getName());

Expand All @@ -38,6 +43,15 @@ public void updateIf(String id, String doc, long seqNo, long primaryTerm) {
updateDocument(id, doc, false, seqNo, primaryTerm);
}

/**
* Internal method for updating or upserting a document with optional optimistic concurrency control.
*
* @param id The document ID.
* @param doc The document content in JSON format.
* @param upsert Flag indicating whether to upsert the document.
* @param seqNo The sequence number for optimistic concurrency control.
* @param primaryTerm The primary term for optimistic concurrency control.
*/
private void updateDocument(String id, String doc, boolean upsert, long seqNo, long primaryTerm) {
// we might need to keep the updater for a long time. Reusing the client may not work as the temporary
// credentials may expire.
Expand Down

0 comments on commit efda5f2

Please sign in to comment.