HBASE-10018 Change the location prefetch

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1585518 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
nkeywal 2014-04-07 16:55:45 +00:00
parent c9864322c5
commit 4b762ee841
15 changed files with 128 additions and 331 deletions

View File

@ -270,7 +270,7 @@ end
# Get configuration instance
def getConfiguration()
config = HBaseConfiguration.create()
# No prefetching on .META.
# No prefetching on .META. This is for versions pre 0.99. Newer versions do not prefetch.
config.setInt("hbase.client.prefetch.limit", 1)
# Make a config that retries at short intervals many times
config.setInt("hbase.client.pause", 500)

View File

@ -36,7 +36,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
@ -421,39 +420,6 @@ class ConnectionManager {
}
}
/**
* It is provided for unit test cases which verify the behavior of region
* location cache prefetch.
* @return Number of cached regions for the table.
* @throws ZooKeeperConnectionException
*/
static int getCachedRegionCount(Configuration conf, final TableName tableName)
throws IOException {
return execute(new HConnectable<Integer>(conf) {
@Override
public Integer connect(HConnection connection) {
return ((HConnectionImplementation)connection).getNumberOfCachedRegionLocations(tableName);
}
});
}
/**
* It's provided for unit test cases which verify the behavior of region
* location cache prefetch.
* @return true if the region where the table and row reside is cached.
* @throws ZooKeeperConnectionException
*/
static boolean isRegionCached(Configuration conf,
final TableName tableName,
final byte[] row)
throws IOException {
return execute(new HConnectable<Boolean>(conf) {
@Override
public Boolean connect(HConnection connection) {
return ((HConnectionImplementation) connection).isRegionCached(tableName, row);
}
});
}
/**
* This convenience method invokes the given {@link HConnectable#connect}
@ -500,7 +466,6 @@ class ConnectionManager {
private final int numTries;
final int rpcTimeout;
private NonceGenerator nonceGenerator = null;
private final int prefetchRegionLimit;
private final AsyncProcess asyncProcess;
private volatile boolean closed;
@ -546,11 +511,6 @@ class ConnectionManager {
// The access to this attribute must be protected by a lock on cachedRegionLocations
private final Set<ServerName> cachedServers = new ConcurrentSkipListSet<ServerName>();
// region cache prefetch is enabled by default. this set contains all
// tables whose region cache prefetch are disabled.
private final Set<Integer> regionCachePrefetchDisabledTables =
new CopyOnWriteArraySet<Integer>();
private int refCount;
// indicates whether this connection's life cycle is managed (by us)
@ -637,10 +597,6 @@ class ConnectionManager {
this.nonceGenerator = new NoNonceGenerator();
}
this.asyncProcess = createAsyncProcess(this.conf);
this.prefetchRegionLimit = conf.getInt(
HConstants.HBASE_CLIENT_PREFETCH_LIMIT,
HConstants.DEFAULT_HBASE_CLIENT_PREFETCH_LIMIT);
}
@Override
@ -1029,62 +985,7 @@ class ConnectionManager {
return this.registry.getMetaRegionLocation();
} else {
// Region not in the cache - have to go to the meta RS
return locateRegionInMeta(TableName.META_TABLE_NAME, tableName, row,
useCache, userRegionLock, retry);
}
}
/*
* Search hbase:meta for the HRegionLocation info that contains the table and
* row we're seeking. It will prefetch certain number of regions info and
* save them to the global region cache.
*/
private void prefetchRegionCache(final TableName tableName,
final byte[] row) {
// Implement a new visitor for MetaScanner, and use it to walk through
// the hbase:meta
MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
public boolean processRow(Result result) throws IOException {
try {
HRegionInfo regionInfo = MetaScanner.getHRegionInfo(result);
if (regionInfo == null) {
return true;
}
// possible we got a region of a different table...
if (!regionInfo.getTable().equals(tableName)) {
return false; // stop scanning
}
if (regionInfo.isOffline()) {
// don't cache offline regions
return true;
}
ServerName serverName = HRegionInfo.getServerName(result);
if (serverName == null) {
return true; // don't cache it
}
// instantiate the location
long seqNum = HRegionInfo.getSeqNumDuringOpen(result);
HRegionLocation loc = new HRegionLocation(regionInfo, serverName, seqNum);
// cache this meta entry
cacheLocation(tableName, null, loc);
return true;
} catch (RuntimeException e) {
throw new IOException(e);
}
}
};
try {
// pre-fetch certain number of regions info at region cache.
MetaScanner.metaScan(conf, this, visitor, tableName, row,
this.prefetchRegionLimit, TableName.META_TABLE_NAME);
} catch (IOException e) {
if (ExceptionUtil.isInterrupt(e)) {
Thread.currentThread().interrupt();
} else {
LOG.warn("Encountered problems when prefetch hbase:meta table: ", e);
}
return locateRegionInMeta(tableName, row, useCache, retry);
}
}
@ -1092,73 +993,58 @@ class ConnectionManager {
* Search the hbase:meta table for the HRegionLocation
* info that contains the table and row we're seeking.
*/
private HRegionLocation locateRegionInMeta(final TableName parentTable,
final TableName tableName, final byte [] row, boolean useCache,
Object regionLockObject, boolean retry)
throws IOException {
HRegionLocation location;
private HRegionLocation locateRegionInMeta(TableName tableName, byte[] row,
boolean useCache, boolean retry) throws IOException {
// If we are supposed to be using the cache, look in the cache to see if
// we already have the region.
if (useCache) {
location = getCachedLocation(tableName, row);
HRegionLocation location = getCachedLocation(tableName, row);
if (location != null) {
return location;
}
}
int localNumRetries = retry ? numTries : 1;
// build the key of the meta region we should be looking for.
// the extra 9's on the end are necessary to allow "exact" matches
// without knowing the precise region names.
byte [] metaKey = HRegionInfo.createRegionName(tableName, row,
HConstants.NINES, false);
byte[] metaKey = HRegionInfo.createRegionName(tableName, row, HConstants.NINES, false);
Scan s = new Scan();
s.setReversed(true);
s.setStartRow(metaKey);
s.setSmall(true);
s.setCaching(1);
HConnection connection = ConnectionManager.getConnectionInternal(conf);
int localNumRetries = (retry ? numTries : 1);
for (int tries = 0; true; tries++) {
if (tries >= localNumRetries) {
throw new NoServerForRegionException("Unable to find region for "
+ Bytes.toStringBinary(row) + " after " + numTries + " tries.");
+ Bytes.toStringBinary(row) + " in " + tableName +
" after " + localNumRetries + " tries.");
}
if (useCache) {
HRegionLocation location = getCachedLocation(tableName, row);
if (location != null) {
return location;
}
}
HRegionLocation metaLocation = null;
// Query the meta region
try {
// locate the meta region
metaLocation = locateRegion(parentTable, metaKey, true, false);
// If null still, go around again.
if (metaLocation == null) continue;
ClientService.BlockingInterface service = getClient(metaLocation.getServerName());
Result regionInfoRow;
// This block guards against two threads trying to load the meta
// region at the same time. The first will load the meta region and
// the second will use the value that the first one found.
if (useCache) {
if (TableName.META_TABLE_NAME.equals(parentTable) &&
getRegionCachePrefetch(tableName)) {
synchronized (regionLockObject) {
// Check the cache again for a hit in case some other thread made the
// same query while we were waiting on the lock.
location = getCachedLocation(tableName, row);
if (location != null) {
return location;
}
// If the parent table is META, we may want to pre-fetch some
// region info into the global region cache for this table.
prefetchRegionCache(tableName, row);
}
Result regionInfoRow = null;
ReversedClientScanner rcs = null;
try {
rcs = new ClientSmallReversedScanner(conf, s, TableName.META_TABLE_NAME, connection);
regionInfoRow = rcs.next();
} finally {
if (rcs != null) {
rcs.close();
}
location = getCachedLocation(tableName, row);
if (location != null) {
return location;
}
} else {
// If we are not supposed to be using the cache, delete any existing cached location
// so it won't interfere.
forceDeleteCachedLocation(tableName, row);
}
// Query the meta region for the location of the meta region
regionInfoRow = ProtobufUtil.getRowOrBefore(service,
metaLocation.getRegionInfo().getRegionName(), metaKey,
HConstants.CATALOG_FAMILY);
if (regionInfoRow == null) {
throw new TableNotFoundException(tableName);
}
@ -1167,7 +1053,7 @@ class ConnectionManager {
HRegionInfo regionInfo = MetaScanner.getHRegionInfo(regionInfoRow);
if (regionInfo == null) {
throw new IOException("HRegionInfo was null or empty in " +
parentTable + ", row=" + regionInfoRow);
TableName.META_TABLE_NAME + ", row=" + regionInfoRow);
}
// possible we got a region of a different table...
@ -1191,7 +1077,7 @@ class ConnectionManager {
ServerName serverName = HRegionInfo.getServerName(regionInfoRow);
if (serverName == null) {
throw new NoServerForRegionException("No server address listed " +
"in " + parentTable + " for region " +
"in " + TableName.META_TABLE_NAME + " for region " +
regionInfo.getRegionNameAsString() + " containing row " +
Bytes.toStringBinary(row));
}
@ -1203,10 +1089,11 @@ class ConnectionManager {
}
// Instantiate the location
location = new HRegionLocation(regionInfo, serverName,
HRegionLocation location = new HRegionLocation(regionInfo, serverName,
HRegionInfo.getSeqNumDuringOpen(regionInfoRow));
cacheLocation(tableName, null, location);
return location;
} catch (TableNotFoundException e) {
// if we got this error, probably means the table just plain doesn't
// exist. rethrow the error immediately. this should always be coming
@ -1218,13 +1105,12 @@ class ConnectionManager {
if (e instanceof RemoteException) {
e = ((RemoteException)e).unwrapRemoteException();
}
if (tries < numTries - 1) {
if (tries < localNumRetries - 1) {
if (LOG.isDebugEnabled()) {
LOG.debug("locateRegionInMeta parentTable=" +
parentTable + ", metaLocation=" +
((metaLocation == null)? "null": "{" + metaLocation + "}") +
TableName.META_TABLE_NAME + ", metaLocation=" +
", attempt=" + tries + " of " +
this.numTries + " failed; retrying after sleep of " +
localNumRetries + " failed; retrying after sleep of " +
ConnectionUtils.getPauseTime(this.pause, tries) + " because: " + e.getMessage());
}
} else {
@ -1233,7 +1119,7 @@ class ConnectionManager {
// Only relocate the parent region if necessary
if(!(e instanceof RegionOfflineException ||
e instanceof NoServerForRegionException)) {
relocateRegion(parentTable, metaKey);
relocateRegion(TableName.META_TABLE_NAME, metaKey);
}
}
try{
@ -2336,30 +2222,26 @@ class ConnectionManager {
}
@Override
public void setRegionCachePrefetch(final TableName tableName,
final boolean enable) {
if (!enable) {
regionCachePrefetchDisabledTables.add(Bytes.mapKey(tableName.getName()));
}
else {
regionCachePrefetchDisabledTables.remove(Bytes.mapKey(tableName.getName()));
}
@Deprecated
public void setRegionCachePrefetch(final TableName tableName, final boolean enable) {
}
@Override
@Deprecated
public void setRegionCachePrefetch(final byte[] tableName,
final boolean enable) {
setRegionCachePrefetch(TableName.valueOf(tableName), enable);
}
@Override
@Deprecated
public boolean getRegionCachePrefetch(TableName tableName) {
return !regionCachePrefetchDisabledTables.contains(Bytes.mapKey(tableName.getName()));
return false;
}
@Override
@Deprecated
public boolean getRegionCachePrefetch(byte[] tableName) {
return getRegionCachePrefetch(TableName.valueOf(tableName));
return false;
}
@Override

View File

@ -35,7 +35,6 @@ import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.catalog.CatalogTracker;
import org.apache.hadoop.hbase.client.coprocessor.Batch;
import org.apache.hadoop.hbase.client.coprocessor.Batch.Callback;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService;
import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService;
import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.MasterService;
@ -466,27 +465,28 @@ public interface HConnection extends Abortable, Closeable {
Batch.Callback<R> callback) throws IOException, InterruptedException;
/**
* Enable or disable region cache prefetch for the table. It will be
* applied for the given table's all HTable instances within this
* connection. By default, the cache prefetch is enabled.
* @param tableName name of table to configure.
* @param enable Set to true to enable region cache prefetch.
*/
* @deprecated does nothing since since 0.99
**/
@Deprecated
public void setRegionCachePrefetch(final TableName tableName,
final boolean enable);
/**
* @deprecated does nothing since 0.99
**/
@Deprecated
public void setRegionCachePrefetch(final byte[] tableName,
final boolean enable);
/**
* Check whether region cache prefetch is enabled or not.
* @param tableName name of table to check
* @return true if table's region cache prefetch is enabled. Otherwise
* it is disabled.
*/
* @deprecated always return false since 0.99
**/
@Deprecated
boolean getRegionCachePrefetch(final TableName tableName);
/**
* @deprecated always return false since 0.99
**/
@Deprecated
boolean getRegionCachePrefetch(final byte[] tableName);

View File

@ -45,7 +45,6 @@ class HConnectionKey {
HConstants.ZOOKEEPER_RECOVERABLE_WAITTIME,
HConstants.HBASE_CLIENT_PAUSE, HConstants.HBASE_CLIENT_RETRIES_NUMBER,
HConstants.HBASE_RPC_TIMEOUT_KEY,
HConstants.HBASE_CLIENT_PREFETCH_LIMIT,
HConstants.HBASE_META_SCANNER_CACHING,
HConstants.HBASE_CLIENT_INSTANCE_ID,
HConstants.RPC_CODEC_CONF_KEY };

View File

@ -716,8 +716,10 @@ public class HTable implements HTableInterface {
/**
* {@inheritDoc}
* @deprecated Use reversed scan instead.
*/
@Override
@Deprecated
public Result getRowOrBefore(final byte[] row, final byte[] family)
throws IOException {
RegionServerCallable<Result> callable = new RegionServerCallable<Result>(this.connection,
@ -1492,22 +1494,20 @@ public class HTable implements HTableInterface {
* @param enable Set to true to enable region cache prefetch. Or set to
* false to disable it.
* @throws IOException
* @deprecated does nothing since 0.99
*/
@Deprecated
public static void setRegionCachePrefetch(final byte[] tableName,
final boolean enable) throws IOException {
setRegionCachePrefetch(TableName.valueOf(tableName), enable);
final boolean enable) throws IOException {
}
/**
* @deprecated does nothing since 0.99
*/
@Deprecated
public static void setRegionCachePrefetch(
final TableName tableName,
final boolean enable) throws IOException {
HConnectionManager.execute(new HConnectable<Void>(HBaseConfiguration.create()) {
@Override
public Void connect(HConnection connection) throws IOException {
connection.setRegionCachePrefetch(tableName, enable);
return null;
}
});
}
/**
@ -1519,22 +1519,20 @@ public class HTable implements HTableInterface {
* @param enable Set to true to enable region cache prefetch. Or set to
* false to disable it.
* @throws IOException
* @deprecated does nothing since 0.99
*/
@Deprecated
public static void setRegionCachePrefetch(final Configuration conf,
final byte[] tableName, final boolean enable) throws IOException {
setRegionCachePrefetch(conf, TableName.valueOf(tableName), enable);
}
/**
* @deprecated does nothing since 0.99
*/
@Deprecated
public static void setRegionCachePrefetch(final Configuration conf,
final TableName tableName,
final boolean enable) throws IOException {
HConnectionManager.execute(new HConnectable<Void>(conf) {
@Override
public Void connect(HConnection connection) throws IOException {
connection.setRegionCachePrefetch(tableName, enable);
return null;
}
});
}
/**
@ -1544,20 +1542,21 @@ public class HTable implements HTableInterface {
* @return true if table's region cache prefecth is enabled. Otherwise
* it is disabled.
* @throws IOException
* @deprecated always return false since 0.99
*/
@Deprecated
public static boolean getRegionCachePrefetch(final Configuration conf,
final byte[] tableName) throws IOException {
return getRegionCachePrefetch(conf, TableName.valueOf(tableName));
return false;
}
/**
* @deprecated always return false since 0.99
*/
@Deprecated
public static boolean getRegionCachePrefetch(final Configuration conf,
final TableName tableName) throws IOException {
return HConnectionManager.execute(new HConnectable<Boolean>(conf) {
@Override
public Boolean connect(HConnection connection) throws IOException {
return connection.getRegionCachePrefetch(tableName);
}
});
return false;
}
/**
@ -1566,20 +1565,20 @@ public class HTable implements HTableInterface {
* @return true if table's region cache prefecth is enabled. Otherwise
* it is disabled.
* @throws IOException
* @deprecated always return false since 0.99
*/
@Deprecated
public static boolean getRegionCachePrefetch(final byte[] tableName) throws IOException {
return getRegionCachePrefetch(TableName.valueOf(tableName));
return false;
}
/**
* @deprecated always return false since 0.99
*/
@Deprecated
public static boolean getRegionCachePrefetch(
final TableName tableName) throws IOException {
return HConnectionManager.execute(new HConnectable<Boolean>(
HBaseConfiguration.create()) {
@Override
public Boolean connect(HConnection connection) throws IOException {
return connection.getRegionCachePrefetch(tableName);
}
});
return false;
}
/**

View File

@ -196,7 +196,7 @@ public interface HTableInterface extends Closeable {
* @since 0.20.0
*
* @deprecated As of version 0.92 this method is deprecated without
* replacement.
* replacement. Since version 0.96+, you can use reversed scan.
* getRowOrBefore is used internally to find entries in hbase:meta and makes
* various assumptions about the table (which are true for hbase:meta but not
* in general) to be efficient.

View File

@ -407,6 +407,7 @@ public class HTablePool implements Closeable {
@Override
@SuppressWarnings("deprecation")
@Deprecated
public Result getRowOrBefore(byte[] row, byte[] family) throws IOException {
checkState();
return table.getRowOrBefore(row, family);

View File

@ -127,21 +127,24 @@ public class MetaScanner {
final MetaScannerVisitor visitor, final TableName tableName,
final byte[] row, final int rowLimit, final TableName metaTableName)
throws IOException {
int rowUpperLimit = rowLimit > 0 ? rowLimit: Integer.MAX_VALUE;
HTable metaTable;
if (connection == null) {
metaTable = new HTable(configuration, TableName.META_TABLE_NAME, null);
} else {
metaTable = new HTable(TableName.META_TABLE_NAME, connection, null);
if (connection == null){
connection = ConnectionManager.getConnectionInternal(configuration);
}
int rowUpperLimit = rowLimit > 0 ? rowLimit: Integer.MAX_VALUE;
// Calculate startrow for scan.
byte[] startRow;
ResultScanner scanner = null;
try {
if (row != null) {
// Scan starting at a particular row in a particular table
byte[] searchRow = HRegionInfo.createRegionName(tableName, row, HConstants.NINES, false);
HTable metaTable;
metaTable = new HTable(TableName.META_TABLE_NAME, connection, null);
Result startRowResult = metaTable.getRowOrBefore(searchRow, HConstants.CATALOG_FAMILY);
metaTable.close();
if (startRowResult == null) {
throw new TableNotFoundException("Cannot find row in "+ TableName
.META_TABLE_NAME.getNameAsString()+" for table: "
@ -175,8 +178,10 @@ public class MetaScanner {
Bytes.toStringBinary(startRow) + " for max=" + rowUpperLimit + " with caching=" + rows);
}
// Run the scan
scanner = metaTable.getScanner(scan);
Result result = null;
scanner = (scan.isSmall() ?
new ClientSmallScanner(configuration, scan, TableName.META_TABLE_NAME, connection) :
new ClientScanner(configuration, scan, TableName.META_TABLE_NAME, connection));
Result result;
int processedRows = 0;
while ((result = scanner.next()) != null) {
if (visitor != null) {
@ -202,14 +207,6 @@ public class MetaScanner {
LOG.debug("Got exception in closing the meta scanner visitor", t);
}
}
if (metaTable != null) {
try {
metaTable.close();
} catch (Throwable t) {
ExceptionUtil.rethrowIfInterrupt(t);
LOG.debug("Got exception in closing the meta table", t);
}
}
}
}

View File

@ -1437,7 +1437,9 @@ public final class ProtobufUtil {
* @param family
* @return the row or the closestRowBefore if it doesn't exist
* @throws IOException
* @deprecated since 0.99 - use reversed scanner instead.
*/
@Deprecated
public static Result getRowOrBefore(final ClientService.BlockingInterface client,
final byte[] regionName, final byte[] row,
final byte[] family) throws IOException {

View File

@ -628,17 +628,6 @@ public final class HConstants {
*/
public static int DEFAULT_HBASE_CLIENT_RETRIES_NUMBER = 31;
/**
* Parameter name for client prefetch limit, used as the maximum number of regions
* info that will be prefetched.
*/
public static String HBASE_CLIENT_PREFETCH_LIMIT = "hbase.client.prefetch.limit";
/**
* Default value of {@link #HBASE_CLIENT_PREFETCH_LIMIT}.
*/
public static int DEFAULT_HBASE_CLIENT_PREFETCH_LIMIT = 10;
/**
* Parameter name to set the default scanner caching for all clients.
*/

View File

@ -126,6 +126,7 @@ public class HTableWrapper implements HTableInterface {
}
}
@Deprecated
public Result getRowOrBefore(byte[] row, byte[] family)
throws IOException {
return table.getRowOrBefore(row, family);

View File

@ -77,7 +77,6 @@ public class TestClientTimeouts {
*/
@Test
public void testAdminTimeout() throws Exception {
long lastLimit = HConstants.DEFAULT_HBASE_CLIENT_PREFETCH_LIMIT;
HConnection lastConnection = null;
boolean lastFailed = false;
int initialInvocations = RandomTimeoutBlockingRpcChannel.invokations.get();
@ -87,7 +86,7 @@ public class TestClientTimeouts {
lastFailed = false;
// Ensure the HBaseAdmin uses a new connection by changing Configuration.
Configuration conf = HBaseConfiguration.create(TEST_UTIL.getConfiguration());
conf.setLong(HConstants.HBASE_CLIENT_PREFETCH_LIMIT, ++lastLimit);
conf.set(HConstants.HBASE_CLIENT_INSTANCE_ID, String.valueOf(-1));
HBaseAdmin admin = null;
try {
admin = new HBaseAdmin(conf);

View File

@ -372,84 +372,6 @@ public class TestFromClientSide {
}
}
/**
* HBASE-2468 use case 3:
*/
@Test
public void testRegionCachePreWarm() throws Exception {
LOG.info("Starting testRegionCachePreWarm");
final TableName TABLENAME =
TableName.valueOf("testCachePrewarm");
Configuration conf = TEST_UTIL.getConfiguration();
// Set up test table:
// Create table:
TEST_UTIL.createTable(TABLENAME, FAMILY);
// disable region cache for the table.
HTable.setRegionCachePrefetch(conf, TABLENAME, false);
assertFalse("The table is disabled for region cache prefetch",
HTable.getRegionCachePrefetch(conf, TABLENAME));
HTable table = new HTable(conf, TABLENAME);
// create many regions for the table.
TEST_UTIL.createMultiRegions(table, FAMILY);
// This count effectively waits until the regions have been
// fully assigned
TEST_UTIL.countRows(table);
table.getConnection().clearRegionCache();
assertEquals("Clearing cache should have 0 cached ", 0,
ConnectionManager.getCachedRegionCount(conf, TABLENAME));
// A Get is suppose to do a region lookup request
Get g = new Get(Bytes.toBytes("aaa"));
table.get(g);
// only one region should be cached if the cache prefetch is disabled.
assertEquals("Number of cached region is incorrect ", 1,
ConnectionManager.getCachedRegionCount(conf, TABLENAME));
// now we enable cached prefetch.
HTable.setRegionCachePrefetch(conf, TABLENAME, true);
assertTrue("The table is enabled for region cache prefetch",
HTable.getRegionCachePrefetch(conf, TABLENAME));
HTable.setRegionCachePrefetch(conf, TABLENAME, false);
assertFalse("The table is disabled for region cache prefetch",
HTable.getRegionCachePrefetch(conf, TABLENAME));
HTable.setRegionCachePrefetch(conf, TABLENAME, true);
assertTrue("The table is enabled for region cache prefetch",
HTable.getRegionCachePrefetch(conf, TABLENAME));
table.getConnection().clearRegionCache();
assertEquals("Number of cached region is incorrect ", 0,
ConnectionManager.getCachedRegionCount(conf, TABLENAME));
// if there is a cache miss, some additional regions should be prefetched.
Get g2 = new Get(Bytes.toBytes("bbb"));
table.get(g2);
// Get the configured number of cache read-ahead regions.
int prefetchRegionNumber = conf.getInt("hbase.client.prefetch.limit", 10);
// the total number of cached regions == region('aaa") + prefeched regions.
LOG.info("Testing how many regions cached");
assertEquals("Number of cached region is incorrect ", prefetchRegionNumber,
ConnectionManager.getCachedRegionCount(conf, TABLENAME));
table.getConnection().clearRegionCache();
Get g3 = new Get(Bytes.toBytes("abc"));
table.get(g3);
assertEquals("Number of cached region is incorrect ", prefetchRegionNumber,
ConnectionManager.getCachedRegionCount(conf, TABLENAME));
LOG.info("Finishing testRegionCachePreWarm");
}
/**
* Verifies that getConfiguration returns the same Configuration object used

View File

@ -281,16 +281,21 @@ public class TestCoprocessorScanPolicy {
public KeyValueScanner preStoreScannerOpen(
final ObserverContext<RegionCoprocessorEnvironment> c, Store store, final Scan scan,
final NavigableSet<byte[]> targetCols, KeyValueScanner s) throws IOException {
Long newTtl = ttls.get(store.getTableName());
Integer newVersions = versions.get(store.getTableName());
ScanInfo oldSI = store.getScanInfo();
HColumnDescriptor family = store.getFamily();
ScanInfo scanInfo = new ScanInfo(family.getName(), family.getMinVersions(),
newVersions == null ? family.getMaxVersions() : newVersions,
newTtl == null ? oldSI.getTtl() : newTtl, family.getKeepDeletedCells(),
oldSI.getTimeToPurgeDeletes(), oldSI.getComparator());
return new StoreScanner(store, scanInfo, scan, targetCols,
((HStore)store).getHRegion().getReadpoint(IsolationLevel.READ_COMMITTED));
TableName tn = store.getTableName();
if (!tn.isSystemTable()) {
Long newTtl = ttls.get(store.getTableName());
Integer newVersions = versions.get(store.getTableName());
ScanInfo oldSI = store.getScanInfo();
HColumnDescriptor family = store.getFamily();
ScanInfo scanInfo = new ScanInfo(family.getName(), family.getMinVersions(),
newVersions == null ? family.getMaxVersions() : newVersions,
newTtl == null ? oldSI.getTtl() : newTtl, family.getKeepDeletedCells(),
oldSI.getTimeToPurgeDeletes(), oldSI.getComparator());
return new StoreScanner(store, scanInfo, scan, targetCols,
((HStore) store).getHRegion().getReadpoint(IsolationLevel.READ_COMMITTED));
} else {
return s;
}
}
}

View File

@ -1396,6 +1396,7 @@ public class ThriftServerRunner implements Runnable {
}
}
@Deprecated
@Override
public List<TCell> getRowOrBefore(ByteBuffer tableName, ByteBuffer row,
ByteBuffer family) throws IOError {