phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sama...@apache.org
Subject phoenix git commit: PHOENIX-4202 Clear client side cache in ConnectionQueryServicesImpl#clearCache()
Date Wed, 13 Sep 2017 22:46:01 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 e46d3d3dc -> 83ad82d7d


PHOENIX-4202 Clear client side cache in ConnectionQueryServicesImpl#clearCache()


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/83ad82d7
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/83ad82d7
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/83ad82d7

Branch: refs/heads/4.x-HBase-1.1
Commit: 83ad82d7d38c08e405497a7551bcc90e11ef57b4
Parents: e46d3d3
Author: Samarth Jain <samarth@apache.org>
Authored: Wed Sep 13 15:45:55 2017 -0700
Committer: Samarth Jain <samarth@apache.org>
Committed: Wed Sep 13 15:45:55 2017 -0700

----------------------------------------------------------------------
 .../query/ConnectionQueryServicesImpl.java      | 64 ++++++++------------
 1 file changed, 25 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/83ad82d7/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 2d8395f..12b2c41 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -3377,60 +3377,46 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices
implement
      */
     @Override
     public long clearCache() throws SQLException {
-        try {
-            SQLException sqlE = null;
-            HTableInterface htable = this.getTable(SchemaUtil
-                    .getPhysicalName(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES, this.getProps()).getName());
-            try {
-                tableStatsCache.invalidateAll();
-                final Map<byte[], Long> results =
-                        htable.coprocessorService(MetaDataService.class, HConstants.EMPTY_START_ROW,
-                                HConstants.EMPTY_END_ROW, new Batch.Call<MetaDataService,
Long>() {
+        synchronized (latestMetaDataLock) {
+            latestMetaData = newEmptyMetaData();
+        }
+        tableStatsCache.invalidateAll();
+        try (HTableInterface htable =
+                this.getTable(
+                    SchemaUtil.getPhysicalName(PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES,
+                        this.getProps()).getName())) {
+            final Map<byte[], Long> results =
+                    htable.coprocessorService(MetaDataService.class, HConstants.EMPTY_START_ROW,
+                        HConstants.EMPTY_END_ROW, new Batch.Call<MetaDataService, Long>()
{
                             @Override
                             public Long call(MetaDataService instance) throws IOException
{
                                 ServerRpcController controller = new ServerRpcController();
                                 BlockingRpcCallback<ClearCacheResponse> rpcCallback
=
                                         new BlockingRpcCallback<ClearCacheResponse>();
                                 ClearCacheRequest.Builder builder = ClearCacheRequest.newBuilder();
-                                builder.setClientVersion(VersionUtil.encodeVersion(PHOENIX_MAJOR_VERSION,
PHOENIX_MINOR_VERSION, PHOENIX_PATCH_NUMBER));
+                                builder.setClientVersion(
+                                    VersionUtil.encodeVersion(PHOENIX_MAJOR_VERSION,
+                                        PHOENIX_MINOR_VERSION, PHOENIX_PATCH_NUMBER));
                                 instance.clearCache(controller, builder.build(), rpcCallback);
-                                if(controller.getFailedOn() != null) {
+                                if (controller.getFailedOn() != null) {
                                     throw controller.getFailedOn();
                                 }
                                 return rpcCallback.get().getUnfreedBytes();
                             }
                         });
-                long unfreedBytes = 0;
-                for (Map.Entry<byte[],Long> result : results.entrySet()) {
-                    if (result.getValue() != null) {
-                        unfreedBytes += result.getValue();
-                    }
-                }
-                return unfreedBytes;
-            } catch (IOException e) {
-                throw ServerUtil.parseServerException(e);
-            } catch (Throwable e) {
-                sqlE = new SQLException(e);
-            } finally {
-                try {
-                    tableStatsCache.invalidateAll();
-                    htable.close();
-                } catch (IOException e) {
-                    if (sqlE == null) {
-                        sqlE = ServerUtil.parseServerException(e);
-                    } else {
-                        sqlE.setNextException(ServerUtil.parseServerException(e));
-                    }
-                } finally {
-                    if (sqlE != null) {
-                        throw sqlE;
-                    }
+            long unfreedBytes = 0;
+            for (Map.Entry<byte[], Long> result : results.entrySet()) {
+                if (result.getValue() != null) {
+                    unfreedBytes += result.getValue();
                 }
             }
-        } catch (Exception e) {
-            throw new SQLException(ServerUtil.parseServerException(e));
+            return unfreedBytes;
+        } catch (IOException e) {
+            throw ServerUtil.parseServerException(e);
+        } catch (Throwable e) {
+            // wrap all other exceptions in a SQLException
+            throw new SQLException(e);
         }
-        return 0;
     }
 
     private void flushTable(byte[] tableName) throws SQLException {


Mime
View raw message