Skip to content

[#14205] feat(tms): Before/after metrics and finish REST for in-job actions - #14121

Open
lasdf1234 wants to merge 16 commits into
apache:branch-tms-schedulerfrom
lasdf1234:feature/tms-a2-rest-sample-finish
Open

lasdf1234 wants to merge 16 commits into
apache:branch-tms-schedulerfrom
lasdf1234:feature/tms-a2-rest-sample-finish

Conversation

@lasdf1234

@lasdf1234 lasdf1234 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

What changes were proposed in this pull request?

Second slice of the in-job track (A2). Stacked on A1 (#14054); targets branch-tms-scheduler.

  • REST callbacks for in-job Spark: metrics/before, metrics/after, and finish (TableMaintenanceActionOperations)
  • MaintenanceMetricsService, binder, and REST utils (aligned with idp-basic style)
  • Shared request DTOs in new module :maintenance:maintenance-common
  • OpenAPI under docs/open-api/maintenance/
  • One Spark job may bind multiple tables / soft slots; callbacks key by (jobId, tableId, policyId)
  • Lazy-bind when a Spark callback arrives before submit-side bindJobId
  • Resolve metalake from the table id via TableMetaService.getMetalakeNameByTableId

Why are the changes needed?

In-job Spark jobs need HTTP hooks to record before/after snapshot metrics and to release soft occupancy per table (with or without metrics). Wire DTOs belong in a thin shared *-common module so the TMS plugin and built-in jobs can share them without coupling through client-java.

Fix: #14205

Part of #13760. Depends on #14054.

Does this PR introduce any user-facing change?

Yes — maintenance action metrics/finish REST (plugin OpenAPI):

  • POST /metalakes/{metalake}/maintenance/actions/{jobId}/metrics/before
  • POST /metalakes/{metalake}/maintenance/actions/{jobId}/metrics/after
  • POST /metalakes/{metalake}/maintenance/actions/{jobId}/finish

How was this patch tested?

./gradlew :maintenance:maintenance-common:compileJava :plugins:tms:compileJava :plugins:tms:compileTestJava -PskipITs

./gradlew :plugins:tms:test -PskipITs -PskipDockerTests=true --tests org.apache.gravitino.maintenance.web.rest.TestTableMaintenanceActionOperations

lasdf1234 and others added 16 commits October 23, 2026 20:46
Expose metalake maintenance action sample and finish endpoints with OpenAPI,
wired through the in-job pipeline and recommenders.

Co-authored-by: Cursor <cursoragent@cursor.com>
…basic

Keep sample/finish DTOs, HK2 binding, and error mapping inside the TMS plugin, and publish the callback OpenAPI as its own spec.

Co-authored-by: Cursor <cursoragent@cursor.com>
…cyMetaService

Drop MetalakeNames after A1 removed it. Sample/finish checks the path metalake against the action policy.

Co-authored-by: Cursor <cursoragent@cursor.com>
…e id

Match OccupancyGate: look up metalake via TableMetaService, not the current policy. Policy deletion must not make a live action look like it belongs to no metalake.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ntenance-api

Share TMS callback DTOs via :maintenance:maintenance-api so the plugin and
built-in jobs can depend on one module without coupling through client-java.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…ommon

Wire DTOs are shared implementation types, not an SPI surface; align the
module name with Gravitino's *-common convention.

Co-authored-by: Cursor <cursoragent@cursor.com>
…napi.yaml

Subdirectory specs must use ../openapi.yaml for shared components;
./openapi.yaml unresolved refs failed :docs:lintMaintenanceOpenAPI.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop tableId/policyId from the sample request body; the server already
has them on the in-flight action bound to jobId.

Co-authored-by: Cursor <cursoragent@cursor.com>
…rt API

Spark decides continue/stop locally; occupancy reclaims on job terminal
state. The only Spark-facing callback persists snapshot metrics.

Co-authored-by: Cursor <cursoragent@cursor.com>
…tables

Drop UNIQUE(job_id), key metrics/before-snapshot by tableId, and finish all
action rows for a job together so a single Spark run can cover a table batch.

Co-authored-by: Cursor <cursoragent@cursor.com>
…able

Expose metrics/before and metrics/after with optional finish to close the
soft slot by (jobId, tableId, policyId). Drop job-terminal occupancy reclaim.

Co-authored-by: Cursor <cursoragent@cursor.com>
…metrics

Jobs that do not sample can POST .../actions/{jobId}/finish with tableId
(and optional afterSnapshotId) to release occupancy per table/policy.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ubmit bind

Callbacks that arrive before bindJobId CAS the sole unbound claim for the
table onto the path jobId; submit-side bind is idempotent for the same id.
Also moves metrics finish to a query param and drops MaintenanceActionOperation.

Co-authored-by: Cursor <cursoragent@cursor.com>
One Spark job can bind multiple soft slots on the same table; require
policyId on callback DTOs and look up/bind/record by (jobId, tableId,
policyId) so metrics and finish attribute to the correct action row.

Co-authored-by: Cursor <cursoragent@cursor.com>
@lasdf1234
lasdf1234 force-pushed the feature/tms-a2-rest-sample-finish branch from 65b8672 to ecf7487 Compare October 23, 2026 12:48
@github-actions

Copy link
Copy Markdown

Code Coverage Report

Overall Project 71.75% +0.02% 🟢
Files changed 76.59% 🟢

Module Coverage
aliyun 19.74% 🔴
api 54.37% 🟢
authorization-common 85.96% 🟢
authorization-ranger 14.44% 🔴
aws 53.54% 🟢
aws-bundle 0.0% 🔴
azure 32.1% 🔴
azure-bundle 0.0% 🔴
catalog-common 29.49% 🔴
catalog-fileset 82.37% 🟢
catalog-glue 73.24% 🟢
catalog-hive 83.63% 🟢
catalog-jdbc-common 57.98% 🟢
catalog-jdbc-doris 87.56% 🟢
catalog-jdbc-mysql 81.91% 🟢
catalog-jdbc-postgresql 84.02% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 75.21% 🟢
catalog-lakehouse-generic 84.58% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.93% 🟢
catalog-lakehouse-paimon 84.36% 🟢
catalog-model 77.99% 🟢
cli 44.62% 🟢
client-java 79.34% 🟢
client-java-runtime 0.0% 🔴
common 60.24% 🟢
core 87.5% 🟢
filesystem-hadoop3 76.89% 🟢
flink 55.44% 🟢
flink-common 32.2% 🔴
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 62.3% 🟢
hive-metastore3-libs 58.8% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 66.53% 🟢
iceberg-rest-server 77.08% 🟢
idp-basic 86.77% 🟢
integration-test-common 0.0% 🔴
jobs 71.35% 🟢
k8s-job-executor 99.81% 🟢
lance-common 39.9% 🔴
lance-rest-server 69.51% 🟢
lineage 59.39% 🟢
optimizer 83.95% 🟢
optimizer-api 40.6% 🟢
server 91.43% 🟢
server-common 83.85% 🟢
spark 61.79% 🟢
tencent 81.78% 🟢
tms 77.29% -0.54% 🟢
trino-connector 63.31% 🟢
Files
Module File Coverage
tms TableMaintenanceActionOperations.java 100.0% 🟢
TableMaintenanceActionSQLProviderFactory.java 92.59% 🟢
TableMaintenanceActionBaseSQLProvider.java 91.3% 🟢
MaintenanceMetricsService.java 89.74% 🟢
TableMaintenanceActionMetaService.java 87.5% 🟢
OccupancyGate.java 86.96% 🟢
TableMaintenanceInJobSampler.java 80.95% 🟢
TableMaintenanceRESTUtils.java 60.87% 🟢
TableMaintenanceRESTFeature.java 23.81% 🔴
TableMaintenanceActionMapper.java 0.0% 🔴
TableMaintenanceBinder.java 0.0% 🔴

@lasdf1234 lasdf1234 changed the title [#13760] feat(tms): REST sample/finish for maintenance actions [#13760] feat(tms): Before/after metrics and finish REST for in-job actions Oct 24, 2026
@lasdf1234 lasdf1234 changed the title [#13760] feat(tms): Before/after metrics and finish REST for in-job actions [#14205] feat(tms): Before/after metrics and finish REST for in-job actions Oct 24, 2026
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