diff --git a/CHANGES.txt b/CHANGES.txt index 0621f116fbb..9b02bc0751c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -147,6 +147,7 @@ Release 0.21.0 - Unreleased HBASE-1921 When the Master's session times out and there's only one, cluster is wedged HBASE-1942 Update hadoop jars in trunk; update to r831142 HBASE-1943 Remove AgileJSON; unused + HBASE-1944 Add a "deferred log flush" attribute to HTD OPTIMIZATIONS HBASE-410 [testing] Speed up the test suite diff --git a/src/java/org/apache/hadoop/hbase/HTableDescriptor.java b/src/java/org/apache/hadoop/hbase/HTableDescriptor.java index 5aca9417b5a..b871e8439bb 100644 --- a/src/java/org/apache/hadoop/hbase/HTableDescriptor.java +++ b/src/java/org/apache/hadoop/hbase/HTableDescriptor.java @@ -75,6 +75,10 @@ public class HTableDescriptor implements WritableComparable { public static final ImmutableBytesWritable IS_META_KEY = new ImmutableBytesWritable(Bytes.toBytes(IS_META)); + public static final String DEFERRED_LOG_FLUSH = "DEFERRED_LOG_FLUSH"; + public static final ImmutableBytesWritable DEFERRED_LOG_FLUSH_KEY = + new ImmutableBytesWritable(Bytes.toBytes(DEFERRED_LOG_FLUSH)); + // The below are ugly but better than creating them each time till we // replace booleans being saved as Strings with plain booleans. Need a @@ -89,6 +93,8 @@ public class HTableDescriptor implements WritableComparable { public static final int DEFAULT_MEMSTORE_FLUSH_SIZE = 1024*1024*64; public static final int DEFAULT_MAX_FILESIZE = 1024*1024*256; + + public static final boolean DEFAULT_DEFERRED_LOG_FLUSH = false; private volatile Boolean meta = null; private volatile Boolean root = null; @@ -366,6 +372,21 @@ public class HTableDescriptor implements WritableComparable { setValue(READONLY_KEY, readOnly? TRUE: FALSE); } + /** + * @return true if that table's log is hflush by other means + */ + public boolean isDeferredLogFlush() { + return isSomething(DEFERRED_LOG_FLUSH_KEY, DEFAULT_DEFERRED_LOG_FLUSH); + } + + /** + * @param isDeferredLogFlush true if that table's log is hlfush by oter means + * only. + */ + public void setDeferredLogFlush(final boolean isDeferredLogFlush) { + setValue(DEFERRED_LOG_FLUSH_KEY, isDeferredLogFlush? TRUE: FALSE); + } + /** @return name of table */ public byte [] getName() { return name; diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 084311844b5..10fcbbf51ae 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -1655,7 +1655,7 @@ public class HRegionServer implements HConstants, HRegionInterface, cacheFlusher.reclaimMemStoreMemory(); region.put(put, getLockFromId(put.getLockId())); - this.hlog.sync(region.getRegionInfo().isMetaRegion()); + this.syncWal(region); } catch (Throwable t) { throw convertThrowableToIOE(cleanup(t)); } @@ -1666,11 +1666,9 @@ public class HRegionServer implements HConstants, HRegionInterface, // Count of Puts processed. int i = 0; checkOpen(); - boolean isMetaRegion = false; + HRegion region = null; try { - HRegion region = getRegion(regionName); - isMetaRegion = region.getRegionInfo().isMetaRegion(); - + region = getRegion(regionName); this.cacheFlusher.reclaimMemStoreMemory(); Integer[] locks = new Integer[puts.length]; for (i = 0; i < puts.length; i++) { @@ -1681,19 +1679,16 @@ public class HRegionServer implements HConstants, HRegionInterface, } catch (WrongRegionException ex) { LOG.debug("Batch puts: " + i, ex); + return i; } catch (NotServingRegionException ex) { + return i; } catch (Throwable t) { throw convertThrowableToIOE(cleanup(t)); } // All have been processed successfully. - this.hlog.sync(isMetaRegion); - - if (i == puts.length) { - return -1; - } else { - return i; - } + this.syncWal(region); + return -1; } /** @@ -1722,7 +1717,7 @@ public class HRegionServer implements HConstants, HRegionInterface, boolean retval = region.checkAndPut(row, family, qualifier, value, put, getLockFromId(put.getLockId()), true); - this.hlog.sync(region.getRegionInfo().isMetaRegion()); + this.syncWal(region); return retval; } catch (Throwable t) { throw convertThrowableToIOE(cleanup(t)); @@ -1871,7 +1866,7 @@ public class HRegionServer implements HConstants, HRegionInterface, HRegion region = getRegion(regionName); region.delete(delete, lid, writeToWAL); - this.hlog.sync(region.getRegionInfo().isMetaRegion()); + this.syncWal(region); } catch (WrongRegionException ex) { } catch (NotServingRegionException ex) { // ignore @@ -1885,13 +1880,12 @@ public class HRegionServer implements HConstants, HRegionInterface, // Count of Deletes processed. int i = 0; checkOpen(); - boolean isMetaRegion = false; + HRegion region = null; try { boolean writeToWAL = true; this.cacheFlusher.reclaimMemStoreMemory(); Integer[] locks = new Integer[deletes.length]; - HRegion region = getRegion(regionName); - isMetaRegion = region.getRegionInfo().isMetaRegion(); + region = getRegion(regionName); for (i = 0; i < deletes.length; i++) { this.requestCount.incrementAndGet(); @@ -1907,8 +1901,7 @@ public class HRegionServer implements HConstants, HRegionInterface, throw convertThrowableToIOE(cleanup(t)); } - this.hlog.sync(isMetaRegion); - // All have been processed successfully. + this.syncWal(region); return -1; } @@ -2348,7 +2341,7 @@ public class HRegionServer implements HConstants, HRegionInterface, long retval = region.incrementColumnValue(row, family, qualifier, amount, writeToWAL); - this.hlog.sync(region.getRegionInfo().isMetaRegion()); + syncWal(region); return retval; } catch (IOException e) { @@ -2372,6 +2365,13 @@ public class HRegionServer implements HConstants, HRegionInterface, return serverInfo; } + // Sync the WAL if the table permits it + private void syncWal(HRegion region) { + if(!region.getTableDesc().isDeferredLogFlush()) { + this.hlog.sync(region.getRegionInfo().isMetaRegion()); + } + } + /** * @param args */