http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d16c85/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexOnOwnClusterIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexOnOwnClusterIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexOnOwnClusterIT.java deleted file mode 100644 index 4f0da4d..0000000 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexOnOwnClusterIT.java +++ /dev/null @@ -1,324 +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.end2end.index; - -import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.hbase.HRegionInfo; -import org.apache.hadoop.hbase.MetaTableAccessor; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.HBaseAdmin; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.phoenix.end2end.BaseOwnClusterHBaseManagedTimeIT; -import org.apache.phoenix.end2end.IndexToolIT; -import org.apache.phoenix.jdbc.PhoenixConnection; -import org.apache.phoenix.mapreduce.index.IndexTool; -import org.apache.phoenix.query.QueryServices; -import org.apache.phoenix.query.QueryServicesOptions; -import org.apache.phoenix.util.ByteUtil; -import org.apache.phoenix.util.PropertiesUtil; -import org.apache.phoenix.util.QueryUtil; -import org.apache.phoenix.util.ReadOnlyProps; -import org.apache.phoenix.util.SchemaUtil; -import org.apache.phoenix.util.TestUtil; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.google.common.collect.Maps; - -public class IndexOnOwnClusterIT extends BaseOwnClusterHBaseManagedTimeIT { - - @BeforeClass - public static void doSetup() throws Exception { - Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(1); - serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB, - QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS); - setUpRealDriver(new ReadOnlyProps(serverProps.entrySet().iterator()), - ReadOnlyProps.EMPTY_PROPS); - } - - @Test - public void testDeleteFromImmutable() throws Exception { - Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); - try (Connection conn = DriverManager.getConnection(getUrl(), props)) { - conn.createStatement().execute("CREATE TABLE TEST_TABLE (\n" + - " pk1 VARCHAR NOT NULL,\n" + - " pk2 VARCHAR NOT NULL,\n" + - " pk3 VARCHAR\n" + - " CONSTRAINT PK PRIMARY KEY \n" + - " (\n" + - " pk1,\n" + - " pk2,\n" + - " pk3\n" + - " )\n" + - " ) IMMUTABLE_ROWS=true"); - conn.createStatement().execute("upsert into TEST_TABLE (pk1, pk2, pk3) values ('a', '1', '1')"); - conn.createStatement().execute("upsert into TEST_TABLE (pk1, pk2, pk3) values ('b', '2', '2')"); - conn.commit(); - conn.createStatement().execute("CREATE INDEX TEST_INDEX ON TEST_TABLE (pk3, pk2) ASYNC"); - - // this delete will be issued at a timestamp later than the above timestamp of the index table - conn.createStatement().execute("delete from TEST_TABLE where pk1 = 'a'"); - conn.commit(); - - // run the index MR job - final IndexTool indexingTool = new IndexTool(); - indexingTool.setConf(new Configuration(getUtility().getConfiguration())); - final String[] cmdArgs = - IndexToolIT.getArgValues(null, "TEST_TABLE", "TEST_INDEX", true); - int status = indexingTool.run(cmdArgs); - assertEquals(0, status); - - // upsert two more rows - conn.createStatement().execute( - "upsert into TEST_TABLE (pk1, pk2, pk3) values ('a', '3', '3')"); - conn.createStatement().execute( - "upsert into TEST_TABLE (pk1, pk2, pk3) values ('b', '4', '4')"); - conn.commit(); - - // validate that delete markers were issued correctly and only ('a', '1', 'value1') was - // deleted - String query = "SELECT pk3 from TEST_TABLE ORDER BY pk3"; - ResultSet rs = conn.createStatement().executeQuery("EXPLAIN " + query); - String expectedPlan = - "CLIENT PARALLEL 1-WAY FULL SCAN OVER TEST_INDEX\n" - + " SERVER FILTER BY FIRST KEY ONLY"; - assertEquals("Wrong plan ", expectedPlan, QueryUtil.getExplainPlan(rs)); - rs = conn.createStatement().executeQuery(query); - assertTrue(rs.next()); - assertEquals("2", rs.getString(1)); - assertTrue(rs.next()); - assertEquals("3", rs.getString(1)); - assertTrue(rs.next()); - assertEquals("4", rs.getString(1)); - assertFalse(rs.next()); - } - } - - private Connection getConnection() throws SQLException{ - Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); - props.put(QueryServices.EXPLAIN_ROW_COUNT_ATTRIB, - Boolean.FALSE.toString()); - props.put(QueryServices.EXPLAIN_CHUNK_COUNT_ATTRIB, - Boolean.FALSE.toString()); - props.put(QueryServices.FORCE_ROW_KEY_ORDER_ATTRIB, - Boolean.TRUE.toString()); - return DriverManager.getConnection(getUrl(),props); - } - - private void createBaseTable(String tableName, String splits) throws SQLException { - Connection conn = getConnection(); - String ddl = "CREATE TABLE " + tableName + " (t_id VARCHAR NOT NULL,\n" + - "k1 INTEGER NOT NULL,\n" + - "k2 INTEGER NOT NULL,\n" + - "k3 INTEGER,\n" + - "v1 VARCHAR,\n" + - "CONSTRAINT pk PRIMARY KEY (t_id, k1, k2))\n" - + (splits != null ? (" split on " + splits) : ""); - conn.createStatement().execute(ddl); - conn.close(); - } - - // Moved from LocalIndexIT because it was causing parallel runs to hang - @Test - public void testLocalIndexScanAfterRegionSplit() throws Exception { - String schemaName = generateRandomString(); - String tableName = schemaName + "." + generateRandomString(); - String indexName = "IDX_" + generateRandomString(); - TableName physicalTableName = SchemaUtil.getPhysicalTableName(tableName.getBytes(), false); - String indexPhysicalTableName = physicalTableName.getNameAsString(); - - createBaseTable(tableName, "('e','j','o')"); - Connection conn1 = getConnection(); - try{ - String[] strings = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}; - for (int i = 0; i < 26; i++) { - conn1.createStatement().execute( - "UPSERT INTO " + tableName + " values('"+strings[i]+"'," + i + "," - + (i + 1) + "," + (i + 2) + ",'" + strings[25 - i] + "')"); - } - conn1.commit(); - conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName + " ON " + tableName + "(v1)"); - conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName + "_2 ON " + tableName + "(k3)"); - - ResultSet rs = conn1.createStatement().executeQuery("SELECT * FROM " + tableName); - assertTrue(rs.next()); - - HBaseAdmin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); - for (int i = 1; i < 5; i++) { - admin.split(physicalTableName, ByteUtil.concat(Bytes.toBytes(strings[3*i]))); - List<HRegionInfo> regionsOfUserTable = - MetaTableAccessor.getTableRegions(getUtility().getZooKeeperWatcher(), admin.getConnection(), - physicalTableName, false); - - while (regionsOfUserTable.size() != (4+i)) { - Thread.sleep(100); - regionsOfUserTable = MetaTableAccessor.getTableRegions(getUtility().getZooKeeperWatcher(), - admin.getConnection(), physicalTableName, false); - } - assertEquals(4+i, regionsOfUserTable.size()); - String[] tIdColumnValues = new String[26]; - String[] v1ColumnValues = new String[26]; - int[] k1ColumnValue = new int[26]; - String query = "SELECT t_id,k1,v1 FROM " + tableName; - rs = conn1.createStatement().executeQuery(query); - Thread.sleep(1000); - for (int j = 0; j < 26; j++) { - assertTrue(rs.next()); - tIdColumnValues[j] = rs.getString("t_id"); - k1ColumnValue[j] = rs.getInt("k1"); - v1ColumnValues[j] = rs.getString("V1"); - } - Arrays.sort(tIdColumnValues); - Arrays.sort(v1ColumnValues); - Arrays.sort(k1ColumnValue); - assertTrue(Arrays.equals(strings, tIdColumnValues)); - assertTrue(Arrays.equals(strings, v1ColumnValues)); - for(int m=0;m<26;m++) { - assertEquals(m, k1ColumnValue[m]); - } - - rs = conn1.createStatement().executeQuery("EXPLAIN " + query); - assertEquals( - "CLIENT PARALLEL " + (4 + i) + "-WAY RANGE SCAN OVER " - + indexPhysicalTableName + " [1]\n" - + " SERVER FILTER BY FIRST KEY ONLY\n" - + "CLIENT MERGE SORT", QueryUtil.getExplainPlan(rs)); - - query = "SELECT t_id,k1,k3 FROM " + tableName; - rs = conn1.createStatement().executeQuery("EXPLAIN "+query); - assertEquals( - "CLIENT PARALLEL " - + ((strings[3 * i].compareTo("j") < 0) ? (4 + i) : (4 + i - 1)) - + "-WAY RANGE SCAN OVER " - + indexPhysicalTableName + " [2]\n" - + " SERVER FILTER BY FIRST KEY ONLY\n" - + "CLIENT MERGE SORT", QueryUtil.getExplainPlan(rs)); - rs = conn1.createStatement().executeQuery(query); - Thread.sleep(1000); - int[] k3ColumnValue = new int[26]; - for (int j = 0; j < 26; j++) { - assertTrue(rs.next()); - tIdColumnValues[j] = rs.getString("t_id"); - k1ColumnValue[j] = rs.getInt("k1"); - k3ColumnValue[j] = rs.getInt("k3"); - } - Arrays.sort(tIdColumnValues); - Arrays.sort(k1ColumnValue); - Arrays.sort(k3ColumnValue); - assertTrue(Arrays.equals(strings, tIdColumnValues)); - for(int m=0;m<26;m++) { - assertEquals(m, k1ColumnValue[m]); - assertEquals(m+2, k3ColumnValue[m]); - } - } - } finally { - conn1.close(); - } - } - - // Moved from LocalIndexIT because it was causing parallel runs to hang - @Test - public void testLocalIndexScanAfterRegionsMerge() throws Exception { - String schemaName = generateRandomString(); - String tableName = schemaName + "." + generateRandomString(); - String indexName = "IDX_" + generateRandomString(); - TableName physicalTableName = SchemaUtil.getPhysicalTableName(tableName.getBytes(), false); - String indexPhysicalTableName = physicalTableName.getNameAsString(); - - createBaseTable(tableName, "('e','j','o')"); - Connection conn1 = getConnection(); - try{ - String[] strings = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}; - for (int i = 0; i < 26; i++) { - conn1.createStatement().execute( - "UPSERT INTO " + tableName + " values('"+strings[i]+"'," + i + "," - + (i + 1) + "," + (i + 2) + ",'" + strings[25 - i] + "')"); - } - conn1.commit(); - conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName + " ON " + tableName + "(v1)"); - conn1.createStatement().execute("CREATE LOCAL INDEX " + indexName + "_2 ON " + tableName + "(k3)"); - - ResultSet rs = conn1.createStatement().executeQuery("SELECT * FROM " + tableName); - assertTrue(rs.next()); - - HBaseAdmin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin(); - List<HRegionInfo> regionsOfUserTable = - MetaTableAccessor.getTableRegions(getUtility().getZooKeeperWatcher(), admin.getConnection(), - physicalTableName, false); - admin.mergeRegions(regionsOfUserTable.get(0).getEncodedNameAsBytes(), - regionsOfUserTable.get(1).getEncodedNameAsBytes(), false); - regionsOfUserTable = - MetaTableAccessor.getTableRegions(getUtility().getZooKeeperWatcher(), admin.getConnection(), - physicalTableName, false); - - while (regionsOfUserTable.size() != 3) { - Thread.sleep(100); - regionsOfUserTable = MetaTableAccessor.getTableRegions(getUtility().getZooKeeperWatcher(), - admin.getConnection(), physicalTableName, false); - } - String query = "SELECT t_id,k1,v1 FROM " + tableName; - rs = conn1.createStatement().executeQuery(query); - Thread.sleep(1000); - for (int j = 0; j < 26; j++) { - assertTrue(rs.next()); - assertEquals(strings[25 - j], rs.getString("t_id")); - assertEquals(25 - j, rs.getInt("k1")); - assertEquals(strings[j], rs.getString("V1")); - } - rs = conn1.createStatement().executeQuery("EXPLAIN " + query); - assertEquals( - "CLIENT PARALLEL " + 3 + "-WAY RANGE SCAN OVER " - + indexPhysicalTableName - + " [1]\n" + " SERVER FILTER BY FIRST KEY ONLY\n" - + "CLIENT MERGE SORT", QueryUtil.getExplainPlan(rs)); - - query = "SELECT t_id,k1,k3 FROM " + tableName; - rs = conn1.createStatement().executeQuery("EXPLAIN " + query); - assertEquals( - "CLIENT PARALLEL " + 3 + "-WAY RANGE SCAN OVER " - + indexPhysicalTableName - + " [2]\n" + " SERVER FILTER BY FIRST KEY ONLY\n" - + "CLIENT MERGE SORT", QueryUtil.getExplainPlan(rs)); - - rs = conn1.createStatement().executeQuery(query); - Thread.sleep(1000); - for (int j = 0; j < 26; j++) { - assertTrue(rs.next()); - assertEquals(strings[j], rs.getString("t_id")); - assertEquals(j, rs.getInt("k1")); - assertEquals(j + 2, rs.getInt("k3")); - } - } finally { - conn1.close(); - } - } -}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d16c85/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java index cbd1472..e1eac48 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java @@ -51,7 +51,6 @@ import org.apache.phoenix.end2end.Shadower; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; -import org.apache.phoenix.jdbc.PhoenixResultSet; import org.apache.phoenix.query.QueryConstants; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.query.QueryServicesOptions; @@ -146,13 +145,14 @@ public class TransactionIT extends BaseHBaseManagedTimeTableReuseIT { rs = conn.createStatement().executeQuery(selectSql); TestUtil.validateRowKeyColumns(rs, 1); TestUtil.validateRowKeyColumns(rs, 2); - Long currentTx = rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp(); + // Long currentTx = rs.unwrap(PhoenixResultSet.class).getCurrentRow().getValue(0).getTimestamp(); assertFalse(rs.next()); conn.close(); // start new connection - conn.createStatement().executeQuery(selectSql); - assertFalse("This transaction should not be on the invalid transactions", txManager.getCurrentState().getInvalid().contains(currentTx)); + // conn.createStatement().executeQuery(selectSql); + // assertFalse("This transaction should not be on the invalid transactions", + // txManager.getCurrentState().getInvalid().contains(currentTx)); } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/14d16c85/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 a28ef3b..57df138 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 @@ -137,7 +137,6 @@ import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.exception.SQLExceptionInfo; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData; -import org.apache.phoenix.jdbc.PhoenixDriver; import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver; import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.ConnectionInfo; import org.apache.phoenix.jdbc.PhoenixTestDriver; @@ -491,7 +490,6 @@ public abstract class BaseTest { protected static String url; protected static PhoenixTestDriver driver; - protected static PhoenixDriver realDriver; protected static boolean clusterInitialized = false; private static HBaseTestingUtility utility; protected static final Configuration config = HBaseConfiguration.create(); @@ -574,13 +572,6 @@ public abstract class BaseTest { driver = null; } } - if (realDriver != null) { - try { - assertTrue(destroyDriver(realDriver)); - } finally { - realDriver = null; - } - } teardownTxManager(); } @@ -625,27 +616,6 @@ public abstract class BaseTest { } } - protected static void setUpRealDriver(ReadOnlyProps serverProps, ReadOnlyProps clientProps) throws Exception { - if (!clusterInitialized) { - setUpConfigForMiniCluster(config, serverProps); - utility = new HBaseTestingUtility(config); - try { - utility.startMiniCluster(NUM_SLAVES_BASE); - utility.startMiniMapReduceCluster(); - url = QueryUtil.getConnectionUrl(new Properties(), utility.getConfiguration()); - } catch (Throwable t) { - throw new RuntimeException(t); - } - clusterInitialized = true; - } - Class.forName(PhoenixDriver.class.getName()); - realDriver = PhoenixDriver.INSTANCE; - DriverManager.registerDriver(realDriver); - if (clientProps.getBoolean(QueryServices.TRANSACTIONS_ENABLED, QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED)) { - setupTxManager(); - } - } - private static boolean isDistributedClusterModeEnabled(Configuration conf) { boolean isDistributedCluster = false; //check if the distributed mode was specified as a system property.