Exemple #1
0
  @Override
  public boolean compile(VoltProjectBuilder builder) {
    if (m_compiled) {
      return true;
    }
    m_compiled =
        builder.compile(m_jarFileName, m_partitionPerSite, m_siteCount, m_replication, "localhost");

    // (1) Load catalog from Jar
    Catalog tmpCatalog = CatalogUtil.loadCatalogFromJar(m_jarFileName);

    // (2) Update catalog to include target cluster configuration
    ClusterConfiguration cc = new ClusterConfiguration();
    // Update cc with a bunch of hosts/sites/partitions
    for (int site = 0, currentPartition = 0; site < m_siteCount; ++site) {
      for (int partition = 0; partition < m_partitionPerSite; ++partition, ++currentPartition) {
        cc.addPartition("localhost", site, currentPartition);
      }
    }
    this.catalog = FixCatalog.addHostInfo(tmpCatalog, cc);

    // (3) Write updated catalog back out to jar file
    try {
      CatalogUtil.updateCatalogInJar(m_jarFileName, catalog);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }

    tmpCatalog = CatalogUtil.loadCatalogFromJar(m_jarFileName);
    // System.err.println(CatalogInfo.getInfo(this.catalog, new File(m_jarFileName)));

    // Construct the base command that we will want to use to start
    // all of the "remote" HStoreSites
    List<String> siteCommand = new ArrayList<String>();
    CollectionUtil.addAll(siteCommand, "ant", "hstore-site", "-Djar=" + m_jarFileName);
    // Be sure to include our HStoreConf parameters
    for (Entry<String, String> e : this.confParams.entrySet()) {
      siteCommand.add(String.format("-D%s=%s", e.getKey(), e.getValue()));
    }
    // Lastly, we will include the site.id as the last parameter
    // so that we can easily change it
    siteCommand.add("-Dsite.id=-1");

    m_procBuilder = new ProcessBuilder(siteCommand.toArray(new String[0]));
    m_procBuilder.redirectErrorStream(true);
    // set the working directory to obj/release/prod
    // m_procBuilder.directory(new File(m_buildDir + File.separator + "prod"));

    return m_compiled;
  }
Exemple #2
0
 /**
  * Add fake partitions to the loaded catalog Assuming that there is one partition per site
  *
  * @param num_partitions
  */
 protected void addPartitions(int num_partitions) throws Exception {
   // HACK! If we already have this many partitions in the catalog, then we won't recreate it
   // This fixes problems where we need to reference the same catalog objects in multiple test
   // cases
   if (CatalogUtil.getNumberOfPartitions(catalog_db) != num_partitions) {
     ClusterConfiguration cc = new ClusterConfiguration();
     for (Integer i = 0; i < num_partitions; i++) {
       cc.addPartition("localhost", 0, i);
       // System.err.println("[" + i + "] " + Arrays.toString(triplets.lastElement()));
     } // FOR
     catalog = FixCatalog.addHostInfo(catalog, cc);
     this.init(this.last_type, catalog);
   }
   Cluster cluster = CatalogUtil.getCluster(catalog_db);
   assertEquals(num_partitions, cluster.getNum_partitions());
   assertEquals(num_partitions, CatalogUtil.getNumberOfPartitions(cluster));
 }