Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 ed61837f5 -> ccbbb79df


PHOENIX-3938 Don't throw IOException out of coprocessor hooks


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

Branch: refs/heads/4.x-HBase-0.98
Commit: ccbbb79df2de8e86256b0b5ed54542953e8965b8
Parents: ed61837
Author: Samarth Jain <[email protected]>
Authored: Thu Jul 6 13:54:58 2017 -0700
Committer: Samarth Jain <[email protected]>
Committed: Thu Jul 6 13:54:58 2017 -0700

----------------------------------------------------------------------
 .../coprocessor/MetaDataEndpointImpl.java       | 14 ++++--
 .../coprocessor/ServerCachingEndpointImpl.java  | 48 ++++++++++----------
 .../UngroupedAggregateRegionObserver.java       |  2 +
 3 files changed, 36 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ccbbb79d/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
----------------------------------------------------------------------
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 550b133..58178e9 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
@@ -3097,8 +3097,10 @@ public class MetaDataEndpointImpl extends 
MetaDataProtocol implements Coprocesso
             if (result != null) {
                 done.run(MetaDataMutationResult.toProto(result));
             }
-        } catch (IOException ioe) {
-            ProtobufUtil.setControllerException(controller, ioe);
+        } catch (Throwable e) {
+            logger.error("Add column failed: ", e);
+            ProtobufUtil.setControllerException(controller,
+                ServerUtil.createIOException("Error when adding column: ", e));
         }
     }
 
@@ -3344,8 +3346,10 @@ public class MetaDataEndpointImpl extends 
MetaDataProtocol implements Coprocesso
             if (result != null) {
                 done.run(MetaDataMutationResult.toProto(result));
             }
-        } catch (IOException ioe) {
-            ProtobufUtil.setControllerException(controller, ioe);
+        } catch (Throwable e) {
+            logger.error("Drop column failed: ", e);
+            ProtobufUtil.setControllerException(controller,
+                ServerUtil.createIOException("Error when dropping column: ", 
e));
         }
     }
     
@@ -3724,7 +3728,7 @@ public class MetaDataEndpointImpl extends 
MetaDataProtocol implements Coprocesso
                     GlobalCache.getInstance(this.env).getMetaDataCache();
             metaDataCache.invalidate(cacheKey);
         } catch (Throwable t) {
-            logger.error("incrementTableTimeStamp failed", t);
+            logger.error("clearTableFromCache failed", t);
             ProtobufUtil.setControllerException(controller,
                 
ServerUtil.createIOException(SchemaUtil.getTableName(schemaName, tableName), 
t));
         }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ccbbb79d/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
index 98f57ad..0944fdf 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/ServerCachingEndpointImpl.java
@@ -36,6 +36,7 @@ import 
org.apache.phoenix.coprocessor.generated.ServerCachingProtos.ServerCachin
 import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.protobuf.ProtobufUtil;
 import org.apache.phoenix.util.ByteUtil;
+import org.apache.phoenix.util.ServerUtil;
 
 import com.google.protobuf.RpcCallback;
 import com.google.protobuf.RpcController;
@@ -55,31 +56,32 @@ public class ServerCachingEndpointImpl extends 
ServerCachingService implements C
 
   @Override
   public void addServerCache(RpcController controller, AddServerCacheRequest 
request,
-      RpcCallback<AddServerCacheResponse> done) {
-    ImmutableBytesPtr tenantId = null;
-    if (request.hasTenantId()) {
-      tenantId = new ImmutableBytesPtr(request.getTenantId().toByteArray());
-    }
-    TenantCache tenantCache = GlobalCache.getTenantCache(this.env, tenantId);
-    ImmutableBytesWritable cachePtr =
-        org.apache.phoenix.protobuf.ProtobufUtil
-            .toImmutableBytesWritable(request.getCachePtr());
-    byte[] txState = request.hasTxState() ? request.getTxState().toByteArray() 
: ByteUtil.EMPTY_BYTE_ARRAY;
+          RpcCallback<AddServerCacheResponse> done) {
+      ImmutableBytesPtr tenantId = null;
+      if (request.hasTenantId()) {
+          tenantId = new 
ImmutableBytesPtr(request.getTenantId().toByteArray());
+      }
+      TenantCache tenantCache = GlobalCache.getTenantCache(this.env, tenantId);
+      ImmutableBytesWritable cachePtr =
+              org.apache.phoenix.protobuf.ProtobufUtil
+              .toImmutableBytesWritable(request.getCachePtr());
+      byte[] txState = request.hasTxState() ? 
request.getTxState().toByteArray() : ByteUtil.EMPTY_BYTE_ARRAY;
 
-    try {
-      @SuppressWarnings("unchecked")
-      Class<ServerCacheFactory> serverCacheFactoryClass =
+      try {
+          @SuppressWarnings("unchecked")
+          Class<ServerCacheFactory> serverCacheFactoryClass =
           (Class<ServerCacheFactory>) 
Class.forName(request.getCacheFactory().getClassName());
-      ServerCacheFactory cacheFactory = serverCacheFactoryClass.newInstance();
-      tenantCache.addServerCache(new 
ImmutableBytesPtr(request.getCacheId().toByteArray()),
-        cachePtr, txState, cacheFactory, 
request.hasHasProtoBufIndexMaintainer() && 
request.getHasProtoBufIndexMaintainer());
-    } catch (Throwable e) {
-      ProtobufUtil.setControllerException(controller, new IOException(e));
-    }
-    AddServerCacheResponse.Builder responseBuilder = 
AddServerCacheResponse.newBuilder();
-    responseBuilder.setReturn(true);
-    AddServerCacheResponse result = responseBuilder.build();
-    done.run(result);
+          ServerCacheFactory cacheFactory = 
serverCacheFactoryClass.newInstance();
+          tenantCache.addServerCache(new 
ImmutableBytesPtr(request.getCacheId().toByteArray()),
+              cachePtr, txState, cacheFactory, 
request.hasHasProtoBufIndexMaintainer() && 
request.getHasProtoBufIndexMaintainer());
+        } catch (Throwable e) {
+            ProtobufUtil.setControllerException(controller,
+                ServerUtil.createIOException("Error when adding cache: ", e));
+        }
+      AddServerCacheResponse.Builder responseBuilder = 
AddServerCacheResponse.newBuilder();
+      responseBuilder.setReturn(true);
+      AddServerCacheResponse result = responseBuilder.build();
+      done.run(result);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/ccbbb79d/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
index 3a2fbca..3eaec2b 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UngroupedAggregateRegionObserver.java
@@ -244,6 +244,7 @@ public class UngroupedAggregateRegionObserver extends 
BaseScannerRegionObserver
         try {
             table.batch(mutations);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new RuntimeException(e);
         }
     }
@@ -1177,6 +1178,7 @@ public class UngroupedAggregateRegionObserver extends 
BaseScannerRegionObserver
                 try {
                     lock.wait(1000);
                 } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
                 }
             }
         }

Reply via email to