This is an automated email from the ASF dual-hosted git repository. chinmayskulkarni pushed a commit to branch 4.x-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push: new 03ff867 PHOENIX-5614: Remove unnecessary instances of ClassNotFoundException thrown stemming from various QueryUtil APIs 03ff867 is described below commit 03ff8678d184f3e8fa222ac3f79e389d46c2f27d Author: Chinmay Kulkarni <chinmayskulka...@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 | 4 +-- .../java/org/apache/phoenix/util/QueryUtil.java | 19 ++++++------- .../java/org/apache/phoenix/util/ViewUtil.java | 6 ++-- 13 files changed, 29 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 bfa0d5d..3a8cb99 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 @@ -626,7 +626,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 0ba228d..3e58c39 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 @@ -166,8 +166,6 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver { return new IndexHalfStoreFileReader(fs, p, cacheConf, in, size, r, ctx.getEnvironment().getConfiguration(), indexMaintainers, viewConstants, childRegion, regionStartKeyInHFile, splitKey, region.getRegionInfo()); - } catch (ClassNotFoundException e) { - throw new IOException(e); } catch (SQLException e) { throw new IOException(e); } finally { @@ -273,7 +271,7 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver { maintainers, store.getFamily().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 3d94253..5ceada3 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 @@ -129,13 +129,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 12e2f12..1d5f99a 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 @@ -2068,7 +2068,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso } builder.setMutationTime(currentTimeStamp); done.run(builder.build()); - return; } finally { releaseRowLocks(region, locks); } @@ -2135,8 +2134,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso 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), @@ -2477,8 +2474,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso 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, @@ -2583,7 +2578,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso QueryUtil.getConnectionOnServer(props, env.getConfiguration()) .unwrap(PhoenixConnection.class)) { table = ViewUtil.addDerivedColumnsAndIndexesFromParent(connection, table, parentTable); - } catch (ClassNotFoundException e) { } } @@ -2725,8 +2719,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso 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, @@ -2766,7 +2758,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso ConnectionQueryServices queryServices = connection.getQueryServices(); queryServices.clearTableFromCache(ByteUtil.EMPTY_BYTE_ARRAY, schemaName, tableName, clientTimeStamp); - } catch (ClassNotFoundException e) { } } @@ -2972,12 +2963,9 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso // 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)) { @@ -3006,8 +2994,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso // 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 @@ -3044,12 +3031,9 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso // 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); @@ -3076,8 +3060,7 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso // 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 e8f4d0a..6e0b8b3 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 @@ -640,7 +640,7 @@ public class MetaDataRegionObserver extends BaseRegionObserver { } 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 4d736a2..00cbc1e 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 d476e4d..63840e7 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 @@ -142,7 +142,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 52d539b..343f42d 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 @@ -86,7 +86,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 a8a42a9..00f1634 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 @@ -119,7 +119,7 @@ class DefaultStatisticsCollector implements StatisticsCollector { } } - private void initGuidepostDepth() throws IOException, ClassNotFoundException, SQLException { + private void initGuidepostDepth() throws IOException, SQLException { // First check is if guidepost info set on statement itself if (guidePostPerRegionBytes != null || guidePostWidthBytes != null) { int guidepostPerRegion = 0; @@ -362,7 +362,7 @@ class DefaultStatisticsCollector implements StatisticsCollector { public void init() throws IOException { try { initGuidepostDepth(); - } catch (ClassNotFoundException | SQLException e) { + } catch (SQLException e) { throw new IOException("Unable to initialize the guide post depth", e); } this.statsWriter = StatisticsWriter.newWriter(env, tableName, clientTimeStamp, guidePostDepth); 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 829c633..ba0e456 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 5757adc..d08a9d9 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 @@ -182,7 +182,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, sysCatOrSysChildLink); @@ -251,9 +251,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);