public RTScanner(String runId, List<SerializerEngine> engines) { this.engines = engines; this.blackListedRepository = new ArrayList<>(); this.whiteListedRepository = new ArrayList<>(); this.tempBlackList = new HashMap<>(); this.buildRunner = new BuildRunner(this); this.inspectBuilds = new InspectBuilds(this); this.inspectJobs = new InspectJobs(this); this.runId = runId; this.blacklistedSerializer = new BlacklistedSerializer(this.engines, this); }
@Override public void run() { Instant endOfProcessDate = new Date().toInstant().plus(duration); LOGGER.info("The process will finish at: " + endOfProcessDate); while (!new Date().toInstant().isAfter(endOfProcessDate)) { try { Thread.sleep(SLEEP_TIME * 1000); } catch (InterruptedException e) { LOGGER.warn("Sleep interrupted: premature stop will occured."); } } LOGGER.info("The process will now stop."); this.inspectBuilds.switchOff(); this.inspectJobs.switchOff(); this.buildRunner.switchOff(); if (this.endProcessNotifier != null) { this.endProcessNotifier.notifyEnd(); } } }
/** * Use this method to submit a build to the thread which refresh their status. */ public void submitWaitingBuild(int buildId) { Optional<Build> optionalBuild = RepairnatorConfig.getInstance().getJTravis().build().fromId(buildId); if (optionalBuild.isPresent()) { this.inspectBuilds.submitNewBuild(optionalBuild.get()); } } }
@Override public void run() { LOGGER.debug("Start running inspect Jobs..."); if (sleepTime == -1) { throw new RuntimeException("Sleep time has to be set before running this."); } while (!shouldStop) { Optional<List<JobV2>> jobListOpt = RepairnatorConfig.getInstance().getJTravis().job().allFromV2(); if (jobListOpt.isPresent()) { List<JobV2> jobList = jobListOpt.get(); LOGGER.info("Retrieved "+jobList.size()+" jobs"); for (JobV2 job : jobList) { if (this.rtScanner.isRepositoryInteresting(job.getRepositoryId())) { this.rtScanner.submitWaitingBuild(job.getBuildId()); } } } if (this.rtScanner.getInspectBuilds().maxSubmittedBuildsReached() || !jobListOpt.isPresent()) { LOGGER.debug("Max number of submitted builds reached. Sleep for "+sleepTime+" seconds."); try { Thread.sleep(sleepTime * 1000); } catch (InterruptedException e) { e.printStackTrace(); } } } LOGGER.info("This will now stop."); } }