Tinkerpop3 connects to a remote TitanDB server

I am trying to get a Graph object using Tinkerpop3 in Java as a client from an already running TitanDB server (I don't want to create a server).

In other words, I'm trying to implement a function like this: public Graph getGraph (String serverIp, String graphName);

I tried to do it like here: AWS Lambda + Tinkerpop / Gremlin + TitanDB on EC2 + AWS DynamoDB in the cloud

but, as I understand it, TitanFactory.open () starts the server, and I do not want to do this - I just want to connect to an existing server.

The documentation, as well as most of the materials on the Internet, use in-memory graphics for examples, and I cannot find it, which shows how:

  • create a new chart and save it on a remote server

  • get an existing graph from a remote server

  • update such a deleted chart, so after adding / removing edges making changes

  • delete the whole chart

I do not want to do the above material through the Gremlin language (Strings), but through the Java API (TinkerpopBlueprins). This guy comes close to what I need: Add vertices to TitanDB Graph in Java however his method already accepts Graph as an argument.

I have seen in many places on the Internet that GraphFactory.open () gets the path to the properties file, however I have not seen an example of the contents of such a file, especially with the corresponding TitanDB data, so I would prefer to use the configuration object.

Graph graph = GraphFactory.open (new BaseConfiguration ())

says there is no gremlin.graph property.

Configuration Configuration = new BaseConfiguration (); configuration.setProperty ("gremlin.graph", "titan");

Graph graph = GraphFactory.open (configuration);

says GraphFactory could not be found [titan] - make sure jar is in classpath

Is there any statically typed builder with enumerations and constants instead of Map that will tell me which properties I should provide and what their type is? Is there any open source project that uses Tinkerpop3 to connect as a client to a remote TitanDB server that I could use as an example?

I would like to see a fully working example, and not in memory with an external configuration.

+7
java gremlin titan tinkerpop3 tinkerpop-blueprint
source share
1 answer

Here is an example of a Titan driver program that connects to a running Titan server. https://github.com/pluradj/titan-tp3-driver-example As you noted, this will pass Gremlin as a string on the remote Titan server.

If you do not want to do this because you want to use the Java API directly, you should use TitanFactory.open() to make a direct connection to your schedule. TitanFactory.open() creates an instance of TitanGraph with which you can make calls to the chart APIs. It does not start the Titan Server. Under the covers, he creates client connections to the repository and backend index.

You can refer to this example for the Titan Java program without the Titan server https://github.com/pluradj/titan-tp3-java-example

You can configure this using the properties file (here is an example configuration using Cassandra and Elasticsearch) or by creating Configuration through code (basically setting the same key-value pairs that are in the properties file).

  • If the graph does not exist before your initial connection, Titan will create a keyspace in Cassandra and an index in Elasticsearch.

  • Pay attention to storage.hostname and index.search.hostname , as these are your Cassandra and Elasticsearch clusters respectively. This is essentially your โ€œgraph serverโ€. You do not need a separate Titan server.

  • Titan does not have any APIs to remove graphs from internal storage. To remove the entire graph, you will need to connect to Cassandra through the Java client driver and execute the API to reset the key space. Similarly, you will need to connect to Elasticsearch via the index API and delete the index.

+7
source share

All Articles