-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additionally export request configuration
- Loading branch information
Showing
6 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/ch/sbb/rssched/client/pipeline/request/RequestConfigWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ch.sbb.rssched.client.pipeline.request; | ||
|
||
import ch.sbb.rssched.client.config.RsschedRequestConfig; | ||
import ch.sbb.rssched.client.pipeline.core.ResultSink; | ||
import ch.sbb.rssched.client.pipeline.utils.io.OutputDirectoryManager; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
|
||
/** | ||
* Request config JSON writer | ||
* <p> | ||
* Writes the scheduler request configuration to a JSON file in the specified output directory. | ||
* | ||
* @author munterfi | ||
*/ | ||
@Log4j2 | ||
public class RequestConfigWriter implements ResultSink<RequestPipe> { | ||
private static final String REQUEST_CONFIG_FILE_NAME = "scheduler_request_config.json"; | ||
private final RsschedRequestConfig config; | ||
|
||
public RequestConfigWriter(RsschedRequestConfig config) { | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public void process(RequestPipe pipe) { | ||
String filePath = new OutputDirectoryManager(config.getOutputDirectory(), pipe.getRunId(), | ||
config.getInstanceId()).buildFilePath(REQUEST_CONFIG_FILE_NAME); | ||
log.info("Exporting request config JSON to {}", filePath); | ||
try (FileWriter fileWriter = new FileWriter(filePath)) { | ||
fileWriter.write(config.toJSON()); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Error writing the JSON file: " + e.getMessage(), e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters