com.ibm.streams.operator.compile
Interface OperatorContextChecker
-
public interface OperatorContextChecker
Interface for checking a Java primitive operator is being invoked with a valid context. Any public static method of anOperator
implementation or its super-classes annotated@ContextCheck
will be called at compile and/or runtime to verify its invocation environment. The method must be declared with a single parameter of typeOperatorContextChecker
A single
OperatorContextChecker
instance is used to check an operator's invocation context. Any call to one of itscheckXXX
methods that returned false will result in the context being marked invalid (isContextValid()
will returnfalse
). Once all@ContextCheck
annotated methods have been called then ifisContextValid()
returnsfalse
then the compile or runtime invocation will fail.OperatorContextChecker serves a similar purpose for Java primitive operators that the validate and check helper functions in
CodeGen.pm
serve for C++ operators.- Since:
- InfoSphere® Streams Version 3.0
- See Also:
OperatorContext.ContextCheck
-
-
Method Summary
Methods Modifier and Type Method and Description boolean
checkAttributes(StreamingData port, boolean optional, StreamSchema expectedAttributes)
Check that one or more attributes for a input or output port have the required type.boolean
checkAttributes(StreamingData port, boolean optional, java.lang.String expectedAttributes)
Check that one or more attributes for a input or output port have the required type.boolean
checkAttributes(StreamSchema schema, boolean optional, StreamSchema expectedAttributes)
Check that one or more attributes for aStreamSchema
have the required type.boolean
checkAttributes(StreamSchema schema, boolean optional, java.lang.String expectedAttributes)
Check that one or more attributes for aStreamSchema
have the required type.boolean
checkAttributeType(Attribute attribute, Type.MetaType... validTypes)
Check thatattribute
is one of the types listed invalidTypes
.boolean
checkDependentParameters(java.lang.String parameterName, java.lang.String... dependentParameterNames)
Check that ifparameterName
is set as a parameter, then all of the parameters independentParameterNames
are set.boolean
checkExcludedParameters(java.lang.String parameterName, java.lang.String... excludedParameterNames)
Check that ifparameterName
is set as a parameter, then none of the parameters inexcludedParameterNames
are set.boolean
checkMatchingSchemas(StreamingData port, StreamingData... matchingPorts)
Check that one or more ports has a stream schema that matches another port.boolean
checkRequiredAttributes(StreamingData port, java.lang.String... attributeNames)
Check that one or more required attributes exist for a port.boolean
checkRequiredAttributes(StreamSchema schema, java.lang.String... attributeNames)
Check that a set of required attributes exist in aStreamSchema
.boolean
checkSlidingWindow(StreamingInput<?> inputPort)
Check the streaming window for an input port issliding
.boolean
checkTumblingWindow(StreamingInput<?> inputPort)
Check the streaming window for an input port istumbling
.OperatorContext
getOperatorContext()
Get the operator context for the operator's invocation.boolean
isContextValid()
Is the invocation context valid so far.void
setInvalidContext()
Set that the context is invalid and thus the compile or runtime invocation will fail once all@ContextCheck
annotated methods have been called.void
setInvalidContext(java.lang.String msg, java.lang.Object[] params)
Set that the context is invalid and log a message atERROR
level.
-
-
-
Method Detail
-
getOperatorContext
OperatorContext getOperatorContext()
Get the operator context for the operator's invocation. At compile time the functionality of theOperatorContext
is limited and use of any runtime only functionality, such as submitting tuples will result in anIllegalStateException
. Specifically for compile time context checking these restrictions exist:- The operator's name
OperatorContext.getName()
is not available. - Parameter values are not available, though the fact a parameter is set can be checked through
OperatorContext.getParameterNames()
.
- Returns:
- OperatorContext for this invocation.
- The operator's name
-
setInvalidContext
void setInvalidContext()
Set that the context is invalid and thus the compile or runtime invocation will fail once all@ContextCheck
annotated methods have been called. It is recommended that an associated error message is also logged, this may be achieved usingsetInvalidContext(String, Object[])
.
-
setInvalidContext
void setInvalidContext(java.lang.String msg, java.lang.Object[] params)
Set that the context is invalid and log a message atERROR
level.- Parameters:
msg
- the message to logparams
- the parameter array associated with the error that need to be logged- See Also:
setInvalidContext()
-
isContextValid
boolean isContextValid()
Is the invocation context valid so far.- Returns:
- True if no errors have been reported against the invocation context, false if at least one error has been reported.
-
checkDependentParameters
boolean checkDependentParameters(java.lang.String parameterName, java.lang.String... dependentParameterNames)
Check that ifparameterName
is set as a parameter, then all of the parameters independentParameterNames
are set.- Parameters:
parameterName
- Parameter that requires other parameters.dependentParameterNames
- Parameters thatparameterName
depends on.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkExcludedParameters
boolean checkExcludedParameters(java.lang.String parameterName, java.lang.String... excludedParameterNames)
Check that ifparameterName
is set as a parameter, then none of the parameters inexcludedParameterNames
are set.- Parameters:
parameterName
- Parameter that excludes other parameters.excludedParameterNames
- Parameters thatparameterName
excludes.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkMatchingSchemas
boolean checkMatchingSchemas(StreamingData port, StreamingData... matchingPorts)
Check that one or more ports has a stream schema that matches another port. Typically used to check that one or more output ports matches an input port.- Parameters:
port
- Port with schema to check against.matchingPorts
- Ports that must have the same schema asport
.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkRequiredAttributes
boolean checkRequiredAttributes(StreamSchema schema, java.lang.String... attributeNames)
Check that a set of required attributes exist in aStreamSchema
. No ordering is required for the attributes.- Parameters:
schema
- Schema to be checked.attributeNames
- Set of required attributes.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkRequiredAttributes
boolean checkRequiredAttributes(StreamingData port, java.lang.String... attributeNames)
Check that one or more required attributes exist for a port. No ordering is required for the attributes within the schema.- Parameters:
port
- Port to be checked.attributeNames
- Set of required attributes.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkAttributes
boolean checkAttributes(StreamSchema schema, boolean optional, StreamSchema expectedAttributes)
Check that one or more attributes for aStreamSchema
have the required type. No ordering is required for the attributes within the schema.- Parameters:
schema
- Schema to be checked.optional
- True if all the attributes must exist, false if each attributes is optional but when present must have the required type.expectedAttributes
- Schema object representing expected attributes.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkAttributes
boolean checkAttributes(StreamSchema schema, boolean optional, java.lang.String expectedAttributes)
Check that one or more attributes for aStreamSchema
have the required type. No ordering is required for the attributes within the schema.- Parameters:
schema
- Schema to be checked.optional
- True if all the attributes must exist, false if each attributes is optional but when present must have the required type.expectedAttributes
- SPL tuple definition containing expected attributes.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkAttributes
boolean checkAttributes(StreamingData port, boolean optional, StreamSchema expectedAttributes)
Check that one or more attributes for a input or output port have the required type. No ordering is required for the attributes within the port's schema.- Parameters:
port
- Port to be checked.optional
- True if all the attributes must exist, false if each attributes is optional but when present must have the required type.expectedAttributes
- Schema object representing expected attributes.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkAttributes
boolean checkAttributes(StreamingData port, boolean optional, java.lang.String expectedAttributes)
Check that one or more attributes for a input or output port have the required type. No ordering is required for the attributes within the port's schema.- Parameters:
port
- Port to be checked.optional
- True if all the attributes must exist, false if each attributes is optional but when present must have the required type.expectedAttributes
- SPL tuple definition containing expected attributes.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkAttributeType
boolean checkAttributeType(Attribute attribute, Type.MetaType... validTypes)
Check thatattribute
is one of the types listed invalidTypes
.- Parameters:
attribute
- Attribute to be checked.validTypes
- ValidMetaType
values that the operator supports for this attribute.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkTumblingWindow
boolean checkTumblingWindow(StreamingInput<?> inputPort)
Check the streaming window for an input port istumbling
.- Parameters:
inputPort
- Input port to be checked.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
checkSlidingWindow
boolean checkSlidingWindow(StreamingInput<?> inputPort)
Check the streaming window for an input port issliding
.- Parameters:
inputPort
- Input port to be checked.- Returns:
- True if invocation context is valid for this check, false otherwise.
-
-