use of com.serotonin.util.properties.MangoConfigurationWatcher.MangoConfigurationReloadedEvent in project ma-core-public by MangoAutomation.
the class MigrationPointValueDao method postConstruct.
@PostConstruct
private void postConstruct() {
if (env.getProperty("db.migration.startNewMigration", boolean.class, false)) {
migrationProgressDao.deleteAll();
}
if (migrationProgressDao.count() > 0) {
// migration in progress, restore from DB
try (var stream = migrationProgressDao.stream()) {
stream.map(progress -> new MigrationSeries(progress.getSeriesId(), progress.getStatus(), progress.getTimestamp())).forEach(this::addMigration);
}
} else {
// start a new migration, get all points and insert progress items for them
try (var stream = dataPointDao.streamSeriesIds()) {
Stream<MigrationProgress> progressStream = stream.mapToObj(MigrationSeries::new).peek(this::addMigration).map(migration -> new MigrationProgress(migration.seriesId, migration.status, migration.timestamp));
migrationProgressDao.bulkInsert(progressStream);
}
}
context.addApplicationListener((ApplicationListener<MangoConfigurationReloadedEvent>) e -> loadProperties());
loadProperties();
}
use of com.serotonin.util.properties.MangoConfigurationWatcher.MangoConfigurationReloadedEvent 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());
}
}
use of com.serotonin.util.properties.MangoConfigurationWatcher.MangoConfigurationReloadedEvent in project ma-core-public by infiniteautomation.
the class MigrationPointValueDao method postConstruct.
@PostConstruct
private void postConstruct() {
if (env.getProperty("db.migration.startNewMigration", boolean.class, false)) {
migrationProgressDao.deleteAll();
}
if (migrationProgressDao.count() > 0) {
// migration in progress, restore from DB
try (var stream = migrationProgressDao.stream()) {
stream.map(progress -> new MigrationSeries(progress.getSeriesId(), progress.getStatus(), progress.getTimestamp())).forEach(this::addMigration);
}
} else {
// start a new migration, get all points and insert progress items for them
try (var stream = dataPointDao.streamSeriesIds()) {
Stream<MigrationProgress> progressStream = stream.mapToObj(MigrationSeries::new).peek(this::addMigration).map(migration -> new MigrationProgress(migration.seriesId, migration.status, migration.timestamp));
migrationProgressDao.bulkInsert(progressStream);
}
}
context.addApplicationListener((ApplicationListener<MangoConfigurationReloadedEvent>) e -> loadProperties());
loadProperties();
}
Aggregations