use of com.ibm.streams.operator.OperatorContext in project streamsx.kafka by IBMStreams.
the class AbstractKafkaConsumerOperator method shutdown.
/**
* Shutdown this operator, which will interrupt the thread executing the
* <code>produceTuples()</code> method.
*
* @throws Exception
* Operator failure, will cause the enclosing PE to terminate.
*/
public void shutdown() throws Exception {
synchronized (monitor) {
final OperatorContext context = getOperatorContext();
logger.info(// $NON-NLS-1$ //$NON-NLS-2$
"Operator " + context.getName() + " shutting down in PE: " + context.getPE().getPEId() + " in Job: " + // $NON-NLS-1$
context.getPE().getJobId());
shutdown.set(true);
if (processThreadEndedLatch != null) {
processThreadEndedLatch.await(SHUTDOWN_TIMEOUT, SHUTDOWN_TIMEOUT_TIMEUNIT);
processThreadEndedLatch = null;
}
final ConsumerClient consumer = consumerRef.get();
if (consumer.isProcessing()) {
consumer.onShutdown(SHUTDOWN_TIMEOUT, SHUTDOWN_TIMEOUT_TIMEUNIT);
}
logger.info("Operator " + context.getName() + ": shutdown done");
// Must call super.shutdown()
super.shutdown();
}
}
use of com.ibm.streams.operator.OperatorContext in project streamsx.kafka by IBMStreams.
the class AbstractKafkaConsumerOperator method checkStartOffsetRequiresPartition.
@ContextCheck(compile = true)
public static void checkStartOffsetRequiresPartition(OperatorContextChecker checker) {
// parameters startOffset and partition must have the same size - can be checked only at runtime.
// This implies that partition parameter is required when startOffset is specified - can be checked at compile time.
OperatorContext operatorContext = checker.getOperatorContext();
Set<String> parameterNames = operatorContext.getParameterNames();
if (parameterNames.contains(START_OFFSET_PARAM) && !parameterNames.contains(PARTITION_PARAM)) {
// $NON-NLS-1$
checker.setInvalidContext(Messages.getString("PARAM_X_REQUIRED_WHEN_PARAM_Y_USED", PARTITION_PARAM, START_OFFSET_PARAM), new Object[0]);
}
}
use of com.ibm.streams.operator.OperatorContext in project streamsx.kafka by IBMStreams.
the class AbstractKafkaConsumerOperator method allPortsReady.
@Override
public void allPortsReady() throws Exception {
synchronized (monitor) {
OperatorContext context = getOperatorContext();
logger.info(// $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());
// start the thread that produces the tuples out of the message queue. The thread runs the produceTuples() method.
if (processThread != null) {
processThread.start();
}
}
}
use of com.ibm.streams.operator.OperatorContext in project streamsx.health by IBMStreams.
the class QRSDetector method shutdown.
/**
* Shutdown this operator.
*
* @throws Exception
* Operator failure, will cause the enclosing PE to terminate.
*/
public synchronized void shutdown() throws Exception {
OperatorContext context = getOperatorContext();
logger.trace("Operator " + context.getName() + " shutting down in PE: " + context.getPE().getPEId() + " in Job: " + context.getPE().getJobId());
super.shutdown();
}
use of com.ibm.streams.operator.OperatorContext in project streamsx.kafka by IBMStreams.
the class AbstractKafkaConsumerOperator method checkTriggerCommitCount.
@ContextCheck(compile = true)
public static void checkTriggerCommitCount(OperatorContextChecker checker) {
OperatorContext operatorContext = checker.getOperatorContext();
ConsistentRegionContext crContext = operatorContext.getOptionalContext(ConsistentRegionContext.class);
Set<String> parameterNames = operatorContext.getParameterNames();
if (crContext != null) {
if (parameterNames.contains(COMMIT_COUNT_PARAM)) {
System.err.println(Messages.getString("PARAM_IGNORED_IN_CONSITENT_REGION", COMMIT_COUNT_PARAM));
}
if (parameterNames.contains(COMMIT_PERIOD_PARAM)) {
System.err.println(Messages.getString("PARAM_IGNORED_IN_CONSITENT_REGION", COMMIT_PERIOD_PARAM));
}
if (crContext.isStartOfRegion()) {
if (crContext.isTriggerOperator()) {
// 'triggerCount' parameter required
if (!parameterNames.contains(TRIGGER_COUNT_PARAM)) {
// $NON-NLS-1$
checker.setInvalidContext(Messages.getString("TRIGGER_PARAM_MISSING"), new Object[0]);
}
} else {
// periodic CR; 'triggerCount' ignored
if (parameterNames.contains(TRIGGER_COUNT_PARAM)) {
System.err.println(Messages.getString("PARAM_IGNORED_FOR_PERIODIC_CR", TRIGGER_COUNT_PARAM));
}
}
}
} else {
// not in a CR ...
if (parameterNames.contains(TRIGGER_COUNT_PARAM)) {
System.err.println(Messages.getString("PARAM_IGNORED_NOT_IN_CONSITENT_REGION", TRIGGER_COUNT_PARAM));
}
if (parameterNames.contains(COMMIT_COUNT_PARAM) && parameterNames.contains(COMMIT_PERIOD_PARAM)) {
// $NON-NLS-1$
checker.setInvalidContext(Messages.getString("PARAMETERS_EXCLUDE_EACH_OTHER", COMMIT_COUNT_PARAM, COMMIT_PERIOD_PARAM), new Object[0]);
}
}
}
Aggregations