【问题标题】:Google App Engine : use mapreduce to empty datastoreGoogle App Engine:使用 mapreduce 清空数据存储
【发布时间】:2011-04-11 01:51:27
【问题描述】:

我正在尝试使用early experimental release of mapper implementation 来清空数据存储。这个解决方案是在similar SO question 中提出的。

这是我目前正在使用的 AppEngineMapper。它只是删除实体。

public class EmptyFixesMapper extends AppEngineMapper<Key, Entity, NullWritable, NullWritable> {

    public EmptyFixesMapper() {
    }

    @Override
    public void taskSetup(Context context) {
    }

    @Override
    public void taskCleanup(Context context) {
    }

    @Override
    public void setup(Context context) throws IOException, InterruptedException {
        super.setup(context);
    }

    @Override
    public void cleanup(Context context) {
        getAppEngineContext(context).flush();
    }

    @Override
    public void map(Key key, Entity value, Context context) {
        log.warning("Mapping key: " + key);

        DatastoreMutationPool mutationPool = 
                    this.getAppEngineContext(context).getMutationPool();
        mutationPool.delete(value.getKey());
    }
}

这是我的 ma​​preduce.xml 配置文件:

<configurations>
    <configuration name="Empty Entities">
        <property>
            <name>mapreduce.map.class</name>
            <value>com.google.appengine.demos.mapreduce.EmptyFixesMapper</value>
        </property>
        <property>
            <name>mapreduce.inputformat.class</name>
            <value>com.google.appengine.tools.mapreduce.DatastoreInputFormat</value>
        </property>
        <property>
            <name human="Entity Kind to Map Over">mapreduce.mapper.inputformat.datastoreinputformat.entitykind</name>
            <value template="optional">Fix</value>
        </property>
    </configuration>
...

当我进入 mydomain/mapreduce/status 中的 ma​​preduce 控制面板 时,我可以启动任务,但它们永远不会完成。这是您可以看到字段“0/0 shards”的屏幕截图:

我可以看到在 appengine 默认任务队列中创建了一些任务,并进行了很多重试:

最后,在我的 GAE 应用程序日志中,我看到:

1。 09-11 03:23AM 08.556 /mapreduce/mapperCallback 500 10081ms 0cpu_ms 0kb AppEngine-谷歌; (+http://code.google.com/appengine)

  0.1.0.2 - - [11/Sep/2010:03:23:18 -0700] "POST

/mapreduce/mapperCallback HTTP/1.1" 500 0 “http://xxx.appspot.com/mapreduce/command/start_job” “AppEngine-谷歌; (+http://code.google.com/appengine)" xxx.appspot.com" ms=10081 cpu_ms=0 api_cpu_ms=0 cpm_usd=0.000057 queue_name=默认值 task_name=worker-attempt-1284198892815-0001-m-000002-1--0

2。 W 09-11 03:23AM 18.638

  Request was aborted after waiting too long to attempt to service

您的请求。这可能会发生 偶尔当 App Engine 服务集群意外处于下 高负载或不均匀负载。如果你看到这个 经常留言,请联系 App Engine 团队。

会发生什么?我确定我已按照getting started guide 中描述的步骤进行操作,并且数据存储区中的实体少于 1000 个...

【问题讨论】:

    标签: google-app-engine google-cloud-datastore mapreduce


    【解决方案1】:

    嗯,这个问题与 appengine-mapreduce 无关。我正在保护 /mapreduce/** URI,因此默认任务队列中的任务无法到达 /mapreduce/mapperCallback、/mapreduce/command/start_job 等,因为没有发送用户名/密码信息。

    无论如何这是一个有趣的问题,因为我真的不想向所有人打开 /mapreduce/**...

    【讨论】:

    • 任务以管理员角色运行,因此您可以(并且应该)保护 /mapreduce/** uri。中止的请求通常会消失,而中止的任务将被重试。
    猜你喜欢
    • 1970-01-01
    • 2011-04-15
    • 2011-05-26
    • 2013-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多