示例#1
0
  private void ensureDirectoryIsRecreated(final Context ctx) {
    final File aeronDir = new File(ctx.aeronDirectoryName());
    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);
  }
示例#2
0
 /**
  * Used to access the configured aeronDirectoryName for this MediaDriver, typically used after the
  * {@link #launchEmbedded()} method is used.
  *
  * @return the context aeronDirectoryName
  */
 public String aeronDirectoryName() {
   return ctx.aeronDirectoryName();
 }
示例#3
0
 /**
  * Launch an isolated MediaDriver embedded in the current process with a provided configuration
  * context and a generated aeronDirectoryName (overwrites configured aeronDirectoryName) that can
  * be retrieved by calling aeronDirectoryName.
  *
  * @param context containing the configuration options.
  * @return the newly started MediaDriver.
  */
 public static MediaDriver launchEmbedded(final Context context) {
   context.aeronDirectoryName(CommonContext.generateRandomDirName());
   return launch(context);
 }