Package org.apache.nifi.controller
Interface Triggerable
public interface Triggerable
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionint
Indicates theScheduledState
of thisTriggerable
.long
getSchedulingPeriod
(TimeUnit timeUnit) boolean
Indicates whether or not thisTriggerable
is "running".void
onTrigger
(ProcessContext context, ProcessSessionFactory sessionFactory) The method called when this processor is triggered to operate by the controller.void
setMaxConcurrentTasks
(int taskCount) Determines the number of concurrent tasks that may be running for thisTriggerable
.void
setSchedulingPeriod
(String schedulingPeriod) Updates how often this Triggerable should be triggered to run
-
Field Details
-
MINIMUM_SCHEDULING_NANOS
static final long MINIMUM_SCHEDULING_NANOS- See Also:
-
-
Method Details
-
onTrigger
void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException The method called when this processor is triggered to operate by the controller. This method may be called concurrently from different threads. When this method is called depends on how this processor is configured within a controller to be triggered (timing or event based).
The processor may commit, roll back, or allow the framework to automatically manage the session. If the sessions are to be managed by the framework (recommended) then what it will do depends on several factors. If the method call returns due to an exception then the session will be rolled back. If the method returns normally then the session will be committed or the framework may use the session again for another processor down stream
- Parameters:
context
- in which the component is triggeredsessionFactory
- used to generateProcessSession
s to use for operating on flow files within the repository- Throws:
ProcessException
- if processing did not complete normally though indicates the problem is an understood potential outcome of processing. The controller/caller will handle these exceptions gracefully such as logging, etc.. If another type of exception is allowed to propagate the controller may no longer trigger this processor to operate as this would indicate a probable coding defect.
-
setMaxConcurrentTasks
void setMaxConcurrentTasks(int taskCount) Determines the number of concurrent tasks that may be running for thisTriggerable
.- Parameters:
taskCount
- a number of concurrent tasks this processor may have running- Throws:
IllegalArgumentException
- if the given value is less than 1
-
getMaxConcurrentTasks
int getMaxConcurrentTasks()- Returns:
- the number of tasks that may execute concurrently for this
Triggerable
.
-
getScheduledState
ScheduledState getScheduledState()Indicates theScheduledState
of thisTriggerable
. A value of stopped does NOT indicate that theTriggerable
has no active threads, only that it is not currently scheduled to be given any more threads. To determine whether or not theTriggerable
has any active threads, seeinvalid reference
ProcessScheduler#getActiveThreadCount(nifi.connectable.Connectable)
- Returns:
- the schedule state
-
isRunning
boolean isRunning()Indicates whether or not thisTriggerable
is "running". It is considered "running" if it is scheduled to run OR if it is no longer scheduled to be given threads but the remaining threads from the last invocation ofonTrigger(ProcessContext, ProcessSessionFactory)
have not yet returned- Returns:
- true if running;false otherwise
-
getSchedulingPeriod
- Parameters:
timeUnit
- for the scheduling period of the component- Returns:
- the amount of time between each scheduling period
-
getSchedulingPeriod
String getSchedulingPeriod()- Returns:
- a string representation of the time between each scheduling period
-
setSchedulingPeriod
Updates how often this Triggerable should be triggered to run- Parameters:
schedulingPeriod
- to set
-