From commits-return-22993-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Sat Sep 29 08:53:37 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 9D797180672 for ; Sat, 29 Sep 2018 08:53:36 +0200 (CEST) Received: (qmail 16864 invoked by uid 500); 29 Sep 2018 06:53:35 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 16855 invoked by uid 99); 29 Sep 2018 06:53:35 -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; Sat, 29 Sep 2018 06:53:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6CB61E0130; Sat, 29 Sep 2018 06:53:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tdsilva@apache.org To: commits@phoenix.apache.org Message-Id: <149e8faf30c04faab9a59ec8d10e0bfa@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-4934 Make BaseTest.splitSystemCatalog generic Date: Sat, 29 Sep 2018 06:53:35 +0000 (UTC) Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.2 f4ebaff0d -> 5b04764b8 PHOENIX-4934 Make BaseTest.splitSystemCatalog generic Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/5b04764b Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/5b04764b Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/5b04764b Branch: refs/heads/4.x-HBase-1.2 Commit: 5b04764b8648cd0c916bea51c6fd80688d610bfb Parents: f4ebaff Author: Thomas D'Silva Authored: Fri Sep 28 17:56:22 2018 -0700 Committer: Thomas D'Silva Committed: Fri Sep 28 17:56:56 2018 -0700 ---------------------------------------------------------------------- .../java/org/apache/phoenix/query/BaseTest.java | 73 +++++++++----------- 1 file changed, 34 insertions(+), 39 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/5b04764b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java index 45b61c1..5ca247b 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java @@ -1804,36 +1804,14 @@ public abstract class BaseTest { } return false; } - - /** - * Splits SYSTEM.CATALOG into multiple regions based on the table or view names passed in. - * Metadata for each table or view is moved to a separate region, - * @param tenantToTableAndViewMap map from tenant to tables and views owned by the tenant - */ - protected static void splitSystemCatalog(Map> tenantToTableAndViewMap) throws Exception { - List splitPoints = Lists.newArrayListWithExpectedSize(5); - // add the rows keys of the table or view metadata rows - Set schemaNameSet=Sets.newHashSetWithExpectedSize(15); - for (Entry> entrySet : tenantToTableAndViewMap.entrySet()) { - String tenantId = entrySet.getKey(); - for (String fullName : entrySet.getValue()) { - String schemaName = SchemaUtil.getSchemaNameFromFullName(fullName); - // we don't allow SYSTEM.CATALOG to split within a schema, so to ensure each table - // or view is on a separate region they need to have a unique tenant and schema name - assertTrue("Schema names of tables/view must be unique ", schemaNameSet.add(tenantId+"."+schemaName)); - String tableName = SchemaUtil.getTableNameFromFullName(fullName); - splitPoints.add( - SchemaUtil.getTableKey(tenantId, "".equals(schemaName) ? null : schemaName, tableName)); - } - } - Collections.sort(splitPoints, Bytes.BYTES_COMPARATOR); - + + protected static void splitTable(TableName fullTableName, List splitPoints) throws Exception { HBaseAdmin admin = driver.getConnectionQueryServices(getUrl(), TestUtil.TEST_PROPERTIES).getAdmin(); assertTrue("Needs at least two split points ", splitPoints.size() > 1); assertTrue( - "Number of split points should be less than or equal to the number of region servers ", - splitPoints.size() <= NUM_SLAVES_BASE); + "Number of split points should be less than or equal to the number of region servers ", + splitPoints.size() <= NUM_SLAVES_BASE); HBaseTestingUtility util = getUtility(); MiniHBaseCluster cluster = util.getHBaseCluster(); HMaster master = cluster.getMaster(); @@ -1848,7 +1826,7 @@ public abstract class BaseTest { availableRegionServers.push(util.getHBaseCluster().getRegionServer(i).getServerName()); } List tableRegions = - admin.getTableRegions(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME); + admin.getTableRegions(fullTableName); for (HRegionInfo hRegionInfo : tableRegions) { // filter on regions we are interested in if (regionContainsMetadataRows(hRegionInfo, splitPoints)) { @@ -1858,15 +1836,6 @@ public abstract class BaseTest { } serverToRegionsList.get(serverName).add(hRegionInfo); availableRegionServers.remove(serverName); - // Scan scan = new Scan(); - // scan.setStartRow(hRegionInfo.getStartKey()); - // scan.setStopRow(hRegionInfo.getEndKey()); - // HTable primaryTable = new HTable(getUtility().getConfiguration(), - // PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME); - // ResultScanner resultScanner = primaryTable.getScanner(scan); - // for (Result result : resultScanner) { - // System.out.println(result); - // } } } assertTrue("No region servers available to move regions on to ", !availableRegionServers.isEmpty()); @@ -1878,10 +1847,10 @@ public abstract class BaseTest { } } } - - // verify each region of SYSTEM.CATALOG is on its own region server + + // verify each region is on its own region server tableRegions = - admin.getTableRegions(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME); + admin.getTableRegions(fullTableName); Set serverNames = Sets.newHashSet(); for (HRegionInfo hRegionInfo : tableRegions) { // filter on regions we are interested in @@ -1896,6 +1865,32 @@ public abstract class BaseTest { } } } + + /** + * Splits SYSTEM.CATALOG into multiple regions based on the table or view names passed in. + * Metadata for each table or view is moved to a separate region, + * @param tenantToTableAndViewMap map from tenant to tables and views owned by the tenant + */ + protected static void splitSystemCatalog(Map> tenantToTableAndViewMap) throws Exception { + List splitPoints = Lists.newArrayListWithExpectedSize(5); + // add the rows keys of the table or view metadata rows + Set schemaNameSet=Sets.newHashSetWithExpectedSize(15); + for (Entry> entrySet : tenantToTableAndViewMap.entrySet()) { + String tenantId = entrySet.getKey(); + for (String fullName : entrySet.getValue()) { + String schemaName = SchemaUtil.getSchemaNameFromFullName(fullName); + // we don't allow SYSTEM.CATALOG to split within a schema, so to ensure each table + // or view is on a separate region they need to have a unique tenant and schema name + assertTrue("Schema names of tables/view must be unique ", schemaNameSet.add(tenantId+"."+schemaName)); + String tableName = SchemaUtil.getTableNameFromFullName(fullName); + splitPoints.add( + SchemaUtil.getTableKey(tenantId, "".equals(schemaName) ? null : schemaName, tableName)); + } + } + Collections.sort(splitPoints, Bytes.BYTES_COMPARATOR); + + splitTable(PhoenixDatabaseMetaData.SYSTEM_CATALOG_HBASE_TABLE_NAME, splitPoints); + } private static int getRegionServerIndex(MiniHBaseCluster cluster, ServerName serverName) { // we have a small number of region servers, this should be fine for now.