我有以下代码:
trait InMemoryConnectScala {
def messageSerializer(): MessageSerializer = {
import java.util.Collections
import org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0
import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry
val config = new util.HashMap[String, Object]()
config.put("ioRegistries", Collections.singletonList(classOf[JanusGraphIoRegistry].getName))
val serializer = new GryoMessageSerializerV1d0()
serializer.configure(config, null)
serializer
}
def connect(): JanusGraph = {
import org.apache.commons.configuration.BaseConfiguration
val conf = new BaseConfiguration()
conf.setProperty("storage.backend", "inmemory")
conf.setProperty("type", "remote")
val jg = JanusGraphFactory.open(conf)
jg
}
}
val clusterBuilder = Cluster.build.port(8182).serializer(messageSerializer()).addContactPoint("localhost")
val cl = clusterBuilder.create()
val client: Client = cl.connect()
val jg = EmptyGraph.instance.traversal.withRemote(DriverRemoteConnection.using(cl))
val res = client.submit("g.V().count()")
}
我遇到提交方法时出现以下错误
12:25:34.979 [pool-1-thread-1] INFO o.a.t.gremlin.driver.ConnectionPool - Opening connection pool on Host{address=localhost/127.0.0.1:8182, hostUri=ws://localhost:8182/gremlin} with core size of 2
[info] AcmTestSpec *** ABORTED ***
[info] java.lang.RuntimeException: java.lang.RuntimeException: java.util.concurrent.TimeoutException: Timed out while waiting for an available host - check the client configuration and connectivity to the server if this message persists
[info] at org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:214)
[info] at org.apache.tinkerpop.gremlin.driver.Client.submit(Client.java:198)
[info] at AcmTestSpec.beforeAll(AcmTestSpec.scala:407)
[info] at org.scalatest.BeforeAndAfterAll.liftedTree1$1(BeforeAndAfterAll.scala:212)
[info] at org.scalatest.BeforeAndAfterAll.run(BeforeAndAfterAll.scala:210)
[info] at org.scalatest.BeforeAndAfterAll.run$(BeforeAndAfterAll.scala:208)
[info] at AcmTestSpec.run(AcmTestSpec.scala:60)