1

我正在使用 objectify 4 写入 HRD 数据存储。在单元测试中一切正常,在开发服务器或生产中运行应用程序。

但是,当我尝试使用 REMOTE API 连接到 devserver 数据存储时,代码启动 XG 事务时会引发错误。在连接远程 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();
    }
}

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

仅在 High Replication 应用程序中允许的多个实体组上的事务

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

4

2 回答 2

0

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

在此处输入图像描述

于 2013-12-22T13:19:41.663 回答
0

如果您的应用程序正在使用High Replication Datastore,请在应用程序 ID 中添加显式s~前缀(或e~前缀,如果您的应用程序位于欧盟)

对于 Java 版本,在appengine-web.xml中的应用程序标签中添加此前缀,然后部署您已激活 remote_api servlet 的版本

例子

<application>myappid</application>

变得

<application>s~myappid</application>

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

于 2013-12-20T12:56:51.527 回答