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
Modifier and TypeClassDescriptionstatic class
Indicates a failure of one or more function operations. -
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionPulsarFunctionAdministration
(PulsarAdministration pulsarAdministration, ObjectProvider<PulsarFunction> pulsarFunctions, ObjectProvider<PulsarSink> pulsarSinks, ObjectProvider<PulsarSource> pulsarSources, boolean failFast, boolean propagateFailures, boolean propagateStopFailures) Construct aPulsarFunctionAdministration
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
start()
void
stop()
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, ObjectProvider<PulsarFunction> pulsarFunctions, ObjectProvider<PulsarSink> pulsarSinks, ObjectProvider<PulsarSource> pulsarSources, boolean failFast, boolean propagateFailures, boolean propagateStopFailures) Construct aPulsarFunctionAdministration
instance.- 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
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 thepropagateFailures
property 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
propagateStopFailures
property.- Throws:
PulsarFunctionAdministration.PulsarFunctionException
- containing processing errors if thepropagateStopFailures
property is set totrue
-