Closed ticholNyler closed 7 years ago
Hi! I'm not really familiar with Amazon's set up. The basic idea however should be to run gremlin server on your aws instance and then connect to it via the driver. I just found this article that might help with that http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.TitanDB.GremlinServerEC2.html
Can I connect to the gremlin server with the class without specifying a graph and then send regular commands through the 'send('')' method? That is all I would need to do. I can connect with gremlin.sh and send the command:
graph = TitanFactory.open("conf/gremlin-server/dynamodb.properties")
and then also create a graph.traversal() by following it with:
g = graph.traversal()
after that I have complete access to my existing graph stored in the dynamoDB.
So with the class is it possible to do a
db->send('graph = TitanFactory.open("conf/gremlin-server/dynamodb.properties")');
Does that make sense?
So I was able to get a little more feedback from a php fatal error. Here is what I used.
ini_set('display_errors', '1');
ini_set('log_errors_max_len', 0);
require_once('vendor/autoload.php'); // depending on your project this may not be necessary
use \Brightzone\GremlinDriver\Connection;
$db = new Connection([
'host' => 'localhost',
'port' => 8182,
]);
$db->open();
$result = $db->send('graph = TitanFactory.open("conf/gremlin-server/dynamodb.properties")');
print_r($result);
$db->close();
and then got this error.
Fatal error: Uncaught exception 'Brightzone\GremlinDriver\ServerException' with message 'The server was not capable of serializing an object that was returned from the script supplied on the request. Either transform the object into something Gremlin Server can process within the script or install mapper serialization classes to Gremlin Server. : Error during serialization: (was java.lang.UnsupportedOperationException) (through reference chain: java.util.ArrayList[0]->com.thinkaurelius.titan.graphdb.database.StandardTitanGraph["backend"]->com.thinkaurelius.titan.diskstorage.Backend["storeManager"]->com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager["localKeyPartition"]) > ' in /var/www/html/vendor/brightzone/gremlin-php/src/Connection.php:795 Stack trace: #0 /var/www/html/vendor/brightzone/gremlin-php/src/Connection.php(336): Brightzone\GremlinDriver\Connection->error('Error during se...', 599) #1 /var/www/html/vendor/brightzone/gremlin-php/src/Connection.php(471): Brightzone\GremlinDriver\Connection->socketGetUnpack() #2 [internal function]: Brightzone\GremlinDriver\Connection->Brightzone\GremlinDriver\{closure}(Object(Brightzone\GremlinDriver\Connection), 'graph = TitanFa...', '', 'eval', Array) #3 /var/www/html/vendor/brightzone/gremlin-php/src/Workload.php(78): call_user_func_array(Object(Closure), Array) #4 /var/www/html/vendor/brightzone/gremlin-php/src/Connection.php(474): Brightzone\GremlinDriver\Workload->linearRetry(1) #5 /var/www/html/test.php(15): Brightzone\GremlinDriver\Connection->send('graph = TitanFa...') #6 {main} thrown in /var/www/html/vendor/brightzone/gremlin-php/src/Connection.php on line 795
Sorry for the very late reply.
This is because gremlin-server can't serialize graph objects to json. Trying
$result = $db->send('graph = TitanFactory.open("conf/gremlin-server/dynamodb.properties");null');
should work so long as you are in a session (to allow you access to graph
again)
Closing this now but feel free to reopen if you're still having issues
Sorry, commenting so that I can quickly reference this for later as well as any updates. I'm curious to try out @PommeVerte solution for doing
mgmt = g.openManagement()
because I was getting the same fatal error message as above. Great lib though, thanks!
Any help on how I would open an existing graph from an AWS DynamoDB. In gremlin I use
graph = TitanFactory.open("conf/gremlin-server/dynamodb.properties")
The connection through this class selects a default graph instance. Thanks!