/**
  * 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 {
   // This method is commonly used by source operators.
   // Operators that process incoming tuples generally do not need this notification.
   OperatorContext context = getOperatorContext();
   Logger.getLogger(this.getClass())
       .trace(
           "Operator "
               + context.getName()
               + " all ports are ready in PE: "
               + context.getPE().getPEId()
               + " in Job: "
               + context.getPE().getJobId());
 }
  /**
   * 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();
  }
Exemplo n.º 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();
  }
  /**
   * 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.
  }
Exemplo n.º 5
0
  public void initSchema(StreamSchema ss) throws Exception {
    trace.log(TraceLevel.INFO, "Connection properties: " + finalProperties);

    Set<MetaType> supportedTypes = new HashSet<MetaType>();
    supportedTypes.add(MetaType.RSTRING);
    supportedTypes.add(MetaType.USTRING);
    supportedTypes.add(MetaType.BLOB);

    keyAH.initialize(ss, false, supportedTypes);
    messageAH.initialize(ss, true, supportedTypes);

    // blobs are not supported for topics
    supportedTypes.remove(MetaType.BLOB);
    topicAH.initialize(ss, false, supportedTypes);

    OperatorContext operContext = getOperatorContext();
    if (operContext.getParameterNames().contains("partition") == false) {
      // we don't need to create this client if using simpleConsumerClient
      trace.log(TraceLevel.INFO, "Creating client");
      client = new KafkaClient(topicAH, keyAH, messageAH, finalProperties);
    }
  }