use of com.ibm.streams.operator.OperatorContext in project streamsx.health by IBMStreams.
the class QRSDetector method allPortsReady.
/**
* Notification that initialization is complete and all input and output
* ports are connected and ready to receive and submit tuples.
*
* @throws Exception
* Operator failure, will cause the enclosing PE to terminate.
*/
@Override
public synchronized void allPortsReady() throws Exception {
OperatorContext context = getOperatorContext();
logger.trace("Operator " + context.getName() + " all ports are ready in PE: " + context.getPE().getPEId() + " in Job: " + context.getPE().getJobId());
}
use of com.ibm.streams.operator.OperatorContext in project streamsx.kafka by IBMStreams.
the class AbstractKafkaConsumerOperator method warnStartPositionParamRequiresJCP.
// @ContextCheck (compile = true)
public static void warnStartPositionParamRequiresJCP(OperatorContextChecker checker) {
OperatorContext opCtx = checker.getOperatorContext();
Set<String> paramNames = opCtx.getParameterNames();
List<StreamingInput<Tuple>> inputPorts = opCtx.getStreamingInputs();
if (opCtx.getOptionalContext(ConsistentRegionContext.class) == null && (paramNames.contains(START_POSITION_PARAM) || paramNames.contains(START_POSITION_STR_PARAM)) && inputPorts.size() == 0) {
System.err.println(Messages.getString("WARN_ENSURE_JCP_ADDED_STARTPOS_NOT_DEFAULT", opCtx.getKind()));
}
}
use of com.ibm.streams.operator.OperatorContext in project streamsx.kafka by IBMStreams.
the class AbstractKafkaProducerOperator method checkConsistentRegion.
@ContextCheck(compile = true)
public static void checkConsistentRegion(OperatorContextChecker checker) {
// check that the operator is not the start of the consistent region
OperatorContext opContext = checker.getOperatorContext();
ConsistentRegionContext crContext = opContext.getOptionalContext(ConsistentRegionContext.class);
if (crContext != null) {
if (crContext.isStartOfRegion()) {
// //$NON-NLS-1$
checker.setInvalidContext(Messages.getString("OPERATOR_NOT_START_OF_CONSISTENT_REGION", opContext.getKind()), new Object[0]);
}
}
}
use of com.ibm.streams.operator.OperatorContext in project streamsx.kafka by IBMStreams.
the class AbstractKafkaProducerOperator method checkTopicAttributeTypeOrTopicParameter.
/**
* If the `topicAttribute` is not defined, then the operator will look
* for an input attribute called "topic". Here, we need to check that this
* input attribute is of type "rstring".
* When the `topicAttribute`parameter is used, the Streams compiler will do the
* attribute type check.
* When neither the `topicAttribute` parameter is used nor a `topic` attribute with rstring type exists,
* the `topic` parameter must be used.
*/
@ContextCheck(compile = true)
public static void checkTopicAttributeTypeOrTopicParameter(OperatorContextChecker checker) {
/*
* For topics, one of the following must be true:
* * the 'topic' parameter is specified that lists topics to write to
* * the 'topicAttribute' parameter is specified that points to an input attribute containing the topic to write to
* * neither of the above parameters are specified but the input schema contains an attribute named "topic"
*
* An invalid context is set if none of the above conditions are true
*/
final OperatorContext operatorContext = checker.getOperatorContext();
if (!operatorContext.getParameterNames().contains(TOPIC_PARAM_NAME)) {
// no topic parameter - check presence of topicAttribute parameter
if (!operatorContext.getParameterNames().contains(TOPICATTR_PARAM_NAME)) {
// no topicAttribute parameter - check presence and type of 'topic' attribute
StreamSchema schema = operatorContext.getStreamingInputs().get(0).getStreamSchema();
// $NON-NLS-1$
Attribute topicAttribute = schema.getAttribute(DEFAULT_TOPIC_ATTR_NAME);
if (topicAttribute != null) {
if (!checker.checkAttributeType(topicAttribute, MetaType.RSTRING, MetaType.BSTRING, MetaType.USTRING)) {
checker.setInvalidContext(Messages.getString("TOPIC_ATTRIBUTE_NOT_STRING"), new Object[0]);
}
} else {
// no topic parameter, "topic" input attribute does not exist...set invalid context
// $NON-NLS-1$
checker.setInvalidContext(Messages.getString("TOPIC_NOT_SPECIFIED"), new Object[0]);
}
}
}
}
use of com.ibm.streams.operator.OperatorContext in project streamsx.kafka by IBMStreams.
the class AbstractKafkaProducerOperator method allPortsReady.
/**
* Notification that initialization is complete and all input and output
* ports are connected and ready to receive and submit tuples.
*
* @throws Exception
* Operator failure, will cause the enclosing PE to terminate.
*/
@Override
public synchronized void allPortsReady() throws Exception {
OperatorContext context = getOperatorContext();
logger.trace(// $NON-NLS-1$ //$NON-NLS-2$
"Operator " + context.getName() + " all ports are ready in PE: " + context.getPE().getPEId() + " in Job: " + // $NON-NLS-1$
context.getPE().getJobId());
if (this.errorPortSubmitter != null)
this.errorPortSubmitter.start();
}
Aggregations