private OIndex<?> createDictionaryIfNeeded() { acquireExclusiveLock(); try { OIndex<?> idx = getIndex(DICTIONARY_NAME); return idx != null ? idx : createDictionary(); } finally { releaseExclusiveLock(); } }
public ODictionary<ORecord> getDictionary() { OIndex<?> idx; acquireSharedLock(); try { idx = getIndex(DICTIONARY_NAME); } finally { releaseSharedLock(); } // we lock exclusively only when ODictionary not found if (idx == null) { idx = createDictionaryIfNeeded(); } return new ODictionary<>((OIndex<OIdentifiable>) idx); }
@Override public void addClusterToIndex(String clusterName, String indexName) { delegate.addClusterToIndex(clusterName, indexName); }
public void setDefaultClusterName(final String defaultClusterName) { acquireExclusiveLock(); try { this.defaultClusterName = defaultClusterName; } finally { releaseExclusiveLock(); } }
public ODocument getConfiguration() { acquireSharedLock(); try { return getDocument(); } finally { releaseSharedLock(); } }
void addIndexInternal(final OIndex<?> index) { acquireExclusiveLock(); try { final Locale locale = getServerLocale(); indexes.put(index.getName(), index); return; Map<OMultiKey, Set<OIndex<?>>> propertyIndex = getIndexOnProperty(indexDefinition.getClassName()); classPropertyIndex.put(indexDefinition.getClassName().toLowerCase(locale), copyPropertyMap(propertyIndex)); } finally { releaseExclusiveLock();
@Override public Object call() { acquireExclusiveLock(); try { boolean saved = false; for (int retry = 0; retry < 10; retry++) try { toStream(); document.save(); saved = true; break; } catch (OConcurrentModificationException e) { OLogManager.instance().debug(this, "concurrent modification while saving index manager configuration", e); reload(null, true); } if (!saved) OLogManager.instance().error(this, "failed to save the index manager configuration after 10 retries", null); return null; } finally { releaseExclusiveLock(); } } });
public OIndexManagerAbstract load(ODatabaseDocumentInternal database) { if (!autoRecreateIndexesAfterCrash(database)) { acquireExclusiveLock(); try { if (database.getStorage().getConfiguration().getIndexMgrRecordId() == null) // @COMPATIBILITY: CREATE THE INDEX MGR create(database); // RELOAD IT ((ORecordId) document.getIdentity()).fromString(database.getStorage().getConfiguration().getIndexMgrRecordId()); super.reload("*:-1 index:0"); } finally { releaseExclusiveLock(); } } return this; }
public void create(ODatabaseDocumentInternal database) { acquireExclusiveLock(); try { try { save(OMetadataDefault.CLUSTER_INTERNAL_NAME); } catch (Exception e) { OLogManager.instance().error(this, "Error during storing of index manager metadata," + " will try to allocate new document to store index manager metadata", e); // RESET RID TO ALLOCATE A NEW ONE if (ORecordId.isPersistent(document.getIdentity().getClusterPosition())) { document.getIdentity().reset(); save(OMetadataDefault.CLUSTER_INTERNAL_NAME); } } database.getStorage().setIndexMgrRecordId(document.getIdentity().toString()); OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.DICTIONARY.toString(), null); createIndex(DICTIONARY_NAME, OClass.INDEX_TYPE.DICTIONARY.toString(), new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.STRING), null, null, null); } finally { releaseExclusiveLock(); } }
@Override public void fromStream(ODocument iDocument) { //This is the only case where the write locking make sense enabling it using super super.acquireExclusiveLock(); try { super.fromStream(iDocument); } finally { super.releaseExclusiveLock(); } }
private Map<OMultiKey, Set<OIndex<?>>> getIndexOnProperty(final String className) { final Locale locale = getServerLocale(); acquireSharedLock(); try { return classPropertyIndex.get(className.toLowerCase(locale)); } finally { releaseSharedLock(); } } }
public String getDefaultClusterName() { acquireSharedLock(); try { return defaultClusterName; } finally { releaseSharedLock(); } }
public boolean areIndexed(final String className, final Collection<String> fields) { return delegate.areIndexed(className, fields); }
public void create() { delegate.create(database); }
@Override public boolean autoRecreateIndexesAfterCrash() { return delegate.autoRecreateIndexesAfterCrash(database); }
@Override public synchronized void close() { schema.close(); security.close(false); indexManager.close(); functionLibrary.close(); scheduler.close(); sequenceLibrary.close(); commandCache.shutdown(); statementCache.clear(); executionPlanCache.invalidate(); liveQueryOps.close(); liveQueryOpsV2.close(); activeDistributedQueries.values().forEach(x -> x.close()); }
void clearMetadata() { acquireExclusiveLock(); try { indexes.clear(); classPropertyIndex.clear(); } finally { releaseExclusiveLock(); } }
public boolean areIndexed(final String className, final String... fields) { return delegate.areIndexed(className, fields); }
public synchronized void create(ODatabaseDocumentInternal database) { schema.create(database); indexManager.create(database); security.create(); functionLibrary.create(database); sequenceLibrary.create(database); security.createClassTrigger(); scheduler.create(database); schema.forceSnapshot(database); // CREATE BASE VERTEX AND EDGE CLASSES schema.createClass(database, "V"); schema.createClass(database, "E"); //create geospatial classes try { OIndexFactory factory = OIndexes.getFactory(OClass.INDEX_TYPE.SPATIAL.toString(), "LUCENE"); if (factory != null && factory instanceof ODatabaseLifecycleListener) { ((ODatabaseLifecycleListener) factory).onCreate(database); } } catch (OIndexException x) { //the index does not exist } loaded = true; }
@Override public OIndexManagerAbstract reload() { acquireExclusiveLock(); try { return super.reload(); } finally { releaseExclusiveLock(); } }