Example #1
0
  public DataFlowOpInitializeResult initialize(DataFlowOpInitializateContext context)
      throws Exception {
    if (context.getOutputPorts().size() != 1) {
      throw new IllegalArgumentException(
          "EventBusSource operator requires one output stream but produces "
              + context.getOutputPorts().size()
              + " streams");
    }

    DataFlowOpOutputPort portZero = context.getOutputPorts().get(0);
    if (portZero.getOptionalDeclaredType() == null
        || portZero.getOptionalDeclaredType().getEventType() == null) {
      throw new IllegalArgumentException(
          "EventBusSource operator requires an event type declated for the output stream");
    }

    if (!portZero.getOptionalDeclaredType().isUnderlying()) {
      submitEventBean = true;
    }
    this.eventType = portZero.getOptionalDeclaredType().getEventType();
    this.agentInstanceContext = context.getAgentInstanceContext();

    return new DataFlowOpInitializeResult();
  }
  public DataFlowOpInitializeResult initialize(DataFlowOpInitializateContext context)
      throws Exception {
    if (!context.getOutputPorts().isEmpty()) {
      throw new IllegalArgumentException("LogSink operator does not provide an output stream");
    }

    dataflowName = context.getDataflowName();
    dataFlowInstanceId = context.getDataflowInstanceId();

    shellPerStream = new EventBeanSPI[context.getInputPorts().size()];
    for (Map.Entry<Integer, DataFlowOpInputPort> entry : context.getInputPorts().entrySet()) {
      EventType eventType = entry.getValue().getTypeDesc().getEventType();
      if (eventType != null) {
        shellPerStream[entry.getKey()] =
            context.getStatementContext().getEventAdapterService().getShellForType(eventType);
      }
    }

    if (format == null) {
      renderer = new ConsoleOpRendererSummary();
    } else {
      try {
        LogSinkOutputFormat formatEnum = LogSinkOutputFormat.valueOf(format.trim().toLowerCase());
        if (formatEnum == LogSinkOutputFormat.summary) {
          renderer = new ConsoleOpRendererSummary();
        } else {
          renderer = new ConsoleOpRendererXmlJSon(formatEnum, context.getEngine().getEPRuntime());
        }
      } catch (RuntimeException ex) {
        throw new ExprValidationException(
            "Format '"
                + format
                + "' is not supported, expecting any of "
                + Arrays.toString(LogSinkOutputFormat.values()));
      }
    }

    return null;
  }