private void ensureDirectoryIsRecreated(final Context ctx) { final File aeronDir = new File(ctx.dirName()); Consumer<String> logProgress = (message) -> {}; if (aeronDir.exists()) { if (ctx.warnIfDirectoriesExist()) { System.err.println("WARNING: " + aeronDir + " already exists."); logProgress = System.err::println; } if (ctx.dirsDeleteOnStart()) { ctx.deleteAeronDirectory(); } else { final boolean driverActive = ctx.isDriverActive(ctx.driverTimeoutMs(), logProgress); if (driverActive) { throw new ActiveDriverException("active driver detected"); } ctx.deleteAeronDirectory(); } } final BiConsumer<String, String> callback = (path, name) -> { if (ctx.warnIfDirectoriesExist()) { System.err.println("WARNING: " + name + " directory already exists: " + path); } }; IoUtil.ensureDirectoryIsRecreated(aeronDir, "aeron", callback); }
public void close() { // do not close the systemsCounters so that all counters are kept as is. IoUtil.unmap(cncByteBuffer); super.close(); }