我正在学习基础教程,因为我是新手,并且我有以下配置文件:
public class ConcurrentAlphabet {
private volatile Thread current;
public static void main(String[] args) {
new ConcurrentAlphabet().print(3,
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray());
}
public void print(int numberOfThreads, char[] alphabet) {
Thread[] threads = new Thread[numberOfThreads];
for (int i = 1; i <= numberOfThreads; i++) {
int offset = i - 1;
threads[offset] = new Thread(() -> {
Thread me = Thread.currentThread();
Thread next = threads[(offset + 1) % numberOfThreads];
for (int index = offset; index < alphabet.length; index += numberOfThreads) {
synchronized (this) {
while (me != current) {
try {
wait();
} catch (InterruptedException e) { /* NOP */ }
}
System.out.println(me.getName(); + " produced: " + alphabet[index] + ".");
current = next;
notifyAll();
}
}
}, "Thread " + i);
}
current = threads[0];
for (Thread t : threads) {
t.start();
}
}
}
然后我在终端
中执行以下命令input {
file {
path => "D:\elastic\logstash\data\data.csv"
start_position => "beginning"
}
}
filter {
csv {
separator => ","
columns => ["Date","Open","High","Low","Close","Volume","Adj Close"]
}
mutate {convert => ["High", "float"]}
mutate {convert => ["Open", "float"]}
mutate {convert => ["Low", "float"]}
mutate {convert => ["Close", "float"]}
mutate {convert => ["Volume", "float"]}
}
output {
elasticsearch {
action => "index"
host => "localhost"
index => "stock"
workers => 1
}
stdout {}
}
它打印出来:
bin\logstash -f logstash-simple.conf
解析文件的其余部分。 我错过了什么? 它是UTF-8并尝试了EOL UNIX和Windows格式,但都失败了。
答案 0 :(得分:1)
您需要修改file
输入,如下所示:
file {
path => "D:\\elastic\\logstash\\data\\data.csv"
start_position => "beginning"
}
或者像这样
file {
path => "D:/elastic/logstash/data/data.csv"
start_position => "beginning"
}
同样在您的过滤器中,mutate/convert
中存在拼写错误。它们应该是这样的(即用=>
替换=>
):
mutate {convert => ["High", "float"]}
mutate {convert => ["Open", "float"]}
mutate {convert => ["Low", "float"]}
mutate {convert => ["Close", "float"]}
mutate {convert => ["Volume", "float"]}