use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException in project orientdb by orientechnologies.
the class OIndexAbstract method contains.
public boolean contains(Object key) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireSharedLock(key);
try {
acquireSharedLock();
try {
assert indexId >= 0;
while (true) try {
return storage.indexContainsKey(indexId, key);
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseSharedLock(key);
}
}
use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException in project orientdb by orientechnologies.
the class OIndexAbstract method create.
/**
* Creates the index.
*
* @param clusterIndexName Cluster name where to place the TreeMap
* @param clustersToIndex
* @param rebuild
* @param progressListener
* @param valueSerializer
*/
public OIndexInternal<?> create(final OIndexDefinition indexDefinition, final String clusterIndexName, final Set<String> clustersToIndex, boolean rebuild, final OProgressListener progressListener, final OBinarySerializer valueSerializer) {
acquireExclusiveLock();
try {
configuration = indexConfigurationInstance(new ODocument().setTrackingChanges(false));
this.indexDefinition = indexDefinition;
if (clustersToIndex != null)
this.clustersToIndex = new HashSet<String>(clustersToIndex);
else
this.clustersToIndex = new HashSet<String>();
// do not remove this, it is needed to remove index garbage if such one exists
try {
removeValuesContainer();
} catch (Exception e) {
OLogManager.instance().error(this, "Error during deletion of index '%s'", name);
}
final Boolean durableInNonTxMode = isDurableInNonTxMode();
indexId = storage.addIndexEngine(name, algorithm, type, indexDefinition, valueSerializer, isAutomatic(), durableInNonTxMode, version, getEngineProperties(), clustersToIndex, metadata);
assert indexId >= 0;
onIndexEngineChange(indexId);
if (rebuild)
fillIndex(progressListener);
updateConfiguration();
} catch (Exception e) {
OLogManager.instance().error(this, "Exception during index '%s' creation", e, name);
while (true) try {
if (indexId >= 0)
storage.deleteIndexEngine(indexId);
break;
} catch (OInvalidIndexEngineIdException ex) {
doReloadIndexEngine();
} catch (Exception ex) {
OLogManager.instance().error(this, "Exception during index '%s' deletion", ex, name);
}
if (e instanceof OIndexException)
throw (OIndexException) e;
throw OException.wrapException(new OIndexException("Cannot create the index '" + name + "'"), e);
} finally {
releaseExclusiveLock();
}
return this;
}
use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException 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);
}
}
use of com.orientechnologies.orient.core.exception.OInvalidIndexEngineIdException 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.exception.OInvalidIndexEngineIdException 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);
}
}
Aggregations