Skip to content

Extract DelegateRefresher to deduplicate JSON resource wrapper logic#1870

Merged
jnioche merged 3 commits intomainfrom
refactor/opensearch-json-resource-wrapper
Apr 7, 2026
Merged

Extract DelegateRefresher to deduplicate JSON resource wrapper logic#1870
jnioche merged 3 commits intomainfrom
refactor/opensearch-json-resource-wrapper

Conversation

@jnioche
Copy link
Copy Markdown
Contributor

@jnioche jnioche commented Apr 6, 2026

Summary

  • Extracts near-identical delegate loading, JSONResource validation, and periodic OpenSearch refresh logic from JSONURLFilterWrapper and JSONResourceWrapper into a new generic DelegateRefresher<T> class
  • Reduces each wrapper from ~180 lines to ~75 lines while preserving all existing behavior
  • Adds 8 unit tests for DelegateRefresher covering delegate loading for both URLFilter and ParseFilter, error cases (missing config, wrong base type, missing JSONResource), and idempotent cleanup

Test plan

  • mvn test -pl external/opensearch -Dtest=DelegateRefresherTest — all 8 new unit tests pass
  • mvn checkstyle:check -pl external/opensearch — 0 violations
  • mvn compile -pl external/opensearch -am — clean compile

🤖 Generated with Claude Code

jnioche and others added 2 commits April 6, 2026 18:25
JSONURLFilterWrapper and JSONResourceWrapper contained near-identical code
for loading a delegate class, validating it implements JSONResource, and
setting up a periodic refresh timer from OpenSearch. This extracts the
shared logic into a generic DelegateRefresher<T> class, reducing each
wrapper from ~180 lines to ~75 lines. Adds 8 unit tests for the new class.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Julien Nioche <julien@digitalpebble.com>
@jnioche jnioche added this to the 3.6.0 milestone Apr 6, 2026
Signed-off-by: Julien Nioche <julien@digitalpebble.com>
@jnioche jnioche merged commit 197f887 into main Apr 7, 2026
2 checks passed
@jnioche jnioche deleted the refactor/opensearch-json-resource-wrapper branch April 7, 2026 17:41
dpol1 added a commit to dpol1/stormcrawler that referenced this pull request Apr 10, 2026
This commit aligns the opensearch-java module with recent legacy updates,
completes the migration to HC5/API 3.x, and cleans up duplicated resources.

Refactors and Alignment:
- Ported DelegateRefresher for dynamic config reloading (apache#1870).
- Adopted Storm V2 metrics bridge via CrawlerMetrics (apache#1846).
- Aligned log messages and metric scopes to OpenSearch (apache#1871).
- Ported WaitAckCache extraction to centralize bulk-ack logic (apache#1869).
- Fixed a race condition in IndexerBolt by inverting the execution order,
  ensuring tuples are registered in waitAck before bulk dispatch.
- Refactored BulkItemResponseToFailedFlag to a Java record with a compact
  constructor for strict null-safety.

Maintenance and Cleanup:
- Removed duplicated archetype, dashboards, and opensearch-conf.yaml
  to prevent maintenance overhead.
- Updated README with a migration guide pointing to legacy resources.
- Removed dead rat-exclude in root pom.xml.
dpol1 added a commit to dpol1/stormcrawler that referenced this pull request Apr 10, 2026
This commit aligns the opensearch-java module with recent legacy updates,
completes the migration to HC5/API 3.x, and cleans up duplicated resources.

Refactors and Alignment:
- Ported DelegateRefresher for dynamic config reloading (apache#1870).
- Adopted Storm V2 metrics bridge via CrawlerMetrics (apache#1846).
- Aligned log messages and metric scopes to OpenSearch (apache#1871).
- Ported WaitAckCache extraction to centralize bulk-ack logic (apache#1869).
- Fixed a race condition in IndexerBolt by inverting the execution order,
  ensuring tuples are registered in waitAck before bulk dispatch.
- Refactored BulkItemResponseToFailedFlag to a Java record with a compact
  constructor for strict null-safety.

Maintenance and Cleanup:
- Removed duplicated archetype, dashboards, and opensearch-conf.yaml
  to prevent maintenance overhead.
- Updated README with a migration guide pointing to legacy resources.
- Removed dead rat-exclude in root pom.xml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants