Class BrowserIdentifierMigrationService

java.lang.Object
sk.iway.iwcm.stat.rest.BrowserIdentifierMigrationService
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean

@Service public class BrowserIdentifierMigrationService extends Object implements org.springframework.beans.factory.DisposableBean
Migrates versioned browser identifiers to canonical browser-family identifiers.

The migration runs on a single background worker, commits changes in bounded batches, and exposes a synchronized progress snapshot so an administrator can pause, resume, and monitor it. Finalization is a separate explicit step that merges browser counters, removes obsolete identifiers, creates the uniqueness constraint, and refreshes statistics caches across the cluster.

  • Field Details

  • Constructor Details

    • BrowserIdentifierMigrationService

      public BrowserIdentifierMigrationService()
      Creates the production service with one dedicated daemon worker thread.
  • Method Details

    • preview

      Analyzes the current database without creating identifiers or modifying statistics.
      Returns:
      actionable mappings, keys retained only for non-browser dimensions, statistics tables, and whether the unique bot-name index already exists
      Throws:
      SQLException - if identifiers or table metadata cannot be read
    • getStatus

      Returns the latest detached progress snapshot.

      A newly created service also restores the completed flag from the persistent update marker before returning the snapshot.

      Returns:
      a copy of the current migration state
    • start

      Starts or resumes migration on the background worker.

      The request is ignored when a task is already running or the persistent migration marker reports completion. A paused migration reuses its prepared plan and cursor.

      Returns:
      the state immediately after the start request
    • stop

      Requests a cooperative pause after the currently executing database batch finishes.
      Returns:
      the state containing the stop-request flag when migration is active
    • finalizeCompletedMigration

      public BrowserIdentifierMigrationService.State finalizeCompletedMigration() throws SQLException
      Starts asynchronous cleanup after all statistics references have been migrated.
      Returns:
      the state immediately after the finalization request
      Throws:
      SQLException - if the migration has not been marked as completed
    • isAllreadyUpdated

      public static boolean isAllreadyUpdated()
    • destroy

      public void destroy()
      Stops the worker and interrupts any active background migration during bean destruction.
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean