Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add matsim.tempDir property for specifying ImageIO cache directory #3522

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move specification of MATSim temp dir to OutputDirectoryHierarchy
  • Loading branch information
marecabo committed Oct 18, 2024
commit 5fc0d3f6c85612a3b73b334316ce35806d58c916
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@

public final class ControlerDefaultsModule extends AbstractModule {

public static final String MATSIM_TEMP_DIR_PROPERTY = "matsim.tempDir";

@Override
public void install() {
install(new EventsManagerModule());
Expand Down Expand Up @@ -88,16 +86,10 @@ public void install() {
// Maybe not the best place to but this but since ChartUtils is used by many modules, including default ones,
// the cache needs to be always set correctly.
addControlerListenerBinding().toInstance(new StartupListener() {
@Inject
private OutputDirectoryHierarchy outputDirectoryHierarchy;

@Override
public void notifyStartup(StartupEvent event) {
String matsimTempDir = System.getProperty(MATSIM_TEMP_DIR_PROPERTY);
if (matsimTempDir == null) {
matsimTempDir = outputDirectoryHierarchy.getTempPath();
}
ImageIO.setCacheDirectory(new File(matsimTempDir));
ImageIO.setCacheDirectory(new File(event.getServices().getControlerIO().getTempPath()));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public enum OverwriteFileSetting {failIfDirectoryExists, overwriteExistingFiles,

private static final String DIRECTORY_ITERS = "ITERS";

public static final String MATSIM_TEMP_DIR_PROPERTY = "matsim.tempDir";

private static final Logger log = LogManager.getLogger(OutputDirectoryHierarchy.class);

private String runId = null;
Expand Down Expand Up @@ -108,7 +110,11 @@ public OutputDirectoryHierarchy(String outputPath, String runId, OverwriteFileSe
* @return path to a temp-directory.
*/
public final String getTempPath() {
return outputPath + "/tmp";
String matsimTempDir = System.getProperty(MATSIM_TEMP_DIR_PROPERTY);
if (matsimTempDir == null) {
matsimTempDir = outputPath + "/tmp";
}
return matsimTempDir;
}

/**
Expand Down