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.");
  }
  /**
   * 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.
  }