コード例 #1
0
 @Test
 public void testNoSuchTable() throws IOException {
   final String name = "testNoSuchTable";
   FileSystem fs = FileSystem.get(UTIL.getConfiguration());
   // Cleanup old tests if any detrius laying around.
   Path rootdir = new Path(UTIL.getDataTestDir(), name);
   TableDescriptors htds = new FSTableDescriptors(fs, rootdir);
   assertNull("There shouldn't be any HTD for this table", htds.get("NoSuchTable"));
 }
コード例 #2
0
 @Test
 public void testUpdates() throws IOException {
   final String name = "testUpdates";
   FileSystem fs = FileSystem.get(UTIL.getConfiguration());
   // Cleanup old tests if any detrius laying around.
   Path rootdir = new Path(UTIL.getDataTestDir(), name);
   TableDescriptors htds = new FSTableDescriptors(fs, rootdir);
   HTableDescriptor htd = new HTableDescriptor(name);
   htds.add(htd);
   htds.add(htd);
   htds.add(htd);
 }
コード例 #3
0
    /**
     * returns true if the specified entry must be replicated. We should always replicate meta
     * operations (e.g. flush) and use the user HTD flag to decide whether or not replicate the
     * memstore.
     */
    private boolean requiresReplication(final TableName tableName, final List<Entry> entries)
        throws IOException {
      // unit-tests may not the TableDescriptors, bypass the check and always replicate
      if (tableDescriptors == null) return true;

      Boolean requiresReplication = memstoreReplicationEnabled.getIfPresent(tableName);
      if (requiresReplication == null) {
        // check if the table requires memstore replication
        // some unit-test drop the table, so we should do a bypass check and always replicate.
        HTableDescriptor htd = tableDescriptors.get(tableName);
        requiresReplication = htd == null || htd.hasRegionMemstoreReplication();
        memstoreReplicationEnabled.put(tableName, requiresReplication);
      }

      // if memstore replication is not required, check the entries.
      // meta edits (e.g. flush) must be always replicated.
      if (!requiresReplication) {
        int skipEdits = 0;
        java.util.Iterator<Entry> it = entries.iterator();
        while (it.hasNext()) {
          Entry entry = it.next();
          if (entry.getEdit().isMetaEdit()) {
            requiresReplication = true;
          } else {
            it.remove();
            skipEdits++;
          }
        }
        skippedEdits.addAndGet(skipEdits);
      }
      return requiresReplication;
    }