private ORawBuffer readRecord(final OCluster clusterSegment, final ORecordId rid, final boolean prefetchRecords) { checkOpenness(); if (!rid.isPersistent()) { throw new ORecordNotFoundException(rid, "Cannot read record " + rid + " since the position is invalid in database '" + name + '\''); } if (transaction.get() != null) { // Disabled this assert have no meaning anymore // assert iLockingStrategy.equals(LOCKING_STRATEGY.DEFAULT); return doReadRecord(clusterSegment, rid, prefetchRecords); } stateLock.acquireReadLock(); try { if (pessimisticLock) { acquireReadLock(rid); } checkOpenness(); return doReadRecord(clusterSegment, rid, prefetchRecords); } finally { try { if (pessimisticLock) { releaseReadLock(rid); } } finally { stateLock.releaseReadLock(); } } }
private ORawBuffer readRecordIfNotLatest(final OCluster cluster, final ORecordId rid, final int recordVersion) throws ORecordNotFoundException { checkOpenness(); if (!rid.isPersistent()) { throw new ORecordNotFoundException(rid, "Cannot read record " + rid + " since the position is invalid in database '" + name + '\''); } if (transaction.get() != null) { return doReadRecordIfNotLatest(cluster, rid, recordVersion); } stateLock.acquireReadLock(); try { if (pessimisticLock) { acquireReadLock(rid); } final ORawBuffer buff; checkOpenness(); buff = doReadRecordIfNotLatest(cluster, rid, recordVersion); return buff; } finally { try { if (pessimisticLock) { releaseReadLock(rid); } } finally { stateLock.releaseReadLock(); } } }
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(); } }