Class PulsarFunctionAdministration

java.lang.Object
org.springframework.pulsar.function.PulsarFunctionAdministration
All Implemented Interfaces:
org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

public class PulsarFunctionAdministration extends Object implements org.springframework.context.SmartLifecycle
Responsible for creating and updating any user-defined Pulsar functions, sinks, or sources.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Indicates a failure of one or more function operations.
  • Field Summary

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors
    Constructor
    Description
    PulsarFunctionAdministration(PulsarAdministration pulsarAdministration, org.springframework.beans.factory.ObjectProvider<PulsarFunction> pulsarFunctions, org.springframework.beans.factory.ObjectProvider<PulsarSink> pulsarSinks, org.springframework.beans.factory.ObjectProvider<PulsarSource> pulsarSources, boolean failFast, boolean propagateFailures, boolean propagateStopFailures)
    Construct a PulsarFunctionAdministration instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called during server startup, creates or updates any Pulsar functions registered by the application.
    void
    Called during server shutdown, enforces the stop policy on all Pulsar functions that were successfully processed during server startup.
    boolean
     
    void
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.context.SmartLifecycle

    getPhase, isAutoStartup, stop
  • Constructor Details

    • PulsarFunctionAdministration

      public PulsarFunctionAdministration(PulsarAdministration pulsarAdministration, org.springframework.beans.factory.ObjectProvider<PulsarFunction> pulsarFunctions, org.springframework.beans.factory.ObjectProvider<PulsarSink> pulsarSinks, org.springframework.beans.factory.ObjectProvider<PulsarSource> pulsarSources, boolean failFast, boolean propagateFailures, boolean propagateStopFailures)
      Construct a PulsarFunctionAdministration instance.
      Parameters:
      pulsarAdministration - the pulsar admin to make the API calls with
      pulsarFunctions - provider of functions to create/update
      pulsarSinks - provider of sinks to create/update
      pulsarSources - provider of sources to create/update
      failFast - whether to stop processing when a failure occurs
      propagateFailures - whether to throw an exception when a failure occurs during server startup while creating/updating functions
      propagateStopFailures - whether to throw an exception when a failure occurs during server shutdown while enforcing stop policy on functions
  • Method Details

    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
    • createOrUpdateUserDefinedFunctions

      public void createOrUpdateUserDefinedFunctions()
      Called during server startup, creates or updates any Pulsar functions registered by the application.

      The functions, sinks, and sources are processed serially (in that order) as follows:

      • A create or update operation is performed depending on whether or not the function already exists.
      • If the operation fails the failFast property controls whether processing should stop (fail fast) or continue on w/ the next function.

      Once processing is complete, any failures are either logged or thrown to the caller (propagated) dependent on the propagateFailures property.

      Throws:
      PulsarFunctionAdministration.PulsarFunctionException - containing processing errors if the propagateFailures property is set to true
    • enforceStopPolicyOnUserDefinedFunctions

      public void enforceStopPolicyOnUserDefinedFunctions()
      Called during server shutdown, enforces the stop policy on all Pulsar functions that were successfully processed during server startup.

      The functions, sinks, and sources are processed in reverse startup order as follows:

      • The stop policy of each function is used to determine if the function should be stopped, removed, or left alone.

      Once processing is complete, any failures are either logged or thrown to the caller (propagated) dependent on the propagateStopFailures property.

      Throws:
      PulsarFunctionAdministration.PulsarFunctionException - containing processing errors if the propagateStopFailures property is set to true