コード例 #1
0
  @Test(timeout = 10000)
  public void testAccurateProcessListReturned() throws Exception {
    Map<ServerType, Collection<ProcessReference>> procs = accumulo.getProcesses();

    for (ServerType t :
        new ServerType[] {
          ServerType.MASTER,
          ServerType.TABLET_SERVER,
          ServerType.ZOOKEEPER,
          ServerType.GARBAGE_COLLECTOR
        }) {
      Assert.assertTrue(procs.containsKey(t));
      Collection<ProcessReference> procRefs = procs.get(t);
      Assert.assertTrue(1 <= procRefs.size());

      for (ProcessReference procRef : procRefs) {
        Assert.assertNotNull(procRef);
      }
    }
  }
コード例 #2
0
  @BeforeClass
  public static void setupMiniCluster() throws Exception {
    FileUtils.deleteQuietly(testDir);
    testDir.mkdir();
    Logger.getLogger("org.apache.zookeeper").setLevel(Level.ERROR);

    macConfig = new MiniAccumuloConfig(testDir, passwd);
    macConfig.setNumTservers(1);

    // Turn on the garbage collector
    macConfig.runGC(true);

    // And tweak the settings to make it run often
    Map<String, String> config =
        ImmutableMap.of(
            Property.GC_CYCLE_DELAY.getKey(), "1s", Property.GC_CYCLE_START.getKey(), "0s");
    macConfig.setSiteConfig(config);

    accumulo = new MiniAccumuloCluster(macConfig);
    accumulo.start();
  }
コード例 #3
0
  public static void main(String[] args) throws Exception {
    File tmpDir = new File(FileUtils.getTempDirectory(), "macc-" + UUID.randomUUID().toString());

    try {
      MiniAccumuloCluster la =
          new MiniAccumuloCluster(tmpDir, "pass1234", new HashMap<String, String>());
      la.start();

      System.out.println(
          "\n   ---- Running Accumulo App against accumulo-" + la.getAccumuloVersion() + "\n");

      run(la.getInstanceName(), la.getZookeepers(), new PasswordToken("pass1234"), args);

      System.out.println("\n   ---- Ran Accumulo App\n");

      la.stop();
    } finally {
      FileUtils.deleteQuietly(tmpDir);
    }
  }
コード例 #4
0
  @Test(timeout = 40 * 1000)
  public void testFilesAreGarbageCollected() throws Exception {
    ZooKeeperInstance inst =
        new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZooKeepers());
    Connector c = inst.getConnector("root", new PasswordToken(passwd));

    final String table = "foobar";
    c.tableOperations().create(table);

    final String tableId = c.tableOperations().tableIdMap().get(table);

    BatchWriter bw = null;

    // Add some data
    try {
      bw =
          c.createBatchWriter(
              table,
              new BatchWriterConfig()
                  .setMaxMemory(100000l)
                  .setMaxLatency(100, TimeUnit.MILLISECONDS)
                  .setMaxWriteThreads(1));
      Mutation m = new Mutation("a");
      for (int i = 0; i < 500; i++) {
        m.put("colf", Integer.toString(i), "");
      }

      bw.addMutation(m);
    } finally {
      if (null != bw) {
        bw.close();
      }
    }

    File accumuloDir = new File(testDir, "accumulo");
    File tables = new File(accumuloDir.getAbsolutePath(), "tables");
    File myTable = new File(tables, tableId);

    log.trace(
        "Files before compaction: "
            + FileUtils.listFiles(myTable, new SuffixFileFilter(".rf"), TrueFileFilter.TRUE));

    final boolean flush = true, wait = true;

    // Compact the tables to get some rfiles which we can gc
    c.tableOperations().compact(table, null, null, flush, wait);

    Collection<File> filesAfterCompaction =
        FileUtils.listFiles(myTable, new SuffixFileFilter(".rf"), TrueFileFilter.TRUE);
    int fileCountAfterCompaction = filesAfterCompaction.size();

    log.trace("Files after compaction: " + filesAfterCompaction);

    // Sleep for 10s to let the GC do its thing
    for (int i = 1; i < 10; i++) {
      Thread.sleep(1000);
      filesAfterCompaction =
          FileUtils.listFiles(myTable, new SuffixFileFilter(".rf"), TrueFileFilter.TRUE);

      log.trace("Files in loop: " + filesAfterCompaction);

      int fileCountAfterGCWait = filesAfterCompaction.size();

      if (fileCountAfterGCWait < fileCountAfterCompaction) {
        return;
      }
    }

    Assert.fail("Expected to find less files after compaction and pause for GC");
  }
コード例 #5
0
 @AfterClass
 public static void tearDownMiniCluster() throws Exception {
   accumulo.stop();
 }