Skip to content

Commit b0db4d4

Browse files
Implemented zipping of result data. Implemented skipping of already processed commits.
1 parent facbd98 commit b0db4d4

2 files changed

Lines changed: 40 additions & 8 deletions

File tree

Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ FROM alpine:3.14
44
# Prepare the environment
55
RUN apk add maven git
66

7-
# Build the jar files
87
WORKDIR /home/user
8+
9+
RUN git clone --progress https://git.busybox.net/busybox/
10+
RUN git clone --progress https://github.com/torvalds/linux.git
11+
912
COPY local-maven-repo ./local-maven-repo
1013
COPY src ./src
1114
COPY pom.xml .
1215
RUN mvn package || exit
1316

14-
RUN git clone --progress https://git.busybox.net/busybox/
15-
RUN git clone --progress https://github.com/torvalds/linux.git
17+
1618

1719
FROM ubuntu:20.04
1820

src/main/java/de/variantsync/subjects/extraction/AnalysisTask.java

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import de.variantsync.subjects.extraction.util.ConfigManipulator;
44
import de.variantsync.subjects.extraction.util.ShellExecutor;
5+
import net.lingala.zip4j.ZipFile;
6+
import net.lingala.zip4j.exception.ZipException;
57
import net.ssehub.kernel_haven.SetUpException;
68
import net.ssehub.kernel_haven.config.Configuration;
79
import net.ssehub.kernel_haven.config.DefaultSettings;
@@ -76,9 +78,16 @@ public void run() {
7678
return;
7779
}
7880

81+
Path pathToTargetDir = Paths.get(parentDir.getAbsolutePath(), "output");
82+
Set<String> processedCommits = determineProcessedCommits(pathToTargetDir);
83+
7984
int count = 1;
8085
// Process commits assigned to this task
8186
for (RevCommit commit : commits) {
87+
if (processedCommits.contains(commit.getName())) {
88+
LOGGER.logStatus("Skipping " + commit.getName() + " as it was already processed.");
89+
continue;
90+
}
8291
LOGGER.logStatus("Started analysis of commit " + commit.getName() + " in task #" + taskName);
8392
LOGGER.logStatus("Commit number " + count + " of " + commits.size());
8493
// Make sure the directory is not blocked
@@ -105,7 +114,6 @@ public void run() {
105114
Thread.currentThread().setName(threadName);
106115
LOGGER.logStatus("KernelHaven execution finished.");
107116

108-
Path pathToTargetDir = Paths.get(parentDir.getAbsolutePath(), "output");
109117
synchronized (AnalysisTask.class) {
110118
moveResultsToDirectory(workDir, pathToTargetDir, commit, prepareFail);
111119
}
@@ -144,11 +152,26 @@ private void prepareConfig(File workDir, File propertiesFile) throws SetUpExcept
144152
LOGGER.logInfo("Saving configuration " + propertiesFile);
145153
manipulator.writeToFile();
146154
}
155+
156+
private Set<String> determineProcessedCommits(Path pathToTargetDir) {
157+
Set<String> processedCommits = new HashSet<>();
158+
try {
159+
Path successFile = Paths.get(pathToTargetDir.toString(), SUCCESS_COMMIT_FILE);
160+
Path errorFile = Paths.get(pathToTargetDir.toString(), ERROR_COMMIT_FILE);
161+
Path incompletePCFile = Paths.get(pathToTargetDir.toString(), INCOMPLETE_PC_COMMIT_FILE);
162+
if (Files.exists(successFile)) processedCommits.addAll(Files.readAllLines(successFile));
163+
if (Files.exists(errorFile)) processedCommits.addAll(Files.readAllLines(errorFile));
164+
if (Files.exists(incompletePCFile)) processedCommits.addAll(Files.readAllLines(incompletePCFile));
165+
} catch (IOException e) {
166+
LOGGER.logException("Was not able to determine processed commits.", e);
167+
}
168+
return processedCommits;
169+
}
147170

148171
private static void moveResultsToDirectory(File workDir, Path pathToTargetDir, RevCommit commit, File prepareFail) {
149172
String commitId = commit.getName();
150173
LOGGER.logStatus("Moving result to common output directory.");
151-
File data_collection_dir = pathToTargetDir.resolve("data").resolve(commit.getName()).toFile();
174+
File data_collection_dir = pathToTargetDir.resolve("data").resolve(commitId).toFile();
152175
File log_collection_dir = pathToTargetDir.resolve("log").toFile();
153176

154177
if (data_collection_dir.mkdirs()) {
@@ -185,7 +208,7 @@ private static void moveResultsToDirectory(File workDir, Path pathToTargetDir, R
185208
moveKernelHavenLog(workDir, log_collection_dir, commitId);
186209

187210
if (hasError) {
188-
EXECUTOR.execute("echo \"" + commitId + " \" >> " + ERROR_COMMIT_FILE, pathToTargetDir.toFile());
211+
EXECUTOR.execute("echo \"" + commitId + "\" >> " + ERROR_COMMIT_FILE, pathToTargetDir.toFile());
189212
if (Objects.requireNonNull(data_collection_dir.listFiles()).length == 0) {
190213
try {
191214
Files.delete(data_collection_dir.toPath());
@@ -198,12 +221,19 @@ private static void moveResultsToDirectory(File workDir, Path pathToTargetDir, R
198221
writeToFile(data_collection_dir, COMMIT_MESSAGE_FILE, commit.getFullMessage());
199222
if (prepareFail.exists()) {
200223
LOGGER.logWarning("KernelHaven was not able to correctly load the build model, the extracted file presence conditions are incomplete!");
201-
EXECUTOR.execute("echo \"" + commitId + " \" >> " + INCOMPLETE_PC_COMMIT_FILE, pathToTargetDir.toFile());
224+
EXECUTOR.execute("echo \"" + commitId + "\" >> " + INCOMPLETE_PC_COMMIT_FILE, pathToTargetDir.toFile());
202225
} else {
203-
EXECUTOR.execute("echo \"" + commitId + " \" >> " + SUCCESS_COMMIT_FILE, pathToTargetDir.toFile());
226+
EXECUTOR.execute("echo \"" + commitId + "\" >> " + SUCCESS_COMMIT_FILE, pathToTargetDir.toFile());
204227
}
205228
}
206229

230+
try {
231+
new ZipFile(new File(data_collection_dir.getParentFile(), commitId + ".zip")).addFolder(data_collection_dir);
232+
EXECUTOR.execute("rm -rf " + commitId, data_collection_dir.getParentFile());
233+
} catch (ZipException e) {
234+
LOGGER.logError("Was not able to zip variability data of commit " + commit.getName());
235+
}
236+
207237
LOGGER.logInfo("...done.");
208238
}
209239

0 commit comments

Comments
 (0)