@Before
  public void setUp() throws Exception {
    super.setUp(builder, false);
    initializeCatalog(1, 1, NUM_PARTITIONS);
    this.anticache_dir = FileUtil.getTempDirectory();

    // Just make sure that the Table has the evictable flag set to true
    this.locators = new int[TARGET_TABLES.length];
    for (int i = 0; i < TARGET_TABLES.length; i++) {
      Table catalog_tbl = getTable(TARGET_TABLES[i]);
      assertTrue(catalog_tbl.getEvictable());
      this.locators[i] = catalog_tbl.getRelativeIndex();
    } // FOR

    Site catalog_site = CollectionUtil.first(catalogContext.sites);
    this.hstore_conf = HStoreConf.singleton();
    this.hstore_conf.site.anticache_enable = true;
    this.hstore_conf.site.anticache_profiling = true;
    this.hstore_conf.site.anticache_check_interval = Integer.MAX_VALUE;
    this.hstore_conf.site.anticache_dir = this.anticache_dir.getAbsolutePath();

    this.hstore_site = createHStoreSite(catalog_site, hstore_conf);
    this.executor = hstore_site.getPartitionExecutor(0);
    assertNotNull(this.executor);
    this.ee = executor.getExecutionEngine();
    assertNotNull(this.executor);
    this.profiler = hstore_site.getAntiCacheManager().getDebugContext().getProfiler(0);
    assertNotNull(profiler);

    this.client = createClient();
  }
Beispiel #2
0
  /**
   * Returns true if we have access to the Volt lib in our local system
   *
   * @return
   */
  public boolean hasVoltLib() throws Exception {
    File obj_dir = FileUtil.findDirectory("obj");

    // Figure out whether we are on a machine that has the native lib
    // we can use right now
    if (obj_dir != null) {
      File so_path = new File(obj_dir.getAbsolutePath() + "/release/nativelibs/libvoltdb.so");
      if (so_path.exists()) {
        System.load(so_path.getAbsolutePath());
        return (true);
      }
    }
    return (false);
  }
Beispiel #3
0
  /** testLoadFromFile */
  public void testLoadFromFile() throws Exception {
    // First make sure that the values aren't the same
    Class<?> confClass = hstore_conf.site.getClass();
    for (String k : properties.keySet()) {
      Field field = confClass.getField(k.split("\\.")[1]);
      assertNotSame(k, properties.get(k), field.get(hstore_conf.site));
    } // FOR

    // Then create a config file
    String contents = "";
    for (Entry<String, Object> e : properties.entrySet()) {
      contents += String.format("%s = %s\n", e.getKey(), e.getValue());
    } // FOR
    File f = FileUtil.writeStringToTempFile(contents, "properties", true);

    // And load it in. Now the values should be what we expect them to be
    hstore_conf.loadFromFile(f);
    for (String k : properties.keySet()) {
      Field field = confClass.getField(k.split("\\.")[1]);
      assertEquals(k, properties.get(k), field.get(hstore_conf.site));
    } // FOR
  }
 @Override
 protected void tearDown() throws Exception {
   if (this.client != null) this.client.close();
   if (this.hstore_site != null) this.hstore_site.shutdown();
   FileUtil.deleteDirectory(this.anticache_dir);
 }
Beispiel #5
0
 /**
  * Utility method to take a string and put it in a file. This is used by this class to write the
  * project file to a temp file, but it also used by some other tests.
  *
  * @param content The content of the file to create.
  * @return A reference to the file created or null on failure.
  */
 public static File writeStringToTempFile(final String content) {
   return FileUtil.writeStringToTempFile(content, "project", true);
 }