private Path dbFolder;
private final Database database;
private ServiceLocator locator;
+ private FileCache fileCache;
private MainProgram mainProgram;
static class ClientThreadFactory implements ThreadFactory {
this.database = database;
this.dbFolder = dbFolder;
this.locator = locator;
- this.clusters = new ClusterManager(dbFolder);
+ this.fileCache = new FileCache();
+ // This disposes the cache when the session is shut down
+ locator.registerService(FileCache.class, fileCache);
+ this.clusters = new ClusterManager(dbFolder, fileCache);
load();
ClusterSetsSupport cssi = locator.getService(ClusterSetsSupport.class);
cssi.setReadDirectory(clusters.lastSessionDirectory);
try {
if (!unexpectedClose)
makeSnapshot(true);
-
+
mainProgram.close();
clusters.shutdown();
executor.shutdown();
boolean saverTerminated = saver.awaitTermination(500, TimeUnit.MILLISECONDS);
System.err.println("executorTerminated=" + executorTerminated + ", saverTerminated=" + saverTerminated);
-
+
+ try {
+ clusters.mainState.save(dbFolder);
+ } catch (IOException e) {
+ LOGGER.error("Failed to save " + MainState.MAIN_STATE + " file in database folder " + dbFolder);
+ }
+
mainProgram = null;
executor = null;
saver = null;