无法在Mac上将JanusGraph连接到本地Cassandra [英] Can not connect JanusGraph to local Cassandra on Mac
问题描述
我已经在Mac(OS X 10.11.6)上安装并运行了Cassandra 3.11.1.在终端中运行 cqlsh
会显示以下消息:
已连接到127.0.0.1:9042的测试群集.[cqlsh 5.0.1 |卡桑德拉3.11.1 |CQL规范3.4.4 |本机协议v4]使用帮助.cqlsh>
所以Cassandra应该工作正常.使用Java API,我尝试使用以下这些行来创建连接到Cassandra存储后端的 Graph
:
JanusGraph图= JanusGraphFactory.build().set("storage.backend","cassandra").set("storage.hostname","127.0.0.1").打开();
但是,这将导致以下异常:
java.lang.IllegalArgumentException:无法实例化实现:org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager在org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:69)在org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:477)在org.janusgraph.diskstorage.Backend.getStorageManager(Backend.java:409)在org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.< init>(GraphDatabaseConfiguration.java:1353)在org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:107)在org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:97)在org.janusgraph.core.JanusGraphFactory $ Builder.open(JanusGraphFactory.java:152)在engineering.divine.core.GraphFactory.cassandraGraph(GraphFactory.java:395)在engineering.divine.core.GraphFactory.graph(GraphFactory.java:301)在engineering.divine.core.GraphFactory.getDefault(GraphFactory.java:102)在engineering.divine.repository.Repository.listRepositoriesToUpdate(Repository.java:130)在engineering.divine.daemon.RepositoryAnalysisDaemon.run(RepositoryAnalysisDaemon.java:24)在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)在java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.access $ 301(ScheduledThreadPoolExecutor.java:180)在java.util.concurrent.ScheduledThreadPoolExecutor $ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)在java.lang.Thread.run(Thread.java:745)造成原因:java.lang.reflect.InvocationTargetException在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)处在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)在java.lang.reflect.Constructor.newInstance(Constructor.java:422)在org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:58)...另外18个由以下原因引起:org.janusgraph.diskstorage.TemporaryBackendException:存储后端中的临时故障在org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.ensureKeyspaceExists(AstyanaxStoreManager.java:590)在org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.< init>(AstyanaxStoreManager.java:302)...另外23个引起原因:com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException:PoolTimeoutException:[host = 127.0.0.1(127.0.0.1):9160,latency = 10003(10003),尝试= 1]超时,等待连接在com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.waitForConnection(SimpleHostConnectionPool.java:231)在com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.borrowConnection(SimpleHostConnectionPool.java:198)在com.netflix.astyanax.connectionpool.impl.RoundRobinExecuteWithFailover.borrowConnection(RoundRobinExecuteWithFailover.java:84)在com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:117)在com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:352)在com.netflix.astyanax.thrift.ThriftClusterImpl.executeSchemaChangeOperation(ThriftClusterImpl.java:146)在com.netflix.astyanax.thrift.ThriftClusterImpl.internalCreateKeyspace(ThriftClusterImpl.java:321)在com.netflix.astyanax.thrift.ThriftClusterImpl.addKeyspace(ThriftClusterImpl.java:294)在org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.ensureKeyspaceExists(AstyanaxStoreManager.java:585)...另外24个
我也已经尝试过端口 127.0.0.1:9160
, 127.0.0.1:9042
, 127.0.0.1:7000
和<代码> 127.0.0.1:7199 .我在这里想念什么?
cassandra
和 cassandrathrift
后端使用Thrift,在Cassandra 3.11.1中默认未启用.您可以通过设置 start_rpc:true
在 cassandra.yaml
中启用Thrift,也可以在命令行中使用 nodetool enablethrift
启用Thrift.
如果使用的是JanusGraph 0.2.0或更高版本,则可以使用使用本机CQL协议的CQL存储适配器.您可以通过将 storage.backend
设置为 cql
来实现.在JanusGraph 配置参考中了解有关CQL选项的更多信息..>
I've Cassandra 3.11.1 installed and running on my Mac (OS X 10.11.6). Running cqlsh
in terminal prints the following message:
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.1 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cqlsh>
So Cassandra should be working fine. Using the Java API, I attempt to create a Graph
connected to the Cassandra storage backend using these lines:
JanusGraph graph = JanusGraphFactory.build()
.set("storage.backend", "cassandra")
.set("storage.hostname", "127.0.0.1")
.open();
However that will cause the following exception:
java.lang.IllegalArgumentException: Could not instantiate implementation: org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager
at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:69)
at org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:477)
at org.janusgraph.diskstorage.Backend.getStorageManager(Backend.java:409)
at org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.<init>(GraphDatabaseConfiguration.java:1353)
at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:107)
at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:97)
at org.janusgraph.core.JanusGraphFactory$Builder.open(JanusGraphFactory.java:152)
at engineering.divine.core.GraphFactory.cassandraGraph(GraphFactory.java:395)
at engineering.divine.core.GraphFactory.graph(GraphFactory.java:301)
at engineering.divine.core.GraphFactory.getDefault(GraphFactory.java:102)
at engineering.divine.repository.Repository.listRepositoriesToUpdate(Repository.java:130)
at engineering.divine.daemon.RepositoryAnalysisDaemon.run(RepositoryAnalysisDaemon.java:24)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:58)
... 18 more
Caused by: org.janusgraph.diskstorage.TemporaryBackendException: Temporary failure in storage backend
at org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.ensureKeyspaceExists(AstyanaxStoreManager.java:590)
at org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.<init>(AstyanaxStoreManager.java:302)
... 23 more
Caused by: com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException: PoolTimeoutException: [host=127.0.0.1(127.0.0.1):9160, latency=10003(10003), attempts=1]Timed out waiting for connection
at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.waitForConnection(SimpleHostConnectionPool.java:231)
at com.netflix.astyanax.connectionpool.impl.SimpleHostConnectionPool.borrowConnection(SimpleHostConnectionPool.java:198)
at com.netflix.astyanax.connectionpool.impl.RoundRobinExecuteWithFailover.borrowConnection(RoundRobinExecuteWithFailover.java:84)
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:117)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:352)
at com.netflix.astyanax.thrift.ThriftClusterImpl.executeSchemaChangeOperation(ThriftClusterImpl.java:146)
at com.netflix.astyanax.thrift.ThriftClusterImpl.internalCreateKeyspace(ThriftClusterImpl.java:321)
at com.netflix.astyanax.thrift.ThriftClusterImpl.addKeyspace(ThriftClusterImpl.java:294)
at org.janusgraph.diskstorage.cassandra.astyanax.AstyanaxStoreManager.ensureKeyspaceExists(AstyanaxStoreManager.java:585)
... 24 more
I've also already tried ports 127.0.0.1:9160
, 127.0.0.1:9042
, 127.0.0.1:7000
and 127.0.0.1:7199
. What am I missing here?
The cassandra
and cassandrathrift
backend uses Thrift, which is not enabled by default in Cassandra 3.11.1. You can enable Thrift either in the cassandra.yaml
by setting start_rpc: true
or on the command line with nodetool enablethrift
.
If you are using JanusGraph 0.2.0 or later, you can use the CQL storage adapter which uses the native CQL protocol. You can do this by setting storage.backend
to cql
. Read more about the CQL options in the JanusGraph configuration reference.
这篇关于无法在Mac上将JanusGraph连接到本地Cassandra的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!