ODatabaseDocument conn = null;
try {
conn = new ODatabaseDocumentTx(dbName).open(username, password);
// do stuff
} finally{
conn.close();
}
--
---
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/groups/opt_out.
@Schedule(minute="*/10", hour="*")
public void automaticRestart() {
logger.info("Restarting orient client connections");
Orient.instance().shutdown();
Orient.instance().startup();
}
With this approach the connections are successfully reset and the threads decrease as expected. The only drawback is that during the restart operation any ongoing request using a connection fails. Could you please tell me if there is a way to execute the restart only when all the connections are inactive?
Thanks,
Fabrizio
synchronized (this) {
db0 = new ODatabaseDocumentTx(dbName).open(username, password);
}
db0.registerListener(this);
@Override
public void onClose(ODatabase iDatabase) {
synchronized (this) {
OStorage storage = iDatabase.getStorage();
if (storage.getUsers() <= 1) {
LOGGER.debug("Closing database storage {}", storage);
storage.close(true);
}
}
}