[phoenix] 22/34: PHOENIX-5025 Tool to clean up orphan views
This is an automated email from the ASF dual-hosted git repository. tdsilva pushed a commit to branch 4.14-HBase-1.4 in repository https://gitbox.apache.org/repos/asf/phoenix.git commit e907249a80748f11c8558f8ce5c8d7b832791c17 Author: Kadir AuthorDate: Mon Nov 12 22:24:10 2018 -0800 PHOENIX-5025 Tool to clean up orphan views --- .../apache/phoenix/end2end/OrphanViewToolIT.java | 472 +++ .../apache/phoenix/mapreduce/OrphanViewTool.java | 879 + 2 files changed, 1351 insertions(+) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java new file mode 100644 index 000..f9a1785 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java @@ -0,0 +1,472 @@ +/* + * 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; + +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LINK_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE; +import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import com.google.common.collect.Lists; +import org.apache.hadoop.conf.Configuration; +import org.apache.phoenix.mapreduce.OrphanViewTool; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.util.SchemaUtil; +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RunWith(Parameterized.class) +public class OrphanViewToolIT extends ParallelStatsDisabledIT { +private static final Logger LOG = LoggerFactory.getLogger(OrphanViewToolIT.class); + +private final boolean isMultiTenant; +private final boolean columnEncoded; + +private static final long fanout = 2; +private static final long childCount = fanout; +private static final long grandChildCount = fanout * fanout; +private static final long grandGrandChildCount = fanout * fanout * fanout; + +private static final String filePath = "/tmp/"; +private static final String viewFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.VIEW]; +private static final String physicalLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.PHYSICAL_TABLE_LINK]; +private static final String parentLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.PARENT_TABLE_LINK]; +private static final String childLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.CHILD_TABLE_LINK]; + +protected static String SCHEMA1 = "SCHEMA1"; +protected static String SCHEMA2 = "SCHEMA2"; +protected static String SCHEMA3 = "SCHEMA3"; +protected static String SCHEMA4 = "SCHEMA4"; + +private final String TENANT_SPECIFIC_URL = getUrl() + ';' + TENANT_ID_ATTRIB + "=tenant"; + +private static final String createBaseTableFirstPartDDL = "CREATE TABLE IF NOT EXISTS %s"; +private static final String createBaseTableSecondPartDDL = "(%s PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " + +" CONSTRAINT NAME_PK PRIMARY KEY (%s PK2)) %s"; +private static final String deleteTableRows = "DELETE FROM " + SYSTEM_CATALOG_NAME + +" WHERE " + TABLE_SCHEM + " %s AND " + +TABLE_TYPE + " = '" + PTableType.TABLE.getSerializedValue() + "'"; + +private static final String createViewDDL =
[phoenix] 22/34: PHOENIX-5025 Tool to clean up orphan views
This is an automated email from the ASF dual-hosted git repository. tdsilva pushed a commit to branch 4.14-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git commit 0ec78d2a881dc82f240deb9e4a4b73f709cbf941 Author: Kadir AuthorDate: Mon Nov 12 22:24:10 2018 -0800 PHOENIX-5025 Tool to clean up orphan views --- .../apache/phoenix/end2end/OrphanViewToolIT.java | 472 +++ .../apache/phoenix/mapreduce/OrphanViewTool.java | 879 + 2 files changed, 1351 insertions(+) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java new file mode 100644 index 000..f9a1785 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java @@ -0,0 +1,472 @@ +/* + * 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; + +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LINK_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE; +import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import com.google.common.collect.Lists; +import org.apache.hadoop.conf.Configuration; +import org.apache.phoenix.mapreduce.OrphanViewTool; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.util.SchemaUtil; +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RunWith(Parameterized.class) +public class OrphanViewToolIT extends ParallelStatsDisabledIT { +private static final Logger LOG = LoggerFactory.getLogger(OrphanViewToolIT.class); + +private final boolean isMultiTenant; +private final boolean columnEncoded; + +private static final long fanout = 2; +private static final long childCount = fanout; +private static final long grandChildCount = fanout * fanout; +private static final long grandGrandChildCount = fanout * fanout * fanout; + +private static final String filePath = "/tmp/"; +private static final String viewFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.VIEW]; +private static final String physicalLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.PHYSICAL_TABLE_LINK]; +private static final String parentLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.PARENT_TABLE_LINK]; +private static final String childLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.CHILD_TABLE_LINK]; + +protected static String SCHEMA1 = "SCHEMA1"; +protected static String SCHEMA2 = "SCHEMA2"; +protected static String SCHEMA3 = "SCHEMA3"; +protected static String SCHEMA4 = "SCHEMA4"; + +private final String TENANT_SPECIFIC_URL = getUrl() + ';' + TENANT_ID_ATTRIB + "=tenant"; + +private static final String createBaseTableFirstPartDDL = "CREATE TABLE IF NOT EXISTS %s"; +private static final String createBaseTableSecondPartDDL = "(%s PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " + +" CONSTRAINT NAME_PK PRIMARY KEY (%s PK2)) %s"; +private static final String deleteTableRows = "DELETE FROM " + SYSTEM_CATALOG_NAME + +" WHERE " + TABLE_SCHEM + " %s AND " + +TABLE_TYPE + " = '" + PTableType.TABLE.getSerializedValue() + "'"; + +private static final String createViewDDL =
[phoenix] 22/34: PHOENIX-5025 Tool to clean up orphan views
This is an automated email from the ASF dual-hosted git repository. tdsilva pushed a commit to branch 4.14-HBase-1.2 in repository https://gitbox.apache.org/repos/asf/phoenix.git commit e3bd6032207360652f4586eddc4f0f630abc2c76 Author: Kadir AuthorDate: Mon Nov 12 22:24:10 2018 -0800 PHOENIX-5025 Tool to clean up orphan views --- .../apache/phoenix/end2end/OrphanViewToolIT.java | 472 +++ .../apache/phoenix/mapreduce/OrphanViewTool.java | 879 + 2 files changed, 1351 insertions(+) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java new file mode 100644 index 000..f9a1785 --- /dev/null +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java @@ -0,0 +1,472 @@ +/* + * 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; + +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LINK_TYPE; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CHILD_LINK_NAME; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_SCHEM; +import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_TYPE; +import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import com.google.common.collect.Lists; +import org.apache.hadoop.conf.Configuration; +import org.apache.phoenix.mapreduce.OrphanViewTool; +import org.apache.phoenix.schema.PTable; +import org.apache.phoenix.schema.PTableType; +import org.apache.phoenix.util.SchemaUtil; +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RunWith(Parameterized.class) +public class OrphanViewToolIT extends ParallelStatsDisabledIT { +private static final Logger LOG = LoggerFactory.getLogger(OrphanViewToolIT.class); + +private final boolean isMultiTenant; +private final boolean columnEncoded; + +private static final long fanout = 2; +private static final long childCount = fanout; +private static final long grandChildCount = fanout * fanout; +private static final long grandGrandChildCount = fanout * fanout * fanout; + +private static final String filePath = "/tmp/"; +private static final String viewFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.VIEW]; +private static final String physicalLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.PHYSICAL_TABLE_LINK]; +private static final String parentLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.PARENT_TABLE_LINK]; +private static final String childLinkFileName = "/tmp/" + OrphanViewTool.fileName[OrphanViewTool.CHILD_TABLE_LINK]; + +protected static String SCHEMA1 = "SCHEMA1"; +protected static String SCHEMA2 = "SCHEMA2"; +protected static String SCHEMA3 = "SCHEMA3"; +protected static String SCHEMA4 = "SCHEMA4"; + +private final String TENANT_SPECIFIC_URL = getUrl() + ';' + TENANT_ID_ATTRIB + "=tenant"; + +private static final String createBaseTableFirstPartDDL = "CREATE TABLE IF NOT EXISTS %s"; +private static final String createBaseTableSecondPartDDL = "(%s PK2 VARCHAR NOT NULL, V1 VARCHAR, V2 VARCHAR " + +" CONSTRAINT NAME_PK PRIMARY KEY (%s PK2)) %s"; +private static final String deleteTableRows = "DELETE FROM " + SYSTEM_CATALOG_NAME + +" WHERE " + TABLE_SCHEM + " %s AND " + +TABLE_TYPE + " = '" + PTableType.TABLE.getSerializedValue() + "'"; + +private static final String createViewDDL =