Class PulsarFunctionAdministration
java.lang.Object
org.springframework.pulsar.function.PulsarFunctionAdministration
- All Implemented Interfaces:
Lifecycle,Phased,SmartLifecycle
Responsible for creating and updating any user-defined Pulsar functions, sinks, or
sources.
- Author:
- Chris Bono
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIndicates a failure of one or more function operations. -
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionPulsarFunctionAdministration(PulsarAdministration pulsarAdministration, ObjectProvider<PulsarFunction> pulsarFunctions, ObjectProvider<PulsarSink> pulsarSinks, ObjectProvider<PulsarSource> pulsarSources, boolean failFast, boolean propagateFailures, boolean propagateStopFailures) Construct aPulsarFunctionAdministrationinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled during server startup, creates or updates any Pulsar functions registered by the application.voidCalled during server shutdown, enforces the stop policy on all Pulsar functions that were successfully processed during server startup.booleanvoidstart()voidstop()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
getPhase, isAutoStartup, stop
-
Constructor Details
-
PulsarFunctionAdministration
public PulsarFunctionAdministration(PulsarAdministration pulsarAdministration, ObjectProvider<PulsarFunction> pulsarFunctions, ObjectProvider<PulsarSink> pulsarSinks, ObjectProvider<PulsarSource> pulsarSources, boolean failFast, boolean propagateFailures, boolean propagateStopFailures) Construct aPulsarFunctionAdministrationinstance.- Parameters:
pulsarAdministration- the pulsar admin to make the API calls withpulsarFunctions- provider of functions to create/updatepulsarSinks- provider of sinks to create/updatepulsarSources- provider of sources to create/updatefailFast- whether to stop processing when a failure occurspropagateFailures- whether to throw an exception when a failure occurs during server startup while creating/updating functionspropagateStopFailures- whether to throw an exception when a failure occurs during server shutdown while enforcing stop policy on functions
-
-
Method Details
-
start
public void start() -
stop
public void stop() -
isRunning
public boolean isRunning() -
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
failFastproperty 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
propagateFailuresproperty.- Throws:
PulsarFunctionAdministration.PulsarFunctionException- containing processing errors if thepropagateFailuresproperty is set totrue
-
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
propagateStopFailuresproperty.- Throws:
PulsarFunctionAdministration.PulsarFunctionException- containing processing errors if thepropagateStopFailuresproperty is set totrue
-