[英]How to request Redis server using a streaming input PCollection in Apache Beam?
Using RedisIO , I'm trying to query a collection to a redis server.使用RedisIO ,我正在尝试将集合查询到 redis 服务器。
The Redis server is ok and responding good only when batch pipeline (no streaming). Redis 服务器正常并且只有在批处理管道(无流)时响应良好。
But, using streaming input data (from files) like this:但是,使用这样的流输入数据(来自文件):
PCollection<String> stream = pipeline.apply("ReadMyFile", TextIO.read().from("/home/out/**")
.watchForNewFiles(Duration.standardSeconds(60), Watch.Growth.<String>never()))
.apply("ParseFn", ParDo.of(new ParseFn()))
.apply("GlobalString", GlobalString.get(Duration.ZERO, Duration.standardSeconds(60)));
And then, apply the redisIO read() function:然后,应用 redisIO read() 函数:
PCollection<KV<String, String>> redis = stream.apply(RedisIO.readAll().withEndpoint("127.0.0.1", 6379));
Finally, want to use the result collection, so:最后,想使用结果集合,所以:
PCollection<String> result = redis.apply("Compose Final Object", ParDo.of(new DoFn<KV<String, String>, String>() {
@ProcessElement
public void processElement(ProcessContext c) {
System.out.println(c.element().getKey());
c.output(c.element().getKey());
}
}));
As far as I tested, the files are being loaded and processed as needed.据我测试,文件正在根据需要加载和处理。
For further developments, it is a bug:对于进一步的发展,这是一个错误:
https://github.com/apache/beam/pull/10624/commits https://github.com/apache/beam/pull/10624/commits
https://issues.apache.org/jira/browse/BEAM-9134 https://issues.apache.org/jira/browse/BEAM-9134
It will be fixed soon.它很快就会被修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.