hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject git commit: HBASE-12377 HBaseAdmin#deleteTable fails when META region is moved around the same timeframe (Stephen Yuan Jiang)
Date Fri, 31 Oct 2014 19:14:33 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 1f18d706a -> 8938aba4e


HBASE-12377 HBaseAdmin#deleteTable fails when META region is moved around the same timeframe
(Stephen Yuan Jiang)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8938aba4
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8938aba4
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8938aba4

Branch: refs/heads/branch-1
Commit: 8938aba4e265dd4d94515312df2a9ebe63ab544f
Parents: 1f18d70
Author: Enis Soztutar <enis@apache.org>
Authored: Fri Oct 31 12:09:38 2014 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Fri Oct 31 12:11:31 2014 -0700

----------------------------------------------------------------------
 .../apache/hadoop/hbase/client/HBaseAdmin.java  | 71 +++++++++-----------
 1 file changed, 31 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/8938aba4/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
index 3893035..fea38ab 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
@@ -68,11 +68,9 @@ import org.apache.hadoop.hbase.exceptions.DeserializationException;
 import org.apache.hadoop.hbase.exceptions.MergeRegionException;
 import org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel;
 import org.apache.hadoop.hbase.ipc.MasterCoprocessorRpcChannel;
-import org.apache.hadoop.hbase.ipc.PayloadCarryingRpcController;
 import org.apache.hadoop.hbase.ipc.RegionServerCoprocessorRpcChannel;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.RequestConverter;
-import org.apache.hadoop.hbase.protobuf.ResponseConverter;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.CloseRegionRequest;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.CloseRegionResponse;
@@ -85,9 +83,6 @@ import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.RollWALWriterReque
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.RollWALWriterResponse;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.StopServerRequest;
 import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.UpdateConfigurationRequest;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
-import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanResponse;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ProcedureDescription;
@@ -111,8 +106,6 @@ import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetCompletedSnaps
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetNamespaceDescriptorRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetSchemaAlterStatusResponse;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsRequest;
-import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.GetTableDescriptorsResponse;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsProcedureDoneRequest;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsProcedureDoneResponse;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos.IsRestoreSnapshotDoneRequest;
@@ -664,47 +657,24 @@ public class HBaseAdmin implements Admin {
     // Wait until all regions deleted
     for (int tries = 0; tries < (this.numRetries * this.retryLongerMultiplier); tries++)
{
       try {
-        HRegionLocation firstMetaServer = getFirstMetaServerForTable(tableName);
-        Scan scan = MetaTableAccessor.getScanForTableName(tableName);
-        scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-        ScanRequest request = RequestConverter.buildScanRequest(
-          firstMetaServer.getRegionInfo().getRegionName(), scan, 1, true);
-        Result[] values = null;
-        // Get a batch at a time.
-        ClientService.BlockingInterface server = connection.getClient(firstMetaServer
-            .getServerName());
-        PayloadCarryingRpcController controller = new PayloadCarryingRpcController();
-        try {
-          controller.setPriority(tableName);
-          ScanResponse response = server.scan(controller, request);
-          values = ResponseConverter.getResults(controller.cellScanner(), response);
-        } catch (ServiceException se) {
-          throw ProtobufUtil.getRemoteException(se);
-        }
+        // Find whether all regions are deleted.
+        List<RegionLocations> regionLations =
+            MetaScanner.listTableRegionLocations(conf, connection, tableName);
 
         // let us wait until hbase:meta table is updated and
         // HMaster removes the table from its HTableDescriptors
-        if (values == null || values.length == 0) {
-          tableExists = false;
-          GetTableDescriptorsResponse htds;
-          MasterKeepAliveConnection master = connection.getKeepAliveMasterService();
-          try {
-            GetTableDescriptorsRequest req =
-              RequestConverter.buildGetTableDescriptorsRequest(tableName);
-            htds = master.getTableDescriptors(null, req);
-          } catch (ServiceException se) {
-            throw ProtobufUtil.getRemoteException(se);
-          } finally {
-            master.close();
-          }
-          tableExists = !htds.getTableSchemaList().isEmpty();
-          if (!tableExists) {
+        if (regionLations == null || regionLations.size() == 0) {
+          HTableDescriptor htd = getTableDescriptorByTableName(tableName);
+
+          if (htd == null) {
+            // table could not be found in master - we are done.
+            tableExists = false;
             break;
           }
         }
       } catch (IOException ex) {
         failures++;
-        if(failures == numRetries - 1) {           // no more tries left
+        if(failures >= numRetries - 1) {           // no more tries left
           if (ex instanceof RemoteException) {
             throw ((RemoteException) ex).unwrapRemoteException();
           } else {
@@ -2604,6 +2574,27 @@ public class HBaseAdmin implements Admin {
   }
 
   /**
+   * Get tableDescriptor
+   * @param tableName one table name
+   * @return HTD the HTableDescriptor or null if the table not exists
+   * @throws IOException if a remote or network exception occurs
+   */
+  private HTableDescriptor getTableDescriptorByTableName(TableName tableName)
+      throws IOException {
+    List<TableName> tableNames = new ArrayList<TableName>(1);
+    tableNames.add(tableName);
+
+    HTableDescriptor[] htdl = getTableDescriptorsByTableName(tableNames);
+
+    if (htdl == null || htdl.length == 0) {
+      return null;
+    }
+    else {
+      return htdl[0];
+    }
+  }
+
+  /**
    * Get tableDescriptors
    * @param names List of table names
    * @return HTD[] the tableDescriptor


Mime
View raw message