Writing to an appengine blob asynchronously and finalizing it when all tasks complete

后端 未结 3 712
自闭症患者
自闭症患者 2021-01-07 08:06

I have a difficult problem.

I am iterating through a set of URLs parameterized by date and fetching them. For example, here is an example of one:

somewebserv

3条回答
  •  孤城傲影
    2021-01-07 08:52

    Here is an example using Java Pipeline

    package com.example;

    import com.google.appengine.tools.pipeline.FutureValue;
    import com.google.appengine.tools.pipeline.Job1;
    import com.google.appengine.tools.pipeline.Job2;
    import com.google.appengine.tools.pipeline.Value;
    
    public class PipelineRecursionDemo {
    
      /**
       * A Job to count the number of letters in a word
       * using recursion
       */
      public static class LetterCountJob extends Job1 {
    
        public Value run(String word) {
          int length = word.length();
          if (length < 2) {
            return immediate(word.length());
          } else {
            int mid = length / 2;
            FutureValue first = futureCall(new LetterCountJob(),
                immediate(word.substring(0, mid)));
            FutureValue second = futureCall(new LetterCountJob(),
                immediate(word.substring(mid, length)));
            return futureCall(new SumJob(), first, second);
          }
        }
      }
    
      /**
       * An immediate Job to add two integers
       */
      public static class SumJob extends Job2 {
    
        public Value run(Integer x, Integer y) {
          return immediate(x + y);
        }
      }
    }
    

提交回复
热议问题