HBASE-1944 Add a "deferred log flush" attribute to HTD

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@831445 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2009-10-30 20:30:26 +00:00
parent 502cfe7b5d
commit beaac2c27f
3 changed files with 42 additions and 20 deletions

View File

@ -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-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-1942 Update hadoop jars in trunk; update to r831142
HBASE-1943 Remove AgileJSON; unused HBASE-1943 Remove AgileJSON; unused
HBASE-1944 Add a "deferred log flush" attribute to HTD
OPTIMIZATIONS OPTIMIZATIONS
HBASE-410 [testing] Speed up the test suite HBASE-410 [testing] Speed up the test suite

View File

@ -75,6 +75,10 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
public static final ImmutableBytesWritable IS_META_KEY = public static final ImmutableBytesWritable IS_META_KEY =
new ImmutableBytesWritable(Bytes.toBytes(IS_META)); 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 // The below are ugly but better than creating them each time till we
// replace booleans being saved as Strings with plain booleans. Need a // replace booleans being saved as Strings with plain booleans. Need a
@ -89,6 +93,8 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
public static final int DEFAULT_MEMSTORE_FLUSH_SIZE = 1024*1024*64; public static final int DEFAULT_MEMSTORE_FLUSH_SIZE = 1024*1024*64;
public static final int DEFAULT_MAX_FILESIZE = 1024*1024*256; 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 meta = null;
private volatile Boolean root = null; private volatile Boolean root = null;
@ -366,6 +372,21 @@ public class HTableDescriptor implements WritableComparable<HTableDescriptor> {
setValue(READONLY_KEY, readOnly? TRUE: FALSE); 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 */ /** @return name of table */
public byte [] getName() { public byte [] getName() {
return name; return name;

View File

@ -1655,7 +1655,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
cacheFlusher.reclaimMemStoreMemory(); cacheFlusher.reclaimMemStoreMemory();
region.put(put, getLockFromId(put.getLockId())); region.put(put, getLockFromId(put.getLockId()));
this.hlog.sync(region.getRegionInfo().isMetaRegion()); this.syncWal(region);
} catch (Throwable t) { } catch (Throwable t) {
throw convertThrowableToIOE(cleanup(t)); throw convertThrowableToIOE(cleanup(t));
} }
@ -1666,11 +1666,9 @@ public class HRegionServer implements HConstants, HRegionInterface,
// Count of Puts processed. // Count of Puts processed.
int i = 0; int i = 0;
checkOpen(); checkOpen();
boolean isMetaRegion = false; HRegion region = null;
try { try {
HRegion region = getRegion(regionName); region = getRegion(regionName);
isMetaRegion = region.getRegionInfo().isMetaRegion();
this.cacheFlusher.reclaimMemStoreMemory(); this.cacheFlusher.reclaimMemStoreMemory();
Integer[] locks = new Integer[puts.length]; Integer[] locks = new Integer[puts.length];
for (i = 0; i < puts.length; i++) { for (i = 0; i < puts.length; i++) {
@ -1681,19 +1679,16 @@ public class HRegionServer implements HConstants, HRegionInterface,
} catch (WrongRegionException ex) { } catch (WrongRegionException ex) {
LOG.debug("Batch puts: " + i, ex); LOG.debug("Batch puts: " + i, ex);
return i;
} catch (NotServingRegionException ex) { } catch (NotServingRegionException ex) {
return i;
} catch (Throwable t) { } catch (Throwable t) {
throw convertThrowableToIOE(cleanup(t)); throw convertThrowableToIOE(cleanup(t));
} }
// All have been processed successfully. // All have been processed successfully.
this.hlog.sync(isMetaRegion); this.syncWal(region);
return -1;
if (i == puts.length) {
return -1;
} else {
return i;
}
} }
/** /**
@ -1722,7 +1717,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
boolean retval = region.checkAndPut(row, family, qualifier, value, put, boolean retval = region.checkAndPut(row, family, qualifier, value, put,
getLockFromId(put.getLockId()), true); getLockFromId(put.getLockId()), true);
this.hlog.sync(region.getRegionInfo().isMetaRegion()); this.syncWal(region);
return retval; return retval;
} catch (Throwable t) { } catch (Throwable t) {
throw convertThrowableToIOE(cleanup(t)); throw convertThrowableToIOE(cleanup(t));
@ -1871,7 +1866,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
HRegion region = getRegion(regionName); HRegion region = getRegion(regionName);
region.delete(delete, lid, writeToWAL); region.delete(delete, lid, writeToWAL);
this.hlog.sync(region.getRegionInfo().isMetaRegion()); this.syncWal(region);
} catch (WrongRegionException ex) { } catch (WrongRegionException ex) {
} catch (NotServingRegionException ex) { } catch (NotServingRegionException ex) {
// ignore // ignore
@ -1885,13 +1880,12 @@ public class HRegionServer implements HConstants, HRegionInterface,
// Count of Deletes processed. // Count of Deletes processed.
int i = 0; int i = 0;
checkOpen(); checkOpen();
boolean isMetaRegion = false; HRegion region = null;
try { try {
boolean writeToWAL = true; boolean writeToWAL = true;
this.cacheFlusher.reclaimMemStoreMemory(); this.cacheFlusher.reclaimMemStoreMemory();
Integer[] locks = new Integer[deletes.length]; Integer[] locks = new Integer[deletes.length];
HRegion region = getRegion(regionName); region = getRegion(regionName);
isMetaRegion = region.getRegionInfo().isMetaRegion();
for (i = 0; i < deletes.length; i++) { for (i = 0; i < deletes.length; i++) {
this.requestCount.incrementAndGet(); this.requestCount.incrementAndGet();
@ -1907,8 +1901,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
throw convertThrowableToIOE(cleanup(t)); throw convertThrowableToIOE(cleanup(t));
} }
this.hlog.sync(isMetaRegion); this.syncWal(region);
// All have been processed successfully.
return -1; return -1;
} }
@ -2348,7 +2341,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
long retval = region.incrementColumnValue(row, family, qualifier, amount, long retval = region.incrementColumnValue(row, family, qualifier, amount,
writeToWAL); writeToWAL);
this.hlog.sync(region.getRegionInfo().isMetaRegion()); syncWal(region);
return retval; return retval;
} catch (IOException e) { } catch (IOException e) {
@ -2372,6 +2365,13 @@ public class HRegionServer implements HConstants, HRegionInterface,
return serverInfo; 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 * @param args
*/ */