From commits-return-65924-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Tue Jan 23 11:24:40 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 9AEF6180621 for ; Tue, 23 Jan 2018 11:24:40 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 8AC85160C4E; Tue, 23 Jan 2018 10:24:40 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 26E6E160C17 for ; Tue, 23 Jan 2018 11:24:39 +0100 (CET) Received: (qmail 63879 invoked by uid 500); 23 Jan 2018 10:24:38 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 63870 invoked by uid 99); 23 Jan 2018 10:24:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 23 Jan 2018 10:24:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 71862F4DEF; Tue, 23 Jan 2018 10:24:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: zhangduo@apache.org To: commits@hbase.apache.org Date: Tue, 23 Jan 2018 10:24:36 -0000 Message-Id: <70a6e3b73d3e458b9cd86de44b81fbec@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/50] [abbrv] hbase git commit: HBASE-19774 incorrect behavior of locateRegionInMeta [Forced Update!] Repository: hbase Updated Branches: refs/heads/HBASE-19397-branch-2 46a9db935 -> 7aaad6f4c (forced update) HBASE-19774 incorrect behavior of locateRegionInMeta Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/6f8c3124 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6f8c3124 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6f8c3124 Branch: refs/heads/HBASE-19397-branch-2 Commit: 6f8c31242a211e09acabd8b2c0a5d264839f72af Parents: 5f62041 Author: Sergey Soldatov Authored: Thu Jan 11 13:40:38 2018 -0800 Committer: Michael Stack Committed: Mon Jan 22 11:49:19 2018 -0800 ---------------------------------------------------------------------- .../hbase/client/ConnectionImplementation.java | 23 ++++----- .../client/TestScannersFromClientSide.java | 50 +++++++++++++++----- 2 files changed, 49 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/6f8c3124/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java ---------------------------------------------------------------------- diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java index 562630f..8807884 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java @@ -786,11 +786,14 @@ class ConnectionImplementation implements ClusterConnection, Closeable { // 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 = RegionInfo.createRegionName(tableName, row, HConstants.NINES, false); + byte[] metaStartKey = RegionInfo.createRegionName(tableName, row, HConstants.NINES, false); + byte[] metaStopKey = + RegionInfo.createRegionName(tableName, HConstants.EMPTY_START_ROW, "", false); Scan s = new Scan(); s.setReversed(true); - s.withStartRow(metaKey); + s.withStartRow(metaStartKey); + s.withStopRow(metaStopKey, true); s.addFamily(HConstants.CATALOG_FAMILY); if (this.useMetaReplicas) { @@ -840,12 +843,11 @@ class ConnectionImplementation implements ClusterConnection, Closeable { // convert the row result into the HRegionLocation we need! RegionLocations locations = MetaTableAccessor.getRegionLocations(regionInfoRow); if (locations == null || locations.getRegionLocation(replicaId) == null) { - throw new IOException("HRegionInfo was null in " + - tableName + ", row=" + regionInfoRow); + throw new IOException("RegionInfo null in " + tableName + ", row=" + regionInfoRow); } RegionInfo regionInfo = locations.getRegionLocation(replicaId).getRegion(); if (regionInfo == null) { - throw new IOException("HRegionInfo was null or empty in " + + throw new IOException("RegionInfo null or empty in " + TableName.META_TABLE_NAME + ", row=" + regionInfoRow); } @@ -857,13 +859,12 @@ class ConnectionImplementation implements ClusterConnection, Closeable { "hbase:meta might be damaged."); } if (regionInfo.isSplit()) { - throw new RegionOfflineException( - "the only available region for the required row is a split parent," - + " the daughters should be online soon: " + regionInfo.getRegionNameAsString()); + throw new RegionOfflineException ("Region for row is a split parent, daughters not online: " + + regionInfo.getRegionNameAsString()); } if (regionInfo.isOffline()) { - throw new RegionOfflineException("the region is offline, could" - + " be caused by a disable table call: " + regionInfo.getRegionNameAsString()); + throw new RegionOfflineException("Region offline; disable table call? " + + regionInfo.getRegionNameAsString()); } ServerName serverName = locations.getRegionLocation(replicaId).getServerName(); @@ -908,7 +909,7 @@ class ConnectionImplementation implements ClusterConnection, Closeable { // Only relocate the parent region if necessary if(!(e instanceof RegionOfflineException || e instanceof NoServerForRegionException)) { - relocateRegion(TableName.META_TABLE_NAME, metaKey, replicaId); + relocateRegion(TableName.META_TABLE_NAME, metaStartKey, replicaId); } } finally { userRegionLock.unlock(); http://git-wip-us.apache.org/repos/asf/hbase/blob/6f8c3124/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java index 5441e2b..9173726 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java @@ -16,19 +16,6 @@ */ package org.apache.hadoop.hbase.client; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; -import java.util.stream.IntStream; - import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CompareOperator; @@ -41,6 +28,7 @@ import org.apache.hadoop.hbase.HTestConst; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.MiniHBaseCluster; import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.TableNotFoundException; import org.apache.hadoop.hbase.filter.BinaryComparator; import org.apache.hadoop.hbase.filter.ColumnPrefixFilter; import org.apache.hadoop.hbase.filter.ColumnRangeFilter; @@ -61,6 +49,21 @@ import org.junit.rules.TestName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; +import java.util.stream.IntStream; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + + /** * A client-side test, mostly testing scanners with various parameters. */ @@ -236,6 +239,27 @@ public class TestScannersFromClientSide { clientScanner.getCacheSize() <= 1); } + /** + * Scan on not existing table should throw the exception with correct message + */ + @Test + public void testScannerForNotExistingTable() { + String[] tableNames = {"A", "Z", "A:A", "Z:Z"}; + for(String tableName : tableNames) { + try { + Table table = TEST_UTIL.getConnection().getTable(TableName.valueOf(tableName)); + testSmallScan(table, true, 1, 5); + fail("TableNotFoundException was not thrown"); + } catch (TableNotFoundException e) { + // We expect that the message for TableNotFoundException would have only the table name only + // Otherwise that would mean that localeRegionInMeta doesn't work properly + assertEquals(e.getMessage(), tableName); + } catch (Exception e) { + fail("Unexpected exception " + e.getMessage()); + } + } + } + @Test public void testSmallScan() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName());