コード例 #1
0
  @Override
  protected void onBeforeProcess(IRuntimeConfig runtimeConfig) throws IOException {
    super.onBeforeProcess(runtimeConfig);

    MongodConfig config = getConfig();

    File tmpDbDir;
    if (config.getDatabaseDir() != null) {
      tmpDbDir = Files.createOrCheckDir(config.getDatabaseDir());
    } else {
      tmpDbDir = Files.createTempDir("embedmongo-db");
      dbDirIsTemp = true;
    }
    this.dbDir = tmpDbDir;
  }
コード例 #2
0
  @Override
  public void stop() {

    synchronized (this) {
      if (!stopped) {

        stopped = true;

        logger.info("try to stop mongos");
        if (!sendStopToMongoInstance()) {
          logger.warning("could not stop mongos with db command, try next");
          if (!sendKillToProcess()) {
            logger.warning("could not stop mongos, try next");
            if (!tryKillToProcess()) {
              logger.warning("could not stop mongos the second time, try one last thing");
            }
          }
        }

        stopProcess();

        if ((dbDir != null) && (dbDirIsTemp) && (!Files.forceDelete(dbDir)))
          logger.warning("Could not delete temp db dir: " + dbDir);
      }
    }
  }
コード例 #3
0
 public static boolean store(IDownloadConfig runtime, Distribution distribution, File download) {
   File dir = createOrGetBaseDir(runtime);
   String artifactFileName = runtime.getPackageResolver().getPath(distribution);
   File artifactFile = new File(dir, artifactFileName);
   createOrCheckDir(artifactFile.getParentFile());
   if (!Files.moveFile(download, artifactFile))
     throw new IllegalArgumentException("Could not move " + download + " to " + artifactFile);
   File checkFile = new File(dir, artifactFileName);
   return checkFile.exists() & checkFile.isFile() & checkFile.canRead();
 }
コード例 #4
0
 @Override
 protected MongodConfigBuilder createMongodConfigBuilder() throws IOException {
   MongodConfigBuilder builder = super.createMongodConfigBuilder();
   builder
       .processListener(
           new ProcessListenerBuilder()
               .copyDbFilesBeforeStopInto(
                   Files.createTempDir(new PlatformTempDir(), "embedmongo-snapshot"))
               .build())
       .cmdOptions(new MongoCmdOptionsBuilder().syncDelay(1).build());
   return builder;
 }