Esempio n. 1
0
  /**
   * Assert that getSplitEditFilesSorted returns files in expected order and that it skips
   * moved-aside files.
   *
   * @throws IOException
   */
  @Test
  public void testGetSplitEditFilesSorted() throws IOException {
    FileSystem fs = FileSystem.get(util.getConfiguration());
    Path regiondir = util.getDataTestDir("regiondir");
    fs.delete(regiondir, true);
    fs.mkdirs(regiondir);
    Path recoverededits = WALSplitter.getRegionDirRecoveredEditsDir(regiondir);
    String first = WALSplitter.formatRecoveredEditsFileName(-1);
    createFile(fs, recoverededits, first);
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(0));
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(1));
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(11));
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(2));
    createFile(fs, recoverededits, WALSplitter.formatRecoveredEditsFileName(50));
    String last = WALSplitter.formatRecoveredEditsFileName(Long.MAX_VALUE);
    createFile(fs, recoverededits, last);
    createFile(
        fs, recoverededits, Long.toString(Long.MAX_VALUE) + "." + System.currentTimeMillis());

    final Configuration walConf = new Configuration(util.getConfiguration());
    FSUtils.setRootDir(walConf, regiondir);
    (new WALFactory(walConf, null, "dummyLogName")).getWAL(new byte[] {}, null);

    NavigableSet<Path> files = WALSplitter.getSplitEditFilesSorted(fs, regiondir);
    assertEquals(7, files.size());
    assertEquals(files.pollFirst().getName(), first);
    assertEquals(files.pollLast().getName(), last);
    assertEquals(files.pollFirst().getName(), WALSplitter.formatRecoveredEditsFileName(0));
    assertEquals(files.pollFirst().getName(), WALSplitter.formatRecoveredEditsFileName(1));
    assertEquals(files.pollFirst().getName(), WALSplitter.formatRecoveredEditsFileName(2));
    assertEquals(files.pollFirst().getName(), WALSplitter.formatRecoveredEditsFileName(11));
  }
Esempio n. 2
0
  /**
   * Assert that getSplitEditFilesSorted returns files in expected order and that it skips
   * moved-aside files.
   *
   * @throws IOException
   */
  @Test
  public void testGetSplitEditFilesSorted() throws IOException {
    FileSystem fs = FileSystem.get(util.getConfiguration());
    Path regiondir = util.getDataTestDir("regiondir");
    fs.delete(regiondir, true);
    fs.mkdirs(regiondir);
    Path recoverededits = HLogUtil.getRegionDirRecoveredEditsDir(regiondir);
    String first = HLogSplitter.formatRecoveredEditsFileName(-1);
    createFile(fs, recoverededits, first);
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(0));
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(1));
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(11));
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(2));
    createFile(fs, recoverededits, HLogSplitter.formatRecoveredEditsFileName(50));
    String last = HLogSplitter.formatRecoveredEditsFileName(Long.MAX_VALUE);
    createFile(fs, recoverededits, last);
    createFile(
        fs, recoverededits, Long.toString(Long.MAX_VALUE) + "." + System.currentTimeMillis());

    HLogFactory.createHLog(fs, regiondir, "dummyLogName", util.getConfiguration());
    NavigableSet<Path> files = HLogUtil.getSplitEditFilesSorted(fs, regiondir);
    assertEquals(7, files.size());
    assertEquals(files.pollFirst().getName(), first);
    assertEquals(files.pollLast().getName(), last);
    assertEquals(files.pollFirst().getName(), HLogSplitter.formatRecoveredEditsFileName(0));
    assertEquals(files.pollFirst().getName(), HLogSplitter.formatRecoveredEditsFileName(1));
    assertEquals(files.pollFirst().getName(), HLogSplitter.formatRecoveredEditsFileName(2));
    assertEquals(files.pollFirst().getName(), HLogSplitter.formatRecoveredEditsFileName(11));
  }
 @SuppressWarnings("EmptyCatchBlock")
 static void ensureNotDirectlyModifiable(NavigableSet<Integer> unmod) {
   try {
     unmod.add(4);
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.remove(4);
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.addAll(Collections.singleton(4));
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.pollFirst();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.pollLast();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     Iterator<Integer> iterator = unmod.iterator();
     iterator.next();
     iterator.remove();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     Iterator<Integer> iterator = unmod.descendingIterator();
     iterator.next();
     iterator.remove();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
 }
Esempio n. 4
0
 @GwtIncompatible("NavigableSet")
 void ensureNotDirectlyModifiable(NavigableSet<Integer> unmod) {
   try {
     unmod.add(4);
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.remove(4);
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.addAll(Collections.singleton(4));
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.pollFirst();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     unmod.pollLast();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     Iterator<Integer> iterator = unmod.iterator();
     iterator.next();
     iterator.remove();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
   try {
     Iterator<Integer> iterator = unmod.descendingIterator();
     iterator.next();
     iterator.remove();
     fail("UnsupportedOperationException expected");
   } catch (UnsupportedOperationException expected) {
   }
 }