E52D task(IndexAPI) Migrate IndexAPI to OpenSearch Part2 Refs #34728 by fabrizzio-dotCMS · Pull Request #34916 · dotCMS/core · GitHub
[go: up one dir, main page]

Skip to content

task(IndexAPI) Migrate IndexAPI to OpenSearch Part2 Refs #34728#34916

Open
fabrizzio-dotCMS wants to merge 17 commits intomainfrom
issue-34728-IndexRoutig
Open

task(IndexAPI) Migrate IndexAPI to OpenSearch Part2 Refs #34728#34916
fabrizzio-dotCMS wants to merge 17 commits intomainfrom
issue-34728-IndexRoutig

Conversation

@fabrizzio-dotCMS
Copy link
Contributor
@fabrizzio-dotCMS fabrizzio-dotCMS commented Mar 9, 2026

Summary

Replaces the two binary feature flags (FEATURE_FLAG_OPEN_SEARCH_WRITE / FEATURE_FLAG_OPEN_SEARCH_READ) with a single integer phase flag (FEATURE_FLAG_OPEN_SEARCH_PHASE, ordinal 0–3) that models the full ES → OpenSearch migration lifecycle. Implements the real routing logic in IndexAPIImpl and ESContentFactoryImpl so read/write operations are dispatched to the correct backend based on the active phase, with ES remaining authoritative until phase 3.

Changes

Config & Feature Flags

  • Replaced two boolean flags with FEATURE_FLAG_OPEN_SEARCH_PHASE (int 0–3)
  • Added IndexConfigHelper — central phase-decision helper exposing isMigrationNotStarted(), isDualWrite(), isReadEnabled(), isMigrationComplete()
  • Added OSIndexProperty enum — single source of truth for OS config keys with automatic ES fallback resolution

Routing

  • IndexAPIImpl: implemented full phase-aware routing — reads go to OS at phase 2+, writes dual-write at phases 1–2, OS-only at phase 3
  • ESContentFactoryImpl: content search operations (indexSearch, indexCount, indexSearchScroll, createScrollQuery, findContentletsByHost) now routed through indexOperationsDelegate() based on active phase

Annotation cleanup

  • Renamed @IndexMetadata@IndexRouter; removed IndexEngine enum and currentlySupports() attribute (replaced by phase-based routing)

Structural cleanup

  • removeClusterIdFromName promoted to default method on IndexAPI interface; removed from ESIndexAPI
  • IndexSourceHelper deleted
  • ContentletIndexAPIImpl: de-static'd queueApi/esIndexApi fields; made objectMapper final

Tests

  • Added MigrationPhaseTest — covers all four phases, boundary conditions (missing flag, out-of-range ordinals), and static helpers on IndexConfigHelper
  • Added to OpenSearchUpgradeSuite

Testing

  1. Set FEATURE_FLAG_OPEN_SEARCH_PHASE=0 → all traffic goes to ES (default behavior, no regression)
  2. Set FEATURE_FLAG_OPEN_SEARCH_PHASE=1 → writes go to both ES and OS; reads still from ES
  3. Set FEATURE_FLAG_OPEN_SEARCH_PHASE=2 → writes go to both; reads from OS
  4. Set FEATURE_FLAG_OPEN_SEARCH_PHASE=3 → all traffic to OS only
  5. Run MigrationPhaseTest via ./mvnw verify -pl :dotcms-integration -Dcoreit.test.skip=false -Dit.test=MigrationPhaseTest

@github-actions github-actions bot added the Area : Backend PR changes Java/Maven backend code label Mar 9, 2026
@fabrizzio-dotCMS fabrizzio-dotCMS marked this pull request as ready for review March 10, 2026 15:18
@nollymar
Copy link
Contributor

@claude review this PR

@fabrizzio-dotCMS fabrizzio-dotCMS linked an issue Mar 11, 2026 that may be closed by this pull request
@fabrizzio-dotCMS fabrizzio-dotCMS changed the title task(Migrate Core infra clases, Part 2) Refs #34728 task(IndexAPI) Migrate IndexAPI to OpenSearch Part2 Refs #34728 Mar 11, 2026
public class VersionedIndicesAPIImpl implements VersionedIndicesAPI {

private static final SimpleDateFormat TIMESTAMP_FORMATTER = new SimpleDateFormat("yyyyMMddHHmmss");
final SimpleDateFormat timestampFormatter = new SimpleDateFormat("yyyyMMddHHmmss");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SimpleDateFormat is not thread safe in use. This is a single bean that could be called by separate threads. Use DateTimeFormatter.ofPattern("yyyyMMddHHmmss") instead.

"OpenSearch Connection Attempt #" + (i + 1) + ": " + e.getMessage());
}
DateUtil.sleep(Config.getIntProperty("OS_CONNECTION_TIMEOUT", 5) * 1000);
DateUtil.sleep(IndexConfigHelper.getInt(OSIndexProperty.CONNECTION_TIMEOUT, 5) * 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OSIndexProperty.CONNECTION_TIMEOUT has conflicting semantics. In the provider it means "HTTP timeout in ms" (default 10000). In waitUtilIndexReady() it means "retry sleep in seconds" (default 5, multiplied by ×1000). If someone sets OS_CONNECTION_TIMEOUT=30000, the retry loop sleeps 8.3 hours.
Fix: Create a separate CONNECTION_RETRY_SLEEP_SECONDS property.

* on the active feature flags:</p>
* <ul>
* <li><strong>Read operations</strong> — routed to {@link OSIndexAPIImpl} when
* {@code FEATURE_FLAG_OPEN_SEARCH_READ} is enabled, otherwise to {@link ESIndexAPI}.</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure Javadoc is updated with changes. Let claude verify the changes are in sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[TASK] Migrate ESIndexAPI To OS

3 participants

0