This is an automated email from the ASF dual-hosted git repository. vincentpoon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push: new 77fdcc2 Revert "PHOENIX-4993 added test to check cached connections are not closed when region closes" 77fdcc2 is described below commit 77fdcc2845d56fa3b39e5a6bdd4d5d058a5aa977 Author: Vincent Poon <vincentp...@apache.org> AuthorDate: Mon Jan 28 17:05:09 2019 -0800 Revert "PHOENIX-4993 added test to check cached connections are not closed when region closes" This reverts commit 1455763b43cc71bff9e69daf928be59251e97235. --- .../CoprocessorHConnectionTableFactoryTest.java | 114 --------------------- .../java/org/apache/phoenix/util/ServerUtil.java | 5 - 2 files changed, 119 deletions(-) diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/CoprocessorHConnectionTableFactoryTest.java b/phoenix-core/src/main/java/org/apache/phoenix/util/CoprocessorHConnectionTableFactoryTest.java deleted file mode 100644 index 2629ac6..0000000 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/CoprocessorHConnectionTableFactoryTest.java +++ /dev/null @@ -1,114 +0,0 @@ - -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable - * law or agreed to in writing, software distributed under the License is distributed on an "AS IS" - * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License - * for the specific language governing permissions and limitations under the License. - */ - -package org.apache.phoenix.util; - -import static org.junit.Assert.assertTrue; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HRegionInfo; -import org.apache.hadoop.hbase.MiniHBaseCluster; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.HBaseAdmin; -import org.apache.hadoop.hbase.regionserver.HRegionServer; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.phoenix.end2end.BaseUniqueNamesOwnClusterIT; -import org.junit.BeforeClass; -import org.junit.Test; - -/* - * This test is wrt to https://issues.apache.org/jira/browse/PHOENIX-4993.Test checks 1. region - * close should not close the shared connections 2. region server close should close the shared - * connections - */ -public class CoprocessorHConnectionTableFactoryTest extends BaseUniqueNamesOwnClusterIT { - private static String ORG_PREFIX = "ORG"; - private static final Log LOG = LogFactory.getLog(CoprocessorHConnectionTableFactoryTest.class); - - @BeforeClass - public static final void doSetup() throws Exception { - - setUpTestDriver(ReadOnlyProps.EMPTY_PROPS); - - } - - static String getOrgId(long id) { - return ORG_PREFIX + "-" + id; - } - - static String getRandomOrgId(int maxOrgId) { - return getOrgId(Math.round(Math.random() * maxOrgId)); - } - - static void writeToTable(String tableName, Connection conn, int maxOrgId) throws SQLException { - try { - - String orgId = getRandomOrgId(maxOrgId); - Statement stmt = conn.createStatement(); - for (int i = 0; i < 10; i++) { - stmt.executeUpdate("UPSERT INTO " + tableName + " VALUES('" + orgId + "'," + i + "," - + (i + 1) + "," + (i + 2) + ")"); - - } - conn.commit(); - } catch (Exception e) { - LOG.error("Client side exception:" + e); - } - - } - - static int getActiveConnections(HRegionServer regionServer, Configuration conf) throws Exception { - return ServerUtil.ConnectionFactory.getConnectionsCount(); - } - - @Test - public void testCachedConnections() throws Exception { - final String tableName = generateUniqueName(); - final String index1Name = generateUniqueName(); - final Connection conn = DriverManager.getConnection(getUrl()); - - final HBaseAdmin admin = getUtility().getHBaseAdmin(); - final MiniHBaseCluster cluster = getUtility().getHBaseCluster(); - final HRegionServer regionServer = cluster.getRegionServer(0); - Configuration conf = admin.getConfiguration(); - final int noOfOrgs = 20; - final AtomicBoolean flag = new AtomicBoolean(); - flag.set(false); - // create table and indices - String createTableSql = "CREATE TABLE " + tableName - + "(org_id VARCHAR NOT NULL PRIMARY KEY, v1 INTEGER, v2 INTEGER, v3 INTEGER) VERSIONS=1 SPLIT ON ('" - + ORG_PREFIX + "-" + noOfOrgs / 2 + "')"; - conn.createStatement().execute(createTableSql); - conn.createStatement().execute("CREATE INDEX " + index1Name + " ON " + tableName + "(v1)"); - - List<HRegionInfo> regions = admin.getTableRegions(Bytes.toBytes(tableName)); - final HRegionInfo regionInfo = regions.get(0); - writeToTable(tableName, conn, noOfOrgs); - int beforeRegionCloseCount = getActiveConnections(regionServer, conf); - admin.unassign(regionInfo.getEncodedNameAsBytes(), true); - getUtility().waitUntilAllRegionsAssigned(TableName.valueOf(tableName)); - int afterRegionCloseCount = getActiveConnections(regionServer, conf); - assertTrue("Cached connections not closed when region closes: ", - afterRegionCloseCount == beforeRegionCloseCount && afterRegionCloseCount > 0); - - } - -} diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java index d6c9713..334b65c 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java @@ -347,11 +347,6 @@ public class ServerUtil { connections.clear(); } } - - public static int getConnectionsCount() { - return connections.size(); - } - } public static Configuration getCompactionConfig(Configuration conf) {