dmvk commented on a change in pull request #12560:
URL: https://github.com/apache/flink/pull/12560#discussion_r437893569
##########
File path:
flink-runtime-web/src/test/java/org/apache/flink/runtime/webmonitor/history/HistoryServerTest.java
##########
@@ -78,6 +78,7 @@
.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT);
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
.enable(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES);
+ private static final String JSON_FILE_ENDING = ".json";
Review comment:
nit: can we reuse the variable defined in
HistoryServerArchiveFetcher.java?
##########
File path:
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServerArchiveFetcher.java
##########
@@ -302,18 +289,37 @@ public void run() {
cachedArchives.removeAll(jobsToRemove);
jobsToRemove.forEach(removedJobID -> {
- try {
- Files.deleteIfExists(new
File(webOverviewDir, removedJobID + JSON_FILE_ENDING).toPath());
- FileUtils.deleteDirectory(new
File(webJobDir, removedJobID));
- } catch (IOException e) {
- LOG.error("Failure while removing job
overview for job {}.", removedJobID, e);
- }
+ deleteJobFiles(removedJobID);
deleteLog.add(new ArchiveEvent(removedJobID,
ArchiveEventType.DELETED));
});
return deleteLog;
}
+ private void deleteJobFiles(String jobID) {
+ // Make sure we do not include this job in the overview
+ try {
+ Files.deleteIfExists(new File(webOverviewDir,
jobID + JSON_FILE_ENDING).toPath());
+ } catch (IOException ioe) {
+ LOG.warn("Could not delete file from overview
directory.", ioe);
+ }
+
+ // Clean up job files we may have created
+ File jobDirectory = new File(webJobDir, jobID);
+ try {
+ FileUtils.deleteDirectory(jobDirectory);
+ } catch (IOException ioe) {
+ LOG.warn("Could not clean up job directory.",
ioe);
+ }
+
+ // Also clean up job json file in webJobDir
+ try {
+ Files.deleteIfExists(new File(webJobDir, jobID
+ JSON_FILE_ENDING).toPath());
+ } catch (IOException ioe) {
Review comment:
👍
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]