[phoenix] 23/34: PHOENIX-5025 Tool to clean up orphan views (addendum)

2019-04-19 Thread tdsilva
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 d2e70b6756fc4fbe019334376886202e85e02bf7
Author: Kadir 
AuthorDate: Wed Dec 12 17:53:38 2018 -0800

PHOENIX-5025 Tool to clean up orphan views (addendum)
---
 .../apache/phoenix/end2end/OrphanViewToolIT.java   | 25 +++---
 .../apache/phoenix/mapreduce/OrphanViewTool.java   | 89 +-
 2 files changed, 71 insertions(+), 43 deletions(-)

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
index f9a1785..38d4afc 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
@@ -19,7 +19,6 @@ 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;
@@ -27,9 +26,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.io.LineNumberReader;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
@@ -54,6 +53,7 @@ import org.slf4j.LoggerFactory;
 
 @RunWith(Parameterized.class)
 public class OrphanViewToolIT extends ParallelStatsDisabledIT {
+private static final String SYSTEM_CHILD_LINK_NAME = SYSTEM_CATALOG_NAME;
 private static final Logger LOG = 
LoggerFactory.getLogger(OrphanViewToolIT.class);
 
 private final boolean isMultiTenant;
@@ -206,9 +206,13 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 
 private void verifyLineCount(String fileName, long lineCount) throws 
IOException {
-if (Files.lines(Paths.get(fileName)).count() != lineCount)
-LOG.debug(Files.lines(Paths.get(fileName)).count() + " != " + 
lineCount);
-assertTrue(Files.lines(Paths.get(fileName)).count() == lineCount);
+LineNumberReader reader = new LineNumberReader(new 
FileReader(fileName));
+while (reader.readLine() != null) {
+}
+int count = reader.getLineNumber();
+if (count != lineCount)
+LOG.debug(count + " != " + lineCount);
+assertTrue(count == lineCount);
 }
 
 private void verifyCountQuery(Connection connection, String query, String 
schemaName, long count)
@@ -238,7 +242,6 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 }
 
-
 private void verifyNoChildLink(Connection connection, String 
viewSchemaName) throws Exception {
 // Verify that there there is no link in the system child link table
 verifyCountQuery(connection, countChildLinksQuery, viewSchemaName, 0);
@@ -264,6 +267,7 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 schemaName == null ? "IS NULL" : "= '" + schemaName + "'"));
 connection.commit();
 }
+
 @Test
 public void testDeleteBaseTableRows() throws Exception {
 String baseTableName = generateUniqueName();
@@ -438,7 +442,8 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 }
 
-public static String[] getArgValues(boolean clean, boolean identify, 
boolean outputPath, boolean inputPath) {
+public static String[] getArgValues(boolean clean, boolean identify, 
boolean outputPath, boolean inputPath)
+throws InterruptedException{
 final List args = Lists.newArrayList();
 if (outputPath) {
 args.add("-op");
@@ -454,8 +459,10 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 if (identify) {
 args.add("-i");
 }
+final long ageMs = 2000;
+Thread.sleep(ageMs);
 args.add("-a");
-args.add("0");
+args.add(Long.toString(ageMs));
 return args.toArray(new String[0]);
 }
 
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
index a8a30b6..2e0dd0d 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
@@ -21,7 +21,6 @@ import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_FAMILY;
 

[phoenix] 23/34: PHOENIX-5025 Tool to clean up orphan views (addendum)

2019-04-19 Thread tdsilva
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 c9e850de15f199d13c3fcb6d1f50a0499efdafa5
Author: Kadir 
AuthorDate: Wed Dec 12 17:53:38 2018 -0800

PHOENIX-5025 Tool to clean up orphan views (addendum)
---
 .../apache/phoenix/end2end/OrphanViewToolIT.java   | 25 +++---
 .../apache/phoenix/mapreduce/OrphanViewTool.java   | 89 +-
 2 files changed, 71 insertions(+), 43 deletions(-)

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
index f9a1785..38d4afc 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
@@ -19,7 +19,6 @@ 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;
@@ -27,9 +26,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.io.LineNumberReader;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
@@ -54,6 +53,7 @@ import org.slf4j.LoggerFactory;
 
 @RunWith(Parameterized.class)
 public class OrphanViewToolIT extends ParallelStatsDisabledIT {
+private static final String SYSTEM_CHILD_LINK_NAME = SYSTEM_CATALOG_NAME;
 private static final Logger LOG = 
LoggerFactory.getLogger(OrphanViewToolIT.class);
 
 private final boolean isMultiTenant;
@@ -206,9 +206,13 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 
 private void verifyLineCount(String fileName, long lineCount) throws 
IOException {
-if (Files.lines(Paths.get(fileName)).count() != lineCount)
-LOG.debug(Files.lines(Paths.get(fileName)).count() + " != " + 
lineCount);
-assertTrue(Files.lines(Paths.get(fileName)).count() == lineCount);
+LineNumberReader reader = new LineNumberReader(new 
FileReader(fileName));
+while (reader.readLine() != null) {
+}
+int count = reader.getLineNumber();
+if (count != lineCount)
+LOG.debug(count + " != " + lineCount);
+assertTrue(count == lineCount);
 }
 
 private void verifyCountQuery(Connection connection, String query, String 
schemaName, long count)
@@ -238,7 +242,6 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 }
 
-
 private void verifyNoChildLink(Connection connection, String 
viewSchemaName) throws Exception {
 // Verify that there there is no link in the system child link table
 verifyCountQuery(connection, countChildLinksQuery, viewSchemaName, 0);
@@ -264,6 +267,7 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 schemaName == null ? "IS NULL" : "= '" + schemaName + "'"));
 connection.commit();
 }
