use of com.orientechnologies.orient.core.db.ODatabase in project orientdb by orientechnologies.
the class DbClosedTest method testRemoteConns.
@Test
public void testRemoteConns() {
if (!url.startsWith("remote:"))
return;
final int max = OGlobalConfiguration.NETWORK_MAX_CONCURRENT_SESSIONS.getValueAsInteger();
for (int i = 0; i < max * 2; ++i) {
final ODatabase db = new ODatabaseDocumentTx(url).open("admin", "admin");
db.close();
}
}
use of com.orientechnologies.orient.core.db.ODatabase in project orientdb by orientechnologies.
the class OIndexMultiValues method get.
public Set<OIdentifiable> get(Object key) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireSharedLock(key);
try {
acquireSharedLock();
try {
Set<OIdentifiable> values;
while (true) {
try {
values = (Set<OIdentifiable>) storage.getIndexValue(indexId, key);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
if (values == null)
return Collections.emptySet();
return Collections.unmodifiableSet(values);
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseSharedLock(key);
}
}
use of com.orientechnologies.orient.core.db.ODatabase in project orientdb by orientechnologies.
the class OIndexMultiValues method remove.
@Override
public boolean remove(Object key, final OIdentifiable value) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireExclusiveLock(key);
try {
acquireSharedLock();
try {
Set<OIdentifiable> values = null;
while (true) {
try {
values = (Set<OIdentifiable>) storage.getIndexValue(indexId, key);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
if (values == null) {
return false;
}
final OModifiableBoolean removed = new OModifiableBoolean(false);
final Callable<Object> creator = new EntityRemover(value, removed, values);
while (true) try {
storage.updateIndexEntry(indexId, key, creator);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
return removed.getValue();
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseExclusiveLock(key);
}
}
use of com.orientechnologies.orient.core.db.ODatabase in project orientdb by orientechnologies.
the class OIndexMultiValues method put.
public OIndexMultiValues put(Object key, final OIdentifiable singleValue) {
if (singleValue != null && !singleValue.getIdentity().isPersistent())
throw new IllegalArgumentException("Cannot index a non persistent record (" + singleValue.getIdentity() + ")");
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive) {
keyLockManager.acquireExclusiveLock(key);
}
try {
acquireSharedLock();
try {
if (!singleValue.getIdentity().isValid())
(singleValue.getRecord()).save();
final ORID identity = singleValue.getIdentity();
final boolean durable;
if (metadata != null && Boolean.TRUE.equals(metadata.field("durableInNonTxMode")))
durable = true;
else
durable = false;
Set<OIdentifiable> values = null;
while (true) {
try {
values = (Set<OIdentifiable>) storage.getIndexValue(indexId, key);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
final Set<OIdentifiable> cvalues = values;
final Callable<Object> creator = new Callable<Object>() {
@Override
public Object call() throws Exception {
Set<OIdentifiable> result = cvalues;
if (result == null) {
if (ODefaultIndexFactory.SBTREEBONSAI_VALUE_CONTAINER.equals(valueContainerAlgorithm)) {
result = new OIndexRIDContainer(getName(), durable);
} else {
throw new IllegalStateException("MVRBTree is not supported any more");
}
}
result.add(identity);
return result;
}
};
while (true) {
try {
storage.updateIndexEntry(indexId, key, creator);
return this;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseExclusiveLock(key);
}
}
use of com.orientechnologies.orient.core.db.ODatabase in project orientdb by orientechnologies.
the class OIndexAbstract method remove.
public boolean remove(Object key) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireExclusiveLock(key);
try {
acquireSharedLock();
try {
while (true) try {
return storage.removeKeyFromIndex(indexId, key);
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseExclusiveLock(key);
}
}
Aggregations