Author: jdcryans
Date: Fri Oct 30 20:30:26 2009
New Revision: 831445
URL: http://svn.apache.org/viewvc?rev=831445&view=rev
Log:
HBASE-1944 Add a "deferred log flush" attribute to HTD
Modified:
hadoop/hbase/trunk/CHANGES.txt
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Modified: hadoop/hbase/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=831445&r1=831444&r2=831445&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Fri Oct 30 20:30:26 2009
@@ -147,6 +147,7 @@
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
Modified:
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
URL:
http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java?rev=831445&r1=831444&r2=831445&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
(original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/HTableDescriptor.java
Fri Oct 30 20:30:26 2009
@@ -75,6 +75,10 @@
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 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 @@
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;
Modified:
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL:
http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=831445&r1=831444&r2=831445&view=diff
==============================================================================
---
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++
hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Fri Oct 30 20:30:26 2009
@@ -1655,7 +1655,7 @@
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 @@
// 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 @@
} 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 @@
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 @@
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 @@
// 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 @@
throw convertThrowableToIOE(cleanup(t));
}
- this.hlog.sync(isMetaRegion);
- // All have been processed successfully.
+ this.syncWal(region);
return -1;
}
@@ -2348,7 +2341,7 @@
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 @@
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
*/