@Test public void shouldCleanup() { testee.cleanup(); assertThat(indexerConfigDisabledTempOutsideTimeWindow.getState()).isEqualTo(IndexerConfig.State.ENABLED); assertThat(indexerConfigDisabledTempOutsideTimeWindow.getDisabledUntil()).isNull(); assertThat(indexerConfigDisabledTempOutsideTimeWindow.getLastError()).isNull(); assertThat(indexerConfigDisabledTempOutsideTimeWindow.getDisabledLevel()).isEqualTo(1); assertThat(indexerConfigDisabledTempInTimeWindow.getState()).isEqualTo(IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY); assertThat(indexerConfigDisabledTempInTimeWindow.getDisabledUntil()).isNotNull(); assertThat(indexerConfigDisabledTempInTimeWindow.getLastError()).isEqualTo("someerror"); assertThat(indexerConfigDisabledTempInTimeWindow.getDisabledLevel()).isEqualTo(1); assertThat(indexerConfigEnabled.getState()).isEqualTo(IndexerConfig.State.ENABLED); assertThat(indexerConfigUserDisabled.getState()).isEqualTo(IndexerConfig.State.DISABLED_USER); assertThat(indexerConfigDisabledSystem.getState()).isEqualTo(IndexerConfig.State.DISABLED_SYSTEM); }
@HydraTask(configId = "cleanUpIndexerStatuses", name = "Clean up indexer statuses", interval = MINUTE) public void cleanup() { boolean anyChanges = false; for (IndexerConfig config : configProvider.getBaseConfig().getIndexers()) { if (config.getState() == IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY && config.getDisabledUntil() != null && Instant.ofEpochMilli(config.getDisabledUntil()).isBefore(Instant.now())) { logger.debug("Setting indexer {} back to enabled after having been temporarily disabled until {}", config.getName(), Instant.ofEpochMilli(config.getDisabledUntil())); config.setState(IndexerConfig.State.ENABLED); config.setDisabledUntil(null); config.setLastError(null); anyChanges = true; } } if (anyChanges) { configProvider.getBaseConfig().save(false); } }
IndexerStatusesCleanupTask { @HydraTask(configId = "cleanUpIndexerStatuses", name = "Clean up indexer statuses", interval = MINUTE) public void cleanup() { boolean anyChanges = false; for (IndexerConfig config : configProvider.getBaseConfig().getIndexers()) { if (config.getState() == IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY && config.getDisabledUntil() != null && Instant.ofEpochMilli(config.getDisabledUntil()).isBefore(Instant.now())) { logger.debug("Setting indexer {} back to enabled after having been temporarily disabled until {}", config.getName(), Instant.ofEpochMilli(config.getDisabledUntil())); config.setState(IndexerConfig.State.ENABLED); config.setDisabledUntil(null); config.setLastError(null); anyChanges = true; } } if (anyChanges) { configProvider.getBaseConfig().save(false); } } }
IndexerStatusesCleanupTask { @HydraTask(configId = "cleanUpIndexerStatuses", name = "Clean up indexer statuses", interval = MINUTE) public void cleanup() { boolean anyChanges = false; for (IndexerConfig config : configProvider.getBaseConfig().getIndexers()) { if (config.getState() == IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY && config.getDisabledUntil() != null && Instant.ofEpochMilli(config.getDisabledUntil()).isBefore(Instant.now())) { logger.debug("Setting indexer {} back to enabled after having been temporarily disabled until {}", config.getName(), Instant.ofEpochMilli(config.getDisabledUntil())); config.setState(IndexerConfig.State.ENABLED); config.setDisabledUntil(null); config.setLastError(null); anyChanges = true; } } if (anyChanges) { configProvider.getBaseConfig().save(false); } } @Autowired  IndexerStatusesCleanupTask(ConfigProvider configProvider); }
IndexerStatusesCleanupTask { @HydraTask(configId = "cleanUpIndexerStatuses", name = "Clean up indexer statuses", interval = MINUTE) public void cleanup() { boolean anyChanges = false; for (IndexerConfig config : configProvider.getBaseConfig().getIndexers()) { if (config.getState() == IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY && config.getDisabledUntil() != null && Instant.ofEpochMilli(config.getDisabledUntil()).isBefore(Instant.now())) { logger.debug("Setting indexer {} back to enabled after having been temporarily disabled until {}", config.getName(), Instant.ofEpochMilli(config.getDisabledUntil())); config.setState(IndexerConfig.State.ENABLED); config.setDisabledUntil(null); config.setLastError(null); anyChanges = true; } } if (anyChanges) { configProvider.getBaseConfig().save(false); } } @Autowired  IndexerStatusesCleanupTask(ConfigProvider configProvider); @HydraTask(configId = "cleanUpIndexerStatuses", name = "Clean up indexer statuses", interval = MINUTE) void cleanup(); }
IndexerStatusesCleanupTask { @HydraTask(configId = "cleanUpIndexerStatuses", name = "Clean up indexer statuses", interval = MINUTE) public void cleanup() { boolean anyChanges = false; for (IndexerConfig config : configProvider.getBaseConfig().getIndexers()) { if (config.getState() == IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY && config.getDisabledUntil() != null && Instant.ofEpochMilli(config.getDisabledUntil()).isBefore(Instant.now())) { logger.debug("Setting indexer {} back to enabled after having been temporarily disabled until {}", config.getName(), Instant.ofEpochMilli(config.getDisabledUntil())); config.setState(IndexerConfig.State.ENABLED); config.setDisabledUntil(null); config.setLastError(null); anyChanges = true; } } if (anyChanges) { configProvider.getBaseConfig().save(false); } } @Autowired  IndexerStatusesCleanupTask(ConfigProvider configProvider); @HydraTask(configId = "cleanUpIndexerStatuses", name = "Clean up indexer statuses", interval = MINUTE) void cleanup();  }