Ejemplo n.º 1
0
 /*
  * Verify that every logs in the table directory has just the specified table and regions.
  */
 private void verifyRecoverEdits(
     final Path tableDir, final byte[] tableName, final Map<byte[], byte[]> regionsMap)
     throws IOException {
   for (FileStatus regionStatus : FSUtils.listStatus(fs, tableDir)) {
     assertTrue(regionStatus.getPath().getName().startsWith(Bytes.toString(tableName)));
     Path regionEdits = HLog.getRegionDirRecoveredEditsDir(regionStatus.getPath());
     byte[] regionName = Bytes.toBytes(regionStatus.getPath().getName());
     assertFalse(regionsMap.containsKey(regionName));
     for (FileStatus logStatus : FSUtils.listStatus(fs, regionEdits)) {
       HLog.Reader reader = HLog.getReader(fs, logStatus.getPath(), conf);
       try {
         HLog.Entry entry;
         while ((entry = reader.next()) != null) {
           HLogKey key = entry.getKey();
           assertArrayEquals(tableName, key.getTablename());
           assertArrayEquals(regionName, key.getEncodedRegionName());
         }
       } finally {
         reader.close();
       }
     }
   }
 }