Cannot connect gremlin console to Cosmos DB account: "log4j:WARN No appenders could be found for logger" - azure-cosmosdb-gremlinapi

I am trying to create a graph in Cosmos DB using a Gremlin API.
I updated the remote-secure.yaml file, but for some reason the gremlin console keeps giving me the same error message:
gremlin> :remote connect tinkerpop.server conf/remote-secure.yaml
log4j:WARN No appenders could be found for logger
(io.netty.util.internal.logging.InternalLoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.
==>Configured graphtestcosmos.gremlin.cosmos.azure.com/104.45.16.183:443
gremlin>
When I try to interact with the graph, I get the following:
gremlin> g.V()
org.apache.tinkerpop.gremlin.jsr223.console.RemoteException
Type ':help' or ':h' for help.
Display stack trace? [yN]
And when trying to add a vertex:
gremlin> g.addV('person').property('firstName', 'Thomas').property('lastName', 'Andersen').property('age', 44).property('userid', 1)
Host did not respond in a timely fashion - check the server status and submit again.
Type ':help' or ':h' for help.
Display stack trace? [yN]
gremlin>
What does this mean, and how do I fix it?

Related

gremlin how to set scriptevaluationtimeout 0

I want to set scriptevaluationtimeout 0.
I'm using apache-tinkerpop-gremlin-console-3.4.9.
and I want to use gremlin-python.
As the question above noted, it's not quite clear whether you mean Gremlin Console or gremlin-python so I will just answer both ways. For Gremlin Console, the preferred method for remote connections is to issue this command:
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote config timeout none
The above is detailed in this section of the Reference Documentation. For gremlin-python you can configure per request timeouts as described here for scripts:
result_set = client.submit('g.V().repeat(both()).times(100)', result_options={'evaluationTimeout': 0})
or here for bytecode:
vertices = g.with_('evaluationTimeout', 0).V().out('knows').toList()

How to set up gremlin console to work against local Azure CosmosDB Emulator?

I have some software running locally against Azure CosmosDB Emulator which works fine, but when i try to use the gremlin console (version 3.4.4) I just can't get it to work.
Based on the Microsoft documentation https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/cosmos-db/create-graph-gremlin-console.md and my existing working app I set up my local yaml file
hosts: [localhost]
port: 8901
username: /dbs/GremlinNoteDB/colls/CrmCollection
password: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
connectionPool: { enableSsl: true }
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0, config: { serializeResultToString: true }}
And running the command...
gremlin> :remote connect tinkerpop.server conf/cosmos_local.yaml
...results in the following output which (to my untrained eye) looks ok.
gremlin> :remote connect tinkerpop.server conf/cosmos_local.yaml
==>Configured localhost/127.0.0.1:8901, localhost/0:0:0:0:0:0:0:1:8901
But when I then try to run a gremlin command like the following it fails. Have I missed something obvious? I have tried changing ssl and using other serializers but to no avail.
gremlin> :> g.V().count()
Host did not respond in a timely fashion - check the server status and submit again.
Type ':help' or ':h' for help.
Display stack trace? [yN]
Any and all help is welcome. I checked the other related posts here on stackoverflow, but they didn't solve my problem. So to summarize: The Azure CosmosDB Emulator works since I can connect with my .net application, but I can't get the gremlin console to work.
Seems like at the moment gremlin console (version 3.4.4) doesn't support connection to Azure CosmosDB Emulator (at least in the form it is shown here). Use gremlin console 3.3.4 instead.
CosmosDB Emulator works without SSL.
Setting { enableSsl: false } should fix your issue.

How can I use gremlin-console to remotely create and access variables?

