Nifi:nifi 中的线程
Nifi: Threads in nifi
我想知道线程在 nifi 中是如何工作的我的意思是一个处理器有一个线程或者它们在一个主线程中?也许我想从处理器获取一个文件然后我要更新它
- 如何防止多个处理器同时获取文件数据
除了使用 keep file =false 操作?
- 是否可以在执行脚本处理器代码中使用 Thread.sleep?
- 是否可以通过groovy做出相同的逻辑?
我尝试使用 java 文件锁,但似乎效果不佳 这是我的代码,
File file = new File("C://Users//user//Desktop//try2//nifi-
1.3.0//4//conf2.xml");
String content = "";
String material = "";
BufferedReader s;
BufferedWriter w;
int m;
RandomAccessFile ini = new RandomAccessFile(file, "rwd");
FileLock lock = ini.getChannel().lock();
DocumentBuilder dBuilder;
Document document, doc;
String date="";
String data="";
boolean make = false;
try {
String sCurrentLine;
s = new BufferedReader(Channels.newReader(ini.getChannel(), "UTF-8"));
while ((sCurrentLine = s.readLine()) != null) {
content += sCurrentLine;
}
ini.seek(0);
I want to know how threads work in nifi i mean one processor has one thread or they are in one main thread?
Nifi 有一个可配置的线程池 ( sandwich menu -> controller settings -> general )
,当任何处理器计划执行时,系统从池中获取空闲线程,在该线程中执行处理器,然后 returns 线程到线程池。因此,每个处理器都在一个单独的随机线程中执行。
how can i prevent getting file data by several processor at a time
except using keep file =false action?
您需要存储一个标志 file XXX processed
。您将如何存储它 - 这是您的选择。例如,您可以创建一个具有相同名称但添加扩展名的空文件:conf.xml -> conf.xml.done
。并在代码中检查文件 conf.xml.done
是否存在然后跳过 conf.xml
文件处理。
您可以将标志存储在数据库、缓存系统等中
Is it possible to use Thread.sleep inside Execute script processor code?
可能,但我认为这没有任何意义。
Is it possible to make same logic by groovy?
你可以在 groovy 中做任何事情:)
我想知道线程在 nifi 中是如何工作的我的意思是一个处理器有一个线程或者它们在一个主线程中?也许我想从处理器获取一个文件然后我要更新它
- 如何防止多个处理器同时获取文件数据 除了使用 keep file =false 操作?
- 是否可以在执行脚本处理器代码中使用 Thread.sleep?
- 是否可以通过groovy做出相同的逻辑?
我尝试使用 java 文件锁,但似乎效果不佳 这是我的代码,
File file = new File("C://Users//user//Desktop//try2//nifi-
1.3.0//4//conf2.xml");
String content = "";
String material = "";
BufferedReader s;
BufferedWriter w;
int m;
RandomAccessFile ini = new RandomAccessFile(file, "rwd");
FileLock lock = ini.getChannel().lock();
DocumentBuilder dBuilder;
Document document, doc;
String date="";
String data="";
boolean make = false;
try {
String sCurrentLine;
s = new BufferedReader(Channels.newReader(ini.getChannel(), "UTF-8"));
while ((sCurrentLine = s.readLine()) != null) {
content += sCurrentLine;
}
ini.seek(0);
I want to know how threads work in nifi i mean one processor has one thread or they are in one main thread?
Nifi 有一个可配置的线程池 ( sandwich menu -> controller settings -> general )
,当任何处理器计划执行时,系统从池中获取空闲线程,在该线程中执行处理器,然后 returns 线程到线程池。因此,每个处理器都在一个单独的随机线程中执行。
how can i prevent getting file data by several processor at a time except using keep file =false action?
您需要存储一个标志 file XXX processed
。您将如何存储它 - 这是您的选择。例如,您可以创建一个具有相同名称但添加扩展名的空文件:conf.xml -> conf.xml.done
。并在代码中检查文件 conf.xml.done
是否存在然后跳过 conf.xml
文件处理。
您可以将标志存储在数据库、缓存系统等中
Is it possible to use Thread.sleep inside Execute script processor code?
可能,但我认为这没有任何意义。
Is it possible to make same logic by groovy?
你可以在 groovy 中做任何事情:)