예제 #1
0
 @BeforeClass
 public void initDirs() throws Exception {
   this.tmpDir = new File("target/antbundletest/tmp");
   FileUtil.purge(this.tmpDir, true);
   this.bundleFilesDir = new File("target/antbundletest/bundlefiles");
   FileUtil.purge(this.bundleFilesDir, true);
   this.destDir = new File("target/antbundletest/destination");
   FileUtil.purge(this.destDir, true);
 }
예제 #2
0
 /**
  * Given a directory where the current deployment's bundle files will reside, this method will
  * clear out any other files located in other peer directories. In other words, the given
  * directory and all its subdirectories and child files are left untouched, but all files and
  * directories found in peer directories are wiped. This helps clean out our temp directory so we
  * don't fill up the file system with old downloaded files that we don't need anymore. See BZ
  * 752550.
  *
  * @param currentBundleVersionFilesDir
  */
 private void removeOldDownloadedBundleFiles(final File currentBundleVersionFilesDir) {
   File parent = null;
   try {
     parent = currentBundleVersionFilesDir.getParentFile();
     File[] doomedFiles =
         parent.listFiles(
             new FileFilter() {
               public boolean accept(File child) {
                 return !currentBundleVersionFilesDir.equals(child);
               }
             });
     for (File doomedFile : doomedFiles) {
       FileUtil.purge(doomedFile, true);
     }
   } catch (Exception e) {
     log.warn(
         "Failed to clean up old downloaded bundle files in ["
             + parent
             + "]. You can ignore this but if the agent is asked to deploy a lot of bundles, the file system may fill up."
             + " Cause: "
             + e);
   }
 }
예제 #3
0
 @AfterMethod(alwaysRun = true)
 public void cleanDestDir() {
   FileUtil.purge(this.destDir, true);
 }
예제 #4
0
 @AfterMethod(alwaysRun = true)
 public void cleanPluginDirs() {
   FileUtil.purge(this.tmpDir, true);
   FileUtil.purge(this.bundleFilesDir, true);
 }
  public void createCluster() {
    if (log.isDebugEnabled()) {
      log.debug(
          "Installing embedded "
              + deploymentOptions.getNumNodes()
              + " node cluster to "
              + deploymentOptions.getClusterDir());
    } else {
      log.info("Installing embedded cluster");
    }

    File clusterDir = new File(deploymentOptions.getClusterDir());
    File installedMarker = new File(clusterDir, ".installed");

    if (installedMarker.exists()) {
      log.info("It appears that the cluster already exists in " + clusterDir);
      log.info("Skipping cluster creation.");
      getStorageClusterConfiguration();
    }
    FileUtil.purge(clusterDir, false);

    String seeds = collectionToString(calculateLocalIPAddresses(deploymentOptions.getNumNodes()));

    this.nodes = new String[deploymentOptions.getNumNodes()];
    this.jmxPorts = new int[deploymentOptions.getNumNodes()];
    this.cqlPort = deploymentOptions.getCqlPort();

    boolean useRemoteJMX = this.nodes.length > 1;

    for (int i = 0; i < deploymentOptions.getNumNodes(); ++i) {
      File basedir = new File(deploymentOptions.getClusterDir(), "node" + i);
      String address = getLocalIPAddress(i + 1);

      DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
      DeploymentOptions nodeOptions = factory.newDeploymentOptions();
      nodeOptions.setSeeds(seeds);
      nodeOptions.setJmxPort(deploymentOptions.getJmxPort() + i);
      nodeOptions.setBasedir(basedir.getAbsolutePath());
      nodeOptions.setListenAddress(address);
      nodeOptions.setRpcAddress(address);
      nodeOptions.setCommitLogDir(new File(basedir, "commit_log").getAbsolutePath());
      nodeOptions.setDataDir(new File(basedir, "data").getAbsolutePath());
      nodeOptions.setSavedCachesDir(new File(basedir, "saved_caches").getAbsolutePath());

      nodeOptions.merge(deploymentOptions);
      try {
        nodeOptions.load();
        Deployer deployer = new Deployer();
        deployer.setDeploymentOptions(nodeOptions);

        deployer.unzipDistro();
        deployer.applyConfigChanges();
        deployer.updateFilePerms();
        deployer.updateStorageAuthConf(calculateLocalIPAddresses(deploymentOptions.getNumNodes()));

        if (useRemoteJMX) {
          File confDir = new File(nodeOptions.getBasedir(), "conf");
          File cassandraJvmPropsFile = new File(confDir, "cassandra-jvm.properties");
          PropertiesFileUpdate propertiesUpdater =
              new PropertiesFileUpdate(cassandraJvmPropsFile.getAbsolutePath());
          Properties properties = propertiesUpdater.loadExistingProperties();
          String jmxOpts =
              "\"-Djava.rmi.server.hostname="
                  + nodeOptions.getRpcAddress()
                  + " -Dcom.sun.management.jmxremote.port="
                  + nodeOptions.getJmxPort()
                  + " -Dcom.sun.management.jmxremote.rmi.port="
                  + nodeOptions.getJmxPort()
                  + " -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false \"";

          properties.setProperty("JMX_OPTS", jmxOpts);

          propertiesUpdater.update(properties);
        }

        this.nodes[i] = address;
        this.jmxPorts[i] = deploymentOptions.getJmxPort() + i;

        installedNodeDirs.add(basedir);
      } catch (Exception e) {
        log.error("Failed to install node at " + basedir);
        throw new RuntimeException("Failed to install node at " + basedir, e);
      }
    }
    try {
      FileUtil.writeFile(new ByteArrayInputStream(new byte[] {0}), installedMarker);
    } catch (IOException e) {
      log.warn("Failed to write installed file marker to " + installedMarker, e);
    }
  }