use of fr.inria.spirals.repairnator.InputBuildId in project repairnator by Spirals-Team.
the class BuildRunner method submitBuild.
public void submitBuild(Build build) {
if (this.limitDateNextRetrieveDockerImage.before(new Date())) {
this.refreshDockerImage();
}
if (getRunning() < this.nbThreads) {
LOGGER.info("Build (id: " + build.getId() + ") immediately submitted for running.");
this.executorService.submit(this.submitBuild(this.dockerImageId, new InputBuildId(build.getId())));
} else {
LOGGER.info("All threads currently running (Limit: " + this.nbThreads + "). Add build (id: " + build.getId() + ") to list");
if (this.waitingBuilds.size() == this.nbThreads) {
Build b = this.waitingBuilds.removeLast();
LOGGER.debug("Remove oldest build (id: " + b.getId() + ")");
}
this.waitingBuilds.push(build);
}
}
use of fr.inria.spirals.repairnator.InputBuildId in project repairnator by Spirals-Team.
the class Launcher method readListOfBuildIds.
private List<InputBuildId> readListOfBuildIds() {
List<InputBuildId> result = new ArrayList<>();
File inputFile = new File(this.config.getInputPath());
try {
BufferedReader reader = new BufferedReader(new FileReader(inputFile));
while (reader.ready()) {
String line = reader.readLine().trim();
String[] buildIds = line.split(Utils.COMMA + "");
if (buildIds.length > 0) {
int buggyBuildId = Integer.parseInt(buildIds[0]);
if (this.config.getLauncherMode() == LauncherMode.REPAIR) {
result.add(new InputBuildId(buggyBuildId));
} else {
if (buildIds.length > 1) {
int patchedBuildId = Integer.parseInt(buildIds[1]);
result.add(new InputBuildId(buggyBuildId, patchedBuildId));
} else {
LOGGER.error("The build " + buggyBuildId + " will not be processed because there is no next build for it in the input file.");
}
}
}
}
reader.close();
} catch (IOException e) {
throw new RuntimeException("Error while reading build ids from file: " + inputFile.getPath(), e);
}
return result;
}
use of fr.inria.spirals.repairnator.InputBuildId in project repairnator by Spirals-Team.
the class Launcher method runPool.
private void runPool() throws IOException {
String runId = this.config.getRunId();
HardwareInfoSerializer hardwareInfoSerializer = new HardwareInfoSerializer(this.engines, runId, "dockerPool");
hardwareInfoSerializer.serialize();
EndProcessSerializer endProcessSerializer = new EndProcessSerializer(this.engines, runId);
List<InputBuildId> buildIds = this.readListOfBuildIds();
LOGGER.info("Find " + buildIds.size() + " builds to run.");
endProcessSerializer.setNbBuilds(buildIds.size());
String imageId = this.findDockerImage(this.config.getDockerImageName());
LOGGER.info("Found the following docker image id: " + imageId);
this.setDockerOutputDir(this.config.getLogDirectory());
this.setRunId(runId);
this.setEngines(this.engines);
ExecutorService executorService = Executors.newFixedThreadPool(this.config.getNbThreads());
for (InputBuildId inputBuildId : buildIds) {
executorService.submit(this.submitBuild(imageId, inputBuildId));
}
executorService.shutdown();
try {
if (executorService.awaitTermination(this.config.getGlobalTimeout(), TimeUnit.DAYS)) {
LOGGER.info("Job finished within time.");
endProcessSerializer.setStatus("ok");
} else {
LOGGER.warn("Timeout launched: the job is running for one day. Force stopped " + submittedRunnablePipelineContainers.size() + " docker container(s).");
executorService.shutdownNow();
this.setStatusForUnexecutedJobs();
endProcessSerializer.setStatus("timeout");
}
} catch (InterruptedException e) {
LOGGER.error("Error while await termination. Force stopped " + submittedRunnablePipelineContainers.size() + " docker container(s).", e);
executorService.shutdownNow();
this.setStatusForUnexecutedJobs();
endProcessSerializer.setStatus("interrupted");
}
this.getDockerClient().close();
endProcessSerializer.serialize();
if (this.endProcessNotifier != null) {
this.endProcessNotifier.notifyEnd();
}
}
Aggregations