private static final Logger LOG = Loggers.get(ProjectsInWarningDaemon.class);
- private static final String FREQUENCY_IN_SECONDS_PROPERTY = "sonar.projectsInWarning.frequencyInSeconds";
- private static final int DEFAULT_FREQUENCY_IN_SECONDS = 60 * 60 * 24;
+ private static final String FREQUENCY_IN_MILLISECONDS_PROPERTY = "sonar.projectsInWarning.frequencyInMilliseconds";
+ private static final int DEFAULT_FREQUENCY_IN_MILLISECONDS = 1000 * 60 * 60 * 24;
private static final String THREAD_NAME_PREFIX = "sq-projects-in-warning-service-";
private static final String LOCK_NAME = "ProjectsInWarn";
}
LOG.info("Counting number of projects in warning is enabled.");
executorService = Executors.newSingleThreadScheduledExecutor(newThreadFactory());
- executorService.scheduleWithFixedDelay(countProjectsInWarning(), 0, frequency(), TimeUnit.SECONDS);
+ executorService.scheduleWithFixedDelay(countProjectsInWarning(), 0, frequency(), TimeUnit.MILLISECONDS);
}
private int frequency() {
- return config.getInt(FREQUENCY_IN_SECONDS_PROPERTY).orElse(DEFAULT_FREQUENCY_IN_SECONDS);
+ return config.getInt(FREQUENCY_IN_MILLISECONDS_PROPERTY).orElse(DEFAULT_FREQUENCY_IN_MILLISECONDS);
}
private Runnable countProjectsInWarning() {
@Before
public void setUp() throws Exception {
- settings.setProperty("sonar.projectsInWarning.frequencyInSeconds", "1");
+ settings.setProperty("sonar.projectsInWarning.frequencyInMilliseconds", "100");
}
@After
public void update_internal_properties_when_already_exits_and_projects_in_warnings_more_than_zero() throws InterruptedException {
allowLockToBeAcquired();
MetricDto qualityGateStatus = insertQualityGateStatusMetric();
- ;
insertProjectInWarning(qualityGateStatus);
insertProjectInWarning(qualityGateStatus);
// Setting contains 10, it should be updated with new value
}
private void waitForValueToBeComputed(long expectedValue) throws InterruptedException {
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < 1000; i++) {
if (projectsInWarning.isInitialized() && projectsInWarning.count() == expectedValue) {
break;
}