Implement "Reset to Initial/New Config" API and Command Processing Mechanism for Provider

Title: #547 (closed) 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:

  1. 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.
  2. 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.
  3. 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.
  4. 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 Sep 13, 2024 by Rostislav Dublin (EPAM)
Assignee Loading
Time tracking Loading