OrientGraphFactory best practice?

67 views
Skip to first unread message

hihim...@gmail.com

unread,
Oct 26, 2014, 2:08:18 PM10/26/14
to orient-...@googlegroups.com
Hi,

I have the following setup

User -> MultiplayerServer -> OrientDBServer

MultiplayerServer is the one that always connects to OrientDBServer, currently to connect to the database Im always doing the following:

try {

OrientGraphFactory orientDBfactory = new OrientGraphFactory(Constants.orientDBURL, x, y).setupPool(1,50);
OrientGraph graph = orientDBfactory.getTx();
Vertex vMode= graph.getVertex("#17:3");
vMode
.setProperty("stuff", "stuffValue");
graph
.commit();

} catch (Exception e) {
     
System.out.println("ERROR: " + e.toString());
     
if (graph != null) {
graph.rollback();
}
orientDBfactory.close();
} finally {
if (graph != (null)) {
graph.shutdown();
}
orientDBfactory.close();
}


My question is, do I create and close each time a OrientGraphFactory? or should I do that only once (at server startup) and leave it open?

thanks a bunch!

Keith Freeman

unread,
Oct 26, 2014, 2:59:48 PM10/26/14
to orient-...@googlegroups.com
You only need to create the factory once, then use getTx() as many times as you like.  Be sure to do the graph.shutdown() to "release" the OrientGraph instance, but DON'T close the factory until your app is ready to exit.

hihim...@gmail.com

unread,
Oct 27, 2014, 7:40:01 AM10/27/14
to orient-...@googlegroups.com
Hi Keith,

Thanks a lot :) that clears many things. I've got another small question about pools, should I keep track of current Pool to close/make new openGraph ?

if (Constants.orientDBfactory.getCreatedInstancesInPool() >= (10)) {
Constants.orientDBfactory.close();
Constants.orientDBfactory = new OrientGraphFactory(Constants.orientDBURL, x, y).setupPool(1, 10);
}

or is this completely unnecessary?

Keith Freeman

unread,
Oct 27, 2014, 8:41:20 AM10/27/14
to orient-...@googlegroups.com
We don't do that, but I can't say whether it's a good idea or not.  Hopefully one of the orient guys will chime in.
Reply all
Reply to author
Forward
0 new messages