Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 4198ea6af -> 481a802ee
PHOENIX-2111 Addendum - prevent IllegalStateException for older clients Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/481a802e Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/481a802e Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/481a802e Branch: refs/heads/4.x-HBase-0.98 Commit: 481a802ee56b0560c34cec0bb956931f73c73d2c Parents: 4198ea6 Author: Samarth <[email protected]> Authored: Tue Jul 14 17:05:21 2015 -0700 Committer: Samarth <[email protected]> Committed: Tue Jul 14 17:05:35 2015 -0700 ---------------------------------------------------------------------- .../coprocessor/MetaDataEndpointImpl.java | 22 ++++---------------- 1 file changed, 4 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/481a802e/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 6372700..da8110c 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 @@ -1110,20 +1110,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso return physicalTableRow; } - private long getSequenceNumberForTable(byte[] headerRowKey) throws IOException { - Get get = new Get(headerRowKey); - get.addColumn(TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES); - byte[] b; - try (HTableInterface hTable = ServerUtil.getHTableForCoprocessorScan(env, PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES)) { - Result result = hTable.get(get); - b = result.getValue(TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES); - } - if (b == null) { - throw new IllegalArgumentException("No rows returned for the row key: " + Bytes.toString(headerRowKey)); - } - return PLong.INSTANCE.getCodec().decodeLong(new ImmutableBytesWritable(b), SortOrder.getDefault()); - } - @Override public void createTable(RpcController controller, CreateTableRequest request, RpcCallback<MetaDataResponse> done) { @@ -1203,10 +1189,10 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso if (tableType == PTableType.VIEW && viewPhysicalTableRow != null && request.hasClientVersion()) { // Starting 4.5, the client passes the sequence number of the physical table in the table metadata. parentTableSeqNumber = MetaDataUtil.getSequenceNumber(viewPhysicalTableRow); - } else if (tableType == PTableType.VIEW) { - // Before 4.5, due to a bug, the parent table key wasn't available. Using get to - // figure out the parent table sequence number. - parentTableSeqNumber = getSequenceNumberForTable(parentTableKey); + } else if (tableType == PTableType.VIEW && !request.hasClientVersion()) { + // Before 4.5, due to a bug, the parent table key wasn't available. + // So don't do anything and prevent the exception from being thrown. + parentTableSeqNumber = parentTable.getSequenceNumber(); } else { parentTableSeqNumber = MetaDataUtil.getParentSequenceNumber(tableMetadata); }
