我无法通过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,以将它与主控制器线程隔离,但无济于事。
答案 0 :(得分:1)
我们还没有用Tomcat测试过。
为了让Jetty运行,我不得不将alpn-boot添加到jetty JAVA执行行,然后将alpn-boot添加到servlet类加载器的系统类列表中。
您的堆栈跟踪中没有任何内容表明这是问题,但它会是我第一次看到的地方。
gRPC使用的http / 2需要Alpn。即使它是Jetty项目的一部分,你也需要它用于Tomcat。
alpn-boot的版本会根据您使用的次要版本更改。 (即Java7大约有4个罐子,Java8大约有8个罐子。)