This is an automated email from the ASF dual-hosted git repository.
vjasani 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 137cca5734 spotless fix
137cca5734 is described below
commit 137cca5734ebde3285ca455af708e90903603554
Author: Viraj Jasani <[email protected]>
AuthorDate: Sun Feb 1 13:48:02 2026 -0800
spotless fix
---
.../mapreduce/index/IndexToolTableUtil.java | 228 ++++-----
.../phoenix/query/ConnectionQueryServicesImpl.java | 3 +-
.../apache/phoenix/mapreduce/index/IndexTool.java | 12 +-
.../index/IndexVerificationOutputRepository.java | 12 +-
.../index/IndexVerificationResultRepository.java | 13 +-
.../phoenix/end2end/AsyncIndexPermissionIT.java | 552 +++++++++++----------
.../apache/phoenix/end2end/BasePermissionsIT.java | 2 +-
.../org/apache/phoenix/end2end/IndexToolIT.java | 39 +-
.../end2end/LoadSystemTableSnapshotBase.java | 19 +-
.../MigrateSystemTablesToSystemNamespaceIT.java | 17 +-
.../end2end/SkipSystemTablesExistenceCheckIT.java | 2 +-
.../SystemTablesCreationOnConnectionIT.java | 6 +-
.../phoenix/end2end/UpgradeIndexToolTablesIT.java | 118 +++--
...eIndexToolTablesNameSpaceMappingDisabledIT.java | 15 +-
14 files changed, 530 insertions(+), 508 deletions(-)
diff --git
a/phoenix-core-client/src/main/java/org/apache/phoenix/mapreduce/index/IndexToolTableUtil.java
b/phoenix-core-client/src/main/java/org/apache/phoenix/mapreduce/index/IndexToolTableUtil.java
index fd03a5c18e..e679e46870 100644
---
a/phoenix-core-client/src/main/java/org/apache/phoenix/mapreduce/index/IndexToolTableUtil.java
+++
b/phoenix-core-client/src/main/java/org/apache/phoenix/mapreduce/index/IndexToolTableUtil.java
@@ -7,7 +7,7 @@
* "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
+ * 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,
@@ -17,152 +17,144 @@
*/
package org.apache.phoenix.mapreduce.index;
-
+import static org.apache.phoenix.query.QueryConstants.SYSTEM_SCHEMA_NAME;
import java.io.IOException;
import java.sql.Connection;
-
import java.sql.SQLException;
import java.util.UUID;
-
-
+import org.apache.hadoop.conf.Configured;
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.TableName;
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.query.QueryConstants;
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;
+import
org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting;
/**
* 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 OUTPUT_TABLE_FULL_NAME =
SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,
- OUTPUT_TABLE_NAME);
-
- public final static String RESULT_TABLE_NAME = "PHOENIX_INDEX_TOOL_RESULT";
- public static String RESULT_TABLE_FULL_NAME =
SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,
- RESULT_TABLE_NAME);
-
- public static void setIndexToolTableName(Connection connection) throws
Exception {
- ConnectionQueryServices queryServices =
connection.unwrap(PhoenixConnection.class).getQueryServices();
- if (SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM,
queryServices.getConfiguration())) {
- OUTPUT_TABLE_FULL_NAME =
SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME, OUTPUT_TABLE_NAME).replace(
- QueryConstants.NAME_SEPARATOR,
- QueryConstants.NAMESPACE_SEPARATOR);
- RESULT_TABLE_FULL_NAME =
SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME, RESULT_TABLE_NAME).replace(
- QueryConstants.NAME_SEPARATOR,
- QueryConstants.NAMESPACE_SEPARATOR);
- } else {
- OUTPUT_TABLE_FULL_NAME =
SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME, OUTPUT_TABLE_NAME);
- RESULT_TABLE_FULL_NAME =
SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME, RESULT_TABLE_NAME);
- }
+ private static final Logger LOGGER =
LoggerFactory.getLogger(IndexToolTableUtil.class);
+
+ public final static String OUTPUT_TABLE_NAME = "PHOENIX_INDEX_TOOL";
+ public static String OUTPUT_TABLE_FULL_NAME =
+ SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME, OUTPUT_TABLE_NAME);
+
+ public final static String RESULT_TABLE_NAME = "PHOENIX_INDEX_TOOL_RESULT";
+ public static String RESULT_TABLE_FULL_NAME =
+ SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME, RESULT_TABLE_NAME);
+
+ public static void setIndexToolTableName(Connection connection) throws
Exception {
+ ConnectionQueryServices queryServices =
+ connection.unwrap(PhoenixConnection.class).getQueryServices();
+ if (SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM,
queryServices.getConfiguration())) {
+ OUTPUT_TABLE_FULL_NAME = SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,
OUTPUT_TABLE_NAME)
+ .replace(QueryConstants.NAME_SEPARATOR,
QueryConstants.NAMESPACE_SEPARATOR);
+ RESULT_TABLE_FULL_NAME = SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,
RESULT_TABLE_NAME)
+ .replace(QueryConstants.NAME_SEPARATOR,
QueryConstants.NAMESPACE_SEPARATOR);
+ } else {
+ OUTPUT_TABLE_FULL_NAME = SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,
OUTPUT_TABLE_NAME);
+ RESULT_TABLE_FULL_NAME = SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,
RESULT_TABLE_NAME);
}
-
- public static Table createResultTable(Connection connection) throws
IOException, SQLException {
- ConnectionQueryServices queryServices =
connection.unwrap(PhoenixConnection.class).getQueryServices();
- try (Admin admin = queryServices.getAdmin()) {
- TableName resultTableName =
TableName.valueOf(RESULT_TABLE_FULL_NAME);
- if
(RESULT_TABLE_FULL_NAME.contains(QueryConstants.NAMESPACE_SEPARATOR)) {
- createSystemNamespaceTable(connection);
- }
- return createTable(admin, resultTableName);
- }
- }
-
- public static Table createOutputTable(Connection connection) throws
IOException, SQLException {
- ConnectionQueryServices queryServices =
connection.unwrap(PhoenixConnection.class).getQueryServices();
- try (Admin admin = queryServices.getAdmin()) {
- TableName outputTableName =
TableName.valueOf(OUTPUT_TABLE_FULL_NAME);
- if
(OUTPUT_TABLE_FULL_NAME.contains(QueryConstants.NAMESPACE_SEPARATOR)) {
- createSystemNamespaceTable(connection);
- }
- return createTable(admin, outputTableName);
- }
+ }
+
+ public static Table createResultTable(Connection connection) throws
IOException, SQLException {
+ ConnectionQueryServices queryServices =
+ connection.unwrap(PhoenixConnection.class).getQueryServices();
+ try (Admin admin = queryServices.getAdmin()) {
+ TableName resultTableName = TableName.valueOf(RESULT_TABLE_FULL_NAME);
+ if (RESULT_TABLE_FULL_NAME.contains(QueryConstants.NAMESPACE_SEPARATOR))
{
+ createSystemNamespaceTable(connection);
+ }
+ return createTable(admin, resultTableName);
}
-
- public static void createSystemNamespaceTable(Connection connection)
throws IOException, SQLException {
- ConnectionQueryServices queryServices =
connection.unwrap(PhoenixConnection.class).getQueryServices();
- if (SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM,
queryServices.getConfiguration())) {
- try (Admin admin = queryServices.getAdmin()) {
- if (!ClientUtil.isHBaseNamespaceAvailable(admin,
SYSTEM_SCHEMA_NAME)) {
- NamespaceDescriptor namespaceDescriptor =
-
NamespaceDescriptor.create(SYSTEM_SCHEMA_NAME).build();
- admin.createNamespace(namespaceDescriptor);
- }
- }
- }
+ }
+
+ public static Table createOutputTable(Connection connection) throws
IOException, SQLException {
+ ConnectionQueryServices queryServices =
+ connection.unwrap(PhoenixConnection.class).getQueryServices();
+ try (Admin admin = queryServices.getAdmin()) {
+ TableName outputTableName = TableName.valueOf(OUTPUT_TABLE_FULL_NAME);
+ if (OUTPUT_TABLE_FULL_NAME.contains(QueryConstants.NAMESPACE_SEPARATOR))
{
+ createSystemNamespaceTable(connection);
+ }
+ return createTable(admin, outputTableName);
}
-
- @VisibleForTesting
- private static Table createTable(Admin admin, TableName tableName) throws
IOException {
- if (!admin.tableExists(tableName)) {
- ColumnFamilyDescriptor columnDescriptor =
- ColumnFamilyDescriptorBuilder
-
.newBuilder(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES)
- .setTimeToLive(MetaDataProtocol.DEFAULT_LOG_TTL)
- .build();
- TableDescriptor tableDescriptor =
TableDescriptorBuilder.newBuilder(tableName)
- .setColumnFamily(columnDescriptor).build();
- try {
- admin.createTable(tableDescriptor);
- } catch (TableExistsException e) {
- LOGGER.warn("Table exists, ignoring", e);
- }
+ }
+
+ public static void createSystemNamespaceTable(Connection connection)
+ throws IOException, SQLException {
+ ConnectionQueryServices queryServices =
+ connection.unwrap(PhoenixConnection.class).getQueryServices();
+ if (SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM,
queryServices.getConfiguration())) {
+ try (Admin admin = queryServices.getAdmin()) {
+ if (!ClientUtil.isHBaseNamespaceAvailable(admin, SYSTEM_SCHEMA_NAME)) {
+ NamespaceDescriptor namespaceDescriptor =
+ NamespaceDescriptor.create(SYSTEM_SCHEMA_NAME).build();
+ admin.createNamespace(namespaceDescriptor);
}
- return admin.getConnection().getTable(tableName);
+ }
}
-
-
- public static void createNewIndexToolTables(Connection connection) throws
Exception {
- setIndexToolTableName(connection);
-
- migrateTable(connection, OUTPUT_TABLE_NAME);
- migrateTable(connection, RESULT_TABLE_NAME);
+ }
+
+ @VisibleForTesting
+ private static Table createTable(Admin admin, TableName tableName) throws
IOException {
+ if (!admin.tableExists(tableName)) {
+ ColumnFamilyDescriptor columnDescriptor =
+
ColumnFamilyDescriptorBuilder.newBuilder(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES)
+ .setTimeToLive(MetaDataProtocol.DEFAULT_LOG_TTL).build();
+ TableDescriptor tableDescriptor =
+
TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(columnDescriptor).build();
+ try {
+ admin.createTable(tableDescriptor);
+ } catch (TableExistsException e) {
+ LOGGER.warn("Table exists, ignoring", e);
+ }
}
-
- private static void migrateTable(Connection connection, String tableName)
throws Exception {
- if (!tableName.equals(OUTPUT_TABLE_NAME) &&
!tableName.equals(RESULT_TABLE_NAME)) {
- LOGGER.info("Only migrating PHOENIX_INDEX_TOOL tables!");
+ return admin.getConnection().getTable(tableName);
+ }
+
+ public static void createNewIndexToolTables(Connection connection) throws
Exception {
+ setIndexToolTableName(connection);
+
+ migrateTable(connection, OUTPUT_TABLE_NAME);
+ migrateTable(connection, RESULT_TABLE_NAME);
+ }
+
+ private static void migrateTable(Connection connection, String tableName)
throws Exception {
+ if (!tableName.equals(OUTPUT_TABLE_NAME) &&
!tableName.equals(RESULT_TABLE_NAME)) {
+ LOGGER.info("Only migrating PHOENIX_INDEX_TOOL tables!");
+ } else {
+ ConnectionQueryServices queryServices =
+ connection.unwrap(PhoenixConnection.class).getQueryServices();
+ try (Admin admin = queryServices.getAdmin()) {
+ TableName oldTableName = TableName.valueOf(tableName);
+ String newTableNameString =
+ tableName.equals(OUTPUT_TABLE_NAME) ? OUTPUT_TABLE_FULL_NAME :
RESULT_TABLE_FULL_NAME;
+
+ TableName newTableName = TableName.valueOf(newTableNameString);
+
+ if (admin.tableExists(oldTableName)) {
+ String snapshotName = tableName + "_" + UUID.randomUUID();
+ admin.disableTable(oldTableName);
+ admin.snapshot(snapshotName, oldTableName);
+ admin.cloneSnapshot(snapshotName, newTableName);
+ admin.deleteSnapshot(snapshotName);
+ admin.deleteTable(oldTableName);
} else {
- ConnectionQueryServices queryServices =
connection.unwrap(PhoenixConnection.class).getQueryServices();
- try (Admin admin = queryServices.getAdmin()) {
- TableName oldTableName = TableName.valueOf(tableName);
- String newTableNameString =
tableName.equals(OUTPUT_TABLE_NAME) ?
- OUTPUT_TABLE_FULL_NAME : RESULT_TABLE_FULL_NAME;
-
- TableName newTableName = TableName.valueOf(newTableNameString);
-
- if (admin.tableExists(oldTableName)) {
- String snapshotName = tableName + "_" + UUID.randomUUID();
- admin.disableTable(oldTableName);
- admin.snapshot(snapshotName, oldTableName);
- admin.cloneSnapshot(snapshotName, newTableName);
- admin.deleteSnapshot(snapshotName);
- admin.deleteTable(oldTableName);
- } else {
- createTable(admin, newTableName);
- }
- }
+ createTable(admin, newTableName);
}
+ }
}
+ }
}
diff --git
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 8b5a4a3870..926089201e 100644
---
a/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++
b/phoenix-core-client/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -4971,7 +4971,8 @@ public class ConnectionQueryServicesImpl extends
DelegateQueryServices
// move data to the new tables under System, or simply create the new
tables
IndexToolTableUtil.createNewIndexToolTables(metaConnection);
- } catch (Exception ignore) {}
+ } catch (Exception ignore) {
+ }
clearUpgradeRequired();
success = true;
diff --git
a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
index c3f0d1aa81..9ca210ae40 100644
---
a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
+++
b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
@@ -88,8 +88,8 @@ import org.apache.phoenix.query.QueryServices;
import org.apache.phoenix.query.QueryServicesOptions;
import org.apache.phoenix.schema.PIndexState;
import org.apache.phoenix.schema.PTable;
-import org.apache.phoenix.schema.PTableType;
import org.apache.phoenix.schema.PTable.IndexType;
+import org.apache.phoenix.schema.PTableType;
import org.apache.phoenix.schema.TableRef;
import org.apache.phoenix.schema.types.PVarchar;
import org.apache.phoenix.util.ByteUtil;
@@ -1008,15 +1008,15 @@ public class IndexTool extends Configured implements
Tool {
pIndexTable = connection.unwrap(PhoenixConnection.class)
.getTable(SchemaUtil.getQualifiedTableName(schemaName, indexTable));
if (SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM, getConf())) {
- pIndexTable = connection.unwrap(PhoenixConnection.class).getTable(
- SchemaUtil.getQualifiedTableName(schemaName, indexTable).replace(
- QueryConstants.NAME_SEPARATOR,
- QueryConstants.NAMESPACE_SEPARATOR));
+ pIndexTable = connection.unwrap(PhoenixConnection.class)
+ .getTable(SchemaUtil.getQualifiedTableName(schemaName, indexTable)
+ .replace(QueryConstants.NAME_SEPARATOR,
QueryConstants.NAMESPACE_SEPARATOR));
}
indexType = pIndexTable.getIndexType();
qIndexTable = SchemaUtil.getQualifiedTableName(schemaName, indexTable);
if (SchemaUtil.isNamespaceMappingEnabled(PTableType.SYSTEM, getConf())) {
- qIndexTable = qIndexTable.replace(QueryConstants.NAME_SEPARATOR,
QueryConstants.NAMESPACE_SEPARATOR);
+ qIndexTable =
+ qIndexTable.replace(QueryConstants.NAME_SEPARATOR,
QueryConstants.NAMESPACE_SEPARATOR);
}
if (IndexType.LOCAL.equals(indexType)) {
isLocalIndexBuild = true;
diff --git
a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java
b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java
index 00d389b069..f59ae64fc2 100644
---
a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java
+++
b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java
@@ -18,13 +18,11 @@
package org.apache.phoenix.mapreduce.index;
import java.io.IOException;
-import java.sql.SQLException;
import java.sql.Connection;
-
+import java.sql.SQLException;
import java.util.ArrayList;
-import java.util.List;
import java.util.Iterator;
-
+import java.util.List;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
@@ -55,8 +53,10 @@ public class IndexVerificationOutputRepository implements
AutoCloseable {
private boolean shouldLogBeyondMaxLookback = true;
public final static String OUTPUT_TABLE_NAME =
IndexToolTableUtil.OUTPUT_TABLE_FULL_NAME;
- public final static byte[] OUTPUT_TABLE_NAME_BYTES =
Bytes.toBytes(IndexToolTableUtil.OUTPUT_TABLE_FULL_NAME);
- public final static byte[] OUTPUT_TABLE_COLUMN_FAMILY =
QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES;
+ public final static byte[] OUTPUT_TABLE_NAME_BYTES =
+ Bytes.toBytes(IndexToolTableUtil.OUTPUT_TABLE_FULL_NAME);
+ public final static byte[] OUTPUT_TABLE_COLUMN_FAMILY =
+ QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES;
public final static String DATA_TABLE_NAME = "DTName";
public final static byte[] DATA_TABLE_NAME_BYTES =
Bytes.toBytes(DATA_TABLE_NAME);
diff --git
a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java
b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java
index ec63f825aa..0fc9940bd0 100644
---
a/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java
+++
b/phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.hadoop.hbase.Cell;
-
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
@@ -46,7 +45,8 @@ public class IndexVerificationResultRepository implements
AutoCloseable {
public static final String ROW_KEY_SEPARATOR = "|";
public static final byte[] ROW_KEY_SEPARATOR_BYTE =
Bytes.toBytes(ROW_KEY_SEPARATOR);
public static String RESULT_TABLE_NAME =
IndexToolTableUtil.RESULT_TABLE_FULL_NAME;
- public static byte[] RESULT_TABLE_NAME_BYTES =
Bytes.toBytes(IndexToolTableUtil.RESULT_TABLE_FULL_NAME);
+ public static byte[] RESULT_TABLE_NAME_BYTES =
+ Bytes.toBytes(IndexToolTableUtil.RESULT_TABLE_FULL_NAME);
public final static byte[] RESULT_TABLE_COLUMN_FAMILY =
QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES;
public final static String SCANNED_DATA_ROW_COUNT = "ScannedDataRowCount";
@@ -160,13 +160,16 @@ public class IndexVerificationResultRepository implements
AutoCloseable {
}
- public IndexVerificationResultRepository(Connection conn, byte[]
indexNameBytes) throws SQLException {
+ public IndexVerificationResultRepository(Connection conn, byte[]
indexNameBytes)
+ throws SQLException {
resultTable = getTable(conn,
Bytes.toBytes(IndexToolTableUtil.RESULT_TABLE_FULL_NAME));
indexTable = getTable(conn, indexNameBytes);
}
- public IndexVerificationResultRepository(byte[] indexName, HTableFactory
hTableFactory) throws IOException {
- resultTable = hTableFactory.getTable(new
ImmutableBytesPtr(Bytes.toBytes(IndexToolTableUtil.RESULT_TABLE_FULL_NAME)));
+ public IndexVerificationResultRepository(byte[] indexName, HTableFactory
hTableFactory)
+ throws IOException {
+ resultTable = hTableFactory
+ .getTable(new
ImmutableBytesPtr(Bytes.toBytes(IndexToolTableUtil.RESULT_TABLE_FULL_NAME)));
indexTable = hTableFactory.getTable(new ImmutableBytesPtr(indexName));
}
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AsyncIndexPermissionIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AsyncIndexPermissionIT.java
index 692e65f032..5094825bcf 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AsyncIndexPermissionIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AsyncIndexPermissionIT.java
@@ -7,7 +7,7 @@
* "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
+ * 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,
@@ -17,6 +17,29 @@
*/
package org.apache.phoenix.end2end;
+import static
org.apache.phoenix.end2end.BasePermissionsIT.configureNamespacesOnServer;
+import static
org.apache.phoenix.end2end.BasePermissionsIT.configureStatsConfigurations;
+import static
org.apache.phoenix.end2end.BasePermissionsIT.enablePhoenixHBaseAuthorization;
+import static org.apache.phoenix.end2end.BasePermissionsIT.updateACLs;
+import static
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.security.PrivilegedExceptionAction;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.Callable;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsPermission;
@@ -36,296 +59,297 @@ import
org.apache.hadoop.hbase.security.access.UserPermission;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.phoenix.query.BaseTest;
import org.apache.phoenix.query.QueryServices;
-import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
import org.apache.phoenix.util.PhoenixRuntime;
import org.apache.phoenix.util.ReadOnlyProps;
import org.apache.phoenix.util.SchemaUtil;
import org.junit.Assert;
-import org.junit.BeforeClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
-
-import java.security.PrivilegedExceptionAction;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.PreparedStatement;
-
-import java.util.Collections;
-import java.util.Properties;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-
-import static org.apache.phoenix.end2end.BasePermissionsIT.updateACLs;
-import static
org.apache.phoenix.end2end.BasePermissionsIT.enablePhoenixHBaseAuthorization;
-import static
org.apache.phoenix.end2end.BasePermissionsIT.configureNamespacesOnServer;
-import static
org.apache.phoenix.end2end.BasePermissionsIT.configureStatsConfigurations;
-import static
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
@Category(NeedsOwnMiniClusterTest.class)
-public class AsyncIndexPermissionIT extends BaseTest{
-
-// static HBaseTestingUtility testUtil;
+public class AsyncIndexPermissionIT extends BaseTest {
- private static final String SUPER_USER = System.getProperty("user.name");
+ // static HBaseTestingUtility testUtil;
- boolean isNamespaceMapped;
+ private static final String SUPER_USER = System.getProperty("user.name");
- // Super User has all the access
- protected static User superUser1 = null;
+ boolean isNamespaceMapped;
- // Regular users are granted and revoked permissions as needed
- protected User regularUser1 = null;
+ // Super User has all the access
+ protected static User superUser1 = null;
- public AsyncIndexPermissionIT() throws Exception {
- isNamespaceMapped = true;
- }
-
- @BeforeClass
- public static synchronized void doSetup() throws Exception {
- if (null != utility) {
- utility.shutdownMiniCluster();
- utility = null;
- }
+ // Regular users are granted and revoked permissions as needed
+ protected User regularUser1 = null;
- enablePhoenixHBaseAuthorization(config, false);
- configureNamespacesOnServer(config, true);
- configureStatsConfigurations(config);
- config.setBoolean(LocalHBaseCluster.ASSIGN_RANDOM_PORTS, true);
+ public AsyncIndexPermissionIT() throws Exception {
+ isNamespaceMapped = 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]);
+ @BeforeClass
+ public static synchronized void doSetup() throws Exception {
+ if (null != utility) {
+ utility.shutdownMiniCluster();
+ utility = null;
}
- @Before
- public void initUsersAndTables() {
- regularUser1 = User.createUserForTesting(config, "regularUser1_"
- + 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;
- }
- };
- }
-
- private BasePermissionsIT.AccessTestAction createIndexAsync(final String
indexName, final String schema, final String tableName, final String columns,
final int status) throws SQLException {
- return new BasePermissionsIT.AccessTestAction() {
- @Override
- public Object run() throws Exception {
- final String dataTable = SchemaUtil.getTableName(schema,
tableName);
- try (Connection conn = DriverManager.getConnection(getUrl());
Statement stmt = conn.createStatement();) {
- String indexStmtSQL = "CREATE index " + indexName + " on "
+ dataTable + " (" + columns +") ASYNC";
- assertFalse(stmt.execute(indexStmtSQL));
- }
- try {
- IndexToolIT.runIndexTool(false, schema, tableName,
indexName, null, status, "-op", "/tmp/regular_User1_dir");
- } catch (Exception ignored) {
- // Running the indexTool might fail because of
AccessDeniedException
- }
- return null;
- }
- };
- }
-
- @Test(timeout = 80000)
- public void testCreateIndex() throws Throwable {
- final String schema = generateUniqueName();
- final String tableName = generateUniqueName();
- verifyAllowed(createSchema(schema), superUser1);
- grantPermissions(regularUser1.getShortName(), schema,
Permission.Action.WRITE,
- Permission.Action.READ, Permission.Action.EXEC,
Permission.Action.ADMIN);
- grantPermissions(regularUser1.getShortName(), "SYSTEM",
Permission.Action.READ, Permission.Action.EXEC);
- grantPermissions(regularUser1.getShortName(),
Collections.singleton("SYSTEM:CATALOG"), Permission.Action.EXEC,
Permission.Action.WRITE, Permission.Action.READ);
-
- Path workDir = new Path("/tmp/regular_User1_dir");
- FileSystem fs = workDir.getFileSystem(config);
-
- fs.mkdirs(workDir, FsPermission.valueOf("-rwxrwxrwx"));
-
- fs.setOwner(workDir, regularUser1.getShortName(), "");
-
- superUser1.runAs(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws Exception {
- Admin admin = utility.getAdmin();
- TableDescriptorBuilder tdb =
TableDescriptorBuilder.newBuilder(TableName.valueOf(schema + ":" + tableName));
- ColumnFamilyDescriptor cfd =
ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("0")).build();
- tdb.setColumnFamily(cfd);
- TableDescriptor td = tdb.build();
- admin.createTable(td);
- return null;
- }
- });
-
- List<UserPermission> perms =
AccessControlClient.getUserPermissions(getUtility().getConnection(),
SYSTEM_CATALOG_NAME, regularUser1.getShortName());
- for (UserPermission perm : perms) {
- Assert.assertEquals(perm.getUser(), regularUser1.getShortName() );
- Permission.Action[] actions = { Permission.Action.READ,
Permission.Action.WRITE, Permission.Action.EXEC };
- Assert.assertEquals(perm.getPermission().getActions(), actions );
+ 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]);
+ }
+
+ @Before
+ public void initUsersAndTables() {
+ regularUser1 =
+ User.createUserForTesting(config, "regularUser1_" +
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));
}
-
- verifyAllowed(createTable(SchemaUtil.getTableName(schema, tableName),
2), regularUser1);
- verifyAllowed(createIndex("ind1", SchemaUtil.getTableName(schema,
tableName), "PK"), regularUser1);
-
- String ind3name = "IND3";
- regularUser1.runAs(createIndexAsync(ind3name, schema, tableName, "PK",
0));
-
- validateIndex(ind3name, schema, "a");
- }
-
- private void validateIndex(String ind3name, String schema, String
expectedStatus) throws SQLException {
- String sql = "SELECT " +
"TABLE_SCHEM,TABLE_NAME,TABLE_TYPE,INDEX_STATE" + " FROM " + SYSTEM_CATALOG_NAME
- + " WHERE TABLE_SCHEM = '%s' AND TABLE_NAME = '%s' and
TABLE_TYPE = 'i'";
- ResultSet rs =
getConnection().createStatement().executeQuery(String.format(sql, schema,
ind3name));
- assertTrue(rs.next());
- assertEquals(expectedStatus, rs.getString(4));
- }
-
- public Connection getConnection() throws SQLException {
- return getConnection(null);
- }
-
- public Connection getConnection(String tenantId) throws SQLException {
- return DriverManager.getConnection(getUrl(),
getClientProperties(tenantId));
- }
-
- private Properties getClientProperties(String tenantId) {
- Properties props = new Properties();
- if(tenantId != null) {
- props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
+ return null;
+ }
+ };
+ }
+
+ private BasePermissionsIT.AccessTestAction createIndexAsync(final String
indexName,
+ final String schema, final String tableName, final String columns, final
int status)
+ throws SQLException {
+ return new BasePermissionsIT.AccessTestAction() {
+ @Override
+ public Object run() throws Exception {
+ final String dataTable = SchemaUtil.getTableName(schema, tableName);
+ try (Connection conn = DriverManager.getConnection(getUrl());
+ Statement stmt = conn.createStatement();) {
+ String indexStmtSQL =
+ "CREATE index " + indexName + " on " + dataTable + " (" + columns
+ ") ASYNC";
+ assertFalse(stmt.execute(indexStmtSQL));
}
- props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
Boolean.toString(isNamespaceMapped));
- return props;
- }
-
- public BasePermissionsIT.AccessTestAction createSchema(final String
schemaName) throws SQLException {
- return new BasePermissionsIT.AccessTestAction() {
- @Override
- public Object run() throws Exception {
- if (isNamespaceMapped) {
- try (Connection conn = getConnection(); Statement stmt =
conn.createStatement();) {
- assertFalse(stmt.execute("CREATE SCHEMA " +
schemaName));
- }
- }
- return null;
- }
- };
+ try {
+ IndexToolIT.runIndexTool(false, schema, tableName, indexName, null,
status, "-op",
+ "/tmp/regular_User1_dir");
+ } catch (Exception ignored) {
+ // Running the indexTool might fail because of AccessDeniedException
+ }
+ return null;
+ }
+ };
+ }
+
+ @Test(timeout = 80000)
+ public void testCreateIndex() throws Throwable {
+ final String schema = generateUniqueName();
+ final String tableName = generateUniqueName();
+ verifyAllowed(createSchema(schema), superUser1);
+ grantPermissions(regularUser1.getShortName(), schema,
Permission.Action.WRITE,
+ Permission.Action.READ, Permission.Action.EXEC, Permission.Action.ADMIN);
+ grantPermissions(regularUser1.getShortName(), "SYSTEM",
Permission.Action.READ,
+ Permission.Action.EXEC);
+ grantPermissions(regularUser1.getShortName(),
Collections.singleton("SYSTEM:CATALOG"),
+ Permission.Action.EXEC, Permission.Action.WRITE, Permission.Action.READ);
+
+ Path workDir = new Path("/tmp/regular_User1_dir");
+ FileSystem fs = workDir.getFileSystem(config);
+
+ fs.mkdirs(workDir, FsPermission.valueOf("-rwxrwxrwx"));
+
+ fs.setOwner(workDir, regularUser1.getShortName(), "");
+
+ superUser1.runAs(new PrivilegedExceptionAction<Void>() {
+ @Override
+ public Void run() throws Exception {
+ Admin admin = utility.getAdmin();
+ TableDescriptorBuilder tdb =
+ TableDescriptorBuilder.newBuilder(TableName.valueOf(schema + ":" +
tableName));
+ ColumnFamilyDescriptor cfd =
+ ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("0")).build();
+ tdb.setColumnFamily(cfd);
+ TableDescriptor td = tdb.build();
+ admin.createTable(td);
+ return null;
+ }
+ });
+
+ List<UserPermission> perms = AccessControlClient.getUserPermissions(
+ getUtility().getConnection(), SYSTEM_CATALOG_NAME,
regularUser1.getShortName());
+ for (UserPermission perm : perms) {
+ Assert.assertEquals(perm.getUser(), regularUser1.getShortName());
+ Permission.Action[] actions =
+ { Permission.Action.READ, Permission.Action.WRITE,
Permission.Action.EXEC };
+ Assert.assertEquals(perm.getPermission().getActions(), actions);
}
- BasePermissionsIT.AccessTestAction createTable(final String tableName, int
numRecordsToInsert) throws SQLException {
- return new BasePermissionsIT.AccessTestAction() {
- @Override
- public Object run() throws Exception {
- try (Connection conn = DriverManager.getConnection(getUrl());
Statement stmt = conn.createStatement();) {
- assertFalse(stmt.execute("CREATE TABLE " + tableName +
"(pk INTEGER not null primary key, data VARCHAR, val integer)"));
- try (PreparedStatement pstmt =
conn.prepareStatement("UPSERT INTO " + tableName + " values(?, ?, ?)")) {
- for (int i = 0; i < numRecordsToInsert; i++) {
- pstmt.setInt(1, i);
- pstmt.setString(2, Integer.toString(i));
- pstmt.setInt(3, i);
- assertEquals(1, pstmt.executeUpdate());
- }
- }
- conn.commit();
- }
- return null;
- }
- };
+ verifyAllowed(createTable(SchemaUtil.getTableName(schema, tableName), 2),
regularUser1);
+ verifyAllowed(createIndex("ind1", SchemaUtil.getTableName(schema,
tableName), "PK"),
+ regularUser1);
+
+ String ind3name = "IND3";
+ regularUser1.runAs(createIndexAsync(ind3name, schema, tableName, "PK", 0));
+
+ validateIndex(ind3name, schema, "a");
+ }
+
+ private void validateIndex(String ind3name, String schema, String
expectedStatus)
+ throws SQLException {
+ String sql =
+ "SELECT " + "TABLE_SCHEM,TABLE_NAME,TABLE_TYPE,INDEX_STATE" + " FROM " +
SYSTEM_CATALOG_NAME
+ + " WHERE TABLE_SCHEM = '%s' AND TABLE_NAME = '%s' and TABLE_TYPE =
'i'";
+ ResultSet rs =
+ getConnection().createStatement().executeQuery(String.format(sql,
schema, ind3name));
+ assertTrue(rs.next());
+ assertEquals(expectedStatus, rs.getString(4));
+ }
+
+ public Connection getConnection() throws SQLException {
+ return getConnection(null);
+ }
+
+ public Connection getConnection(String tenantId) throws SQLException {
+ return DriverManager.getConnection(getUrl(),
getClientProperties(tenantId));
+ }
+
+ private Properties getClientProperties(String tenantId) {
+ Properties props = new Properties();
+ if (tenantId != null) {
+ props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
}
-
- /** This fails only in case of ADE or empty list for any of the users. */
- public void verifyAllowed(BasePermissionsIT.AccessTestAction action,
User... users) throws Exception {
- if(users.length == 0) {
- throw new Exception("Action needs at least one user to run");
- }
- for (User user : users) {
- verifyAllowed(user, action);
+ props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
+ Boolean.toString(isNamespaceMapped));
+ return props;
+ }
+
+ public BasePermissionsIT.AccessTestAction createSchema(final String
schemaName)
+ throws SQLException {
+ return new BasePermissionsIT.AccessTestAction() {
+ @Override
+ public Object run() throws Exception {
+ if (isNamespaceMapped) {
+ try (Connection conn = getConnection(); Statement stmt =
conn.createStatement();) {
+ assertFalse(stmt.execute("CREATE SCHEMA " + schemaName));
+ }
}
- }
-
- private void verifyAllowed(User user,
BasePermissionsIT.AccessTestAction... actions) throws Exception {
- for (BasePermissionsIT.AccessTestAction action : actions) {
- try {
- Object obj = user.runAs(action);
- if (obj != null && obj instanceof List<?>) {
- List<?> results = (List<?>) obj;
- if (results.isEmpty()) {
- fail("Empty non null results from action for user '" +
user.getShortName() + "'");
- }
- }
- } catch (AccessDeniedException ade) {
- fail("Expected action to pass for user '" +
user.getShortName() + "' but was denied");
+ return null;
+ }
+ };
+ }
+
+ BasePermissionsIT.AccessTestAction createTable(final String tableName, int
numRecordsToInsert)
+ throws SQLException {
+ return new BasePermissionsIT.AccessTestAction() {
+ @Override
+ public Object run() throws Exception {
+ try (Connection conn = DriverManager.getConnection(getUrl());
+ Statement stmt = conn.createStatement();) {
+ assertFalse(stmt.execute("CREATE TABLE " + tableName
+ + "(pk INTEGER not null primary key, data VARCHAR, val integer)"));
+ try (PreparedStatement pstmt =
+ conn.prepareStatement("UPSERT INTO " + tableName + " values(?, ?,
?)")) {
+ for (int i = 0; i < numRecordsToInsert; i++) {
+ pstmt.setInt(1, i);
+ pstmt.setString(2, Integer.toString(i));
+ pstmt.setInt(3, i);
+ assertEquals(1, pstmt.executeUpdate());
}
+ }
+ conn.commit();
}
+ return null;
+ }
+ };
+ }
+
+ /** This fails only in case of ADE or empty list for any of the users. */
+ public void verifyAllowed(BasePermissionsIT.AccessTestAction action, User...
users)
+ throws Exception {
+ if (users.length == 0) {
+ throw new Exception("Action needs at least one user to run");
}
-
- void grantPermissions(String toUser, String namespace,
Permission.Action... actions) throws Throwable {
- updateACLs(getUtility(), new Callable<Void>() {
- @Override
- public Void call() throws Exception {
- try {
- AccessControlClient.grant(getUtility().getConnection(),
namespace, toUser, actions);
-
- return null;
- } catch (Throwable t) {
- if (t instanceof Exception) {
- throw (Exception) t;
- } else {
- throw new Exception(t);
- }
- }
- }
- });
+ for (User user : users) {
+ verifyAllowed(user, action);
}
-
- void grantPermissions(String toUser, Set<String> tablesToGrant,
Permission.Action... actions)
- throws Throwable {
- updateACLs(getUtility(), new Callable<Void>() {
- @Override
- public Void call() throws Exception {
- try {
- for (String table : tablesToGrant) {
-
AccessControlClient.grant(getUtility().getConnection(),
TableName.valueOf(table),
- toUser, null, null, actions);
- }
- return null;
- } catch (Throwable t) {
- if (t instanceof Exception) {
- throw (Exception) t;
- } else {
- throw new Exception(t);
- }
- }
- }
- });
+ }
+
+ private void verifyAllowed(User user, BasePermissionsIT.AccessTestAction...
actions)
+ throws Exception {
+ for (BasePermissionsIT.AccessTestAction action : actions) {
+ try {
+ Object obj = user.runAs(action);
+ if (obj != null && obj instanceof List<?>) {
+ List<?> results = (List<?>) obj;
+ if (results.isEmpty()) {
+ fail("Empty non null results from action for user '" +
user.getShortName() + "'");
+ }
+ }
+ } catch (AccessDeniedException ade) {
+ fail("Expected action to pass for user '" + user.getShortName() + "'
but was denied");
+ }
}
-}
\ No newline at end of file
+ }
+
+ void grantPermissions(String toUser, String namespace, Permission.Action...
actions)
+ throws Throwable {
+ updateACLs(getUtility(), new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ try {
+ AccessControlClient.grant(getUtility().getConnection(), namespace,
toUser, actions);
+
+ return null;
+ } catch (Throwable t) {
+ if (t instanceof Exception) {
+ throw (Exception) t;
+ } else {
+ throw new Exception(t);
+ }
+ }
+ }
+ });
+ }
+
+ void grantPermissions(String toUser, Set<String> tablesToGrant,
Permission.Action... actions)
+ throws Throwable {
+ updateACLs(getUtility(), new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ try {
+ for (String table : tablesToGrant) {
+ AccessControlClient.grant(getUtility().getConnection(),
TableName.valueOf(table),
+ toUser, null, null, actions);
+ }
+ return null;
+ } catch (Throwable t) {
+ if (t instanceof Exception) {
+ throw (Exception) t;
+ } else {
+ throw new Exception(t);
+ }
+ }
+ }
+ });
+ }
+}
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java
index 53d6d146d6..e111304e68 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BasePermissionsIT.java
@@ -225,7 +225,7 @@ public abstract class BasePermissionsIT extends BaseTest {
}
static void enablePhoenixHBaseAuthorization(Configuration config,
- boolean
useCustomAccessController) {
+ boolean useCustomAccessController) {
config.set("hbase.superuser", SUPER_USER + "," + "superUser2");
config.set("hbase.security.authorization", Boolean.TRUE.toString());
config.set("hbase.security.exec.permission.checks",
Boolean.TRUE.toString());
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
index c658210832..8533b59c7c 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/IndexToolIT.java
@@ -867,11 +867,12 @@ public class IndexToolIT extends BaseTest {
String indxTable, String tenantId, IndexTool.IndexVerifyType verifyType,
Long startTime,
Long endTime, IndexTool.IndexDisableLoggingType disableLoggingType, Long
incrementalVerify,
boolean useIndexTableAsSource) {
- return getArgList(useSnapshot, schemaName, dataTable, indxTable,
tenantId,verifyType, startTime,
- endTime, disableLoggingType, incrementalVerify,
useIndexTableAsSource, "/tmp/" + UUID.randomUUID().toString());
- }
+ return getArgList(useSnapshot, schemaName, dataTable, indxTable, tenantId,
verifyType,
+ startTime, endTime, disableLoggingType, incrementalVerify,
useIndexTableAsSource,
+ "/tmp/" + UUID.randomUUID().toString());
+ }
- private static List<String> getArgList (boolean useSnapshot, String
schemaName, String dataTable,
+ private static List<String> getArgList(boolean useSnapshot, String
schemaName, String dataTable,
String indxTable, String tenantId, IndexTool.IndexVerifyType verifyType,
Long startTime,
Long endTime, IndexTool.IndexDisableLoggingType disableLoggingType, Long
incrementalVerify,
boolean useIndexTableAsSource, String outputPath) {
@@ -941,10 +942,10 @@ public class IndexToolIT extends BaseTest {
public static String[] getArgValues(boolean useSnapshot, String schemaName,
String dataTable,
String indexTable, String tenantId, IndexTool.IndexVerifyType verifyType,
IndexTool.IndexDisableLoggingType disableLoggingType, String outputPath) {
- List<String> args = getArgList(useSnapshot, schemaName, dataTable,
indexTable,
- tenantId, verifyType, null, null, disableLoggingType, null, false,
outputPath);
+ List<String> args = getArgList(useSnapshot, schemaName, dataTable,
indexTable, tenantId,
+ verifyType, null, null, disableLoggingType, null, false, outputPath);
return args.toArray(new String[0]);
- }
+ }
public static String[] getArgValues(boolean useSnapshot, String schemaName,
String dataTable,
String indexTable, String tenantId, IndexTool.IndexVerifyType verifyType,
Long startTime,
@@ -1037,14 +1038,12 @@ public class IndexToolIT extends BaseTest {
boolean additionalArgsContainPath = false;
String path = "";
List<String> newadditionalArgs = Lists.newArrayList();
- for (String arg : additionalArgs){
+ for (String arg : additionalArgs) {
if (additionalArgsContainPath == true) {
path = arg;
- }
- else if ( arg.equals("-op") || arg.equals("-output-path")) {
- additionalArgsContainPath = true;
- }
- else {
+ } else if (arg.equals("-op") || arg.equals("-output-path")) {
+ additionalArgsContainPath = true;
+ } else {
newadditionalArgs.add(arg);
}
}
@@ -1052,16 +1051,16 @@ public class IndexToolIT extends BaseTest {
String[] cmdArgs;
if (additionalArgsContainPath) {
- cmdArgs = getArgValues(useSnapshot, schemaName, dataTableName,
- indexTableName, tenantId, verifyType, disableLoggingType, path);
- }
- else {
- cmdArgs = getArgValues(useSnapshot, schemaName, dataTableName,
- indexTableName, tenantId, verifyType, disableLoggingType);
+ cmdArgs = getArgValues(useSnapshot, schemaName, dataTableName,
indexTableName, tenantId,
+ verifyType, disableLoggingType, path);
+ } else {
+ cmdArgs = getArgValues(useSnapshot, schemaName, dataTableName,
indexTableName, tenantId,
+ verifyType, disableLoggingType);
}
List<String> cmdArgList = new ArrayList<>(Arrays.asList(cmdArgs));
cmdArgList.addAll(Arrays.asList(additionalArgs));
- LOGGER.info("Running IndexTool with {}",
Arrays.toString(cmdArgList.toArray()), new Exception("Stack Trace"));
+ LOGGER.info("Running IndexTool with {}",
Arrays.toString(cmdArgList.toArray()),
+ new Exception("Stack Trace"));
int status = indexingTool.run(cmdArgList.toArray(new
String[cmdArgList.size()]));
if (expectedStatus == 0) {
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LoadSystemTableSnapshotBase.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LoadSystemTableSnapshotBase.java
index 56adb57673..8f5a541586 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/LoadSystemTableSnapshotBase.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/LoadSystemTableSnapshotBase.java
@@ -73,14 +73,13 @@ public abstract class LoadSystemTableSnapshotBase extends
BaseTest {
private static final Logger LOGGER =
LoggerFactory.getLogger(LoadSystemTableSnapshotBase.class);
- public static String SNAPSHOT_DIR;
- public static String rootDir;
+ public static String SNAPSHOT_DIR;
+ public static String rootDir;
- private static HashMap<String, String> SNAPSHOTS_TO_LOAD;
+ private static HashMap<String, String> SNAPSHOTS_TO_LOAD;
public static final byte[] MUTEX_LOCKED =
"MUTEX_LOCKED".getBytes(StandardCharsets.UTF_8);
-
private static void decompress(String in, File out) throws IOException {
try (TarArchiveInputStream fin = new TarArchiveInputStream(new
FileInputStream(in))) {
TarArchiveEntry entry;
@@ -99,21 +98,25 @@ public abstract class LoadSystemTableSnapshotBase extends
BaseTest {
}
public static synchronized void setupCluster(boolean
createBlockUpgradeMutex) throws Exception {
- //Add any HBase tables, including Phoenix System tables
+ // Add any HBase tables, including Phoenix System tables
HashMap<String, String> snapshotsToLoad = new HashMap<>();
snapshotsToLoad.put("SYSTEM.CATALOG_SNAPSHOT", "SYSTEM.CATALOG");
snapshotsToLoad.put("SYSTEM.FUNCTION_SNAPSHOT", "SYSTEM.FUNCTION");
snapshotsToLoad.put("SYSTEM.SEQUENCE_SNAPSHOT", "SYSTEM.SEQUENCE");
snapshotsToLoad.put("SYSTEM.STATS_SNAPSHOT", "SYSTEM.STATS");
- setupCluster(createBlockUpgradeMutex, "snapshots47.tar.gz",
"snapshots4_7/", snapshotsToLoad, "true");
+ setupCluster(createBlockUpgradeMutex, "snapshots47.tar.gz",
"snapshots4_7/", snapshotsToLoad,
+ "true");
}
- public static synchronized void setupCluster(boolean
createBlockUpgradeMutex, String tarName, String snapshotDir, HashMap<String,
String> snapshotsToLoad, String nameSpaceMapping) throws Exception {
+ public static synchronized void setupCluster(boolean
createBlockUpgradeMutex, String tarName,
+ String snapshotDir, HashMap<String, String> snapshotsToLoad, String
nameSpaceMapping)
+ throws Exception {
SNAPSHOT_DIR = snapshotDir;
SNAPSHOTS_TO_LOAD = snapshotsToLoad;
Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(2);
- serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
+ serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
+ QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
serverProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
nameSpaceMapping);
Map<String, String> clientProps = Maps.newHashMapWithExpectedSize(2);
clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
nameSpaceMapping);
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MigrateSystemTablesToSystemNamespaceIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MigrateSystemTablesToSystemNamespaceIT.java
index 3436026410..9299bc3816 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/MigrateSystemTablesToSystemNamespaceIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/MigrateSystemTablesToSystemNamespaceIT.java
@@ -63,10 +63,10 @@ import org.junit.experimental.categories.Category;
@Category(NeedsOwnMiniClusterTest.class)
public class MigrateSystemTablesToSystemNamespaceIT extends BaseTest {
- private static final Set<String> HBASE_SYSTEM_TABLES = new
HashSet<>(Arrays.asList(
- "SYSTEM.PHOENIX_INDEX_TOOL_RESULT", "SYSTEM.PHOENIX_INDEX_TOOL"));
- private static final Set<String> HBASE_NAMESPACE_MAPPED_SYSTEM_TABLES = new
HashSet<>(
- Arrays.asList("SYSTEM:PHOENIX_INDEX_TOOL_RESULT",
"SYSTEM:PHOENIX_INDEX_TOOL"));
+ private static final Set<String> HBASE_SYSTEM_TABLES =
+ new HashSet<>(Arrays.asList("SYSTEM.PHOENIX_INDEX_TOOL_RESULT",
"SYSTEM.PHOENIX_INDEX_TOOL"));
+ private static final Set<String> HBASE_NAMESPACE_MAPPED_SYSTEM_TABLES =
+ new HashSet<>(Arrays.asList("SYSTEM:PHOENIX_INDEX_TOOL_RESULT",
"SYSTEM:PHOENIX_INDEX_TOOL"));
private static final Set<String> PHOENIX_SYSTEM_TABLES =
new HashSet<>(Arrays.asList("SYSTEM.CATALOG", "SYSTEM.SEQUENCE",
"SYSTEM.STATS",
@@ -196,7 +196,8 @@ public class MigrateSystemTablesToSystemNamespaceIT extends
BaseTest {
});
hbaseTables = getHBaseTables();
- assertTrue(hbaseTables.size() ==
PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES.size() +
HBASE_NAMESPACE_MAPPED_SYSTEM_TABLES.size());
+ assertTrue(hbaseTables.size() ==
PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES.size()
+ + HBASE_NAMESPACE_MAPPED_SYSTEM_TABLES.size());
assertTrue(hbaseTables.containsAll(PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES));
try {
@@ -214,7 +215,8 @@ public class MigrateSystemTablesToSystemNamespaceIT extends
BaseTest {
}
hbaseTables = getHBaseTables();
- assertTrue(hbaseTables.size() ==
PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES.size() +
HBASE_NAMESPACE_MAPPED_SYSTEM_TABLES.size());
+ assertTrue(hbaseTables.size() ==
PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES.size()
+ + HBASE_NAMESPACE_MAPPED_SYSTEM_TABLES.size());
assertTrue(hbaseTables.containsAll(PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES));
}
@@ -290,7 +292,8 @@ public class MigrateSystemTablesToSystemNamespaceIT extends
BaseTest {
});
hbaseTables = getHBaseTables();
- assertTrue(hbaseTables.size() ==
PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES.size() +
HBASE_NAMESPACE_MAPPED_SYSTEM_TABLES.size());
+ assertTrue(hbaseTables.size() ==
PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES.size()
+ + HBASE_NAMESPACE_MAPPED_SYSTEM_TABLES.size());
assertTrue(hbaseTables.containsAll(PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES));
}
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipSystemTablesExistenceCheckIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipSystemTablesExistenceCheckIT.java
index 4f3b2ea625..e24f0f69ff 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipSystemTablesExistenceCheckIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipSystemTablesExistenceCheckIT.java
@@ -67,7 +67,7 @@ public class SkipSystemTablesExistenceCheckIT {
private static final Set<String> PHOENIX_SYSTEM_TABLES =
new HashSet<>(Arrays.asList("SYSTEM.CATALOG", "SYSTEM.SEQUENCE",
"SYSTEM.STATS",
"SYSTEM.FUNCTION", "SYSTEM.MUTEX", "SYSTEM.LOG", "SYSTEM.CHILD_LINK",
"SYSTEM.TASK",
- "SYSTEM.TRANSFORM","SYSTEM.CDC_STREAM_STATUS", "SYSTEM.CDC_STREAM",
+ "SYSTEM.TRANSFORM", "SYSTEM.CDC_STREAM_STATUS", "SYSTEM.CDC_STREAM",
"SYSTEM.PHOENIX_INDEX_TOOL_RESULT", "SYSTEM.PHOENIX_INDEX_TOOL"));
private static class PhoenixSystemTablesCreationTestDriver extends
PhoenixTestDriver {
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesCreationOnConnectionIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesCreationOnConnectionIT.java
index 52fa0d953a..f88385faa6 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesCreationOnConnectionIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SystemTablesCreationOnConnectionIT.java
@@ -74,10 +74,10 @@ import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Category(NeedsOwnMiniClusterTest.class)
public class SystemTablesCreationOnConnectionIT {
@@ -107,10 +107,10 @@ public class SystemTablesCreationOnConnectionIT {
private static final Set<String> PHOENIX_SYSTEM_TABLES =
new HashSet<>(Arrays.asList("SYSTEM.CATALOG", "SYSTEM.SEQUENCE",
"SYSTEM.STATS",
"SYSTEM.FUNCTION", "SYSTEM.MUTEX", "SYSTEM.LOG", "SYSTEM.CHILD_LINK",
"SYSTEM.TASK",
- "SYSTEM.TRANSFORM","SYSTEM.CDC_STREAM_STATUS", "SYSTEM.CDC_STREAM",
+ "SYSTEM.TRANSFORM", "SYSTEM.CDC_STREAM_STATUS", "SYSTEM.CDC_STREAM",
"SYSTEM.PHOENIX_INDEX_TOOL_RESULT", "SYSTEM.PHOENIX_INDEX_TOOL"));
- private static final Set<String> PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES =
+ private static final Set<String> PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES =
new HashSet<>(Arrays.asList("SYSTEM:CATALOG", "SYSTEM:SEQUENCE",
"SYSTEM:STATS",
"SYSTEM:FUNCTION", "SYSTEM:MUTEX", "SYSTEM:LOG", "SYSTEM:CHILD_LINK",
"SYSTEM:TASK",
"SYSTEM:TRANSFORM", "SYSTEM:CDC_STREAM_STATUS", "SYSTEM:CDC_STREAM",
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesIT.java
index ed36b1c840..906b3b69f5 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesIT.java
@@ -7,7 +7,7 @@
* "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
+ * 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,
@@ -17,83 +17,81 @@
*/
package org.apache.phoenix.end2end;
+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.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import java.util.HashMap;
+import java.util.Map;
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.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
+import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
public class UpgradeIndexToolTablesIT extends LoadSystemTableSnapshotBase {
- protected String nameSpaceMapping = "true";
-
- @Before
- public synchronized void doSetup() throws Exception {
- setupCluster(nameSpaceMapping);
+ protected String nameSpaceMapping = "true";
+
+ @Before
+ public synchronized void doSetup() throws Exception {
+ setupCluster(nameSpaceMapping);
+ }
+
+ public synchronized void setupCluster(String nameSpaceMappingEnabled) throws
Exception {
+ HashMap<String, String> snapshotsToLoad = new HashMap<>();
+ snapshotsToLoad.put("phoenixtoolresultsnapshot",
"PHOENIX_INDEX_TOOL_RESULT");
+ setupCluster(false, "indexToolsnapshot.tar.gz",
"indexToolResultSnapshot/", snapshotsToLoad,
+ nameSpaceMappingEnabled);
+ }
+
+ @Test
+ public void testPhoenixUpgradeIndexToolTables() throws Exception {
+ try (Admin admin = utility.getAdmin()) {
+ // we load the RESULT_TABLE_NAME from snapshot
+
assertTrue(admin.tableExists(TableName.valueOf(IndexToolTableUtil.RESULT_TABLE_NAME)));
+
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.RESULT_TABLE_FULL_NAME)));
+ // we don't load the OUTPUT_TABLE_NAME
+
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.OUTPUT_TABLE_NAME)));
+
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.OUTPUT_TABLE_FULL_NAME)));
}
- public synchronized void setupCluster(String nameSpaceMappingEnabled)
throws Exception {
- HashMap<String, String> snapshotsToLoad = new HashMap<>();
- snapshotsToLoad.put("phoenixtoolresultsnapshot",
"PHOENIX_INDEX_TOOL_RESULT");
- setupCluster(false, "indexToolsnapshot.tar.gz",
"indexToolResultSnapshot/", snapshotsToLoad, nameSpaceMappingEnabled);
+ Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(2);
+ serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
+ QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
+ serverProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
nameSpaceMapping);
+ Map<String, String> clientProps = Maps.newHashMapWithExpectedSize(2);
+ clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
nameSpaceMapping);
+
+ // Now we can start Phoenix
+ setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()),
+ new ReadOnlyProps(clientProps.entrySet().iterator()));
+ assertTrue(true);
+
+ // Check the IndexTool Tables after upgrade
+ try (Admin admin = utility.getAdmin()) {
+
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.OUTPUT_TABLE_NAME)));
+
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.RESULT_TABLE_NAME)));
+
assertTrue(admin.tableExists(TableName.valueOf(IndexToolTableUtil.OUTPUT_TABLE_FULL_NAME)));
+
assertTrue(admin.tableExists(TableName.valueOf(IndexToolTableUtil.RESULT_TABLE_FULL_NAME)));
}
- @Test
- public void testPhoenixUpgradeIndexToolTables() throws Exception {
- try (Admin admin = utility.getAdmin()) {
- // we load the RESULT_TABLE_NAME from snapshot
-
assertTrue(admin.tableExists(TableName.valueOf(IndexToolTableUtil.RESULT_TABLE_NAME)));
-
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.RESULT_TABLE_FULL_NAME)));
- // we don't load the OUTPUT_TABLE_NAME
-
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.OUTPUT_TABLE_NAME)));
-
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.OUTPUT_TABLE_FULL_NAME)));
- }
-
- Map<String, String> serverProps = Maps.newHashMapWithExpectedSize(2);
- serverProps.put(QueryServices.EXTRA_JDBC_ARGUMENTS_ATTRIB,
QueryServicesOptions.DEFAULT_EXTRA_JDBC_ARGUMENTS);
- serverProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
nameSpaceMapping);
- Map<String, String> clientProps = Maps.newHashMapWithExpectedSize(2);
- clientProps.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED,
nameSpaceMapping);
-
-
- //Now we can start Phoenix
- setUpTestDriver(new ReadOnlyProps(serverProps.entrySet().iterator()),
new ReadOnlyProps(clientProps.entrySet()
- .iterator()));
- assertTrue(true);
-
-
- // Check the IndexTool Tables after upgrade
- try (Admin admin = utility.getAdmin()) {
-
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.OUTPUT_TABLE_NAME)));
-
assertFalse(admin.tableExists(TableName.valueOf(IndexToolTableUtil.RESULT_TABLE_NAME)));
-
assertTrue(admin.tableExists(TableName.valueOf(IndexToolTableUtil.OUTPUT_TABLE_FULL_NAME)));
-
assertTrue(admin.tableExists(TableName.valueOf(IndexToolTableUtil.RESULT_TABLE_FULL_NAME)));
- }
-
- String tableName = SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,
RESULT_TABLE_NAME);
- if (nameSpaceMapping.equals("true")) {
- assertEquals(IndexToolTableUtil.RESULT_TABLE_FULL_NAME,
tableName.replace(QueryConstants.NAME_SEPARATOR,
- QueryConstants.NAMESPACE_SEPARATOR));
- } else {
- assertEquals(IndexToolTableUtil.RESULT_TABLE_FULL_NAME, tableName);
- }
-
+ String tableName = SchemaUtil.getTableName(SYSTEM_SCHEMA_NAME,
RESULT_TABLE_NAME);
+ if (nameSpaceMapping.equals("true")) {
+ assertEquals(IndexToolTableUtil.RESULT_TABLE_FULL_NAME,
+ tableName.replace(QueryConstants.NAME_SEPARATOR,
QueryConstants.NAMESPACE_SEPARATOR));
+ } else {
+ assertEquals(IndexToolTableUtil.RESULT_TABLE_FULL_NAME, tableName);
}
+ }
+
}
diff --git
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesNameSpaceMappingDisabledIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesNameSpaceMappingDisabledIT.java
index f339550d61..8e265adc6a 100644
---
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesNameSpaceMappingDisabledIT.java
+++
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpgradeIndexToolTablesNameSpaceMappingDisabledIT.java
@@ -7,7 +7,7 @@
* "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
+ * 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,
@@ -19,13 +19,12 @@ package org.apache.phoenix.end2end;
import org.junit.Before;
-
public class UpgradeIndexToolTablesNameSpaceMappingDisabledIT extends
UpgradeIndexToolTablesIT {
- @Override
- @Before
- public synchronized void doSetup() throws Exception {
- nameSpaceMapping = "false";
- setupCluster(nameSpaceMapping);
- }
+ @Override
+ @Before
+ public synchronized void doSetup() throws Exception {
+ nameSpaceMapping = "false";
+ setupCluster(nameSpaceMapping);
+ }
}