configuration not being respected


Karol <karol....@...>
 

In the end I'm not going to use spring data for interaction with janus. For anyone that will do so, below is a snippet which will solve majority of errors that you encounter. There's one more thing tho, you will get this error:

Caused by: java.lang.IllegalArgumentException: should be one instance of Map: org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex
    at org.springframework.util.Assert.instanceCheckFailed(Assert.java:699) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
    at org.springframework.util.Assert.isInstanceOf(Assert.java:599) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
    at com.microsoft.spring.data.gremlin.conversion.result.GremlinResultVertexReader.validate(GremlinResultVertexReader.java:32) ~[spring-data-gremlin-2.3.2-SNAPSHOT.jar:2.3.2-SNAPSHOT]
    at com.microsoft.spring.data.gremlin.conversion.result.GremlinResultVertexReader.read(GremlinResultVertexReader.java:52) ~[spring-data-gremlin-2.3.2-SNAPSHOT.jar:2.3.2-SNAPSHOT]
    .....

To fix that you'll have to tinker with the way the spring data plugin serializes the response from the server, that is provide a custom implementation of GremlinResultVertexReader.






import com.microsoft.spring.data.gremlin.common.GremlinConfig
import com.microsoft.spring.data.gremlin.common.GremlinFactory
import com.microsoft.spring.data.gremlin.config.AbstractGremlinConfiguration
import com.microsoft.spring.data.gremlin.repository.config.EnableGremlinRepositories
import org.apache.tinkerpop.gremlin.driver.Client
import org.apache.tinkerpop.gremlin.driver.Cluster
import org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0
import org.apache.tinkerpop.gremlin.driver.ser.Serializers
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper
import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
@EnableGremlinRepositories
class UserRepositoryConfiguration : AbstractGremlinConfiguration() { 
  override fun getGremlinConfig(): GremlinConfig = GremlinConfig(
    "localhost",
    8182,
    "",
    "",
    false,
    false,
    Serializers.GRAPHSON_V3D0.toString(),
    0
  )

   @Bean
   override fun gremlinFactory(): GremlinFactory = JanusGraphGremlinFactory(gremlinConfig)
}

class JanusGraphGremlinFactory(private val gremlinConfig: GremlinConfig) : GremlinFactory(gremlinConfig) {
   private val gremlinCluster: Cluster by lazy { createGremlinCluster() }
 
   override fun getGremlinClient(): Client {
     return this.gremlinCluster.connect()
   }

   private fun createGremlinCluster(): Cluster = Cluster.build(gremlinConfig.endpoint)
    .serializer(GraphSONMessageSerializerV3d0(GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.instance())))
    .credentials(gremlinConfig.username, gremlinConfig.password)
    .enableSsl(gremlinConfig.isSslEnabled)
    .maxContentLength(gremlinConfig.maxContentLength)
    .port(gremlinConfig.port)
    .create()
}


czwartek, 17 września 2020 o 11:57:56 UTC+2 HadoopMarc napisał(a):

Hi Karol,

Thanks for posting the workaround.
I stared a while at your post earlier this morning and could not see how your session log could be consistent with a working test for graph.set-vertex-id=true on the inmemory storage backend. Others?

Marc

Op donderdag 17 september 2020 om 10:15:22 UTC+2 schreef Karol:
I haven't managed to setup graph.set-vertex-id=true but for anyone using microsoft's gremlin plugin for spring data, add @GeneratedValue to the id field:

@Vertex
class Foo(val name: String, val age: Int? = null, @GeneratedValue val id: Int? = null)


Then the insertion should succeed:
repo.save(Foo("test", 123))

Tho still, it'd be nice to know how to set the value of properties of FIXED level. Any tips will be appreciated.

środa, 16 września 2020 o 14:45:19 UTC+2 Karol napisał(a):
Hi all,

I'm trying to setup janus so that it works with spring data gremlin plugin

In order to do so I have to setup the variable graph.set-vertex-id=true as mentioned here

here's the config I'm using:

$ pwd
/opt/janusgraph
$ cat conf/janusgraph-inmemory.properties | grep -e '^[a-z]'
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=inmemory
graph.set-vertex-id=true

So it clearly is set to true in the config file I'll be later using. Here's how I start the server:

$ bin/gremlin.sh
# console starts here
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-inmemory.properties')
==>standardjanusgraph[inmemory:[127.0.0.1]]
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@2262d6d5
gremlin> mgmt.get("graph.set-vertex-id")
==>false
gremlin> mgmt.set("graph.set-vertex-id", "true")
Cannot change the fixed configuration option: root.graph.set-vertex-id

I'm aware of mutability levels as well as the fact that the property I'm trying to set is of level FIXED and can't be changed once the db is up. The thing is I'm unable to change it no matter what I do.

There's a probably working solution posted already here but janus in this case is embedded and I want mine to be on a dedicated jvm.

