简体   繁体   English

具有Groovy的Nifi ExecuteScript:OOM异常

[英]Nifi ExecuteScript with Groovy: OOM exception

I am using an ExecuteScript processor in NiFi to execute a PUT command with the flowfile I have specified. 我在NiFi中使用ExecuteScript处理器对我指定的流文件执行PUT命令。 However, right now I am getting an OutOfMemory exception when the file is greater than 2GB. 但是,当文件大于2GB时,我现在收到OutOfMemory异常。 My memory settings on NiFi are much higher. 我在NiFi上的内存设置要高得多。 I've also seen much larger flow files work with some of the other provided Nifi processor. 我还看到更大的流文件可与其他提供的Nifi处理器一起使用。

I cannot use InvokeHTTP as I have 2 different return codes with conflicting relationships that I need to handle. 我无法使用InvokeHTTP,因为我有2个具有冲突关系的不同返回码,需要处理。

Currently my JVM settings for NiFi are 目前,我针对NiFi的JVM设置为

java.arg.2=-Xms16g
java.arg.3=-Xmx32g

Here is a snippet of how the data is getting PUT. 这是数据如何获取PUT的片段。

    InputStream i = session.read(flowFile)
    def baseUrl = new URL(Location)
    def connection = baseUrl.openConnection()
    connection.setDoOutput(true)
    connection.setRequestMethod('PUT')
    connection.connect()

    OutputStream os = connection.getOutputStream()
    os << i
    i.close()

    os.flush()
    os.close()

Is there a setting for groovy in NiFi that needs to be set to increase this memory limit? NiFi中是否有用于常规设置的设置,以增加此内存限制? Currently running NiFi 1.9.2 当前正在运行NiFi 1.9.2

Issue was solved using an inputstream read buffer AND adding ChunkedStreamingMode 使用inputstream读取缓冲区并添加ChunkedStreamingMode解决了问题

connection.setChunkedStreamingMode(1024)
byte[] buffer = new byte[1024];
int len;
while ((len = i.read(buffer)) != -1) {
    os.write(buffer, 0, len);
    os.flush;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM