Repository: phoenix Updated Branches: refs/heads/4.0.1 [created] 70ac68380
PHOENIX-1184 Phoenix 4.0 is NOT compatible with CDH HBase 5.1 Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/70ac6838 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/70ac6838 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/70ac6838 Branch: refs/heads/4.0.1 Commit: 70ac68380bf04de36dba0b073b93047114351ab4 Parents: 4d90a49 Author: Andrew Purtell <apurt...@apache.org> Authored: Tue Aug 19 19:38:54 2014 -0700 Committer: Andrew Purtell <apurt...@apache.org> Committed: Tue Aug 19 19:46:13 2014 -0700 ---------------------------------------------------------------------- .../query/ConnectionlessQueryServicesImpl.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/70ac6838/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java index b616356..74cdf52 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java @@ -19,6 +19,7 @@ package org.apache.phoenix.query; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.INDEX_STATE_BYTES; +import java.lang.reflect.Constructor; import java.sql.SQLException; import java.util.Collections; import java.util.List; @@ -138,9 +139,22 @@ public class ConnectionlessQueryServicesImpl extends DelegateQueryServices imple @Override public List<HRegionLocation> getAllTableRegions(byte[] tableName) throws SQLException { + // HBase hides the ServerName constructors and provides static valueOf helper methods + // for obtaining ServerName objects instead. However some commercial Hadoop distributions + // have patched their HBase to remove the valueOf static methods, leaving no common way + // to construct ServerNames except by way of reflection. + ServerName fakeServerName; + try { + Constructor<ServerName> c = ServerName.class.getDeclaredConstructor(String.class, + int.class, long.class); + c.setAccessible(true); + fakeServerName = c.newInstance("localhost", HConstants.DEFAULT_REGIONSERVER_PORT, 0L); + } catch (Exception e) { + throw new SQLException(e); + } return Collections.singletonList(new HRegionLocation( new HRegionInfo(TableName.valueOf(tableName), HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW), - ServerName.valueOf("localhost", HConstants.DEFAULT_REGIONSERVER_PORT,0), -1)); + fakeServerName, -1)); } @Override