public class MigrationServiceImpl extends DefaultComponent implements MigrationService
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
Modifier and Type | Class and Description |
---|---|
static class |
MigrationServiceImpl.InvalidatorMigrator
A
migrator wrapper to send invalidations to other nodes when calling
MigrationServiceImpl.InvalidatorMigrator.notifyStatusChange() . |
protected static class |
MigrationServiceImpl.MigrationContextImpl
Migration context implementation that reports progress in the key/value store and can be shutdown.
|
static class |
MigrationServiceImpl.MigrationInvalidation |
class |
MigrationServiceImpl.MigrationInvalidator |
protected static class |
MigrationServiceImpl.MigrationThreadPoolExecutor
Thread pool executor that records
Runnable s to be able to request shutdown on them. |
protected static class |
MigrationServiceImpl.MigratorWithContext
Runnable for the migrator, that knows about the migration context.
|
protected static class |
MigrationServiceImpl.ProgressReporter
Progress reporter that reports progress in the key/value store.
|
MigrationService.MigrationContext, MigrationService.MigrationStatus, MigrationService.Migrator
Modifier and Type | Field and Description |
---|---|
static String |
CLUSTERING_ENABLED_PROP |
protected MigrationServiceImpl.MigrationThreadPoolExecutor |
executor |
protected MigrationServiceImpl.MigrationInvalidator |
invalidator |
static String |
KEYVALUE_STORE_NAME |
static String |
LOCK |
static String |
MIGRATION_INVAL_PUBSUB_TOPIC |
static String |
NODE_ID_PROP |
static String |
PING_TIME |
static String |
PROGRESS_MESSAGE |
static String |
PROGRESS_NUM |
static String |
PROGRESS_TOTAL |
protected static Random |
RANDOM |
static String |
START_TIME |
static String |
STEP |
static long |
WRITE_LOCK_TTL |
static String |
XP_CONFIG |
lastModified, name
Constructor and Description |
---|
MigrationServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
atomic(String id,
Consumer<KeyValueStore> consumer)
Executes something while setting a lock, retrying a few times if the lock is already set.
|
int |
getApplicationStartedOrder()
The component notification order for
Component.applicationStarted(org.nuxeo.runtime.model.ComponentContext) . |
protected static KeyValueStore |
getKeyValueStore() |
Collection<MigrationDescriptor> |
getMigrationDescriptors() |
protected MigrationService.Migrator |
getMigrator(String id) |
MigrationService.MigrationStatus |
getStatus(String id)
Gets the current status for a migration.
|
String |
probeAndSetState(String id)
Probes the current state of a migration by analyzing persistent data, and sets it as the new current state.
|
void |
runStep(String id,
String step)
Runs a migration step for a migration.
|
protected void |
setState(String id,
String state,
MigrationService.Migrator migrator,
MigrationServiceImpl.ProgressReporter progressReporter) |
protected void |
setState(String id,
String state,
MigrationServiceImpl.ProgressReporter progressReporter,
KeyValueStore kv) |
void |
start(ComponentContext context)
Start the component.
|
void |
stop(ComponentContext context)
Stop the component.
|
activate, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applicationStarted
public static final String KEYVALUE_STORE_NAME
public static final String XP_CONFIG
public static final String LOCK
public static final String STEP
public static final String START_TIME
public static final String PING_TIME
public static final String PROGRESS_MESSAGE
public static final String PROGRESS_NUM
public static final String PROGRESS_TOTAL
public static final long WRITE_LOCK_TTL
public static final String MIGRATION_INVAL_PUBSUB_TOPIC
public static final String CLUSTERING_ENABLED_PROP
public static final String NODE_ID_PROP
protected MigrationServiceImpl.MigrationThreadPoolExecutor executor
protected MigrationServiceImpl.MigrationInvalidator invalidator
public MigrationServiceImpl()
protected static KeyValueStore getKeyValueStore()
public Collection<MigrationDescriptor> getMigrationDescriptors()
public int getApplicationStartedOrder()
Component
Component.applicationStarted(org.nuxeo.runtime.model.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.
getApplicationStartedOrder
in interface Component
public void start(ComponentContext context)
Component
start
in interface Component
start
in class DefaultComponent
public void stop(ComponentContext context) throws InterruptedException
Component
stop
in interface Component
stop
in class DefaultComponent
InterruptedException
public MigrationService.MigrationStatus getStatus(String id)
MigrationService
getStatus
in interface MigrationService
id
- the migration idnull
if the migration is unknownpublic String probeAndSetState(String id)
MigrationService
THIS METHOD MAY TAKE A WHILE as it needs to get information from persistent storage.
probeAndSetState
in interface MigrationService
id
- the migration idnull
if it cannot be determinedprotected void setState(String id, String state, MigrationService.Migrator migrator, MigrationServiceImpl.ProgressReporter progressReporter)
protected void setState(String id, String state, MigrationServiceImpl.ProgressReporter progressReporter, KeyValueStore kv)
public void runStep(String id, String step)
MigrationService
This launches the migration asynchronously. The status of the migration can be checked with MigrationService.getStatus(java.lang.String)
.
runStep
in interface MigrationService
id
- the migration idstep
- the step idprotected MigrationService.Migrator getMigrator(String id)
protected void atomic(String id, Consumer<KeyValueStore> consumer)
Copyright © 2019 Nuxeo. All rights reserved.