Any ideas how to accomplish that?

Cheers
Karol


HadoopMarc <bi...@...>
 

Hi Karol,

Thanks for posting the workaround.
I stared a while at your post earlier this morning and could not see how your session log could be consistent with a working test for graph.set-vertex-id=true on the inmemory storage backend. Others?

Marc

Op donderdag 17 september 2020 om 10:15:22 UTC+2 schreef Karol:

I haven't managed to setup graph.set-vertex-id=true but for anyone using microsoft's gremlin plugin for spring data, add @GeneratedValue to the id field:

@Vertex
class Foo(val name: String, val age: Int? = null, @GeneratedValue val id: Int? = null)


Then the insertion should succeed:
repo.save(Foo("test", 123))

Tho still, it'd be nice to know how to set the value of properties of FIXED level. Any tips will be appreciated.

środa, 16 września 2020 o 14:45:19 UTC+2 Karol napisał(a):
Hi all,

I'm trying to setup janus so that it works with spring data gremlin plugin

In order to do so I have to setup the variable graph.set-vertex-id=true as mentioned here

here's the config I'm using:

$ pwd
/opt/janusgraph
$ cat conf/janusgraph-inmemory.properties | grep -e '^[a-z]'
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=inmemory
graph.set-vertex-id=true

So it clearly is set to true in the config file I'll be later using. Here's how I start the server:

$ bin/gremlin.sh
# console starts here
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-inmemory.properties')
==>standardjanusgraph[inmemory:[127.0.0.1]]
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@2262d6d5
gremlin> mgmt.get("graph.set-vertex-id")
==>false
gremlin> mgmt.set("graph.set-vertex-id", "true")
Cannot change the fixed configuration option: root.graph.set-vertex-id

I'm aware of mutability levels as well as the fact that the property I'm trying to set is of level FIXED and can't be changed once the db is up. The thing is I'm unable to change it no matter what I do.

There's a probably working solution posted already here but janus in this case is embedded and I want mine to be on a dedicated jvm.

Any ideas how to accomplish that?

Cheers
Karol


Karol <karol....@...>
 

I haven't managed to setup graph.set-vertex-id=true but for anyone using microsoft's gremlin plugin for spring data, add @GeneratedValue to the id field:

@Vertex
class Foo(val name: String, val age: Int? = null, @GeneratedValue val id: Int? = null)


Then the insertion should succeed:
repo.save(Foo("test", 123))

Tho still, it'd be nice to know how to set the value of properties of FIXED level. Any tips will be appreciated.

środa, 16 września 2020 o 14:45:19 UTC+2 Karol napisał(a):

Hi all,

I'm trying to setup janus so that it works with spring data gremlin plugin

In order to do so I have to setup the variable graph.set-vertex-id=true as mentioned here

here's the config I'm using:

$ pwd
/opt/janusgraph
$ cat conf/janusgraph-inmemory.properties | grep -e '^[a-z]'
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=inmemory
graph.set-vertex-id=true

So it clearly is set to true in the config file I'll be later using. Here's how I start the server:

$ bin/gremlin.sh
# console starts here
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-inmemory.properties')
==>standardjanusgraph[inmemory:[127.0.0.1]]
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@2262d6d5
gremlin> mgmt.get("graph.set-vertex-id")
==>false
gremlin> mgmt.set("graph.set-vertex-id", "true")
Cannot change the fixed configuration option: root.graph.set-vertex-id

I'm aware of mutability levels as well as the fact that the property I'm trying to set is of level FIXED and can't be changed once the db is up. The thing is I'm unable to change it no matter what I do.

There's a probably working solution posted already here but janus in this case is embedded and I want mine to be on a dedicated jvm.

Any ideas how to accomplish that?

Cheers
Karol


Karol <karol....@...>
 

Hi all,

I'm trying to setup janus so that it works with spring data gremlin plugin

In order to do so I have to setup the variable graph.set-vertex-id=true as mentioned here

here's the config I'm using:

$ pwd
/opt/janusgraph
$ cat conf/janusgraph-inmemory.properties | grep -e '^[a-z]'
gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=inmemory
graph.set-vertex-id=true

So it clearly is set to true in the config file I'll be later using. Here's how I start the server:

$ bin/gremlin.sh
# console starts here
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-inmemory.properties')
==>standardjanusgraph[inmemory:[127.0.0.1]]
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@2262d6d5
gremlin> mgmt.get("graph.set-vertex-id")
==>false
gremlin> mgmt.set("graph.set-vertex-id", "true")
Cannot change the fixed configuration option: root.graph.set-vertex-id

I'm aware of mutability levels as well as the fact that the property I'm trying to set is of level FIXED and can't be changed once the db is up. The thing is I'm unable to change it no matter what I do.

There's a probably working solution posted already here but janus in this case is embedded and I want mine to be on a dedicated jvm.

Any ideas how to accomplish that?

Cheers
Karol