Annotation Type DoFn.Setup


  • @Documented
    @Retention(RUNTIME)
    @Target(METHOD)
    public static @interface DoFn.Setup
    Annotation for the method to use to prepare an instance for processing bundles of elements.

    This is a good place to initialize transient in-memory resources, such as network connections. The resources can then be disposed in DoFn.Teardown.

    This is not a good place to perform external side-effects that later need cleanup, e.g. creating temporary files on distributed filesystems, starting VMs, or initiating data export jobs. Such logic must be instead implemented purely via DoFn.StartBundle, DoFn.ProcessElement and DoFn.FinishBundle methods, references to the objects requiring cleanup must be passed as PCollection elements, and they must be cleaned up via regular Beam transforms, e.g. see the Wait transform.

    The method annotated with this must satisfy the following constraints:

    • It must have zero arguments.