MCPcopy Index your code
hub / github.com/OpenTSDB/asynchbase / findTableRegions

Method findTableRegions

src/HBaseClient.java:2314–2406  ·  view source on GitHub ↗

Scans the meta table for regions belonging to the given table. It can be used to prefetch the region information and/or return the actual regions to the user. NOTE: If the requested table is the meta or root table, the result will be null. @param table The name of the table whose metadata you in

(final byte[] table,
                                        final byte[] start,
                                        final byte[] stop, 
                                        final boolean cache,
                                        final boolean return_locations)

Source from the content-addressed store, hash-verified

2312 * If false, the result will be null on a successful scan.
2313 */
2314 private Deferred<Object> findTableRegions(final byte[] table,
2315 final byte[] start,
2316 final byte[] stop,
2317 final boolean cache,
2318 final boolean return_locations) {
2319 // We're going to scan .META. for the table between the row keys and filter
2320 // out all but the latest entries on the client side. Whatever remains
2321 // will be inserted into the region cache.
2322 // But we don't want to do this for hbase:meta, .META. or -ROOT-.
2323 if (Bytes.equals(table, HBASE96_META) ||
2324 Bytes.equals(table, META) ||
2325 Bytes.equals(table, ROOT) ||
2326 Bytes.equals(table, HBASE98_ROOT)) {
2327 return Deferred.fromResult(null);
2328 }
2329
2330 // Create the scan bounds.
2331 final byte[] meta_start = createRegionSearchKey(table, start);
2332 // In this case, we want the scan to start immediately at the
2333 // first entry, but createRegionSearchKey finds the last entry.
2334 meta_start[meta_start.length - 1] = 0;
2335
2336 // The stop bound is trickier. If the user wants the whole table,
2337 // expressed by passing EMPTY_ARRAY, then we need to append a null
2338 // byte to the table name (thus catching all rows in the desired
2339 // table, but excluding those from others.) If the user specifies
2340 // an explicit stop key, we must leave the table name alone.
2341 final byte[] meta_stop;
2342 if (stop.length == 0) {
2343 meta_stop = createRegionSearchKey(table, stop); // will return "table,,:"
2344 meta_stop[table.length] = 0; // now have "table\0,:"
2345 meta_stop[meta_stop.length - 1] = ','; // now have "table\0,,"
2346 } else {
2347 meta_stop = createRegionSearchKey(table, stop);
2348 }
2349
2350 if (rootregion == null) {
2351 // If we don't know where the root region is, we don't yet know whether
2352 // there is even a -ROOT- region at all (pre HBase 0.95). So we can't
2353 // start scanning meta right away, because we don't yet know whether
2354 // meta is named ".META." or "hbase:meta". So instead we first check
2355 // whether the table exists, which will force us to do a first meta
2356 // lookup (and therefore figure out what the name of meta is).
2357 class Retry implements Callback<Object, Object> {
2358 @Override
2359 public Object call(final Object unused) {
2360 return findTableRegions(table, start, stop, cache, return_locations);
2361 }
2362 @Override
2363 public String toString() {
2364 return "retry (" + Bytes.pretty(table) + ", "
2365 + Bytes.pretty(start) + ", " + Bytes.pretty(stop) + ")";
2366 }
2367 }
2368 return ensureTableExists(table).addCallback(new Retry());
2369 }
2370
2371 final List<RegionLocation> regions =

Callers 3

prefetchMetaMethod · 0.95
locateRegionsMethod · 0.95
callMethod · 0.80

Calls 7

equalsMethod · 0.95
createRegionSearchKeyMethod · 0.95
ensureTableExistsMethod · 0.95
newScannerMethod · 0.95
setStartKeyMethod · 0.95
setStopKeyMethod · 0.95
nextRowsMethod · 0.95

Tested by

no test coverage detected