Package sk.iway.iwcm.stat.rest
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSummarizes how many obsolete statistics keys were deleted or retained during finalization.static classDescribes one source identifier that must be replaced by its canonical target.static classContains the read-only analysis shown before an administrator starts the migration.static classMutable migration progress transferred through the REST API as a detached snapshot. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates the production service with one dedicated daemon worker thread. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Stops the worker and interrupts any active background migration during bean destruction.Starts asynchronous cleanup after all statistics references have been migrated.Returns the latest detached progress snapshot.static booleanpreview()Analyzes the current database without creating identifiers or modifying statistics.start()Starts or resumes migration on the background worker.stop()Requests a cooperative pause after the currently executing database batch finishes.
-
Field Details
-
UPDATE_NOTE
- See Also:
-
-
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
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:
destroyin interfaceorg.springframework.beans.factory.DisposableBean
-