public void initialize(OperatorContext context) throws Exception { super.initialize(context); String propFile = getPropertiesFile(); if (propFile != null) { finalProperties.load(new FileReader(propFile)); } finalProperties.putAll(properties); if (finalProperties == null || finalProperties.isEmpty()) throw new Exception("Kafka connection properties must be specified."); }
/** * Shutdown this operator. * * @throws Exception Operator failure, will cause the enclosing PE to terminate. */ public synchronized void shutdown() throws Exception { OperatorContext context = getOperatorContext(); Logger.getLogger(this.getClass()) .trace( "Operator " + context.getName() + " shutting down in PE: " + context.getPE().getPEId() + " in Job: " + context.getPE().getJobId()); // TODO: If needed, close connections or release resources related to any external system or // data store. // Must call super.shutdown() super.shutdown(); }
@Override public void shutdown() throws Exception { if (client != null) client.shutdown(); if (simpleClient != null) simpleClient.shutdown(); OperatorContext context = getOperatorContext(); trace.log( TraceLevel.ALL, "Operator " + context.getName() + " shutting down in PE: " + context.getPE().getPEId() + " in Job: " + context.getPE().getJobId()); // Must call super.shutdown() super.shutdown(); }
/** * Initialize this operator. Called once before any tuples are processed. * * @param context OperatorContext for this operator. * @throws Exception Operator failure, will cause the enclosing PE to terminate. */ @Override public synchronized void initialize(OperatorContext context) throws Exception { // Must call super.initialize(context) to correctly setup an operator. super.initialize(context); Logger.getLogger(this.getClass()) .trace( "Operator " + context.getName() + " initializing in PE: " + context.getPE().getPEId() + " in Job: " + context.getPE().getJobId()); // TODO: // If needed, insert code to establish connections or resources to communicate an external // system or data store. // The configuration information for this may come from parameters supplied to the operator // invocation, // or external configuration files or a combination of the two. }
/** * Process an incoming punctuation that arrived on the specified port. * * @param stream Port the punctuation is arriving on. * @param mark The punctuation mark * @throws Exception Operator failure, will cause the enclosing PE to terminate. */ @Override public void processPunctuation(StreamingInput<Tuple> stream, Punctuation mark) throws Exception { // For window markers, punctuate all output ports super.processPunctuation(stream, mark); }