Package org.nuxeo.runtime.migration
Class MigrationServiceImpl
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.runtime.migration.MigrationServiceImpl
- All Implemented Interfaces:
MigrationService,Adaptable,Component,Extensible,TimestampedService
Implementation for the Migration Service.
Data about migration status is stored in the "migration" Key/Value Store in the following format:
mymigration:lock write lock, containing debug info about locker; set with a TTL mymigration the state of the migration, if not running mymigration:step the step of the migration, if running mymigration:starttime the migration step start time (milliseconds since epoch) mymigration:pingtime the migration step last ping time (milliseconds since epoch) mymigration:message the migration step current message mymigration:num the migration step current num mymigration:total the migration step current total
- Since:
- 9.3
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAmigratorwrapper to send invalidations to other nodes when callingMigrationServiceImpl.InvalidatorMigrator.notifyStatusChange().protected static classMigration context implementation that reports progress in the key/value store and can be shutdown.static classclassprotected static classThread pool executor that recordsRunnables to be able to request shutdown on them.protected static classRunnable for the migrator, that knows about the migration context.protected static classProgress reporter that reports progress in the key/value store.Nested classes/interfaces inherited from interface org.nuxeo.runtime.migration.MigrationService
MigrationService.MigrationContext, MigrationService.MigrationStatus, MigrationService.Migrator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Randomstatic final Stringstatic final Stringstatic final longstatic final StringFields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidatomic(String id, Consumer<KeyValueStore> consumer) Executes something while setting a lock, retrying a few times if the lock is already set.intThe component notification order forComponent.start(ComponentContext).protected static KeyValueStoregetMigration(String id) Gets a migration object.Gets all the migration objects.getMigrator(String id) Gets the current status for a migration.protected longparseLong(KeyValueStore kv, String key) voidprobeAndRun(String id) Probes the migration state and runs a migration.Probes the current state of a migration by analyzing persistent data, and sets it as the new current state.voidRestart the executor thread, only for testing purpose.voidRuns a migration step for a migration.protected voidprotected voidsetState(String id, String state, MigrationService.Migrator migrator, MigrationServiceImpl.ProgressReporter progressReporter) protected voidsetState(String id, String state, MigrationServiceImpl.ProgressReporter progressReporter, KeyValueStore kv) voidstart(ComponentContext context) Start the component.voidstop(ComponentContext context) Stop the component.Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtension
-
Field Details
-
KEYVALUE_STORE_NAME
- See Also:
-
XP_CONFIG
- See Also:
-
LOCK
- See Also:
-
STEP
- See Also:
-
START_TIME
- See Also:
-
PING_TIME
- See Also:
-
ERROR_MESSAGE
- See Also:
-
ERROR_CODE
- See Also:
-
PROGRESS_MESSAGE
- See Also:
-
PROGRESS_NUM
- See Also:
-
PROGRESS_TOTAL
- See Also:
-
WRITE_LOCK_TTL
public static final long WRITE_LOCK_TTL- See Also:
-
MIGRATION_INVAL_PUBSUB_TOPIC
- See Also:
-
RANDOM
-
executor
-
nodeId
-
invalidator
-
-
Constructor Details
-
MigrationServiceImpl
public MigrationServiceImpl()
-
-
Method Details
-
getKeyValueStore
-
getMigrationDescriptors
-
getApplicationStartedOrder
public int getApplicationStartedOrder()Description copied from interface:ComponentThe component notification order forComponent.start(ComponentContext).Components are notified in increasing order. Order 1000 is the default order for components that don't care. Order 100 is the repository initialization.
- Specified by:
getApplicationStartedOrderin interfaceComponent- Returns:
- the order, 1000 by default
-
start
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
stop
Description copied from interface:ComponentStop the component.- Specified by:
stopin interfaceComponent- Overrides:
stopin classDefaultComponent- Throws:
InterruptedException
-
getStatus
Description copied from interface:MigrationServiceGets the current status for a migration.- Specified by:
getStatusin interfaceMigrationService- Parameters:
id- the migration id- Returns:
- the status, or
nullif the migration is unknown
-
parseLong
-
probeAndSetState
Description copied from interface:MigrationServiceProbes the current state of a migration by analyzing persistent data, and sets it as the new current state.THIS METHOD MAY TAKE A WHILE as it needs to get information from persistent storage.
- Specified by:
probeAndSetStatein interfaceMigrationService- Parameters:
id- the migration id- Returns:
- the new state, or
nullif it cannot be determined
-
setState
protected void setState(String id, String state, MigrationService.Migrator migrator, MigrationServiceImpl.ProgressReporter progressReporter) -
setState
protected void setState(String id, String state, MigrationServiceImpl.ProgressReporter progressReporter, KeyValueStore kv) -
runStep
Description copied from interface:MigrationServiceRuns a migration step for a migration.This launches the migration asynchronously. The status of the migration can be checked with
MigrationService.getStatus(java.lang.String).- Specified by:
runStepin interfaceMigrationService- Parameters:
id- the migration idstep- the step id
-
runStep
-
getMigrator
-
atomic
Executes something while setting a lock, retrying a few times if the lock is already set. -
getMigration
Description copied from interface:MigrationServiceGets a migration object.- Specified by:
getMigrationin interfaceMigrationService- Parameters:
id- the migration id- Returns:
- the migration, or
nullif the migration is unknown
-
getMigrations
Description copied from interface:MigrationServiceGets all the migration objects.- Specified by:
getMigrationsin interfaceMigrationService- Returns:
- a list of all migrations
-
probeAndRun
Description copied from interface:MigrationServiceProbes the migration state and runs a migration.THIS METHOD MAY TAKE A WHILE as it may call
MigrationService.probeAndSetState(String).- Specified by:
probeAndRunin interfaceMigrationService- Parameters:
id- the migration id- Implementation Note:
- Runs a migration if it has exactly one available step to run.
-
restartExecutor
Restart the executor thread, only for testing purpose.- Throws:
InterruptedException- Since:
- 2023.5
-