Class StatefulTeamScore


  • public class StatefulTeamScore
    extends LeaderBoard
    This class is part of a series of pipelines that tell a story in a gaming domain. Concepts include: stateful processing.

    This pipeline processes an unbounded stream of 'game events'. It uses stateful processing to aggregate team scores per team and outputs team name and it's total score every time the team passes a new multiple of a threshold score. For example, multiples of the threshold could be the corresponding scores required to pass each level of the game. By default, this threshold is set to 5000.

    Stateful processing allows us to write pipelines that output based on a runtime state (when a team reaches a certain score, in every 100 game events etc) without time triggers. See https://beam.apache.org/blog/2017/02/13/stateful-processing.html for more information on using stateful processing.

    Run injector.Injector to generate pubsub data for this pipeline. The Injector documentation provides more detail on how to do this.

    To execute this pipeline, specify the pipeline configuration like this:

    
     --project=YOUR_PROJECT_ID
     --tempLocation=gs://YOUR_TEMP_DIRECTORY
     --runner=YOUR_RUNNER
     --dataset=YOUR-DATASET
     --topic=projects/YOUR-PROJECT/topics/YOUR-TOPIC
     

    The BigQuery dataset you specify must already exist. The PubSub topic you specify should be the same topic to which the Injector is publishing.

    • Constructor Detail

      • StatefulTeamScore

        public StatefulTeamScore()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception