1
votes

Titan version: 0.9.0.M2

I'm trying to implement a custom serializer for using a HashMap as a property value. I have written my class according to the instructions provided in here. It implemets AttributeSerializer,has an equals method, and finally a no argument constructor.

I have set my configuration options as follows:

attributes.custom.attribute10.attribute-class = java.util.HashMap attributes.custom.attribute10.serializer-class = com.graph.HashMapSerializer

I have packaged the serializer into a jar and placed in the lib folder of the Titan distribution. I have tried to start Titan but see the error 'Need to set configuration value: root.attributes.custom.serializer-class' and also 'Could not instantiate configured serializer class' in the 'gremlin-server' logs. I have tried a bunch of options including changing the attribute number and placing in the jar in couple of different places but with no success.

Please kindly comment on whether I am doing this the right way and also possible solutions please. I have read in a Titan related post that some configuration keys might change from version to version, can this be the reason somehow?

Also can anyone please comment on how to specify the full 'custom-class' name , 'custom-serializer' name and where exactly to place the jar?

Thanks for your time.

1

1 Answers

2
votes

Placing the jar under $TITAN_HOME/lib is fine, but I think your properties should look like this:

attributes.custom.attribute1.attribute-class = java.util.HashMap
attributes.custom.attribute1.serializer-class = com.graph.HashMapSerializer

The example in the documentation mentions that they already had 9 custom attributes configured, so that's why it was using attribute10. You can verify which serializers are set in your graph using the TitanManagement interface.

$ ./bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.tinkergraph
plugin activated: aurelius.titan
gremlin> graph = TitanFactory.build().set('storage.backend','berkeleyje').set('storage.directory','/home/vagrant/titan-0.9.0-SNAPSHOT-hadoop1/db/berkeley').open()
==>standardtitangraph[berkeleyje:/home/vagrant/titan-0.9.0-SNAPSHOT-hadoop1/db/berkeley]
gremlin> mgmt = graph.openManagement()
==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@78226c36
gremlin> mgmt.get('attributes.custom.attribute10.attribute-class')
==>null
gremlin> mgmt.get('attributes.custom.attribute1.attribute-class')
==>java.util.HashMap