远程API,Objectify和DevServer不喜欢交易?

时间:2013-12-19 21:56:55

标签: google-app-engine google-cloud-datastore objectify remoteapi

我正在使用objectify 4来写入HRD数据存储区。在单元测试中以及在devserver或production中运行应用程序时,一切正常。

但是当我尝试使用REMOTE API连接到devserver数据存储区时,代码启动XG事务时会引发错误。在连接Remote API时,似乎认为未启用HRD。 这是我连接的方式......

public static void main(String[] args) {
    RemoteApiOptions options = new RemoteApiOptions().server("localhost", 8888).credentials("foo", "bar");
    //options = options.
    RemoteApiInstaller installer = new RemoteApiInstaller();
    StoredUser storedUser = null;
    try {
        installer.install(options);
        ObjectifyInitializer.register();
        storedUser = new StoredUserDao().loadStoredUser(<KEY>);
        log.info("found user : " + storedUser.getEmail());

        // !!! ERROR !!!
        new SomeOtherDao().doSomeDataManipulationInTransaction();

    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        ObjectifyFilter.complete();
        installer.uninstall();
    }
}

当新的SomeOtherDao()。doSomeDataManipulationInTransaction()在多个实体组上启动事务时,我会抛出错误:

仅在高复制应用程序中允许

多个实体组上的事务

如何告诉远程api这是一个HRD环境?

2 个答案:

答案 0 :(得分:0)

  

如果您的应用程序使用高复制数据存储区,请添加   显式 s~ 前缀(或 e~ 前缀,如果您的应用位于   欧盟)给app id

对于Java版本,请在 appengine-web.xml 中的 application 标记中添加此前缀,然后部署已激活remote_api servlet的版本

实施例

<application>myappid</application>

成为

<application>s~myappid</application>

来源:https://developers.google.com/appengine/docs/python/tools/uploadingdata#Python_Setting_up_remote_api

答案 1 :(得分:0)

我将'未应用的作业百分比'设置为0,使用远程api的事务失败,就好像devserver正在使用Master / Slave而不是HRD运行。将“未应用的工作百分比”提高到零以上可以解决问题。

enter image description here