Repository navigation
Conversation
93c9a7d to
3c82c2e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Reporter exceptions can mark valid datasets as failed and prevent normal completion.
1 open issue
What changed in this PR
Adds unique resource ID reporting to the service layer for usage metering.
Changes:
- Adds resource collection and reporting APIs.
- Reports resources after worker output computation.
- Adds event definitions and tests for resource collection behavior.
| File | Description |
|---|---|
| service/worker/src/main/java/ai/timefold/solver/service/worker/impl/SolverWorker.java | Reports resources after computation. |
| service/definition/src/test/java/ai/timefold/solver/service/definition/api/usage/UniqueResourcesTest.java | Tests deduplication, immutability, builders and JSON. |
| service/definition/src/main/java/ai/timefold/solver/service/definition/internal/events/UniqueResourceReportEvent.java | Adds the resource reporting event. |
| service/definition/src/main/java/ai/timefold/solver/service/definition/internal/events/SolverChannels.java | Defines the reporting channel. |
| service/definition/src/main/java/ai/timefold/solver/service/definition/internal/events/AbstractEvent.java | Permits the new event type. |
| service/definition/src/main/java/ai/timefold/solver/service/definition/api/usage/UniqueResources.java | Stores immutable, deduplicated resource IDs. |
| service/definition/src/main/java/ai/timefold/solver/service/definition/api/usage/UniqueResourceReporter.java | Defines reporting methods. |
| service/definition/src/main/java/ai/timefold/solver/service/definition/api/usage/UniqueResourceAware.java | Lets models expose their resources. |
Review effort: Balanced
| } | ||
|
|
||
| if (uniqueResources != null) { | ||
| uniqueResourceReporter.reportUniqueResources(OperationId.SCHEDULE, datasetId, uniqueResources); |
| extractOutputMetrics(solverModel)); | ||
|
|
||
| // We report the unique resources once we compute the outputs of the valid dataset. | ||
| reportUniqueResources(id, solverModel); |
|
This pull request, as it stands, would leave the Solver documentation stale in the place below. An automated check found this and can be wrong.
The documentation fix belongs in this pull request. A new commit on the branch updates this comment, and drift that is still there when the group merges gets a docs pull request against
|
| /** | ||
| * Contains IDs of unique resources identified by the optimization model. | ||
| */ | ||
| public record UniqueResources(Map<String, Collection<String>> uniqueResourceIdsPerType) { |
There was a problem hiding this comment.
just a thought, would it be easier to have UniqueResources(String type, Collection<String> uniqueResourceIds) and then we could have collection of it? Bit better from type perspective - having map by unknown keys might bite us soon.
In addition, since the issue says there should be one billable at the moment - how do we know that? will this come from here or?
| storageService.storeSolution(id, modelOutput, metadata, extractInputMetrics(solverModel), | ||
| extractOutputMetrics(solverModel)); | ||
|
|
||
| // We report the unique resources once we compute the outputs of the valid dataset. |
There was a problem hiding this comment.
the document says we should only do this on successful runs - what would it do when compute is fine and then the solving fails?
|
Closing in favor of #2779 |


Fixes https://github.com/TimefoldAI/timefold-solver-enterprise/issues/930.
The PR covers resource reporting for standard operations.
Also model-specific operations are covered by exposing the
UniqueResourceReporterbean to send the data.Related:
https://github.com/TimefoldAI/timefold-solver-enterprise/pull/948