【问题标题】:schedule AppEngine mapreduce jobs from compute engine从计算引擎安排 AppEngine mapreduce 作业
【发布时间】:2015-04-28 18:43:47
【问题描述】:

有没有办法从计算引擎服务器调度 AppEngine mapreduce?

我在 AppEngine 上运行了生产应用程序,我想做的是启动 MapReduce 作业并从计算引擎实例跟踪它们的状态,一旦 MR 作业完成,在计算上做一些额外的工作引擎实例。

我在网上做了一些搜索,找不到很多类似的故事。有什么建议吗?

【问题讨论】:

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


    【解决方案1】:

    如果您将 mapreduce 作业包装在 python 代码中,您可以制作一个触发 mapreduce 的 servlet。

    from mapreduce import control
    class ComputeMRHandler(webapp2.RequestHandler):
        def get(self):
            control.start_map(
                name='Mapreduce Name',
                reader_spec='mapreduce.input_readers.DatastoreInputReader',
                handler_spec='my_mapper_function',
                mapper_parameters={'entity_kind': 'my_datastore.DataRecord'},
            )
    

    然后只需通过对您的 GAE 服务器的 Web 请求调用上述处理程序。

    在最后做一些事情有点困难。你可以在你的计算引擎上写一些东西来轮询 GAE 应用,等待它完成。

    或者您可以探索“管道”库https://github.com/GoogleCloudPlatform/appengine-pipelines,它允许您对一系列操作进行排序(即运行 mapreduce,然后运行“完成”代码块)。要做到这一点,您应该真正了解管道,但代码基本上是:

    class MyCompletionHandlerPipeline(fixed_pipelines.Pipeline):
        def run(self, results):
            # Request some handler on your GCE instance that tells it:
            # "hey we're done, go process your extra work now"
            pass
    
    class MapreduceAndCompletionPipeline(fixed_pipelines.Pipeline):
        def run(self):
            results = yield MyMapReducePipeline(parameters)
            # the dependency on results ensures it runs after MyMapReducePipeline
            yield MyCompletionHandlerPipeline(results)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 2016-03-02
      • 1970-01-01
      • 2012-12-10
      相关资源
      最近更新 更多