コード例 #1
0
ファイル: ExecuteFlumeSink.java プロジェクト: Ianwww/nifi
  @OnScheduled
  public void onScheduled(final SchedulingContext context) {
    try {
      channel = new NifiSinkSessionChannel(SUCCESS, FAILURE);
      channel.start();

      sink =
          SINK_FACTORY.create(
              context.getProperty(SOURCE_NAME).getValue(),
              context.getProperty(SINK_TYPE).getValue());
      sink.setChannel(channel);

      String flumeConfig = context.getProperty(FLUME_CONFIG).getValue();
      String agentName = context.getProperty(AGENT_NAME).getValue();
      String sinkName = context.getProperty(SOURCE_NAME).getValue();
      Configurables.configure(sink, getFlumeSinkContext(flumeConfig, agentName, sinkName));

      sink.start();
    } catch (Throwable th) {
      getLogger().error("Error creating sink", th);
      throw Throwables.propagate(th);
    }
  }