/** * 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; }
@Override public Entry filter(Entry entry) { // if orig seq id is set, skip replaying the entry if (entry.getKey().getOrigLogSeqNum() > 0) { return null; } return entry; }