简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM