从Google App Engine连接到云端Bigtable [英] Connect to Cloud Bigtable from Google App Engine

查看:148
本文介绍了从Google App Engine连接到云端Bigtable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用以下库/依赖项:

< dependency>
< groupId> com.google.cloud.bigtable< / groupId>
< artifactId> bigtable-hbase-1.1< / artifactId>
< version> 0.1.9< / version>
< /依赖关系>

以下几行代码:

  import org.apache.hadoop.hbase.client.ConnectionFactory; 
导入org.apache.hadoop.hbase。*;
配置conf = HBaseConfiguration.create();
connection = ConnectionFactory.createConnection(conf);

看来 ConnectionFactory.createConnection()方法试图使用受限制的类。



你能帮我们解释我们如何在GAE上使用它?



 导致:java.lang.NoClassDefFoundError:java.lang .management.ManagementFactory是一个受限制的类。有关更多详细信息,请参阅Google App Engine开发人员指南。 
at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:52)
at org.apache.hadoop.util.ReflectionUtils。< clinit>(ReflectionUtils .java:137)
在java.lang.Class.forName0(本地方法)$ b $在java.lang.Class.forName(Class.java:191)
在com.google.appengine .tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:65)
at org.apache.hadoop.hbase.security.UserProvider.instantiate(UserProvider.java:45)
at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:214)
at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119)
at org.energyworx.datastore.BigTableTSStorage。< init>(BigTableTSStorage.java:104)
在sun.reflect.NativeConstructorAccessorImpl.newInstance0(Nati (方法)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang。 $ java.lang.Class.newInstance(Class.java:379)$ b $ java.util.ServiceLoader $ b $ $ $ LazyIterator.next(ServiceLoader.java: 373)
... 71 more


解决方案

我已经更新了 GitHub


It appears that I cannot create a connection from Java class running on AppEngine.

I use the following library/dependency:

<dependency>
   <groupId>com.google.cloud.bigtable</groupId>
   <artifactId>bigtable-hbase-1.1</artifactId>
   <version>0.1.9</version>
</dependency>

And the following lines of code:

import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.*;
Configuration conf = HBaseConfiguration.create();
connection  = ConnectionFactory.createConnection(conf);

It appears that the ConnectionFactory.createConnection() method tries to use a restricted class.

Could you help us in explaining how we can use this on GAE?

I get the following error when running locally on devserver:

 Caused by: java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory is a restricted class. Please see the Google  App Engine developer's guide for more details.
    at     com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:52)
        at org.apache.hadoop.util.ReflectionUtils.<clinit>(ReflectionUtils.java:137)
        at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:191)
    at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
    at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:65)
    at org.apache.hadoop.hbase.security.UserProvider.instantiate(UserProvider.java:45)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:214)
    at org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(ConnectionFactory.java:119)
    at org.energyworx.datastore.BigTableTSStorage.<init>(BigTableTSStorage.java:104)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:379)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:373)
    ... 71 more

解决方案

I've updated the sample on GitHub.

这篇关于从Google App Engine连接到云端Bigtable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