Search in sources :

Example 1 with MigrationProgressDao

use of com.serotonin.m2m2.db.dao.migration.MigrationProgressDao in project ma-core-public by MangoAutomation.

the class MigrationPointValueDaoDefinition method initialize.

@Override
public void initialize() {
    if (definitions.size() < 2) {
        throw new IllegalStateException("Migration requires two enabled time-series databases");
    }
    // list of injected definitions does not include ourselves, get the next two definitions
    this.primary = definitions.get(0);
    this.secondary = definitions.get(1);
    primary.initialize();
    secondary.initialize();
    this.pointValueDao = new MigrationPointValueDao(primary.getPointValueDao(), secondary.getPointValueDao(), dataPointDao, vo -> true, env, executorService, scheduledExecutorService, context, timer, migrationProgressDao);
    if (log.isInfoEnabled()) {
        log.info("Time series migration enabled, from {} (secondary) to {} (primary)", secondary.getClass().getSimpleName(), primary.getClass().getSimpleName());
    }
}
Also used : Logger(org.slf4j.Logger) Common(com.serotonin.m2m2.Common) PointValueDao(com.serotonin.m2m2.db.dao.PointValueDao) AbstractTimer(com.serotonin.timer.AbstractTimer) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) PointValueDaoDefinition(com.serotonin.m2m2.db.PointValueDaoDefinition) ConditionalDefinition(com.serotonin.m2m2.module.ConditionalDefinition) List(java.util.List) DataPointDao(com.serotonin.m2m2.db.dao.DataPointDao) Environment(org.springframework.core.env.Environment) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) MigrationProgressDao(com.serotonin.m2m2.db.dao.migration.MigrationProgressDao) ExecutorService(java.util.concurrent.ExecutorService) MigrationPointValueDao(com.serotonin.m2m2.db.dao.migration.MigrationPointValueDao) MigrationPointValueDao(com.serotonin.m2m2.db.dao.migration.MigrationPointValueDao)

Example 2 with MigrationProgressDao

use of com.serotonin.m2m2.db.dao.migration.MigrationProgressDao in project ma-core-public by infiniteautomation.

the class MigrationPointValueDaoDefinition method initialize.

@Override
public void initialize() {
    if (definitions.size() < 2) {
        throw new IllegalStateException("Migration requires two enabled time-series databases");
    }
    // list of injected definitions does not include ourselves, get the next two definitions
    this.primary = definitions.get(0);
    this.secondary = definitions.get(1);
    primary.initialize();
    secondary.initialize();
    this.pointValueDao = new MigrationPointValueDao(primary.getPointValueDao(), secondary.getPointValueDao(), dataPointDao, executorService, scheduledExecutorService, clock.withZone(config.getZone()), migrationProgressDao, config);
    context.addApplicationListener((ApplicationListener<MangoConfigurationReloadedEvent>) e -> pointValueDao.reloadConfig());
    if (log.isInfoEnabled()) {
        log.info("Time series migration enabled, from {} (secondary) to {} (primary)", secondary.getClass().getSimpleName(), primary.getClass().getSimpleName());
    }
}
Also used : MangoConfigurationReloadedEvent(com.serotonin.util.properties.MangoConfigurationWatcher.MangoConfigurationReloadedEvent) Logger(org.slf4j.Logger) Common(com.serotonin.m2m2.Common) MigrationProgressDao(com.serotonin.m2m2.db.dao.migration.progress.MigrationProgressDao) PointValueDao(com.serotonin.m2m2.db.dao.PointValueDao) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) PointValueDaoDefinition(com.serotonin.m2m2.db.PointValueDaoDefinition) ApplicationListener(org.springframework.context.ApplicationListener) ConditionalDefinition(com.serotonin.m2m2.module.ConditionalDefinition) List(java.util.List) DataPointDao(com.serotonin.m2m2.db.dao.DataPointDao) Environment(org.springframework.core.env.Environment) MigrationConfig(com.serotonin.m2m2.db.dao.migration.MigrationConfig) ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Clock(java.time.Clock) ExecutorService(java.util.concurrent.ExecutorService) MigrationPointValueDao(com.serotonin.m2m2.db.dao.migration.MigrationPointValueDao) MangoConfigurationReloadedEvent(com.serotonin.util.properties.MangoConfigurationWatcher.MangoConfigurationReloadedEvent) MigrationPointValueDao(com.serotonin.m2m2.db.dao.migration.MigrationPointValueDao)

Aggregations

Common (com.serotonin.m2m2.Common)2 PointValueDaoDefinition (com.serotonin.m2m2.db.PointValueDaoDefinition)2 DataPointDao (com.serotonin.m2m2.db.dao.DataPointDao)2 PointValueDao (com.serotonin.m2m2.db.dao.PointValueDao)2 MigrationPointValueDao (com.serotonin.m2m2.db.dao.migration.MigrationPointValueDao)2 ConditionalDefinition (com.serotonin.m2m2.module.ConditionalDefinition)2 List (java.util.List)2 ExecutorService (java.util.concurrent.ExecutorService)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)2 Environment (org.springframework.core.env.Environment)2 MigrationConfig (com.serotonin.m2m2.db.dao.migration.MigrationConfig)1 MigrationProgressDao (com.serotonin.m2m2.db.dao.migration.MigrationProgressDao)1 MigrationProgressDao (com.serotonin.m2m2.db.dao.migration.progress.MigrationProgressDao)1 AbstractTimer (com.serotonin.timer.AbstractTimer)1 MangoConfigurationReloadedEvent (com.serotonin.util.properties.MangoConfigurationWatcher.MangoConfigurationReloadedEvent)1 Clock (java.time.Clock)1