+
 @Test
 public void testDeleteBaseTableRows() throws Exception {
 String baseTableName = generateUniqueName();
@@ -438,7 +442,8 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 }
 
-public static String[] getArgValues(boolean clean, boolean identify, 
boolean outputPath, boolean inputPath) {
+public static String[] getArgValues(boolean clean, boolean identify, 
boolean outputPath, boolean inputPath)
+throws InterruptedException{
 final List args = Lists.newArrayList();
 if (outputPath) {
 args.add("-op");
@@ -454,8 +459,10 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 if (identify) {
 args.add("-i");
 }
+final long ageMs = 2000;
+Thread.sleep(ageMs);
 args.add("-a");
-args.add("0");
+args.add(Long.toString(ageMs));
 return args.toArray(new String[0]);
 }
 
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
index a8a30b6..2e0dd0d 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
@@ -21,7 +21,6 @@ import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_FAMILY;
 

[phoenix] 23/34: PHOENIX-5025 Tool to clean up orphan views (addendum)

2019-04-19 Thread tdsilva
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 f741006e7b5e32307cb2636a1a0bcb593116202a
Author: Kadir 
AuthorDate: Wed Dec 12 17:53:38 2018 -0800

PHOENIX-5025 Tool to clean up orphan views (addendum)
---
 .../apache/phoenix/end2end/OrphanViewToolIT.java   | 25 +++---
 .../apache/phoenix/mapreduce/OrphanViewTool.java   | 89 +-
 2 files changed, 71 insertions(+), 43 deletions(-)

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
index f9a1785..38d4afc 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/OrphanViewToolIT.java
@@ -19,7 +19,6 @@ 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;
@@ -27,9 +26,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.FileReader;
 import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.io.LineNumberReader;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
@@ -54,6 +53,7 @@ import org.slf4j.LoggerFactory;
 
 @RunWith(Parameterized.class)
 public class OrphanViewToolIT extends ParallelStatsDisabledIT {
+private static final String SYSTEM_CHILD_LINK_NAME = SYSTEM_CATALOG_NAME;
 private static final Logger LOG = 
LoggerFactory.getLogger(OrphanViewToolIT.class);
 
 private final boolean isMultiTenant;
@@ -206,9 +206,13 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 
 private void verifyLineCount(String fileName, long lineCount) throws 
IOException {
-if (Files.lines(Paths.get(fileName)).count() != lineCount)
-LOG.debug(Files.lines(Paths.get(fileName)).count() + " != " + 
lineCount);
-assertTrue(Files.lines(Paths.get(fileName)).count() == lineCount);
+LineNumberReader reader = new LineNumberReader(new 
FileReader(fileName));
+while (reader.readLine() != null) {
+}
+int count = reader.getLineNumber();
+if (count != lineCount)
+LOG.debug(count + " != " + lineCount);
+assertTrue(count == lineCount);
 }
 
 private void verifyCountQuery(Connection connection, String query, String 
schemaName, long count)
@@ -238,7 +242,6 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 }
 
-
 private void verifyNoChildLink(Connection connection, String 
viewSchemaName) throws Exception {
 // Verify that there there is no link in the system child link table
 verifyCountQuery(connection, countChildLinksQuery, viewSchemaName, 0);
@@ -264,6 +267,7 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 schemaName == null ? "IS NULL" : "= '" + schemaName + "'"));
 connection.commit();
 }
+
 @Test
 public void testDeleteBaseTableRows() throws Exception {
 String baseTableName = generateUniqueName();
@@ -438,7 +442,8 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 }
 }
 
-public static String[] getArgValues(boolean clean, boolean identify, 
boolean outputPath, boolean inputPath) {
+public static String[] getArgValues(boolean clean, boolean identify, 
boolean outputPath, boolean inputPath)
+throws InterruptedException{
 final List args = Lists.newArrayList();
 if (outputPath) {
 args.add("-op");
@@ -454,8 +459,10 @@ public class OrphanViewToolIT extends 
ParallelStatsDisabledIT {
 if (identify) {
 args.add("-i");
 }
+final long ageMs = 2000;
+Thread.sleep(ageMs);
 args.add("-a");
-args.add("0");
+args.add(Long.toString(ageMs));
 return args.toArray(new String[0]);
 }
 
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
index a8a30b6..2e0dd0d 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
@@ -21,7 +21,6 @@ import static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.COLUMN_FAMILY;