Titan 0.9.0.M2 custom attribute serializer- HashMap as a property value - titan

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.

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

Related

CRM D365 update polymorphic/multitable lookup via Plugin

I'm trying to update a polymorphic lookup column on a table via plugin code and it doesn't seem happening. Wondering what additional I’m missing.
var entity1Id = "af435c64-a264-4f2a-9cee-22069ce36b3c";
var destinationEntity = new Entity("bookableresourcebooking", new Guid(myBookingGuid));
destinationEntity["my_ploymorphiclookupid"] = new EntityReference("my_entity1", new Guid(entity1Id));
organizationService.Update(destinationEntity);
my_ploymorphiclookupid is a polymorphic lookup (N:1) to my_entity1
Code looks fine. If you didn’t see any runtime errors in plug-in trace log, then few diagnosis steps needed.
Check audit history of that record
Chances of any other plugin steps replacing the value back or rolling back
Try to profile/debug the plugin for clues

JRHtmlExporter is deprecated now 6.15.X jasper. How to define the IS_USING_IMAGES_TO_ALIGN?

I replaced the usage of this class with JRHtmlExporter to HtmlExporter.
When I build my java file i got below error cannot find symbol IS_USING_IMAGES_TO_ALIGN
MY CODE IS:
exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean("false"));
What is equivalent function?
You need to remove this setting since it's not supported anymore (it's false by default), for more information see:
How to set IS_USING_IMAGES_TO_ALIGN in HtmlExporter in Java ? by lucianc staff of jasper-reports
The new HtmlExporter does not support using images for alignment. So you no longer need to set IS_USING_IMAGES_TO_ALIGN to false, it is false by default.

Initialization of 'g' and 'graph' vars on server start

Upon starting gremlin console, the g and graph objects aren't being automatically instantiated. From reading it seems that I don't have something configured correctly to allow for this during startup.
I've checked my gremlin-server.yaml file, which includes
graphs: {
graph: conf/gremlin-server/dynamodb.properties}
I'm able to manually create the objects in the console, so it does work
gremlin> graph = TitanFactory.open('conf/gremlin-server/dynamodb.properties');
==>standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]]
gremlin> mgmt = graph.openManagement();
==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem#433b546f
gremlin> g = graph.traversal(standard());
==>graphtraversalsource[standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]], standard]
Is there something else I'm missing? I found this issue logged on the gremlin-javascript project, but am still stuck. I think my problem is with my configuration on the server and not my implementation of gremlin-javascript.
Ultimately I'm trying to traverse using gremlin-javascript, but I'm forced to create 'graph' and 'g' each time (slow).
This is the expected behavior when starting the Gremlin console, unless you start it with an init script that does this for you:
// scripts/initMyGraph.groovy
graph = TitanFactory.open('conf/gremlin-server/dynamodb.properties')
g = graph.traversal(standard())
Then start the console with:
bin/gremlin.sh scripts/initMyGraph.groovy
Graph and Traversal objects will be accessible as graph and g variables in the console, respectively.

Elasticsearch scala elastic4s settings from property file

is there a way how to pass settings to elastic4s from property file? The following way works but it is not flexible in munltienvironment:
val settings = ImmutableSettings.settingsBuilder().put("cluster.name","elasticsearch").build()
val client = ElasticClient.remote(settings, "154.86.209.242" -> 9300, "153.89.219.241" -> 9300)
I tried java configuration file elasticsearch.yaml as mantioned in java doc but that doesn't work.
Any suggestion here?
You can do this using the same method you would for the Java client. The ImmutableSettings is a Java Client class not something that is specific to elastic4s.
To load your properties file from the classpath, eg if you have something in src/main/resources/com/package/settings.props
ImmutableSettings.settingsBuilder().loadFromClasspath("/com/package/mysettings.yaml")
Or if you want to load from an input stream:
ImmutableSettings.settingsBuilder().loadFromStream(myinputstream)
There are other methods too, just check out the ImmutableSettings.settingsBuilder object.

Autofac parameter passing

I've been trying to integrate the latest version of autofac (1.3.3.54), and I'm running into the following problem.
The recommended way of consuming parameters in the Register callback, per the Google code wiki for the project is as follows:
builder.Register((c, p) => new Foo(p.Get("arg1")));
However this won't compile with the mentioned version of the autofac code. I looked through the source and I see that p is an IEnumerable (ComponentActivatorWithParameters). Is the code out of date with respect to the documentation?
It appears that the code has changed and the documentation on the Wiki has not been updated. The "Get" method is now "Named" and the "Parameter" class is now "NamedParameter". See the following example:
var builder = new ContainerBuilder();
builder.Register((c, p) => new Person(p.Named<string>("name")));
using (var container = builder.Build())
{
var person = container.Resolve<Person>(new NamedParameter("name", "Fred"));
}
Hopefully someone can update the documentation soon.
I've attached freshly built documentation for AutoFac 1.3 to AutoFac issue #121. I hope they'll resume posting official 1.3 documentation at least until they retire the 1.3 branch and, with it, support for .NET 2.0.