gpt4 book ai didi

java - Appengine for Java 上的编程备份

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:48:51 26 4
gpt4 key购买 nike

我想在 GAE for Java 上以编程方式运行备份作业。所以我尝试移植描述的代码 here在 Appengine for Java 上工作:

Queue queue = QueueFactory.getDefaultQueue();

String backendAddress = BackendServiceFactory.getBackendService().getBackendAddress("ah-builtin-python-bundle");
TaskOptions taskOptions = withUrl("/_ah/datastore_admin/backup.create")
.method(TaskOptions.Method.GET)
.param("name", "Backup_Task")
.param("filesystem", "gs")
.param("gs_bucket_name", "backup_bkt")
.param("queue", queue.getQueueName())
.header("Host", backendAddress).
.param("kind", "customer")
.param("kind", "address")
queue.add(taskOptions);

所有这些似乎都是正确的。当我运行上面的代码时,它会将任务调用添加到推送队列,但不会在 ah-builtin-python-bundle 上执行它,而是在我的应用程序的默认版本上执行,这显然返回 404。请参阅下面的日志:

2013-10-02 15:58:27.315 /_ah/datastore_admin/backup.create?name=Backup_Task&filesystem=gs&gs_bucket_name=backup&queue=next-version&kind=address&kind=customer 404 26ms 0kb AppEngine-Google; (+http://code.google.com/appengine) 0.1.0.2 - - [02/Oct/2013:08:58:27 -0700] "GET /_ah/datastore_admin/backup.create?name=Backup_Task&filesystem=gs&gs_bucket_name=backup&queue=next-version&kind=address&kind=customer HTTP/1.1" 404 294 "http://version.myapp.appspot.com/tasks/backup" "AppEngine-Google; (+http://code.google.com/appengine)" "version.myapp.appspot.com" ms=26 cpu_ms=47 cpm_usd=0.000033 queue_name=next-version task_name=3563633336363 app_engine_release=1.8.5 instance=xxxxxxxxxxxxxxx

我也看过代码here这是在做同样的事情,但我不确定它是否正常工作。

我想知道,我错过了什么?

最佳答案

我找到的解决方案如下:

Queue queue = QueueFactory.getQueue("backupQueue");
TaskOptions taskOptions = withUrl("/_ah/datastore_admin/backup.create")
.method(TaskOptions.Method.GET)
.param("name", 'Backuptask')
.param("filesystem", "gs")
.param("gs_bucket_name", BACKUP_BUCKET + '/' + DateTime.now().toString("yyyy/MM/dd/'" + nameSpace + "'-HH-mm"))
.param("namespace", NamespaceManager.get();)
.param("queue", queue.getQueueName())
.param("kind", "customer")
.param("kind", "address");
queue.add(taskOptions);

诀窍是使用 backupQueue这将针对 ah-builtin-python-bundle .您可以通过将以下内容添加到 queue.xml 来执行此操作:`


<queue>
<!-- a queue for backups tasks -->
<name>backupQueue</name>
<rate>1/s</rate>
<bucket-size>10</bucket-size>
<max-concurrent-requests>3</max-concurrent-requests>
<retry-parameters>
<!-- only 1 retry attempt -->
<task-retry-limit>2</task-retry-limit>
</retry-parameters>
<target>ah-builtin-python-bundle</target>
</queue>

关于java - Appengine for Java 上的编程备份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19142093/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com