Java 客户端执行StorageClientExample失败

  • nebula 版本:nebula-graph-2.0.0-rc1.el7.x86_64.rpm

  • 部署方式(分布式 / 单机 / Docker / DBaaS):阿里云单机

  • 硬件信息

    • 磁盘(推荐使用 SSD): SSD云盘 1000GiB (25000 IOPS)
    • CPU、内存信息:
      • CPU 8 核
      • 内存:64GiB
  • 业务需求描述:

  • 问题的具体描述:

    • Java 客户端执行StorageClientExample失败

space test是存在的

(root@nebula) [nba]> show spaces
+--------+
| Name   |
+--------+
| "nba"  |
+--------+
| "test" |
+--------+
Got 2 rows (time spent 861/1571 us)

Tue, 02 Mar 2021 03:23:57 UTC

Nebula Status

[root@YT-Nebula-1 ~]# /mnt/nebula/scripts/nebula.service status all
[INFO] nebula-metad: Running as 7102, Listening on 9559
[INFO] nebula-graphd: Running as 7144, Listening on 9669
[INFO] nebula-storaged: Running as 7210, Listening on 9779

在客户端中改用了Nebula服务器的IP

public static void main(String[] args) {
//        StorageClient client = new StorageClient("192.168.127.202", 9779);
        StorageClient client = new StorageClient("my nebula ip", 9779);
        try {
            client.connect();
        } catch (Exception e) {
            LOGGER.error("storage client connect error, ", e);
            System.exit(1);
        }
        scanVertex(client);
        scanEdge(client);
    }

报错:

ERROR [main] - Method name listSpaces not found
ERROR [main] - Method name listSpaces not found
Exception in thread "main" java.lang.IllegalArgumentException: Space:test does not exist.
	at com.vesoft.nebula.client.meta.MetaManager.getPartsAlloc(MetaManager.java:307)
	at com.vesoft.nebula.client.meta.MetaManager.getSpaceParts(MetaManager.java:289)
	at com.vesoft.nebula.client.storage.StorageClient.scanVertex(StorageClient.java:200)
	at com.vesoft.nebula.client.storage.StorageClient.scanVertex(StorageClient.java:134)
	at com.vesoft.nebula.client.storage.StorageClient.scanVertex(StorageClient.java:99)
	at com.vesoft.nebula.client.storage.StorageClient.scanVertex(StorageClient.java:67)
	at com.vesoft.nebula.examples.StorageClientExample.scanVertex(StorageClientExample.java:46)
	at com.vesoft.nebula.examples.StorageClientExample.main(StorageClientExample.java:36)

客户端java client已经更新到最新版本

在本地试试 可以通过console 连接到 nebula-graph不

可以

调用GraphClientExample是不报错的,可以执行

你代码中端口号9779写错了,要用metad的端口
一般报错信息为 method name not found 就是端口号写错,服务连接错误。帖子

改成metad端口后,报错

ERROR [pool-1-thread-1] - get storage client error, 
java.util.NoSuchElementException: Unable to activate object
	at org.apache.commons.pool2.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:400)
	at org.apache.commons.pool2.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:277)
	at com.vesoft.nebula.client.storage.StorageConnPool.getStorageConnection(StorageConnPool.java:42)
	at com.vesoft.nebula.client.storage.scan.ScanVertexResultIterator.lambda$next$0(ScanVertexResultIterator.java:81)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.facebook.thrift.transport.TTransportException: java.net.ConnectException: Connection refused (Connection refused)
	at com.facebook.thrift.transport.TSocket.open(TSocket.java:204)
	at com.vesoft.nebula.client.storage.GraphStorageConnection.open(GraphStorageConnection.java:40)
	at com.vesoft.nebula.client.storage.StorageConnPoolFactory.activateObject(StorageConnPoolFactory.java:59)
	at com.vesoft.nebula.client.storage.StorageConnPoolFactory.activateObject(StorageConnPoolFactory.java:16)
	at org.apache.commons.pool2.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:391)
	... 8 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:476)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:218)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:200)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394)
	at java.net.Socket.connect(Socket.java:606)
	at com.facebook.thrift.transport.TSocket.open(TSocket.java:199)
	... 12 more
