You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ch...@apache.org on 2019/12/20 01:04:26 UTC
[phoenix] branch master updated: PHOENIX-5614: Remove unnecessary
instances of ClassNotFoundException thrown stemming from various QueryUtil
APIs
This is an automated email from the ASF dual-hosted git repository.
chinmayskulkarni 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 b18afb7 PHOENIX-5614: Remove unnecessary instances of ClassNotFoundException thrown stemming from various QueryUtil APIs
b18afb7 is described below
commit b18afb768aaa613a648e89b0af0d6e3a79f14063
Author: Chinmay Kulkarni <ch...@gmail.com>
AuthorDate: Mon Dec 16 23:16:28 2019 -0800
PHOENIX-5614: Remove unnecessary instances of ClassNotFoundException thrown stemming from various QueryUtil APIs
---
.../end2end/index/MutableIndexFailureIT.java | 1 -
.../IndexHalfStoreFileReaderGenerator.java | 4 +--
.../phoenix/coprocessor/DropColumnMutator.java | 9 ++----
.../phoenix/coprocessor/MetaDataEndpointImpl.java | 33 ++++++----------------
.../coprocessor/MetaDataRegionObserver.java | 2 +-
.../phoenix/index/PhoenixIndexFailurePolicy.java | 2 --
.../java/org/apache/phoenix/log/LogWriter.java | 3 +-
.../org/apache/phoenix/log/TableLogWriter.java | 2 +-
.../mapreduce/FormatToBytesWritableMapper.java | 2 +-
.../phoenix/mapreduce/FormatToKeyValueReducer.java | 2 +-
.../schema/stats/DefaultStatisticsCollector.java | 2 --
.../java/org/apache/phoenix/util/QueryUtil.java | 19 ++++++-------
.../java/org/apache/phoenix/util/ViewUtil.java | 6 ++--
13 files changed, 27 insertions(+), 60 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java
index a5f72b8..476e71b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexFailureIT.java
@@ -623,7 +623,6 @@ public class MutableIndexFailureIT extends BaseTest {
connection.createStatement().execute(
"DROP INDEX IF EXISTS " + "B_" + FAIL_INDEX_NAME + " ON "
+ fullTableName);
- } catch (ClassNotFoundException e) {
} catch (SQLException e) {
}
}
diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
index e578faa..a6d057e 100644
--- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
+++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
@@ -175,8 +175,6 @@ public class IndexHalfStoreFileReaderGenerator implements RegionObserver, Region
childRegion, regionStartKeyInHFile, splitKey,
childRegion.getReplicaId() == RegionInfo.DEFAULT_REPLICA_ID,
new AtomicInteger(0), region.getRegionInfo());
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
} catch (SQLException e) {
throw new IOException(e);
} finally {
@@ -286,7 +284,7 @@ public class IndexHalfStoreFileReaderGenerator implements RegionObserver, Region
maintainers, store.getColumnFamilyDescriptor().getName(),env.getConfiguration());
- } catch (ClassNotFoundException | SQLException e) {
+ } catch (SQLException e) {
throw new IOException(e);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/DropColumnMutator.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/DropColumnMutator.java
index fc15edd..ea16a0a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/DropColumnMutator.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/DropColumnMutator.java
@@ -130,13 +130,8 @@ public class DropColumnMutator implements ColumnMutator {
if (existingViewColumn != null && view.getViewStatement() != null) {
ParseNode viewWhere =
new SQLParser(view.getViewStatement()).parseQuery().getWhere();
- PhoenixConnection conn=null;
- try {
- conn = QueryUtil.getConnectionOnServer(conf).unwrap(
- PhoenixConnection.class);
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
- }
+ PhoenixConnection conn = QueryUtil.getConnectionOnServer(conf).unwrap(
+ PhoenixConnection.class);
PhoenixStatement statement = new PhoenixStatement(conn);
TableRef baseTableRef = new TableRef(view);
ColumnResolver columnResolver = FromCompiler.getResolver(baseTableRef);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index fb626c4..d0688c1 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -2089,7 +2089,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
}
builder.setMutationTime(currentTimeStamp);
done.run(builder.build());
- return;
} finally {
ServerUtil.releaseRowLocks(locks);
}
@@ -2157,8 +2156,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
QueryUtil.getConnectionOnServer(props, env.getConfiguration())
.unwrap(PhoenixConnection.class)) {
view = PhoenixRuntime.getTableNoCache(connection, SchemaUtil.getTableName(viewSchemaName, viewName));
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
}
if (view == null) {
ServerUtil.throwIOException("View not found", new TableNotFoundException(Bytes.toString(viewSchemaName),
@@ -2494,8 +2491,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class)) {
PTable pTable = PhoenixRuntime.getTableNoCache(connection, table.getParentName().getString());
table = ViewUtil.addDerivedColumnsAndIndexesFromParent(connection, table, pTable);
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
}
}
return new MetaDataMutationResult(MutationCode.TABLE_ALREADY_EXISTS,
@@ -2600,7 +2595,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
QueryUtil.getConnectionOnServer(props, env.getConfiguration())
.unwrap(PhoenixConnection.class)) {
table = ViewUtil.addDerivedColumnsAndIndexesFromParent(connection, table, parentTable);
- } catch (ClassNotFoundException e) {
}
}
@@ -2743,8 +2737,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class)) {
PTable pTable = PhoenixRuntime.getTableNoCache(connection, table.getParentName().getString());
table = ViewUtil.addDerivedColumnsAndIndexesFromParent(connection, table, pTable);
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
}
}
return new MetaDataMutationResult(MutationCode.TABLE_ALREADY_EXISTS, currentTime, table,
@@ -2784,7 +2776,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
ConnectionQueryServices queryServices = connection.getQueryServices();
queryServices.clearTableFromCache(ByteUtil.EMPTY_BYTE_ARRAY, schemaName, tableName,
clientTimeStamp);
- } catch (ClassNotFoundException e) {
}
}
@@ -2990,12 +2981,9 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
// index and then invalidate it
// Covered columns are deleted from the index by the client
Region region = env.getRegion();
- PhoenixConnection connection = null;
- try {
- connection = table.getIndexes().isEmpty() ? null : QueryUtil.getConnectionOnServer(
- env.getConfiguration()).unwrap(PhoenixConnection.class);
- } catch (ClassNotFoundException e) {
- }
+ PhoenixConnection connection =
+ table.getIndexes().isEmpty() ? null : QueryUtil.getConnectionOnServer(
+ env.getConfiguration()).unwrap(PhoenixConnection.class);
for (PTable index : table.getIndexes()) {
// ignore any indexes derived from ancestors
if (index.getName().getString().contains(QueryConstants.CHILD_VIEW_INDEX_NAME_SEPARATOR)) {
@@ -3024,8 +3012,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
// Drop the link between the parent table and the
// index table
Delete linkDelete = new Delete(linkKey, clientTimeStamp);
- Delete tableDelete = delete;
- tableMetaData.add(tableDelete);
+ tableMetaData.add(delete);
tableMetaData.add(linkDelete);
// Since we're dropping the index, lock it to ensure
// that a change in index state doesn't
@@ -3062,12 +3049,9 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
// Look for columnToDelete in any indexes. If found as PK column, get lock and drop the
// index and then invalidate it
// Covered columns are deleted from the index by the client
- PhoenixConnection connection = null;
- try {
- connection = table.getIndexes().isEmpty() ? null : QueryUtil.getConnectionOnServer(
- env.getConfiguration()).unwrap(PhoenixConnection.class);
- } catch (ClassNotFoundException e) {
- }
+ PhoenixConnection connection =
+ table.getIndexes().isEmpty() ? null : QueryUtil.getConnectionOnServer(
+ env.getConfiguration()).unwrap(PhoenixConnection.class);
for (PTable index : table.getIndexes()) {
byte[] tenantId = index.getTenantId() == null ? ByteUtil.EMPTY_BYTE_ARRAY : index.getTenantId().getBytes();
IndexMaintainer indexMaintainer = index.getIndexMaintainer(table, connection);
@@ -3094,8 +3078,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements RegionCopr
// index table
Delete linkDelete = new Delete(linkKey, clientTimeStamp);
List<Mutation> remoteDropMetadata = Lists.newArrayListWithExpectedSize(2);
- Delete tableDelete = delete;
- remoteDropMetadata.add(tableDelete);
+ remoteDropMetadata.add(delete);
remoteDropMetadata.add(linkDelete);
// if the index is not present on the current region make an rpc to drop it
Properties props = new Properties();
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
index 2fc0876..97454e7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataRegionObserver.java
@@ -641,7 +641,7 @@ public class MetaDataRegionObserver implements RegionObserver,RegionCoprocessor
}
public static PhoenixConnection getRebuildIndexConnection(Configuration config)
- throws SQLException, ClassNotFoundException {
+ throws SQLException {
initRebuildIndexConnectionProps(config);
//return QueryUtil.getConnectionOnServer(rebuildIndexConnectionProps, config).unwrap(PhoenixConnection.class);
return QueryUtil.getConnectionOnServerWithCustomUrl(rebuildIndexConnectionProps,
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
index 44ec6e0..a0a765c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexFailurePolicy.java
@@ -361,8 +361,6 @@ public class PhoenixIndexFailurePolicy extends DelegateIndexFailurePolicy {
indexTableNames.add(indexTableName);
}
}
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
} catch (SQLException e) {
throw new IOException(e);
} finally {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/log/LogWriter.java b/phoenix-core/src/main/java/org/apache/phoenix/log/LogWriter.java
index a7a2180..ff58d22 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/log/LogWriter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/log/LogWriter.java
@@ -31,9 +31,8 @@ public interface LogWriter {
* @param event
* @throws SQLException
* @throws IOException
- * @throws ClassNotFoundException
*/
- void write(RingBufferEvent event) throws SQLException, IOException, ClassNotFoundException;
+ void write(RingBufferEvent event) throws SQLException, IOException;
/**
* will be called when disruptor is getting shutdown
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/log/TableLogWriter.java b/phoenix-core/src/main/java/org/apache/phoenix/log/TableLogWriter.java
index 6a7c0b6..fbc6b2d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/log/TableLogWriter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/log/TableLogWriter.java
@@ -82,7 +82,7 @@ public class TableLogWriter implements LogWriter {
}
@Override
- public void write(RingBufferEvent event) throws SQLException, IOException, ClassNotFoundException {
+ public void write(RingBufferEvent event) throws SQLException, IOException {
if (isClosed()) {
LOGGER.warn("Unable to commit query log as Log committer is already closed");
return;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java
index 2940672..663510b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToBytesWritableMapper.java
@@ -140,7 +140,7 @@ public abstract class FormatToBytesWritableMapper<RECORD> extends Mapper<LongWri
logicalNames = TargetTableRefFunctions.NAMES_FROM_JSON.apply(logicalNamesConf);
initColumnIndexes();
- } catch (SQLException | ClassNotFoundException e) {
+ } catch (SQLException e) {
throw new RuntimeException(e);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java
index 0cc89f0..ea727f7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/FormatToKeyValueReducer.java
@@ -85,7 +85,7 @@ public class FormatToKeyValueReducer
tableNames = TargetTableRefFunctions.NAMES_FROM_JSON.apply(tableNamesConf);
logicalNames = TargetTableRefFunctions.NAMES_FROM_JSON.apply(logicalNamesConf);
initColumnsMap(conn);
- } catch (SQLException | ClassNotFoundException e) {
+ } catch (SQLException e) {
throw new RuntimeException(e);
}
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java
index 2b1cfd6..0806a6d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/DefaultStatisticsCollector.java
@@ -202,8 +202,6 @@ public class DefaultStatisticsCollector implements StatisticsCollector {
cell.getValueOffset(), SortOrder.getDefault());
}
}
- } catch (ClassNotFoundException e) {
- throw new IOException(e);
}
}
return guidepostWidth;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
index 117214b..aa3c749 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
@@ -326,8 +326,7 @@ public final class QueryUtil {
* @return {@link PhoenixConnection} with {@value UpgradeUtil#DO_NOT_UPGRADE} set so that we
* don't initiate metadata upgrade
*/
- public static Connection getConnectionOnServer(Configuration conf) throws ClassNotFoundException,
- SQLException {
+ public static Connection getConnectionOnServer(Configuration conf) throws SQLException {
return getConnectionOnServer(new Properties(), conf);
}
@@ -345,8 +344,7 @@ public final class QueryUtil {
* and with the upgrade-required flag cleared so that we don't initiate metadata upgrade.
*/
public static Connection getConnectionOnServer(Properties props, Configuration conf)
- throws ClassNotFoundException,
- SQLException {
+ throws SQLException {
setServerConnection(props);
Connection conn = getConnection(props, conf);
conn.unwrap(PhoenixConnection.class).getQueryServices().clearUpgradeRequired();
@@ -354,20 +352,19 @@ public final class QueryUtil {
}
public static Connection getConnectionOnServerWithCustomUrl(Properties props, String principal)
- throws SQLException, ClassNotFoundException {
+ throws SQLException {
setServerConnection(props);
String url = getConnectionUrl(props, null, principal);
LOGGER.info("Creating connection with the jdbc url: " + url);
return DriverManager.getConnection(url, props);
}
- public static Connection getConnection(Configuration conf) throws ClassNotFoundException,
- SQLException {
+ public static Connection getConnection(Configuration conf) throws SQLException {
return getConnection(new Properties(), conf);
}
private static Connection getConnection(Properties props, Configuration conf)
- throws ClassNotFoundException, SQLException {
+ throws SQLException {
String url = getConnectionUrl(props, conf);
LOGGER.info("Creating connection with the jdbc url: " + url);
props = PropertiesUtil.combineProperties(props, conf);
@@ -375,14 +372,14 @@ public final class QueryUtil {
}
public static String getConnectionUrl(Properties props, Configuration conf)
- throws ClassNotFoundException, SQLException {
+ throws SQLException {
return getConnectionUrl(props, conf, null);
}
/**
* @return connection url using the various properties set in props and conf.
*/
public static String getConnectionUrl(Properties props, Configuration conf, String principal)
- throws ClassNotFoundException, SQLException {
+ throws SQLException {
// read the hbase properties from the configuration
int port = getInt(HConstants.ZOOKEEPER_CLIENT_PORT, HConstants.DEFAULT_ZOOKEPER_CLIENT_PORT, props, conf);
// Build the ZK quorum server string with "server:clientport" list, separated by ','
@@ -462,7 +459,7 @@ public final class QueryUtil {
return partitionColumnName + " " + toSQL(CompareOp.EQUAL) + " " + autoPartitionNum;
}
- public static Connection getConnectionForQueryLog(Configuration config) throws ClassNotFoundException, SQLException {
+ public static Connection getConnectionForQueryLog(Configuration config) throws SQLException {
//we don't need this connection to upgrade anything or start dispatcher
return getConnectionOnServer(config);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java
index 8382c4b..14cc01a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ViewUtil.java
@@ -183,7 +183,7 @@ public class ViewUtil {
public static void dropChildViews(RegionCoprocessorEnvironment env, byte[] tenantIdBytes,
byte[] schemaName, byte[] tableName, byte[] sysCatOrSysChildLink)
- throws IOException, SQLException, ClassNotFoundException {
+ throws IOException, SQLException {
Table hTable = null;
try {
hTable = ServerUtil.getHTableForCoprocessorScan(env, SchemaUtil.getPhysicalTableName(
@@ -253,9 +253,9 @@ public class ViewUtil {
SYSTEM_CHILD_LINK_NAME_BYTES, conf))) {
fullTableName = SYSTEM_CATALOG_NAME_BYTES;
}
- } catch (ClassNotFoundException e) {
+ } catch (SQLException e) {
logger.error("Error getting a connection on the server : " + e);
- throw new SQLException(e);
+ throw e;
}
}
return SchemaUtil.getPhysicalTableName(fullTableName, conf);