1

我无法从 Java 调用 Google Cloud Bigtable 上的任何操作。

我不断收到此错误:

[2015-11-07T01:16:06,214] 21900 ERROR [http-bio-8080-exec-1] com.google.cloud.bigtable.hbase.BigtableTable - Encountered ServiceException when executing put.
com.google.bigtable.repackaged.com.google.common.util.concurrent.UncheckedExecutionException: io.grpc.StatusRuntimeException: UNKNOWN
        at io.grpc.stub.Calls.getUnchecked(Calls.java:117) ~[bigtable-hbase-1.0-0.2.1.jar:?]
        at io.grpc.stub.Calls.blockingUnaryCall(Calls.java:129) ~[bigtable-hbase-1.0-0.2.1.jar:?]
        at com.google.cloud.bigtable.grpc.BigtableDataGrpcClient.mutateRow(BigtableDataGrpcClient.java:250) ~[bigtable-hbase-1.0-0.2.1.jar:?]
        at com.google.cloud.bigtable.hbase.BigtableTable.put(BigtableTable.java:333) ~[bigtable-hbase-1.0-0.2.1.jar:?]
        at com.tango.bigtable.rest.v1.BigTableRestController.insert(BigTableRestController.java:39) ~[BigTableRestController.class:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_66]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_66]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_66]
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:175) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:620) ~[servlet-api.jar:?]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) ~[spring-webmvc-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) ~[servlet-api.jar:?]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) ~[catalina.jar:7.0.55]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) ~[catalina.jar:7.0.55]
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat7-websocket.jar:7.0.55]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) ~[catalina.jar:7.0.55]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) ~[catalina.jar:7.0.55]
        at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:67) ~[log4j-web-2.0.2.jar:2.0.2]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) ~[catalina.jar:7.0.55]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) ~[catalina.jar:7.0.55]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) ~[catalina.jar:7.0.55]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) ~[catalina.jar:7.0.55]
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) ~[catalina.jar:7.0.55]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) ~[catalina.jar:7.0.55]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) ~[catalina.jar:7.0.55]
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950) ~[catalina.jar:7.0.55]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) ~[catalina.jar:7.0.55]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) ~[catalina.jar:7.0.55]
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070) ~[tomcat-coyote.jar:7.0.55]
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) ~[tomcat-coyote.jar:7.0.55]
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314) ~[tomcat-coyote.jar:7.0.55]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_66]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_66]
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-coyote.jar:7.0.55]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_66]
Caused by: io.grpc.StatusRuntimeException: UNKNOWN
        at io.grpc.Status.asRuntimeException(Status.java:428) ~[bigtable-hbase-1.0-0.2.1.jar:?]
        at io.grpc.stub.Calls$UnaryStreamToFuture.onClose(Calls.java:324) ~[bigtable-hbase-1.0-0.2.1.jar:?]
        at io.grpc.ChannelImpl$CallImpl$ClientStreamListenerImpl$3.run(ChannelImpl.java:402) ~[bigtable-hbase-1.0-0.2.1.jar:?]
        at io.grpc.SerializingExecutor$TaskRunner.run(SerializingExecutor.java:154) ~[bigtable-hbase-1.0-0.2.1.jar:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[?:1.8.0_66]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[?:1.8.0_66]
        ... 1 more
Caused by: java.nio.channels.ClosedChannelException

这是生成此错误的测试代码:

    try {
        Connection connection = BigTableHelper.getConnection();
        Table table = connection.getTable(TableName.valueOf("Tango"));

        byte[] rowKey = Bytes.toBytes("username");
        Put p = new Put(rowKey);
        p.addColumn(Bytes.toBytes("O"), Bytes.toBytes("acme"), Bytes.toBytes("sync"));
        LOGGER.trace("Putting to row {}", Bytes.toStringBinary(rowKey));
        table.put(p);
    } catch (IOException e) {
    }

任何人都知道什么可能会关闭连接?我没有明确关闭连接,我什至尝试将 put 操作放入 ThreadPoolExecutor 以将其与主 Controller 线程隔离,但无济于事。

4

1 回答 1

1

我们还没有用 Tomcat 进行测试。

为了让 Jetty 运行,我必须将alpn-boot添加到 jetty JAVA 执行行,然后将 alpn-boot 添加到 servlet 类加载器的系统类列表中。

您的堆栈跟踪中没有任何内容表明这是问题所在,但是,它会是我第一次看到的地方。

gRPC 使用的 http/2 需要 Alpn。即使它是 Jetty 项目的一部分,您也需要它来运行 Tomcat。

alpn-boot 的版本会根据您使用的 Java 的次要版本而变化。(即,Java7 大约有 4 个罐子,Java8 也有同样多的罐子)。

于 2015-11-09T21:38:19.527 回答