Embedded databases don't seem to support graph SQL commands

132 views
Skip to first unread message

Jake

unread,
Apr 10, 2015, 6:18:27 PM4/10/15
to orient-...@googlegroups.com
Hello,

The problem I'm running into is that my embedded server isn't supporting any graph related sql commands (e.g. "create vertex", "out('asdf')" and "in('adsf')".) Those commands are completely valid on the bin/dserver.bat that is included in the zip file that I downloaded from Orientdb's website (http://orientdb.com/download/.) Part of the configuration that is used for the embedded server is from Orientdb's Embedded Database wiki page and the other parts are from dserver.bat's configuration. For the most part they are the same (the same plugins are used and the relevant things seem to be the same.) Here is my embedded server's code:

private OServer _server;
public static void main(String[] args) {
    new EmbeddedServer(args[0]);
}

public EmbeddedServer(String nodeName) {
    try {
        _server = OServerMain.create();

        _server.startup(
                "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
                        + "<orient-server>"
                        + "<handlers>"
                        + "      <handler class=\"com.orientechnologies.orient.graph.handler.OGraphServerHandler\">\n" +
                        "            <parameters>\n" +
                        "                <parameter value=\"true\" name=\"enabled\"/>\n" +
                        "                <parameter value=\"50\" name=\"graph.pool.max\"/>\n" +
                        "            </parameters>\n" +
                        "        </handler>\n"
                        + "      <handler class=\"com.orientechnologies.orient.server.handler.OServerSideScriptInterpreter\">\n" +
                        "            <parameters>\n" +
                        "                <parameter value=\"true\" name=\"enabled\"/>\n" +
                        "                <parameter value=\"SQL\" name=\"allowedLanguages\"/>\n" +
                        "            </parameters>\n" +
                        "        </handler>\n"
                        + "      <handler class=\"com.orientechnologies.orient.server.token.OrientTokenHandler\">\n" +
                        "            <parameters>\n" +
                        "                <parameter value=\"false\" name=\"enabled\"/>\n" +
                        "                <parameter value=\"\" name=\"oAuth2Key\"/>\n" +
                        "                <parameter value=\"60\" name=\"sessionLength\"/>\n" +
                        "                <parameter value=\"HmacSHA256\" name=\"encryptionAlgorithm\"/>\n" +
                        "            </parameters>\n" +
                        "        </handler>\n"
                        + "<handler class=\"com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin\">"
                        + "<parameters>"
                        + "<parameter value=\"Z:/OrientDBTest/config/default-distributed-db-config.json\" name=\"configuration.db.default\"/>"
                        + "<parameter value=\"Z:/OrientDBTest/config/hazelcast.xml\" name=\"configuration.hazelcast\"/>"
                        + "<parameter value=\""+nodeName+"\" name=\"nodeName\"/>"
                        + "</parameters>"
                        + "</handler>"
                        + "</handlers>"
                        + "<network>"
                        + "<protocols>"
                        + "<protocol name=\"binary\" implementation=\"com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary\"/>"
                        + "<protocol name=\"http\" implementation=\"com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpDb\"/>"
                        + "</protocols>"
                        + "<listeners>"
                        + "<listener ip-address=\"0.0.0.0\" port-range=\"2424-2430\" protocol=\"binary\"/>"
                        + "<listener ip-address=\"0.0.0.0\" port-range=\"2480-2490\" protocol=\"http\"/>"
                        + "</listeners>"
                        + "</network>"
                        + "<users>"
                        + "<user name=\"root\" password=\"asdf123$\" resources=\"*\"/>"
                        + "</users>"
                        + "<properties>"
                        + "    <entry value=\"1\" name=\"db.pool.min\"/>\n" +
                        "      <entry value=\"50\" name=\"db.pool.max\"/>\n" +
                        "      <entry value=\"true\" name=\"profiler.enabled\"/>"
                        + "    <entry name=\"log.console.level\" value=\"info\"/>"
                        + "    <entry name=\"log.file.level\" value=\"fine\"/>"
                        + "</properties>"
                        + "</orient-server>");
        _server.activate();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

I first thought this was a configuration or dependency issue, but the configurations are pretty much the same and at one point I had every single Orientdb dependency included just in case it could have been one of them. Orientdb's wiki only states that the orientdb-server and orientdb-enterprise jars are needed for an embedded server, but I thought that the orientdb-graphdb jar might also be needed for graph database support. (The orientdb-client jar is included there, because I have a single project that handles the server or the client depending on the main class that is chosen. This is just for testing Orientdb.) My current build.gradle file is:

apply plugin: 'java'

sourceCompatibility = 1.7
version = '1.0'

repositories {
    mavenCentral()
}

jar {
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}

dependencies {
    compile 'com.orientechnologies:orientdb-graphdb:2.0.6'
    compile 'com.orientechnologies:orientdb-core:2.0.6'
    compile 'com.orientechnologies:orientdb-client:2.0.6'
    compile 'com.orientechnologies:orientdb-distributed:2.0.6'
    compile 'com.orientechnologies:orientdb-server:2.0.6'
    compile 'com.orientechnologies:orientdb-enterprise:2.0.6'
}



I've been using that code to start my server in a standalone manner. Then I've been using other small standalone programs for creating the database as well as remotely talking to the database. Here is the code I use for creating the database:

public class CreateDbEntry {
    public static void main(String[] args) {
        OServerAdmin server = null;
        try {
            server = new OServerAdmin("remote:"+args[0]+"/graphdb");
            server.connect("root", "asdf123$");
            if (!server.existsDatabase("plocal"))
                server.createDatabase("graph", "plocal");

            server.close(true);
            if (server.isConnected()) {
                System.out.println("We're still connected after the close()?");
            }
            else {
                System.out.println("Database Created!");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

I've been using SQL commands similar to the following:

OrientGraphFactory factory = new OrientGraphFactory("remote:"+database+"/graphdb", "root", "asdf123$").setupPool(1, 20);
OrientGraphNoTx graph = factory.getNoTx();

String readQuery = String.format("select from " +
"(traverse OUT('reports'), OUT('followed_by'), OUT('direct_use') from (select from JobRecord where test_id=%d)) " +
"where @class='Artifact'", i);

List artifacts = graph.getRawGraph().command(new OCommandSQL(readQuery)).execute();

and

OrientGraphFactory factory = new OrientGraphFactory("remote:"+database+"/graphdb", "root", "asdf123$").setupPool(1, 20);
OrientGraphNoTx graph = factory.getNoTx();

String deleteQuery = String.format("delete vertex from " +
"(traverse OUT('reports'), OUT('followed_by') from (select from JobRecord where test_id=%d))", i);
int no = graph.getRawGraph().command(new OCommandSQL(deleteQuery)).execute();

These code snippets work perfectly well when I use them with bin/dserver.bat. However they do not work when I create my own embedded server using OServer. The bin/console.bat also has issues using queries such as 'create vertex' with the embedded server as well. I'm unsure of what the problem could be and it seems like I'm the only one that has run into this issue.

These are the exceptions I'm getting when I'm executing sql graph queries against the embedded server (these exceptions were printed by the server):

2015-04-10 14:31:38:780 INFO  [node1] received new status node1.graphdb=ONLINE [OHazelcastPlugin]Sent run-time exception to the client /127.0.0.1:51399: com.or
ientechnologies
.orient.core.exception.OQueryParsingException: Error on parsing query at position #111: Error on parsing query
Query:  (traverse OUT('reports'), OUT('followed_by'), OUT('direct_use') from (select from JobRecord where test_id=0)) where @class='Artifact'
--------------------------------------------------------------------------------------------------------------------^
com
.orientechnologies.orient.core.exception.OQueryParsingException: Error on parsing query at position #111: Error on parsing query
Query:  (traverse OUT('reports'), OUT('followed_by'), OUT('direct_use') from (select from JobRecord where test_id=0)) where @class='Artifact'
--------------------------------------------------------------------------------------------------------------------^
        at com
.orientechnologies.orient.core.sql.filter.OSQLTarget.<init>(OSQLTarget.java:76)
        at com
.orientechnologies.orient.core.sql.OSQLEngine.parseTarget(OSQLEngine.java:440)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.parse(OCommandExecutorSQLSelect.java:218)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.parse(OCommandExecutorSQLSelect.java:96)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:56)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:37)
        at com
.orientechnologies.orient.server.distributed.ODistributedStorage.command(ODistributedStorage.java:223)
        at com
.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:63)
        at com
.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.command(ONetworkProtocolBinary.java:1178)
        at com
.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:385)
        at com
.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.java:220)
        at com
.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:69)
Caused by: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: No function with name 'out', available n
ames are
: [date,encode,distance,document,distinct,traversedelement,sum,decode,uuid,mode,sysdate,avg,min,traversededge,ifnull,traversedvertex,stddev,if,map,uni
onall
,set,intersect,last,max,coalesce,count,format,list,eval,percentile,median,variance,difference,first]
        at com
.orientechnologies.orient.core.sql.OSQLEngine.getFunction(OSQLEngine.java:399)
        at com
.orientechnologies.orient.core.sql.functions.OSQLFunctionRuntime.setRoot(OSQLFunctionRuntime.java:202)
        at com
.orientechnologies.orient.core.sql.filter.OSQLFilterItemAbstract.<init>(OSQLFilterItemAbstract.java:61)
        at com
.orientechnologies.orient.core.sql.functions.OSQLFunctionRuntime.<init>(OSQLFunctionRuntime.java:55)
        at com
.orientechnologies.orient.core.sql.OSQLHelper.getFunction(OSQLHelper.java:220)
        at com
.orientechnologies.orient.core.sql.OSQLHelper.parseValue(OSQLHelper.java:198)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLTraverse.parseFields(OCommandExecutorSQLTraverse.java:209)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLTraverse.parse(OCommandExecutorSQLTraverse.java:70)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLTraverse.parse(OCommandExecutorSQLTraverse.java:55)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:56)
        at com
.orientechnologies.orient.core.sql.filter.OSQLTarget.extractTargets(OSQLTarget.java:177)
        at com
.orientechnologies.orient.core.sql.filter.OSQLTarget.<init>(OSQLTarget.java:67)
       
... 11 more