ERROR [main] - scan error, 
com.vesoft.nebula.client.meta.exception.ExecuteFailedException: Execute failed: no parts succeed, error message: Unable to activate object
	at com.vesoft.nebula.client.storage.scan.ScanResultIterator.throwExceptions(ScanResultIterator.java:99)
	at com.vesoft.nebula.client.storage.scan.ScanVertexResultIterator.next(ScanVertexResultIterator.java:142)
	at com.vesoft.nebula.examples.StorageClientExample.scanVertex(StorageClientExample.java:54)
	at com.vesoft.nebula.examples.StorageClientExample.main(StorageClientExample.java:36)

Process finished with exit code 1

Nebula 查询

(root@nebula) [(none)]> show hosts
+-------------+------+----------+--------------+---------------------+------------------------+
| Host        | Port | Status   | Leader count | Leader distribution | Partition distribution |
+-------------+------+----------+--------------+---------------------+------------------------+
| "127.0.0.1" | 9779 | "ONLINE" | 110          | "nba:10, test:100"  | "nba:10, test:100"     |
+-------------+------+----------+--------------+---------------------+------------------------+
| "Total"     |      |          | 110          | "nba:10, test:100"  | "nba:10, test:100"     |
+-------------+------+----------+--------------+---------------------+------------------------+
Got 2 rows (time spent 1047/35032 us)

Tue, 02 Mar 2021 06:47:47 UTC

(root@nebula) [(none)]> use test
Execution succeeded (time spent 875/28327 us)

Tue, 02 Mar 2021 08:19:12 UTC

(root@nebula) [test]> show tags
+----------+
| Name     |
+----------+
| "person" |
+----------+
Got 1 rows (time spent 866/28583 us)

Tue, 02 Mar 2021 08:19:15 UTC

(root@nebula) [test]>

是不是java client 不支持 2.0-rc1的版本?

2.0.0-rc1版本的Nebula服务,对应着v2.0.0-rc分支的客户端代码,你自己源码打的是2.0.0-SNAPSHOT版本:

版本匹配:

更新client依赖版本后,还是一样的错误 @nicole

rc1后期的Nebula服务,有数据结构和接口参数类型的变动,master分支中的client与当前最新的rc1的服务是匹配的,与rc1的rpm包是不兼容的(因为rpm是之前发布的)。

我看java-client v2.0.0-rc分支中,是对应你安装的Nebula服务的。你确认下连接的Nebula 服务的版本

Nebula版本

nebula-graphd version 2.0.0-rc1, Git: 5713b46, Build Time: Jan  6 2021 15:31:08
This source code is licensed under Apache 2.0 License, attached with Common Clause Condition 1.0.

Java Client版本

2.0.0-rc1.20210129

你用java的graph client执行下fetch prop on 语句看下结果吧。可以直接在examples中的GraphClientExample中增加执行语句:“fetch prop on tag id”

执行正常,无报错

console 执行结果

(root@nebula) [test]> fetch prop on person 'Bob'
+----------+-------------+------------+
| VertexID | person.name | person.age |
+----------+-------------+------------+
| "Bob"    | "Bob"       | 10         |
+----------+-------------+------------+
Got 1 rows (time spent 4250/4962 us)

Wed, 03 Mar 2021 02:04:56 UTC

你的问题跟这个帖子是一样的,是服务端和客户端版本不一致导致的。 但看你使用的版本是一致的,我们这边还需要部署下跟你一样的环境看能否复现。

请帮忙试一下,多谢

@nicole 有结果了吗?

在下面这种配置下复现了:

  1. Nebula各项服务中的addrs 配置的ip是127.0.0.1

问题原因:
java client所连接的Storaged服务的地址是通过metad服务返回的,如果你配置的是127.0.0.1,那么metad返回给你的storaged服务地址就是127.0.0.1:9779。
你的服务是部署在阿里云机器上的,你是无法访问这个地址的。

解决方法:
修改nebula各项服务的ip信息,不要用127.0.0.1

@nicole 各项服务的具体配置是在什么位置?

我看了配置文件,这些配置虽然存在,但都是注释掉的

还是说Nebula默认是127.0.0.1,配置的话要打开注释,改成真实IP?

测试更新上述配置IP后,Nebula无法启动

nebula-metad.conf配置文件

nebula配置文件里 # 开头的是注释, – 不代表注释.

是我弄错了,改了配置文件中的IP后,是否要重新创建space?现在执行fetch prop on person 'Bob'找不到storage

应该得重新弄, 改了配置之后, 之前storage 再 meta 里保存的好多信息就都废了.

可以了,结果出来了,多谢帮助! @nicole @liuyu85cn

2 个赞

浙ICP备20010487号