public class MockProcessContext extends MockControllerServiceLookup implements SchedulingContext, ControllerServiceLookup, NodeTypeProvider
Constructor and Description |
---|
MockProcessContext(ConfigurableComponent component) |
MockProcessContext(ConfigurableComponent component,
StateManager stateManager,
VariableRegistry variableRegistry)
Creates a new MockProcessContext for the given Processor
|
MockProcessContext(ControllerService component,
MockProcessContext context,
StateManager stateManager,
VariableRegistry variableRegistry) |
Modifier and Type | Method and Description |
---|---|
void |
addConnection(Relationship relationship) |
void |
addControllerService(java.lang.String serviceIdentifier,
ControllerService controllerService,
java.util.Map<PropertyDescriptor,java.lang.String> properties,
java.lang.String annotationData) |
void |
assertValid() |
java.lang.String |
decrypt(java.lang.String encrypted)
Decrypts the given value using the password provided in the NiFi
Properties
|
void |
disableExpressionValidation() |
void |
enableExpressionValidation() |
java.lang.String |
encrypt(java.lang.String unencrypted)
Encrypts the given value using the password provided in the NiFi
Properties
|
java.util.Map<java.lang.String,java.lang.String> |
getAllProperties() |
java.lang.String |
getAnnotationData() |
java.util.Set<Relationship> |
getAvailableRelationships() |
ControllerServiceLookup |
getControllerServiceLookup() |
int |
getMaxConcurrentTasks() |
java.lang.String |
getName() |
java.util.Map<PropertyDescriptor,java.lang.String> |
getProperties() |
PropertyValue |
getProperty(PropertyDescriptor descriptor)
Retrieves the current value set for the given descriptor, if a value is
set - else uses the descriptor to determine the appropriate default value
|
PropertyValue |
getProperty(java.lang.String propertyName)
Retrieves the current value set for the given descriptor, if a value is
set - else uses the descriptor to determine the appropriate default value
|
StateManager |
getStateManager() |
java.util.Set<Relationship> |
getUnavailableRelationships() |
boolean |
hasConnection(Relationship relationship) |
boolean |
hasIncomingConnection() |
boolean |
hasNonLoopConnection() |
boolean |
isClustered() |
boolean |
isExpressionLanguagePresent(PropertyDescriptor property) |
boolean |
isPrimary() |
boolean |
isValid() |
boolean |
isYieldCalled() |
void |
leaseControllerService(java.lang.String identifier)
Indicates to the framework that the Controller Service with the given
identifier will be used by this Processor.
|
PropertyValue |
newPropertyValue(java.lang.String rawValue)
Creates and returns a
PropertyValue object that can be used for
evaluating the value of the given String |
void |
removeConnection(Relationship relationship) |
boolean |
removeProperty(PropertyDescriptor descriptor) |
void |
setAnnotationData(java.lang.String annotationData) |
void |
setClustered(boolean clustered) |
void |
setConnections(java.util.Set<Relationship> connections) |
void |
setIncomingConnection(boolean hasIncomingConnection) |
protected void |
setMaxConcurrentTasks(int maxConcurrentTasks) |
void |
setNonLoopConnection(boolean hasNonLoopConnection) |
void |
setPrimaryNode(boolean primaryNode) |
ValidationResult |
setProperty(PropertyDescriptor descriptor,
java.lang.String value)
Updates the value of the property with the given PropertyDescriptor to
the specified value IF and ONLY IF the value is valid according to the
descriptor's validator.
|
ValidationResult |
setProperty(java.lang.String propertyName,
java.lang.String propertyValue) |
void |
setUnavailableRelationships(java.util.Set<Relationship> relationships) |
void |
setValidateExpressionUsage(boolean validate) |
java.util.Collection<ValidationResult> |
validate()
Validates the current properties, returning ValidationResults for any
invalid properties.
|
void |
yield()
Causes the Processor not to be scheduled for some pre-configured amount
of time.
|
addControllerService, addControllerService, addControllerServices, getConfiguration, getControllerService, getControllerServiceIdentifiers, getControllerServiceName, isControllerServiceEnabled, isControllerServiceEnabled, isControllerServiceEnabling, removeControllerService
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getControllerService, getControllerServiceIdentifiers, getControllerServiceName, isControllerServiceEnabled, isControllerServiceEnabled, isControllerServiceEnabling
public MockProcessContext(ConfigurableComponent component)
public MockProcessContext(ConfigurableComponent component, StateManager stateManager, VariableRegistry variableRegistry)
component
- being mockedstateManager
- state managervariableRegistry
- variableRegistrypublic MockProcessContext(ControllerService component, MockProcessContext context, StateManager stateManager, VariableRegistry variableRegistry)
public PropertyValue getProperty(PropertyDescriptor descriptor)
PropertyContext
getProperty
in interface PropertyContext
descriptor
- to lookup the value ofpublic PropertyValue getProperty(java.lang.String propertyName)
ProcessContext
getProperty
in interface ProcessContext
propertyName
- of the property to lookup the value forpublic PropertyValue newPropertyValue(java.lang.String rawValue)
ProcessContext
PropertyValue
object that can be used for
evaluating the value of the given StringnewPropertyValue
in interface ProcessContext
rawValue
- the raw input before any property evaluation has occurredPropertyValue
object that can be used for
evaluating the value of the given Stringpublic ValidationResult setProperty(java.lang.String propertyName, java.lang.String propertyValue)
public ValidationResult setProperty(PropertyDescriptor descriptor, java.lang.String value)
descriptor
- of property to modifyvalue
- new valuepublic boolean removeProperty(PropertyDescriptor descriptor)
public void yield()
ProcessContext
Causes the Processor not to be scheduled for some pre-configured amount of time. The duration of time for which the processor will not be scheduled is configured in the same manner as the processor's scheduling period.
Note: This is NOT a blocking call and does not suspend execution of the current thread.
yield
in interface ProcessContext
public boolean isYieldCalled()
public void addControllerService(java.lang.String serviceIdentifier, ControllerService controllerService, java.util.Map<PropertyDescriptor,java.lang.String> properties, java.lang.String annotationData)
public int getMaxConcurrentTasks()
getMaxConcurrentTasks
in interface ProcessContext
public void setAnnotationData(java.lang.String annotationData)
public java.lang.String getAnnotationData()
getAnnotationData
in interface ProcessContext
public java.util.Map<PropertyDescriptor,java.lang.String> getProperties()
getProperties
in interface ProcessContext
public java.util.Map<java.lang.String,java.lang.String> getAllProperties()
getAllProperties
in interface PropertyContext
public java.util.Collection<ValidationResult> validate()
public boolean isValid()
public void assertValid()
public java.lang.String encrypt(java.lang.String unencrypted)
ProcessContext
encrypt
in interface ProcessContext
unencrypted
- plaintext valuepublic java.lang.String decrypt(java.lang.String encrypted)
ProcessContext
decrypt
in interface ProcessContext
encrypted
- the encrypted valuepublic void setValidateExpressionUsage(boolean validate)
public void enableExpressionValidation()
public void disableExpressionValidation()
public ControllerServiceLookup getControllerServiceLookup()
getControllerServiceLookup
in interface ProcessContext
ControllerServiceLookup
that can be used to obtain a
Controller Servicepublic void leaseControllerService(java.lang.String identifier)
SchedulingContext
Indicates to the framework that the Controller Service with the given identifier will be used by this Processor. This will prevent any Data Flow Manager from disabling the Controller Service while this Processor is still running.
Generally, a Controller Service is accessed by indicating in a
PropertyDescriptor
that the PropertyDescriptor identifies a
Controller Service via the
identifiesControllerService(Class)
method and then calling
PropertyContext.getProperty(PropertyDescriptor)
.asControllerService(Class)
.
In this case, it is not necessary to lease the Controller Service, as the
Framework will handle this.
There are, however, cases in which a Controller Service must be accessed
in a different way, via the ControllerServiceLookup
(accessed via
ProcessContext.getControllerServiceLookup()
). In this case, the
Controller Service that is obtained from the ControllerServiceLookup can
be disabled by a Data Flow Manager while it is still in use by a
Processor, causing IllegalStateException to be thrown whenever the
Processor attempts to interact with the service. This method provides a
mechanism by which a Processor is able to indicate that the Controller
Service with the given identifier should not be disabled while this
Processor is running.
For any Controller Service that is leased by calling this method, the lease will automatically be terminated, allowing the Controller Service to be disabled, whenever the Processor is stopped.
leaseControllerService
in interface SchedulingContext
public java.util.Set<Relationship> getAvailableRelationships()
getAvailableRelationships
in interface ProcessContext
public void setUnavailableRelationships(java.util.Set<Relationship> relationships)
public java.util.Set<Relationship> getUnavailableRelationships()
public boolean hasIncomingConnection()
hasIncomingConnection
in interface ProcessContext
public void setIncomingConnection(boolean hasIncomingConnection)
public boolean hasConnection(Relationship relationship)
hasConnection
in interface ProcessContext
relationship
- a relationship to check for connectionspublic void setNonLoopConnection(boolean hasNonLoopConnection)
public boolean hasNonLoopConnection()
hasNonLoopConnection
in interface ProcessContext
true
if the processor has one or more incoming connections for
which the source of the connection is NOT the processor; returns false
if
the processor has no incoming connections or if all incoming connections are self-loops
(i.e., the processor is also the source of all incoming connections).public void addConnection(Relationship relationship)
public void removeConnection(Relationship relationship)
public void setConnections(java.util.Set<Relationship> connections)
public boolean isExpressionLanguagePresent(PropertyDescriptor property)
isExpressionLanguagePresent
in interface ProcessContext
property
- the Property whose value should be inspected to determined if it contains an Expression Language Expressiontrue
if the value of the given Property contains a NiFi Expression
Language Expression, false
if it does not. Note that false
will be returned if the Property Descriptor
does not allow the Expression Language, even if a seemingly valid Expression is present in the value.public StateManager getStateManager()
getStateManager
in interface ProcessContext
public java.lang.String getName()
getName
in interface ProcessContext
protected void setMaxConcurrentTasks(int maxConcurrentTasks)
public boolean isClustered()
isClustered
in interface NodeTypeProvider
public boolean isPrimary()
isPrimary
in interface NodeTypeProvider
public void setClustered(boolean clustered)
public void setPrimaryNode(boolean primaryNode)