Skip to content

Introduce Ranger ID V2 generation API in ranger-id (2.x) - #123

Merged
santanusinha merged 113 commits into
2.xfrom
issue-116-merge-idv2
Oct 15, 2026
Merged

santanusinha merged 113 commits into
2.xfrom
issue-116-merge-idv2

Conversation

@r0goyal

@r0goyal r0goyal commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Introduces the new Ranger ID V2 generation API in the ranger-id module for the 2.x release line. ID V2 was never merged into 1.x; this is a new feature/change designed for Ranger 2.x, superseding the design work explored in #109 (this is not a port or merge of another branch into 2.x).

The new API is exposed as io.appform.ranger.id.IdGeneratorV2 alongside the existing IdGenerator:

  • V2 generation API: IdGeneratorV2 with random nonce support, base36 handled via decorators (IdDecorators.base36()), and suffix support.
  • Strict parsing: IdParsersV2 requires full-input matches and validates the suffix grammar.
  • Immutability: V2 requests and decorator state are defensively immutable.
  • Node lifecycle: node ID 0 is a valid assigned node; node state is set via NodeUtils.setNode(...) with synchronized access and consistent cleanup.
  • Collision handling: retry/collision handling works on nanosecond timestamps.
  • V1 compatibility: the IdGenerator public surface is largely preserved, now backed by the V2 internals.
  • Bundle wiring: both discovery bundles (DW and DW5 variants of ServiceDiscoveryBundle) initialize and clean up both IdGenerator and IdGeneratorV2.

Breaking changes (explicit list)

  • IdGenerator.generate(IdGenerationRequest) removed; IdGenerationRequest is deprecated for removal.
  • IdFormatter interface changed: getType() removed; format(nodeId, IdGenerationInput) now returns FormattedId.
  • Domain no longer carries an idFormatter.
  • IdGenerator.initialize(int, List, Map) removed in favor of initialize(List, Map) + NodeUtils.setNode(...).
  • Base36IdFormatter, IdFormatters.base36(), IdParserType, and DefaultIdGenerator removed (replaced by decorators).
  • GenerationResult reshaped (now carries the internal ID pipeline).

Validation

  • Full reactor mvn install -DskipTests: BUILD SUCCESS
  • Full reactor mvn test: 185 tests, 0 failures, 0 errors
  • ranger-id: 65 tests green
  • ranger-discovery-bundle and ranger-discovery-dw5-bundle: 16/16 green each
  • CI green on the exact PR head; SonarCloud quality gate passed

Notes

  • This PR targets 2.x (a non-default branch). Closing keywords in this description do not auto-close issues; any related issue must be closed manually after merge.

r0goyal and others added 24 commits June 16, 2026 12:18
Keeps new V2 benchmark files; reverts version bump (1.1.3-ID-V2-RC1 → 1.1.4)
and any changes to existing IdGeneratorPerfTest to reduce diff noise in PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…V1 compat

base36() was dropped during id-v2 redesign but IdGeneratorPerfTest (from main)
references it. Re-implement against the new IdFormatter interface by wrapping
DefaultIdFormatter and base36-encoding its numeric output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
base36() was intentionally removed in id-v2. Keep id-v2 version of
IdGeneratorPerfTest rather than forcing compatibility with main's version.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- IdValidationConstraint: restore isValid(Id) as the abstract method
  (binary-compat break flagged in review); isValid(InternalId) is now
  a default bridging via toInternalId()/toId() helpers
- GenerationResult: document as internal-only (not public API contract)
- IdFormatter: add id() so IdGeneratorType.LOOKUP_MAP keys off a stable
  identifier instead of formatter object identity, which only worked
  for the cached IdFormatters singletons
- IdParsersV2: comment DEFAULT_PATTERN's two-step V1/V2 disambiguation
- NodeUtils: add reset(), called from IdGenerator/IdGeneratorV2
  cleanUp() so a stale node id isn't silently reused by a later
  initialize() that forgets to call setNode() again
- add missing Apache license headers on 9 files
- drop stale @SneakyThrows from perf benchmarks, unused import in
  IdParsersV2Test, deprecate unused IdGenerationRequest
- add IdGeneratorV2Test covering the (asymmetric) V2->legacy parse
  interop contract

Refs review comments on #109

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep V1 and V2 generators on the same process-level node while allowing idempotent startup calls. Reset remains the explicit lifecycle boundary.
Resolve equivalent formatter instances without adding an internal lookup identifier to the public IdFormatter contract.
fix(id): address Santanu's review feedback on #109
Keep the shared node reserved until all initialized generators stop.
Snapshot request lists so builder reuse cannot change encoded formats.
Reject partial IDs and invalid suffixes; join test workers before cleanup.

V2 requests no longer expose setConstraints; use the builder instead.
NodeUtils.reset rejects resets while a generator remains initialized.
Merges origin/id-v2 (e529804) into origin/2.x with semantic conflict
resolution:

- V2 API ported into io.appform.ranger.id: IdGeneratorV2,
  IdGenerationRequestV2/InternalRequest, IdGeneratorType, decorators
  (Base36IdDecorator replaces Base36IdFormatter), IdParsersV2,
  FormattedId/InternalId pipeline, NonceUtils/NonceGenerators.
- 2.x preserved: module layout, 2.0.0-RC6 versions, nanosecond
  collision-checker fixes, discovery-core structure, dw5 variants.
- V1 IdGenerator public surface kept, backed by V2 internals.
- Lifecycle: NodeUtils (single home in ranger-id) + NodeIdManager;
  ServiceDiscoveryBundle (dw + dw5) initializes both generators.
- Removed legacy: Base36IdFormatter, DefaultIdGenerator, IdParserType.

Validation: full reactor build green; 185 tests, 0 failures across
all modules including ranger-id (65) and both discovery bundle
variants (16/16).
@r0goyal r0goyal changed the title Merge ID V2 into 2.x: integrate V2 ID generation API into ranger-id Introduce Ranger ID V2 generation API in ranger-id (2.x) Oct 14, 2026
@r0goyal
r0goyal requested a review from santanusinha October 15, 2026 09:13
Bump project version 2.0.0-RC6 -> 2.0.0-RC7 across all 24 reactor POMs
(root, ranger-parent, ranger-bom, and module parent references).
Full reactor 'mvn install -DskipTests' passes.
@sonarqubecloud

Copy link
Copy Markdown

@santanusinha
santanusinha merged commit 4e152ab into 2.x Oct 15, 2026
3 checks passed
@santanusinha
santanusinha deleted the issue-116-merge-idv2 branch October 15, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants