-
Notifications
You must be signed in to change notification settings - Fork 0
RexConnect Usage Examples
zachkinstner edited this page May 1, 2013
·
3 revisions
Written for version 0.3.0.
The following text is RexConnectConsole
output to demonstrate various usage scenarios. The output represents a single use of the console. For clarity, it has been split into sections, and annotated with several "//" notes.
$ bin/rexConnectConsole.sh
" ---===##\
" --==##\
" ---===################>
" --==##/
" ---===##/
RexConnect Console 0.3.0
{rexpro_port=8184, rexpro_graph_name=FabricTest, rexconnect_port=8184, rexpro_hosts=rexster, rexpro_timeout_ms=120000}
-------------------------------------------------------------
# RexConnect> config
# ...setting (0; string): pretty
# ...mode (1; int): 1
// Make this example a little more attractive...
{
"timer": 0
}
# RexConnect> query
# ...script (0; string): g
# ...params (1; string; opt):
{
"timer": 5,
"results": [
"titangraph[local:data/FabricTest]"
]
}
# RexConnect> query
# ...script (0; string): x=5
# ...params (1; string; opt):
{
"timer": 5,
"results": [
5
]
}
# RexConnect> query
# ...script (0; string): x
# ...params (1; string; opt):
// Without a session, "x" is not available.
{
"timer": 20,
"err": "com.tinkerpop.rexster.client.RexProException> An error occurred while processing the script for language [groovy]. All transactions across all graphs in the session have been concluded with failure: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: x for class: Script184"
}
# RexConnect> session
# ...action (0; string): start
{
"timer": 37,
"results": [
"946622a7-42e4-4795-a67e-0b9cf1751781"
]
}
# RexConnect> query
# ...script (0; string): x=5
# ...params (1; string; opt):
{
"timer": 8,
"results": [
5
]
}
# RexConnect> query
# ...script (0; string): x
# ...params (1; string; opt):
// Within this session, the "x" variable is available across requests/commands.
{
"timer": 5,
"results": [
5
]
}
# RexConnect> query
# ...script (0; string): g.addVertex([TestId:123])
# ...params (1; string; opt):
{
"timer": 27,
"results": [
{
"_properties": {
"TestId": 123
},
"_id": "194848",
"_type": "vertex"
}
]
}
# RexConnect> query
# ...script (0; string): g.v(194848)
# ...params (1; string; opt):
// Within the session, this vertex is available even though it has not been committed.
{
"timer": 20,
"results": [
{
"_properties": {
"TestId": 123
},
"_id": "194848",
"_type": "vertex"
}
]
}
# RexConnect> session
# ...action (0; string): close
{
"timer": 11
}
# RexConnect> query
# ...script (0; string): x
# ...params (1; string; opt):
// The session has been closed, so "x" is no longer available.
{
"timer": 8,
"err": "com.tinkerpop.rexster.client.RexProException> An error occurred while processing the script for language [groovy]. All transactions across all graphs in the session have been concluded with failure: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: x for class: Script184"
}
# RexConnect> query
# ...script (0; string): g.v(194848)
# ...params (1; string; opt):
// The session was closed without a commit, so the new vertex is not persisted.
{
"timer": 7,
"results": [
null
]
}
# RexConnect> session
# ...action (0; string): start
{
"timer": 7,
"results": [
"57685f20-23d9-431b-be9e-b9d1c7238c71"
]
}
# RexConnect> query
# ...script (0; string): g.addVertex([TestId:345])
# ...params (1; string; opt):
{
"timer": 29,
"results": [
{
"_properties": {
"TestId": 345
},
"_id": "194852",
"_type": "vertex"
}
]
}
# RexConnect> session
# ...action (0; string): commit
{
"timer": 360
}
# RexConnect> query
# ...script (0; string): g.v(194852)
# ...params (1; string; opt):
{
"timer": 21,
"results": [
{
"_properties": {
"TestId": 345
},
"_id": "194852",
"_type": "vertex"
}
]
}
# RexConnect> session
# ...action (0; string): close
//Always close your sessions!
{
"timer": 11
}
# RexConnect> query
# ...script (0; string): g.v(194852)
# ...params (1; string; opt):
// The session was committed, so the new vertex was persisted to the database.
{
"timer": 8,
"results": [
{
"_properties": {
"TestId": 345
},
"_id": "194852",
"_type": "vertex"
}
]
}
# RexConnect> QUERY
// Commands and arguments are case-sensitive.
{
"timer": 0,
"err": "Unknown command 'QUERY'."
}
# RexConnect> session
# ...action (0; string): begin
// Invalid argument error messages include helpful information.
{
"timer": 6,
"err": "Invalid 'action' argument ('begin') at index 0, for command 'session': Argument value not supported. Available values: 'start', 'close', 'commit', 'rollback'. "
}
# RexConnect> query
# ...script (0; string): g.v(x)
# ...params (1; string; opt): {x:123}
//Always format your parameter JSON correctly...
{
"timer": 23,
"err": "Invalid 'params' argument ('{x:123}') at index 1, for command 'query': Invalid parameter format: Unexpected character ('x' (code 120)): was expecting double-quote to start field name\n at [Source: java.io.StringReader@2fe6e305; line: 1, column: 3]. "
}