我有一些在 Spring XD 中使用的自定义模块。我可以在 XD 的单节点部署中使用“模块上传”,没有问题,但在分布式模式下运行时出现以下异常:
org.springframework.xd.dirt.module.NoSuchModuleException: Could not find module with name 'grobid' and type 'processor'
我正在使用 Spring XD 1.1.1.RELEASE 通过 docker 创建 XD 集群。以下是导致此异常的命令序列:
server-unknown:>admin config server http://docker:9393
Successfully targeted http://docker:9393
xd:>module upload --type processor --name grobid --file /opt/.../grobid-1.0-SNAPSHOT.jar
Successfully uploaded module 'processor:grobid'
xd:>stream create --name grobidTest --definition "http --port=11001 | grobid --grobidHost=http://${GROBID_PORT_8080_TCP_ADDR}:${GROBID_PORT_8080_TCP_PORT} | processedXml:log"
Created new stream 'grobidTest'
xd:>stream deploy --name grobidTest --properties "module.grobid.count=1"
Deployed stream 'grobidTest'
根据查看文档,我已经设置了一个独立的 redis 实例,并且在启动 XD 时没有日志表明它有任何连接问题。
什么可能导致我的模块在 shell 中无法访问其信息时对节点不可用:
xd:>module info --name processor:grobid
Information about processor module 'grobid':
Option Name Description Default Type
----------- ----------------------------------------------------- ------- --------
grobidHost Grobid Host <none> String
outputType how this module should emit messages it produces <none> MimeType
inputType how this module should interpret messages it consumes <none> MimeType
到目前为止,我在日志中看到的唯一问题(我不知道它是否是一个拦截器)是当我创建流时,我记录了一些 ZK 错误:
zk_1 | 2015-04-13 19:55:37,257 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@645] - Got user-level KeeperException when processing sessionid:0x14cb4593f940001 type:create cxid:0x59 zxid:0x36 txntype:-1 reqpath:n/a Error Path:/xd/modules/sink/log/dependencies Error:KeeperErrorCode = NoNode for /xd/modules/sink/log/dependencies
zk_1 | 2015-04-13 19:55:37,273 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@645] - Got user-level KeeperException when processing sessionid:0x14cb4593f940001 type:create cxid:0x64 zxid:0x3c txntype:-1 reqpath:n/a Error Path:/xd/modules/processor/grobid/dependencies Error:KeeperErrorCode = NoNode for /xd/modules/processor/grobid/dependencies
zk_1 | 2015-04-13 19:55:37,289 [myid:] - INFO [ProcessThread(sid:0 cport:-1)::PrepRequestProcessor@645] - Got user-level KeeperException when processing sessionid:0x14cb4593f940001 type:create cxid:0x6e zxid:0x41 txntype:-1 reqpath:n/a Error Path:/xd/modules/source/http/dependencies Error:KeeperErrorCode = NoNode for /xd/modules/source/http/dependencies
最佳答案
Spring XD 在 https://github.com/spring-projects/spring-xd/commit/208181c9f4693d2ef2e4e0d4065d9d8727fa1601 中添加了“共享远程模块注册表”的概念(这是 1.2,在撰写本文时尚未发布)。这依赖于共享位置,大概是 HDFS。
在此之前,如果您要使用带有自定义上传模块的集群,那么您需要以某种方式使写入模块的位置可供所有容器使用。传统的方法是使用 NFS 之类的东西。
如果您正在使用 docker(看起来您正在使用,但不确定这是否仅在一台主机上),您可以使用 Docker data volume为此。
澄清一下,最后两段甚至适用于 Spring XD 1.1.x
关于Spring XD - 找不到具有名称的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29612243/