I remotely connect to a gremlin server using gremlin-console(which is janusgraph), but when I create a variable and access it, it doesn't work. My ultimate goal is to use gremlin-console to create index...
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server -
[localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin> a = "b"
==>b
gremlin> a
No such property: a for class: Script3
Type ':help' or ':h' for help.
You can't use variables like this for subsequent requests, because the console is by default sessionless. So every request is executed in its own transaction and no state is shared between two different requests.
However you can configure the console to use a session by simply appending the session keyword to the connect argument:
gremlin> :remote connect tinkerpop.server conf/remote.yaml session
==>Configured localhost/127.0.0.1:8182-[15dc7030-0e5b-4b4b-a997-9d2cf519ebb2]
gremlin> :> x = 1
==>1
gremlin> :> y = 2
==>2
gremlin> :> x + y
==>3
I copied this example from the TinkerPop documentation for this topic.
Download janusdb and launch the gremlin console by running
/bin/gremlin.sh
Construct the janus graph using the following command:
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-cassandra-solr.properties')
Get your graph traversal source by running:
gremlin> g = graph.traversal()
Now you are connected directly to the database with the full control. You can store the return values and use it in the next queries.

add vertex to dynamodb using DynamoDB Storage Backend for Titan

I build Amazon DynamoDB Storage Backend for Titan.
I used this for build the env - based on template.
After the resource was created I saw the dynamodb was created based on dynamodb.properties file.
After the resource was created, I open ssh to Linux EC2 and start bin/gremlin.sh.
I wish to add data to dynamo, so I tried to add vertex by folliwing commands:
gremlin> bin/gremlin.sh
gremlin> :remote connect tinkerpop.server conf/remote.yaml
gremlin> g = TitanFactory.open("/usr/local/packages/dynamodb-titan100-storage-backend-1.0.0-hadoop1/conf/gremlin-server/dynamodb.properties")
gremlin> g.addVertex('date_of_birth').property('date_of_birth','1949-01-01')
vp[date_of_birth->1949-01-01]
but now when I examine my dynamodb table, I see titan_ids was changed, but the data is not clear to read.
The 'v' column is still EMPTY, and not contain the vertex property.
How can I solve that issue and see the vertex property in v column?
Titan Store data in binary format in the storage backend. So you should use gremlin query.
To get all the vertex and it's properties :
Example :
gremlin> graph = TinkerFactory.createModern()
==>tinkergraph[vertices:6 edges:6]
gremlin> g = graph.traversal()
gremlin> g.V().valueMap()
==>[name:[marko],age:[29]]
==>[name:[vadas],age:[27]]
==>[name:[lop],lang:[java]]
==>[name:[josh],age:[32]]
==>[name:[ripple],lang:[java]]
==>[name:[peter],age:[35]]

create multiple vertices in gremlin graph in local dynamodb

I have to create multiple vertices in gremlin graph in its console using local DynamoDB few commands.
Uses := TitanDB
Storage Backend := DynamoDB
Server := Gremlin server
Here's the same example I provided previously
gremlin> graph = TitanFactory.open('conf/gremlin-server/dynamodb-local.properties')
==>standardtitangraph[com.amazon.titan.diskstorage.dynamodb.DynamoDBStoreManager:[127.0.0.1]]
gremlin> v0 = graph.addVertex('name', 'jason'); v1 = graph.addVertex('name', 'mustaffa'); v0.addEdge('helps', v1)
==>e[175-39k-1lh-374][4232-helps->4144]
gremlin> graph.tx().commit()
==>null
It creates 2 vertices and 1 edge. This example shows a direct connection to the Titan graph without using a Gremlin Server.
If you want to connect to a Gremlin Server, the syntax is largely the same. First create a remote connection to the Gremlin Server, then you have to use :> or :submit to send the request to the server. Also note that you don't need to explicitly call graph.tx().commit() because the transaction is automatically committed on each remote request.
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Connected - localhost/127.0.0.1:8182
gremlin> :> v0 = graph.addVertex('name', 'jason'); v1 = graph.addVertex('name', 'mustaffa'); v0.addEdge('helps', v1)
==>e[17c-3b4-1lh-3a8][4288-helps->4256]

Resources