kadirozde commented on code in PR #2031:
URL: https://github.com/apache/phoenix/pull/2031#discussion_r2691398298


##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesIT.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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 org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Admin;
+
+import org.apache.phoenix.mapreduce.index.IndexToolTableUtil;
+import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.query.QueryServicesOptions;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.Before;
+import org.junit.Test;
+import java.util.HashMap;
+import java.util.Map;
+
+import static 
org.apache.phoenix.mapreduce.index.IndexToolTableUtil.RESULT_TABLE_NAME;
+import static org.apache.phoenix.query.QueryConstants.SYSTEM_SCHEMA_NAME;
+import static org.junit.Assert.*;

Review Comment:
   Nit: wildcard import



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesCreationOnConnectionIT.java:
##########
@@ -343,7 +348,7 @@ public void testUpgradeNotAllowed() throws Exception {
   // Expected: We will migrate all SYSTEM\..* tables to the SYSTEM namespace 
and also upgrade
   // SYSTEM:CATALOG
   @Test
-  public void testMigrateToSystemNamespaceAndUpgradeSysCat() throws Exception {
+  public void testABCFirstMigrateToSystemNamespaceAndUpgradeSysCat() throws 
Exception {

Review Comment:
   Was this rename intentional?



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/AsyncIndexPermissionIT.java:
##########
@@ -0,0 +1,340 @@
+/*
+ * 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 org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.LocalHBaseCluster;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.*;

Review Comment:
   Nit : Several wildcard imports in this file. We are supposed to use single 
class imports, right?



##########
phoenix-core/src/it/java/org/apache/phoenix/end2end/AsyncIndexPermissionIT.java:
##########
@@ -0,0 +1,340 @@
+/*
+ * 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 org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.LocalHBaseCluster;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.*;
+import org.apache.hadoop.hbase.security.AccessDeniedException;
+import org.apache.hadoop.hbase.security.User;
+import org.apache.hadoop.hbase.security.access.AccessControlClient;
+import org.apache.hadoop.hbase.security.access.Permission;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.mapreduce.Job;
+import org.apache.phoenix.mapreduce.index.IndexTool;
+import org.apache.phoenix.mapreduce.index.PhoenixIndexImportDirectMapper;
+import org.apache.phoenix.mapreduce.index.PhoenixServerBuildIndexMapper;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.thirdparty.com.google.common.base.Throwables;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.*;
+import org.junit.experimental.categories.Category;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.security.PrivilegedExceptionAction;
+import java.sql.*;
+import java.sql.Connection;
+import java.util.*;
+import java.util.concurrent.Callable;
+
+import static org.apache.phoenix.end2end.BasePermissionsIT.*;
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.*;
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+import static org.junit.Assert.*;
+
+@Category(NeedsOwnMiniClusterTest.class)
+public class AsyncIndexPermissionIT extends BaseTest{
+
+//    static HBaseTestingUtility testUtil;
+
+    private static final String SUPER_USER = System.getProperty("user.name");
+
+    boolean isNamespaceMapped;
+
+    // Super User has all the access
+    protected static User superUser1 = null;
+    protected static User superUser2 = null;
+
+    // Regular users are granted and revoked permissions as needed
+    protected User regularUser1 = null;
+    protected User regularUser2 = null;
+    protected User regularUser3 = null;
+
+    public AsyncIndexPermissionIT() throws Exception {
+        this.isNamespaceMapped = true;
+    }
+
+    @BeforeClass
+    public static synchronized void doSetup() throws Exception {
+        if (null != utility) {
+            utility.shutdownMiniCluster();
+            utility = null;
+        }
+
+        enablePhoenixHBaseAuthorization(config, false);
+        configureNamespacesOnServer(config, true);
+        configureStatsConfigurations(config);
+        config.setBoolean(LocalHBaseCluster.ASSIGN_RANDOM_PORTS, true);
+
+
+        Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(2);
+        serverProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, 
Boolean.toString(true));
+
+        Map<String, String> clientProps = Maps.newHashMapWithExpectedSize(2);
+        clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, 
Boolean.toString(true));
+
+        utility = new HBaseTestingUtility(config);
+
+        setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()),
+                new ReadOnlyProps(clientProps.entrySet().iterator()));
+
+        superUser1 = User.createUserForTesting(config, SUPER_USER, new 
String[0]);
+        superUser2 = User.createUserForTesting(config, "superUser2", new 
String[0]);
+    }
+
+    @Before
+    public void initUsersAndTables() {
+        regularUser1 = User.createUserForTesting(config, "regularUser1_"
+                + generateUniqueName(), new String[0]);
+        regularUser2 = User.createUserForTesting(config, "regularUser2_"
+                + generateUniqueName(), new String[0]);
+        regularUser3 = User.createUserForTesting(config, "regularUser3_"
+                + generateUniqueName(), new String[0]);
+    }
+
+    private BasePermissionsIT.AccessTestAction createIndex(final String 
indexName, final String dataTable, final String columns) throws SQLException {
+        return new BasePermissionsIT.AccessTestAction() {
+            @Override
+            public Object run() throws Exception {
+                try (Connection conn = DriverManager.getConnection(getUrl()); 
Statement stmt = conn.createStatement();) {
+                    String indexStmtSQL = "CREATE index " + indexName + " on " 
+ dataTable + " (" + columns +")";
+                    assertFalse(stmt.execute(indexStmtSQL));
+                }
+                return null;
+            }
+        };
+    }
+
+    public static IndexTool runIndexTool(Configuration conf, boolean 
useSnapshot, String schemaName,

Review Comment:
   Can we use the runIndexTool and verifyMapper methods from IndexToolIT 
instead of reimplementing them here?



##########
phoenix-core-client/src/main/java/org/apache/phoenix/mapreduce/index/IndexToolTableUtil.java:
##########
@@ -0,0 +1,168 @@
+/*
+ * 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.mapreduce.index;
+
+
+
+import java.io.IOException;
+import java.sql.Connection;
+
+import java.sql.SQLException;
+import java.util.UUID;
+
+
+import org.apache.hadoop.hbase.NamespaceDescriptor;
+import 
org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting;
+import org.apache.hadoop.hbase.TableExistsException;
+import org.apache.hadoop.hbase.client.*;
+import org.apache.phoenix.coprocessorclient.MetaDataProtocol;
+import org.apache.phoenix.query.QueryConstants;
+
+import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.hbase.TableName;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+
+import org.apache.phoenix.query.ConnectionQueryServices;
+
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.util.ClientUtil;
+import org.apache.phoenix.util.SchemaUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.phoenix.query.QueryConstants.SYSTEM_SCHEMA_NAME;
+
+/**
+ * Utility class to create index tables and/or migrate them.
+ *
+ */
+public class IndexToolTableUtil extends Configured {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(IndexToolTableUtil.class);
+
+    public final static String OUTPUT_TABLE_NAME = "PHOENIX_INDEX_TOOL";
+    public static String SYSTEM_OUTPUT_TABLE_NAME = 
SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,

Review Comment:
   Nit: Can we use OUTPUT_TABLE_FULL_NAME instead of SYSTEM_OUTPUT_TABLE_NAME?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to