Skip to content

feat(server): add embedded REST Gremlin execution - #3388

Draft
contrueCT wants to merge 1 commit into
apache:masterfrom
hugegraph:task/gremlin-embedded-rest
Draft

contrueCT wants to merge 1 commit into
apache:masterfrom
hugegraph:task/gremlin-embedded-rest

Conversation

@contrueCT

Copy link
Copy Markdown
Contributor

Purpose of the PR

Add opt-in in-process execution for REST /gremlin to remove its internal HTTP forwarding hop. gremlinserver.rest_execution_mode defaults to forward; embedded uses this Server's existing Gremlin runtime.

Builds on the merged Java 17 (#3261) and TinkerPop 3.8.1 (#3263) upgrades. Design and investigation.

Main Changes

forward:  REST -> GremlinClient -> HTTP -> GremlinExecutor
embedded: REST ------------------------> GremlinExecutor
                                         materialize / commit / serialize
  • Reuse the live graph manager, workers and JSON serializer, with authentication context and transaction callbacks on the worker.
  • Preserve request/error handling, blocking admission and REST/evaluation timeout behavior; validate supported local topology and wire startup/shutdown.
  • Add differential contract tests and reproducible HTTP/RocksDB comparison scripts.

Readiness, new overload controls, authentication-cache consistency and global shutdown redesign remain separate tasks.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests.
  • Need tests and can be verified as follows:
    • Java 17: formatting, full clean compile and Apache RAT checks passed.
    • 47 focused tests passed, covering REST/Gremlin contracts, authentication context, Memory/RocksDB transactions and bootstrap.
    • Standalone RocksDB: 76 measurement groups / 316,981 responses validated, including commit/rollback/restart checks; 80,200 successful writes reconciled with stored counts.

Draft follow-up: at concurrency 32 with 1,000-result responses, the extended comparison's p95 medians were 77.94 -> 68.50 ms, while p99 medians were 90.71 -> 109.59 ms (forward -> embedded). Investigate the tail behavior at matched offered load; these were closed-loop runs on a shared host. HStore, full TinkerPop suites and real authentication-store integration remain unverified.

Does this PR potentially affect the following parts?

  • Dependencies
  • Modify configurations
  • The public API
  • Other affects (Server startup/shutdown integration)
  • Nope

Documentation Status

  • Doc - TODO: required documentation is pending; complete it before merging.
  • Doc - Done: documentation is included here or linked below.
  • Doc - No Need: no user-visible documentation is affected.

Documentation: REST Gremlin execution modes, linked from the Server README and shipped configuration.

- Add selectable forward and embedded REST executors with forward as default.
- Reuse the existing Gremlin workers, serializer, auth context and transactions.
- Integrate executor startup, shutdown and supported-topology validation.
- Add differential contract tests, usage docs and reproducible benchmarks.
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.41379% with 254 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.90%. Comparing base (c2ec570) to head (d1239ef).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
...graph/api/gremlin/EmbeddedGremlinRestExecutor.java 0.00% 188 Missing ⚠️
...egraph/api/gremlin/GremlinRestExecutorFactory.java 5.88% 30 Missing and 2 partials ⚠️
...egraph/api/gremlin/ForwardGremlinRestExecutor.java 61.11% 6 Missing and 1 partial ⚠️
.../apache/hugegraph/api/gremlin/GremlinQueryAPI.java 12.50% 6 Missing and 1 partial ⚠️
...n/java/org/apache/hugegraph/server/RestServer.java 44.44% 4 Missing and 1 partial ⚠️
...ava/org/apache/hugegraph/dist/HugeGraphServer.java 50.00% 5 Missing ⚠️
...org/apache/hugegraph/server/ApplicationConfig.java 63.63% 3 Missing and 1 partial ⚠️
...ugegraph/server/HugeGraphWsAndHttpChannelizer.java 0.00% 4 Missing ⚠️
...a/org/apache/hugegraph/api/gremlin/GremlinAPI.java 80.00% 0 Missing and 1 partial ⚠️
...che/hugegraph/api/gremlin/GremlinRestExecutor.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3388      +/-   ##
============================================
- Coverage     55.93%   55.90%   -0.03%     
- Complexity     2277     6784    +4507     
============================================
  Files           774      779       +5     
  Lines         68534    69114     +580     
  Branches       9333     9468     +135     
============================================
+ Hits          38334    38641     +307     
- Misses        26634    26893     +259     
- Partials       3566     3580      +14     
Flag Coverage Δ *Carryforward flag
commons 96.37% <ø> (ø) Carriedforward from c2ec570
hstore 35.81% <ø> (+<0.01%) ⬆️ Carriedforward from c2ec570
pd 49.15% <ø> (-0.03%) ⬇️ Carriedforward from c2ec570
server_hbase 41.83% <ø> (-0.07%) ⬇️ Carriedforward from c2ec570
server_memory 54.29% <ø> (-0.05%) ⬇️ Carriedforward from c2ec570
server_rocksdb 42.58% <12.41%> (+0.23%) ⬆️
store 31.93% <ø> (ø) Carriedforward from c2ec570

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant