Skip to content

feat(optimizer): [2/N] Optimizer REST service layer#531

Open
mkuchenbecker wants to merge 6 commits intomkuchenb/optimizer-1from
mkuchenb/optimizer-2
Open

feat(optimizer): [2/N] Optimizer REST service layer#531
mkuchenbecker wants to merge 6 commits intomkuchenb/optimizer-1from
mkuchenb/optimizer-2

Conversation

@mkuchenbecker
Copy link
Copy Markdown
Collaborator

@mkuchenbecker mkuchenbecker commented Apr 6, 2026

Optimizer Stack

PR Content
#527 Data Model
#530 Database Repos
#531 (this) REST service
#533 Analyzer app
#534 Scheduler app
#tbd Spark BatchedOFD app
#tbd Infra, docker-compose, smoke test

Summary

PR 2 of N in the optimizer stack.
Overall Project
Service Design doc.

Service layer and REST controllers for the optimizer service, plus the apps/optimizer shared module providing lightweight entity/repo copies for the analyzer and scheduler apps.

Changes

  • Client-facing API Changes
  • Internal API Changes
  • Bug Fixes
  • New Features
  • Performance Improvements
  • Code Style
  • Refactoring
  • Documentation
  • Tests

Service layer: OptimizerDataService interface and OptimizerDataServiceImpl — CRUD operations, complete-operation lifecycle, stats upsert with history double-write, filtered queries.

Controllers: TableOperationsController, TableOperationsHistoryController, TableStatsController — REST endpoints per the design doc API spec.

Shared module (apps/optimizer): Lightweight entity and repository copies used by the analyzer and scheduler apps to read optimizer state directly from MySQL.

Testing Done

  • Manually Tested on local docker setup. Please include commands ran, and their output.
  • Added new tests for the changes made.
  • Updated existing tests to reflect the changes made.
  • No tests added or updated. Please explain why. If unsure, please feel free to ask for help.
  • Some other form of testing like staging or soak time in production. Please explain.

H2 integration tests in OptimizerDataServiceImplTest (5 tests):

  • completeOperation_writesHistoryFromOperationRow — saves SCHEDULED row, completes it, asserts history DTO fields
  • completeOperation_notFound_returnsEmpty — completes nonexistent ID, asserts empty
  • upsertTableStats_createsNewRow — upserts new table, asserts DTO and repo row
  • upsertTableStats_updatesExistingRow — upserts twice, asserts overwrite with single row
  • upsertTableStats_appendsHistoryOnEveryCall — upserts twice, asserts 2 history rows
./gradlew :services:optimizer:test
# BUILD SUCCESSFUL — all 25 tests pass (repo tests from PR 1 + 5 new service tests)

Additional Information

  • Breaking Changes
  • Deprecations
  • Large PR broken into smaller PRs, and PR plan linked in the description.

mkuchenbecker and others added 2 commits April 6, 2026 11:36
Service interface and implementation for all optimizer CRUD operations
including complete-operation lifecycle, stats upsert with history
double-write, and filtered queries. Three REST controllers expose the
endpoints. The apps/optimizer shared module provides lightweight
entity/repo copies for the analyzer and scheduler apps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Align OptimizerDataServiceImpl with renamed repository methods from
optimizer-1 review feedback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mkuchenbecker mkuchenbecker force-pushed the mkuchenb/optimizer-2 branch from e628426 to ef3260f Compare April 6, 2026 18:37
Resolve repo conflicts by taking optimizer-1's clean find-only versions.
Scheduler-specific methods and streamAll removed per review feedback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator Author

@mkuchenbecker mkuchenbecker left a comment

Choose a reason for hiding this comment

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

this needs tests

Propagate CompleteOperationRequest orphan field removal.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mkuchenbecker mkuchenbecker changed the title feat(optimizer): add REST service layer, controllers, and shared module feat(optimizer): add REST service layer Apr 6, 2026
@mkuchenbecker mkuchenbecker changed the title feat(optimizer): add REST service layer feat(optimizer): [3/N] Optimizer REST service layer Apr 6, 2026
H2 integration tests for OptimizerDataServiceImpl covering
completeOperation (write history, not-found) and upsertTableStats
(create, update, history append).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TableStatsDto dto = service.upsertTableStats(tableUuid, second);

assertThat(dto.getStats().getSnapshot().getTableSizeBytes()).isEqualTo(200L);
assertThat(statsRepository.findAll()).hasSize(1);
Copy link
Copy Markdown
Collaborator Author

@mkuchenbecker mkuchenbecker Apr 6, 2026

Choose a reason for hiding this comment

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

what about stats history? every call should update the history and do an upsert. The history is the raw delta.

Strengthen upsertTableStats test to verify history rows contain the raw
delta stats from each call, not just the row count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mkuchenbecker mkuchenbecker marked this pull request as ready for review April 6, 2026 19:46
@mkuchenbecker mkuchenbecker changed the title feat(optimizer): [3/N] Optimizer REST service layer feat(optimizer): [2/N] Optimizer REST service layer Apr 6, 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