Interface JvmInitializer

All Known Implementing Classes:
KafkaIOInitializer

public interface JvmInitializer
A service interface for defining one-time initialization of the JVM during pipeline execution.

During pipeline execution, onStartup and beforeProcessing will be invoked at the appropriate stage of execution after the JVM is launched. Currently this is only supported in portable pipelines or when using Google Cloud Dataflow.

ServiceLoader is used to discover implementations of JvmInitializer, note that you will need to register your implementation with the appropriate resources to ensure your code is executed. You can use a tool like AutoService to automate this.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Implement beforeProcessing to run some custom initialization after basic services such as logging, but before data processing begins.
    default void
    Implement onStartup to run some custom initialization immediately after the JVM is launched for pipeline execution.
  • Method Details

    • onStartup

      default void onStartup()
      Implement onStartup to run some custom initialization immediately after the JVM is launched for pipeline execution.

      In general users should prefer to implement beforeProcessing to perform custom initialization so that basic services such as logging can be initialized first, but onStartup is also provided if initialization absolutely needs to be run immediately after starting.

    • beforeProcessing

      default void beforeProcessing(PipelineOptions options)
      Implement beforeProcessing to run some custom initialization after basic services such as logging, but before data processing begins.
      Parameters:
      options - The pipeline options passed to the worker.