有没有人有通过 Camel 将文件写入hdfs2的好例子?
我尝试了以下代码:
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public final class Main {
private Main() {
}
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() {
from("file:C:\\FILES\\SRC\\2015-03-31_16-58-56.png?noop=true")
.to("hdfs2://xxxx:9000/testCamel/D2/qwe.png");
//.to("file:C:\\FILES\\OUT");
}
});
//ProducerTemplate template = context.createProducerTemplate();
context.start();
context.stop();
}
}
这些文件是在HDFS中创建的,但所有文件均为空(0字节)。
最佳答案
从文件消费到HDFS时,请确保noop = false。 hdfs组件使用块来消费,因此如果noop为true, Camel 会认为它已经消耗了它。
关于hadoop - 通过 Camel 将文件复制到HDFS2不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29387481/