use of org.openhab.core.persistence.strategy.PersistenceStrategy in project openhab-core by openhab.
the class PersistenceManagerImpl method createTimers.
/**
* Creates new {@link ScheduledCompletableFuture}s in the group <code>dbId</code> for the given collection of
* {@link PersistenceStrategy strategies}.
*
* @param dbId the database id used by the persistence service
* @param strategies a collection of strategies
*/
private void createTimers(final String dbId, List<PersistenceStrategy> strategies) {
for (PersistenceStrategy strategy : strategies) {
if (strategy instanceof PersistenceCronStrategy) {
PersistenceCronStrategy cronStrategy = (PersistenceCronStrategy) strategy;
String cronExpression = cronStrategy.getCronExpression();
final PersistItemsJob job = new PersistItemsJob(this, dbId, cronStrategy.getName());
ScheduledCompletableFuture<?> schedule = scheduler.schedule(job, cronExpression);
if (persistenceJobs.containsKey(dbId)) {
persistenceJobs.get(dbId).add(schedule);
} else {
final Set<ScheduledCompletableFuture<?>> jobs = new HashSet<>();
jobs.add(schedule);
persistenceJobs.put(dbId, jobs);
}
logger.debug("Scheduled strategy {} with cron expression {}", cronStrategy.getName(), cronExpression);
}
}
}
use of org.openhab.core.persistence.strategy.PersistenceStrategy in project openhab-core by openhab.
the class PersistenceManagerImpl method getDefaultConfig.
@Nullable
private PersistenceServiceConfiguration getDefaultConfig(PersistenceService persistenceService) {
List<PersistenceStrategy> strategies = persistenceService.getDefaultStrategies();
List<PersistenceItemConfiguration> configs = List.of(new PersistenceItemConfiguration(List.of(new PersistenceAllConfig()), null, strategies, null));
return new PersistenceServiceConfiguration(configs, strategies, strategies);
}
Aggregations