Sent run-time exception to the client /127.0.0.1:51704: com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command exec
utor
for the command request: sql.create vertex
com
.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command executor for the command request: sql.create vertex
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:52)
        at com
.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.parse(OCommandExecutorSQLDelegate.java:37)
        at com
.orientechnologies.orient.server.distributed.ODistributedStorage.command(ODistributedStorage.java:223)
        at com
.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:63)
        at com
.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.command(ONetworkProtocolBinary.java:1178)
        at com
.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.executeRequest(ONetworkProtocolBinary.java:385)
        at com
.orientechnologies.orient.server.network.protocol.binary.OBinaryNetworkProtocolAbstract.execute(OBinaryNetworkProtocolAbstract.java:220)
        at com
.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:69)

Thanks for reading.

Colin

unread,
Apr 13, 2015, 10:55:03 AM4/13/15
to orient-...@googlegroups.com
Hi Jake,

When running your embedded database and you connect to it via the console, are you able to see all the created classes (using the classes command)?

What happens if you issue the command: info class <SomeClassName>?

Do any basic queries work on your data?

Thanks,

-Colin

Orient Technologies

The Company behind OrientDB

Jake

unread,
Apr 17, 2015, 1:44:47 PM4/17/15
to orient-...@googlegroups.com
Colin,

The database is being updated with vertices and edges according to 'info'. I'm able to use SELECT to search through my vertices just fine as well. It's just when I try to use the graph specific commands that I'm running into problems. I'm able to traverse the vertices as long as I don't use the 'out()' or 'in()' functions. I'm unable to use 'delete vertex' and I think I also tried to use 'create vertex' unsuccessfully. The server just seems to think that graph specific functions or commands don't exist. The database is created specifically as a graph database though.

I'm using my embedded server the same way I'm using the bin/dserver.bat. The exact same code for creating the database/schema, inserting the vertices/edges, traversing the vertices and deleting the vertices was used on both servers. The bin/dserver.bat worked just fine, but the embedded server didn't know anything about graph specific functions or commands. As well I did use 'info' in the console to check to see if the schema, vertices and edges were being added to each of the servers. The schema and the vertices/edges were added to both servers without a problem (the java api was used for creating the schema, the vertices and the edges.) After that I started using SQL commands for traversing and deleting, which is where the graph specific SQL commands and functions come into play. Those commands worked only on the bin/dserver.bat server.

Thanks for the reply,

Jake

Luca Garulli

unread,
Apr 17, 2015, 6:57:58 PM4/17/15
to orient-...@googlegroups.com
Hi Jake,
Did you add orientdb-graphdb.jar in your classpath?

Lvc@


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Best Regards,

Luca Garulli
CEO at Orient Technologies LTD
the Company behind OrientDB

Jake

unread,
Apr 22, 2015, 3:20:00 PM4/22/15
to orient-...@googlegroups.com
All of my dependencies are listed in my build.gradle file above. Those dependencies are in my classpath when I'm executing my server and orientdb-graphdb is a part of that list. I've included all of the dependencies that are recommended on the wiki for the embedded server as well as a few more of them that seemed necessary (such as the orientdb-distributed.jar.)

This issue doesn't seem to have any easy answer. I've tried adding all of the dependencies that were available and copying the configuration of the server that I downloaded from Orientdb's main website. That server supports 'traverse out() ...' and 'delete vertex ...' just fine, but mine doesn't even though they have had the same configurations and dependencies at one point in time.

I'm unsure of what to do to solve this issue still. Thanks for the suggestions though.

Jake

Jake

unread,
May 6, 2015, 3:08:07 PM5/6/15
to orient-...@googlegroups.com
I'm still not quite sure what caused this issue. Everyone that has responded has asked questions that were answered in my first post though. Is it hard to understand what I've described so far? I really don't see why this issue has occurred at all.

Luca Garulli

unread,
May 6, 2015, 4:58:38 PM5/6/15
to orient-...@googlegroups.com
Hi Jake,
This must be a configuration problem. Try creating a Java project with all libs and you'll see that works. Sorry but I'm not a Gradle expert.

Lvc@


Best Regards,

Luca Garulli
CEO at Orient Technologies LTD
the Company behind OrientDB


Reply all
Reply to author
Forward
0 new messages