Search in sources :

Example 1 with InputBuildId

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);
    }
}
Also used : InputBuildId(fr.inria.spirals.repairnator.InputBuildId) Build(fr.inria.jtravis.entities.Build) Date(java.util.Date)

Example 2 with InputBuildId

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;
}
Also used : InputBuildId(fr.inria.spirals.repairnator.InputBuildId) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) File(java.io.File)

Example 3 with InputBuildId

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();
    }
}
Also used : InputBuildId(fr.inria.spirals.repairnator.InputBuildId) HardwareInfoSerializer(fr.inria.spirals.repairnator.serializer.HardwareInfoSerializer) ExecutorService(java.util.concurrent.ExecutorService) EndProcessSerializer(fr.inria.spirals.repairnator.dockerpool.serializer.EndProcessSerializer)

Aggregations

InputBuildId (fr.inria.spirals.repairnator.InputBuildId)3 Build (fr.inria.jtravis.entities.Build)1 EndProcessSerializer (fr.inria.spirals.repairnator.dockerpool.serializer.EndProcessSerializer)1 HardwareInfoSerializer (fr.inria.spirals.repairnator.serializer.HardwareInfoSerializer)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ExecutorService (java.util.concurrent.ExecutorService)1