hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1570673 - /hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java
Date Fri, 21 Feb 2014 19:18:23 GMT
Author: liyin
Date: Fri Feb 21 19:18:22 2014
New Revision: 1570673

URL: http://svn.apache.org/r1570673
Log:
[HBase-10360] Revert to the original semantics of HTable.getHRegionInfo()

Author: liyintang

Summary: HTable.getHRegionInfo()  has been changed recently that it only returns the regions
which have been assigned. This causes multiple unit tests failure. This diff is to revert
to the original behavior.

Test Plan: mvn test -Dtest=TestHFileOutputFormat

Reviewers: manukranthk

Reviewed By: manukranthk

CC: hbase-dev@, adela, daviddeng

Differential Revision: https://phabricator.fb.com/D1181058

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1570673&r1=1570672&r2=1570673&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HTable.java Fri Feb
21 19:18:22 2014
@@ -450,26 +450,51 @@ public class HTable implements HTableInt
   }
 
   /**
-   * Gets all the regions and their address for this table.
+   * Gets all the regions (assigned and unassigned) and their address for this table.
+   * If the region is not assigned, then the associated  address will be an empty
+   * HServerAddress.
    * <p>
    * This is mainly useful for the MapReduce integration.
    * @return A map of HRegionInfo with it's server address
    * @throws IOException if a remote or network exception occurs
    */
   public NavigableMap<HRegionInfo, HServerAddress> getRegionsInfo()
-      throws IOException {
+    throws IOException {
     final NavigableMap<HRegionInfo, HServerAddress> regionMap =
       new TreeMap<HRegionInfo, HServerAddress>();
 
-    for (HRegionLocation location : getCachedHRegionLocations(true)) {
-      regionMap.put(location.getRegionInfo(), location.getServerAddress());
-    }
+    MetaScannerVisitor visitor = new MetaScannerVisitor() {
+      public boolean processRow(Result rowResult) throws IOException {
+        HRegionInfo info = Writables.getHRegionInfo(
+          rowResult.getValue(HConstants.CATALOG_FAMILY,
+            HConstants.REGIONINFO_QUALIFIER));
+
+        if (!(Bytes.equals(info.getTableDesc().getName(), getTableName()))) {
+          return false;
+        }
+
+        HServerAddress server = new HServerAddress();
+        byte [] value = rowResult.getValue(HConstants.CATALOG_FAMILY,
+          HConstants.SERVER_QUALIFIER);
+        if (value != null && value.length > 0) {
+          String address = Bytes.toString(value);
+          server = new HServerAddress(address);
+        }
+
+        if (!(info.isOffline() || info.isSplit())) {
+          regionMap.put(new UnmodifyableHRegionInfo(info), server);
+        }
+        return true;
+      }
 
+    };
+    MetaScanner.metaScan(configuration, visitor, tableName);
     return regionMap;
   }
 
   /**
-   * Get all the cached HRegionLocations.
+   * Get all the cached HRegionLocations. If the region is not assigned,
+   * then it won't be included.
    * @param forceRefresh
    * @return
    */



Mime
View raw message