Apache NIFI:无法写入流程内容

0 投票
1 回答
22 浏览
提问于 2025-04-12 14:57

我有一个CSV文件,我通过GetFile处理器把它导入到NiFi中,然后用ConvertRecord处理器处理,没有遇到任何问题。但当我把ExecuteStreamCommand拖到画布上,想运行一个Python脚本时,就遇到了一些问题,无法写入文件流。

这是我使用的配置:

点击这里查看配置图片

这是我的Python脚本:

import pandas as pd
import sys
from io import StringIO

try:

    # Read input data from the stdin:
    path_file = sys.stdin.read()
    input_df = pd.read_csv(StringIO(path_file))

    # Fill missing values with column means
    input_df.dropna(inplace=True)

    # Write the processed data to the stdout:
    sys.stdout.write(input_df.to_csv(path_file, index=False))

except Exception as e:
    sys.stderr.write("An error occurred: {}".format(str(e)))

点击这里查看脚本图片

从图片中可以看到,数据流是可以读取的,但无法写入到下一个处理器,我一直收到这个错误信息:

由于归档文件大小限制,无法将流文件内容写入内容库容器默认;正在等待归档清理。当前已归档的文件总数 = 13

顺便提一下,我已经尝试禁用 nifi.flow.configuration.archive.enabled=false,并把最大存储大小调整到10GB,但还是没有用,错误依旧。

我该怎么做才能解决这个问题呢?

1 个回答

0

我想提前告诉大家,我找到了我问题的原因。
在这个Python脚本中:

    # Write the processed data to the stdout:
    sys.stdout.write(input_df.to_csv(path_file, index=False))

应该去掉path_file,然后用这个命令代替:

    sys.stdout.write(input_df.to_csv(index=False))

撰写回答