Repository: phoenix Updated Branches: refs/heads/4.11-HBase-1.3 110b7b5ed -> 6f6b466ea
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/6f6b466e Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/6f6b466e Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/6f6b466e Branch: refs/heads/4.11-HBase-1.3 Commit: 6f6b466ea6fe1b8ecca6dba24f15dc636d005ffd Parents: 110b7b5 Author: Samarth Jain <[email protected]> Authored: Thu Jul 6 13:58:10 2017 -0700 Committer: Samarth Jain <[email protected]> Committed: Thu Jul 6 13:58:10 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/6f6b466e/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 2f06864..eba2e9d 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 @@ -3100,8 +3100,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)); } } @@ -3347,8 +3349,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)); } } @@ -3728,7 +3732,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/6f6b466e/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/6f6b466e/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 229b51c..f29818c 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 @@ -245,6 +245,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver try { table.batch(mutations); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); throw new RuntimeException(e); } } @@ -1173,6 +1174,7 @@ public class UngroupedAggregateRegionObserver extends BaseScannerRegionObserver try { lock.wait(1000); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); } } }
