Implement "Reset to Initial/New Config" API and Command Processing Mechanism for Provider
Title: #547 Implement "Reset to Initial/New Config" API and Command Processing Mechanism for Provider
Description:
In addition to implementing the reset configuration functionality for the Provider service, this task includes a mechanism for processing commands from the Transformer service using an Ignite-backed command queue. The Provider will persist its lastProcessedId
to ensure continuity after restarts and will process only the latest command of each type from a batch of unprocessed commands.
Requirements:
-
Reset Configuration API:
- Create
resetToConfig
method for the Provider service. - Provide API endpoint:
POST /admin/providerConfig/reset
. - Default behavior: reset to the initial configuration file used on the first start.
- Optional: allow the admin to provide a new configuration file that will replace the initial one.
- Validate the configuration before applying and ensure proper error handling.
- Log success and failure of the reset operation.
- Update Swagger to reflect this endpoint for the Provider service.
- Create
-
Command Processing Mechanism:
- Implement a command polling mechanism to read and process commands from the
ProviderCommandCache
. - Use Ignite cache to fetch new commands (e.g.,
LAYER_DEFINITION_CHANGED
,PROVIDER_CONFIG_CHANGED
). - Group unprocessed commands by type and process only the latest one of each type.
- Persist the
lastProcessedId
in the directory with other Provider configuration files (koop-config.json
directory). - Retrieve
lastProcessedId
from the file and update it after processing each command.
- Implement a command polling mechanism to read and process commands from the
-
Logging & Error Handling:
- Add proper logging for command processing and reset operations (both success and failure).
- Handle errors for invalid configurations and command processing failures.
-
Unit & Integration Tests:
- Write tests to verify reset behavior for both default and provided config file scenarios.
- Write tests to verify correct command processing and persistence of
lastProcessedId
.
Acceptance Criteria:
- The Provider service supports "reset to initial/new config" functionality.
- The
POST /admin/providerConfig/reset
endpoint is documented in Swagger. - The Provider successfully polls, processes commands, and persists
lastProcessedId
. - Tests verify both reset behavior and command processing.
Edited by Rostislav Dublin (EPAM)