コード例 #1
0
  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.");
  }
コード例 #2
0
  /**
   * 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();
  }
コード例 #3
0
  @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();
  }
コード例 #4
0
  /**
   * 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.
  }
コード例 #5
0
 /**
  * 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);
 }