reduced lock span on remote OrientDB context
@@ -142,12 +142,13 @@ public class OrientDBRemote implements OrientDBInternal {
}
@Override
- public synchronized ODatabaseDocumentInternal open(
+ public ODatabaseDocumentInternal open(
String name, String user, String password, OrientDBConfig config) {
checkOpen();
OrientDBConfig resolvedConfig = solveConfig(config);
try {
OStorageRemote storage;
+ synchronized (this) {
storage = storages.get(name);
if (storage == null) {
storage =
@@ -155,6 +156,7 @@ public class OrientDBRemote implements OrientDBInternal {
hosts, name, this, "rw", connectionManager, resolvedConfig, connectionNext);
storages.put(name, storage);
}
+ }
ODatabaseDocumentRemote db = new ODatabaseDocumentRemote(storage);
db.internalOpen(user, password, resolvedConfig, getOrCreateSharedContext(storage));
return db;
@@ -206,9 +208,11 @@ public class OrientDBRemote implements OrientDBInternal {
executeServerStatement(create, user, password, parameters);
}
- public synchronized ODatabaseDocumentRemotePooled poolOpen(
+ public ODatabaseDocumentRemotePooled poolOpen(
String name, String user, String password, ODatabasePoolInternal pool) {
- OStorageRemote storage = storages.get(name);
+ OStorageRemote storage;
+ synchronized (this) {
+ storage = storages.get(name);
if (storage == null) {
try {
storage =
@@ -226,6 +230,7 @@ public class OrientDBRemote implements OrientDBInternal {
new ODatabaseException("Cannot open database '" + name + "'"), e);
}
}
+ }
ODatabaseDocumentRemotePooled db = new ODatabaseDocumentRemotePooled(pool, storage);
db.internalOpen(user, password, pool.getConfig(), getOrCreateSharedContext(storage));
return db;
