无法通过 REST 获取 table 数据

Can't obtain table data via REST

我在以下代码片段中使用 Phoenix JDBC 驱动程序创建了一个 HBase table:

    Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
    Connection conn =  DriverManager.getConnection("jdbc:phoenix:serverurl:/hbase-unsecure");
    System.out.println("got connection");

    conn.createStatement().execute("CREATE TABLE IF NOT EXISTS phoenixtest (id BIGINT not null primary key, test VARCHAR)");

    int inserted = conn.createStatement().executeUpdate("UPSERT INTO phoenixtest VALUES (5, '13%')");
    conn.commit();

    System.out.println("Inserted or updated " + inserted + " rows");

    ResultSet rst = conn.createStatement().executeQuery("select * from phoenixtest");

    while (rst.next()) {
      System.out.println(rst.getString(1) + " " + rst.getString(2));
    }

table 已创建,table 循环工作正常。

现在我也尝试通过 HBase REST 服务获取 table 数据,正如我从 "native" HBase 编程中了解到的那样。但是当我尝试

http://server-url:12345/phoenixtest/schema

我得到以下异常

Not found
org.apache.hadoop.hbase.TableNotFoundException: phoenixtest
    at org.apache.hadoop.hbase.client.HTable.getTableDescriptor(HTable.java:597)
    at org.apache.hadoop.hbase.rest.SchemaResource.getTableSchema(SchemaResource.java:79)
    at org.apache.hadoop.hbase.rest.SchemaResource.get(SchemaResource.java:94)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
    at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
    at org.apache.hadoop.hbase.rest.filter.GzipFilter.doFilter(GzipFilter.java:76)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:767)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

当我为我使用 HBase Java API 本身创建的 table 调用此 /schema url 时,我得到一个结果:

{ NAME=> 'sensor-table', IS_META => 'false', COLUMNS => [ { NAME => 'alert', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', COMPRESSION => 'SNAPPY', VERSIONS => '1', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true' }, { NAME => 'sensor', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', COMPRESSION => 'SNAPPY', VERSIONS => '1', MIN_VERSIONS => '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true' } ] }

"native" HBase table 和用 Phoenix 创建的有什么区别?为什么我无法通过 HBase REST 服务获取 table 数据/信息?

我知道了,你必须用大写字母写table名字:

http://server-url:12345/PHOENIXTEST/schema

这与您在 CREATE 语句中是否用小写字母写了 table 名称无关!