Google App Engine fails to connect Aerospike installed on Google Compute Engine

醉酒当歌 提交于 2020-01-16 01:53:07

问题


I'm trying to connect my GAE Application to Aerospike installed on Google Compute Engine. Code snippet below is ok if i use main function.

    public static void main(String[] args) {
        AerospikeClient client = new AerospikeClient("xxx.xxx.xx.xx", 3000);
        boolean isConnect = client.isConnected();       
        Key key = new Key("test", "demo", "putgetkey");
        Bin bin1 = new Bin("bin1", "value1");
        Bin bin2 = new Bin("bin2", "value2");       
        client.put(null, key, bin1, bin2);
        Record record = client.get(null, key);
        client.close();
    }

But when i deploy my application to GAE, i got this error.

    java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "modifyThreadGroup")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
    at java.security.AccessController.checkPermission(AccessController.java:559)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
    at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:454)
    at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
    at java.lang.Thread.init(Thread.java:391)
    at java.lang.Thread.init(Thread.java:349)
    at java.lang.Thread.<init>(Thread.java:461)
    at com.aerospike.client.cluster.Cluster.initTendThread(Cluster.java:163)
    at com.aerospike.client.AerospikeClient.<init>(AerospikeClient.java:195)
    at com.aerospike.client.AerospikeClient.<init>(AerospikeClient.java:160)

I used external and internal IP of Compute Engine instance to create new AerospikeClient("compute_engine_ip",3000) but same error. Any idea to fix my problem? Thank you.


回答1:


GAE does not allow front end instances (GAE instances) to spawn threads, and an attempt to do so results in AccessControlException.

You will need to run the Aerospike client on a GCE machine and then use your GAE application to connect to the GCE machine instead of running the Aerospike Client on GAE.



来源:https://stackoverflow.com/questions/27465052/google-app-engine-fails-to-connect-aerospike-installed-on-google-compute-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!