Skip to content

Commit

Permalink
Issue #2029 was fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
laa committed Oct 17, 2015
1 parent cdbf8ef commit 53ad211
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 102 deletions.
Expand Up @@ -27,7 +27,6 @@
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.index.OIndexEngineException;
import com.orientechnologies.orient.core.storage.cache.OReadCache;
import com.orientechnologies.orient.core.index.sbtree.local.OSBTreeException;
import com.orientechnologies.orient.core.storage.cache.OWriteCache;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
import com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation;
Expand Down Expand Up @@ -83,7 +82,7 @@ private long resolveFileIdByName(String fileName) {
.getUnderlying();
final OAtomicOperation atomicOperation;
try {
atomicOperation = storage.getAtomicOperationsManager().startAtomicOperation(fileName, true);
atomicOperation = storage.getAtomicOperationsManager().startAtomicOperation(fileName);
} catch (IOException e) {
throw OException.wrapException(new OIndexEngineException("Error creation of sbtree with name " + fileName, fileName), e);
}
Expand Down Expand Up @@ -252,7 +251,7 @@ public void checkNotEmbedded() {

private void convertToSbTree() {
final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get();
final OIndexRIDContainerSBTree tree = new OIndexRIDContainerSBTree(fileId, durableNonTxMode, (OAbstractPaginatedStorage) db
final OIndexRIDContainerSBTree tree = new OIndexRIDContainerSBTree(fileId, (OAbstractPaginatedStorage) db
.getStorage().getUnderlying());

tree.addAll(underlying);
Expand Down
Expand Up @@ -48,7 +48,7 @@ public class OIndexRIDContainerSBTree implements Set<OIdentifiable> {

protected static final OProfiler PROFILER = Orient.instance().getProfiler();

public OIndexRIDContainerSBTree(long fileId, boolean durableMode, OAbstractPaginatedStorage storage) {
public OIndexRIDContainerSBTree(long fileId, OAbstractPaginatedStorage storage) {
String fileName;

OAtomicOperation atomicOperation = storage.getAtomicOperationsManager().getCurrentOperation();
Expand All @@ -58,7 +58,7 @@ public OIndexRIDContainerSBTree(long fileId, boolean durableMode, OAbstractPagin
fileName = atomicOperation.fileNameById(fileId);

tree = new OSBTreeBonsaiLocal<OIdentifiable, Boolean>(fileName.substring(0, fileName.length() - INDEX_FILE_EXTENSION.length()),
INDEX_FILE_EXTENSION, durableMode, storage);
INDEX_FILE_EXTENSION, storage);

tree.create(OLinkSerializer.INSTANCE, OBooleanSerializer.INSTANCE);
}
Expand All @@ -74,13 +74,13 @@ public OIndexRIDContainerSBTree(long fileId, OBonsaiBucketPointer rootPointer, b
fileName = atomicOperation.fileNameById(fileId);

tree = new OSBTreeBonsaiLocal<OIdentifiable, Boolean>(fileName.substring(0, fileName.length() - INDEX_FILE_EXTENSION.length()),
INDEX_FILE_EXTENSION, durableMode, storage);
INDEX_FILE_EXTENSION, storage);
tree.load(rootPointer);
}

public OIndexRIDContainerSBTree(String file, OBonsaiBucketPointer rootPointer, boolean durableMode,
OAbstractPaginatedStorage storage) {
tree = new OSBTreeBonsaiLocal<OIdentifiable, Boolean>(file, INDEX_FILE_EXTENSION, durableMode, storage);
tree = new OSBTreeBonsaiLocal<OIdentifiable, Boolean>(file, INDEX_FILE_EXTENSION, storage);
tree.load(rootPointer);
}

Expand Down
Expand Up @@ -28,8 +28,6 @@
import com.orientechnologies.orient.core.OOrientShutdownListener;
import com.orientechnologies.orient.core.OOrientStartupListener;
import com.orientechnologies.orient.core.Orient;
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal;
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.db.record.ridbag.ORidBag;
import com.orientechnologies.orient.core.index.sbtreebonsai.local.OSBTreeBonsai;
Expand Down Expand Up @@ -88,7 +86,7 @@ public OBonsaiCollectionPointer createSBTree(int clusterId, UUID ownerUUID) {
protected OSBTreeBonsaiLocal<OIdentifiable, Integer> createTree(int clusterId) {

OSBTreeBonsaiLocal<OIdentifiable, Integer> tree = new OSBTreeBonsaiLocal<OIdentifiable, Integer>(FILE_NAME_PREFIX + clusterId,
DEFAULT_EXTENSION, true, storage);
DEFAULT_EXTENSION, storage);
tree.create(OLinkSerializer.INSTANCE, OIntegerSerializer.INSTANCE);

return tree;
Expand All @@ -105,7 +103,7 @@ protected OSBTreeBonsai<OIdentifiable, Integer> loadTree(OBonsaiCollectionPointe
}

OSBTreeBonsaiLocal<OIdentifiable, Integer> tree = new OSBTreeBonsaiLocal<OIdentifiable, Integer>(fileName.substring(0,
fileName.length() - DEFAULT_EXTENSION.length()), DEFAULT_EXTENSION, true, storage);
fileName.length() - DEFAULT_EXTENSION.length()), DEFAULT_EXTENSION, storage);

tree.load(collectionPointer.getRootPointer());

Expand Down
Expand Up @@ -24,7 +24,6 @@
import com.orientechnologies.common.serialization.types.OByteSerializer;
import com.orientechnologies.common.serialization.types.OLongSerializer;
import com.orientechnologies.orient.core.exception.OHashTableDirectoryException;
import com.orientechnologies.orient.core.exception.OStorageException;
import com.orientechnologies.orient.core.storage.cache.OCacheEntry;
import com.orientechnologies.orient.core.storage.cache.OCachePointer;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
Expand Down Expand Up @@ -605,6 +604,6 @@ private int getLocalNodeIndex(int nodeIndex) {

@Override
protected OAtomicOperation startAtomicOperation() throws IOException {
return atomicOperationsManager.startAtomicOperation(this, !durableInNonTxMode);
return atomicOperationsManager.startAtomicOperation(this);
}
}
Expand Up @@ -7,7 +7,6 @@
import com.orientechnologies.orient.core.exception.OStorageException;
import com.orientechnologies.orient.core.index.OIndexException;
import com.orientechnologies.orient.core.storage.cache.OCacheEntry;
import com.orientechnologies.orient.core.index.sbtree.local.OSBTreeException;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.serialization.serializer.binary.OBinarySerializerFactory;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
Expand Down Expand Up @@ -196,7 +195,7 @@ public void create(OBinarySerializer<K> keySerializer, OBinarySerializer<V> valu

@Override
protected OAtomicOperation startAtomicOperation() throws IOException {
return atomicOperationsManager.startAtomicOperation(this, !durableInNonTxMode);
return atomicOperationsManager.startAtomicOperation(this);
}

@Override
Expand Down
Expand Up @@ -22,14 +22,11 @@
import com.orientechnologies.common.exception.OException;
import com.orientechnologies.common.serialization.types.OBinarySerializer;
import com.orientechnologies.common.util.OCommonConst;
import com.orientechnologies.orient.core.exception.OLocalHashTableException;
import com.orientechnologies.orient.core.exception.OStorageException;
import com.orientechnologies.orient.core.index.OIndexEngineException;
import com.orientechnologies.orient.core.index.OIndexException;
import com.orientechnologies.orient.core.storage.cache.OCacheEntry;
import com.orientechnologies.orient.core.index.sbtree.local.OSBTreeException;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.serialization.serializer.binary.OBinarySerializerFactory;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
import com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation;
import com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurableComponent;
Expand Down Expand Up @@ -212,7 +209,7 @@ public void create(OBinarySerializer<K> keySerializer, OBinarySerializer<V> valu

@Override
protected OAtomicOperation startAtomicOperation() throws IOException {
return atomicOperationsManager.startAtomicOperation(this, !durableInNonTxMode);
return atomicOperationsManager.startAtomicOperation(this);
}

@Override
Expand Down
Expand Up @@ -37,11 +37,9 @@
import com.orientechnologies.orient.core.index.OAlwaysGreaterKey;
import com.orientechnologies.orient.core.index.OAlwaysLessKey;
import com.orientechnologies.orient.core.index.OCompositeKey;
import com.orientechnologies.orient.core.index.OIndexException;
import com.orientechnologies.orient.core.iterator.OEmptyIterator;
import com.orientechnologies.orient.core.iterator.OEmptyMapEntryIterator;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.serialization.serializer.stream.OStreamSerializer;
import com.orientechnologies.orient.core.storage.cache.OCacheEntry;
import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage;
import com.orientechnologies.orient.core.storage.impl.local.paginated.atomicoperations.OAtomicOperation;
Expand Down Expand Up @@ -785,7 +783,7 @@ public void flush() {

@Override
protected OAtomicOperation startAtomicOperation() throws IOException {
return atomicOperationsManager.startAtomicOperation(this, !durableInNonTxMode);
return atomicOperationsManager.startAtomicOperation(this);
}

private void checkNullSupport(K key) {
Expand Down
Expand Up @@ -79,12 +79,8 @@ public class OSBTreeBonsaiLocal<K, V> extends ODurableComponent implements OSBTr
private OBinarySerializer<K> keySerializer;
private OBinarySerializer<V> valueSerializer;

private final boolean durableInNonTxMode;

public OSBTreeBonsaiLocal(String name, String dataFileExtension, boolean durableInNonTxMode, OAbstractPaginatedStorage storage) {
public OSBTreeBonsaiLocal(String name, String dataFileExtension, OAbstractPaginatedStorage storage) {
super(storage, name, dataFileExtension);

this.durableInNonTxMode = durableInNonTxMode;
}

public void create(OBinarySerializer<K> keySerializer, OBinarySerializer<V> valueSerializer) {
Expand Down Expand Up @@ -566,11 +562,6 @@ public V remove(K key) {
}
}

@Override
protected OAtomicOperation startAtomicOperation() throws IOException {
return atomicOperationsManager.startAtomicOperation(this, !durableInNonTxMode);
}

@Override
public Collection<V> getValuesMinor(K key, boolean inclusive, final int maxValuesToFetch) {
final List<V> result = new ArrayList<V>();
Expand Down
Expand Up @@ -1543,7 +1543,7 @@ private <T> T doCallIndexEngine(boolean atomicOperation, boolean readOperation,
checkIndexId(indexId);
try {
if (atomicOperation)
atomicOperationsManager.startAtomicOperation((String) null, false);
atomicOperationsManager.startAtomicOperation((String) null);
} catch (IOException e) {
throw OException.wrapException(new OStorageException("Can not put key value entry in index"), e);
}
Expand Down Expand Up @@ -1575,7 +1575,7 @@ private <T> T doCallIndexEngine(boolean atomicOperation, boolean readOperation,

private void doUpdateIndexEntry(int indexId, Object key, Callable<Object> valueCreator) {
try {
atomicOperationsManager.startAtomicOperation((String) null, false);
atomicOperationsManager.startAtomicOperation((String) null);
} catch (IOException e) {
throw OException.wrapException(new OStorageException("Can not put key value entry in index"), e);
}
Expand Down Expand Up @@ -2684,12 +2684,13 @@ public OLogSequenceNumber incrementalBackup(final OutputStream stream, final OLo
Charset.forName(configuration.getCharset()));
try {
final long startSegment;
final long newSegmentFreezeId = atomicOperationsManager.freezeAtomicOperations(null, null);

final long newSegmentFreezeId = atomicOperationsManager.freezeAtomicOperations(null, null);
try {
writeAheadLog.newSegment();
final OLogSequenceNumber startLsn = writeAheadLog.end();
writeAheadLog.preventCutTill(startLsn);

writeAheadLog.newSegment();
startSegment = writeAheadLog.activeSegment();
} finally {
atomicOperationsManager.releaseAtomicOperations(newSegmentFreezeId);
Expand Down Expand Up @@ -2737,7 +2738,7 @@ protected abstract OLogSequenceNumber copyWALToIncrementalBackup(ZipOutputStream

protected abstract boolean isWritesAllowedDuringBackup();

private OLogSequenceNumber backupPagesWithChanges(OLogSequenceNumber changeLsn, ZipOutputStream stream) throws IOException {
private OLogSequenceNumber backupPagesWithChanges(final OLogSequenceNumber changeLsn, ZipOutputStream stream) throws IOException {
OLogSequenceNumber lastLsn = changeLsn;

final Map<String, Long> files = writeCache.files();
Expand Down Expand Up @@ -2911,7 +2912,7 @@ public void restoreFromIncrementalBackup(final InputStream inputStream, final bo
if (!writeCache.fileIdsAreEqual(expectedFileId, fileId))
throw new OStorageException("Can not restore database from backup because expected and actual file ids are not the same");

while (zipInputStream.available() > 0) {
while (true) {
final byte[] data = new byte[pageSize + OLongSerializer.LONG_SIZE];

int rb = 0;
Expand All @@ -2923,6 +2924,9 @@ public void restoreFromIncrementalBackup(final InputStream inputStream, final bo
if (rb > 0)
throw new OStorageException("Can not read data from file " + zipEntry.getName());
else {
if (isClosed)
readCache.closeFile(fileId, true, writeCache);

processedFiles.add(zipEntry.getName());
continue entryLoop;
}
Expand Down Expand Up @@ -2971,11 +2975,6 @@ public void restoreFromIncrementalBackup(final InputStream inputStream, final bo
readCache.release(cacheEntry, writeCache);
}
}

if (isClosed)
readCache.closeFile(fileId, true, writeCache);

processedFiles.add(zipEntry.getName());
}

currentFiles.removeAll(processedFiles);
Expand Down Expand Up @@ -3030,7 +3029,7 @@ private void replaceConfiguration(ZipInputStream zipInputStream) throws IOExcept
byte[] buffer = new byte[1024];

int rb = 0;
while (zipInputStream.available() > 0) {
while (true) {
final int b = zipInputStream.read(buffer, rb, buffer.length - rb);

if (b == -1)
Expand Down Expand Up @@ -3234,7 +3233,7 @@ private void startStorageTx(OTransaction clientTx) throws IOException {

transaction.set(new OStorageTransaction(clientTx));
try {
atomicOperationsManager.startAtomicOperation((String) null, false);
atomicOperationsManager.startAtomicOperation((String) null);
} catch (RuntimeException e) {
transaction.set(null);
throw e;
Expand Down Expand Up @@ -3276,7 +3275,7 @@ private OStorageOperationResult<OPhysicalPosition> doCreateRecord(ORecordId rid,
recordVersion = OVersionFactory.instance().createVersion();

makeStorageDirty();
atomicOperationsManager.startAtomicOperation((String) null, false);
atomicOperationsManager.startAtomicOperation((String) null);
try {
ppos = cluster.createRecord(content, recordVersion, recordType);
rid.clusterPosition = ppos.clusterPosition;
Expand Down Expand Up @@ -3351,7 +3350,7 @@ private OStorageOperationResult<ORecordVersion> doUpdateRecord(ORecordId rid, bo
}

makeStorageDirty();
atomicOperationsManager.startAtomicOperation((String) null, false);
atomicOperationsManager.startAtomicOperation((String) null);
try {
if (updateContent)
cluster.updateRecord(rid.clusterPosition, content, ppos.recordVersion, recordType);
Expand Down Expand Up @@ -3409,7 +3408,7 @@ private OStorageOperationResult<Boolean> doDeleteRecord(ORecordId rid, ORecordVe
throw new OConcurrentModificationException(rid, ppos.recordVersion, version, ORecordOperation.DELETED);

makeStorageDirty();
atomicOperationsManager.startAtomicOperation((String) null, false);
atomicOperationsManager.startAtomicOperation((String) null);
try {
cluster.deleteRecord(ppos.clusterPosition);

Expand Down Expand Up @@ -3442,7 +3441,7 @@ private OStorageOperationResult<Boolean> doHideMethod(ORecordId rid, OCluster cl
return new OStorageOperationResult<Boolean>(false);

makeStorageDirty();
atomicOperationsManager.startAtomicOperation((String) null, false);
atomicOperationsManager.startAtomicOperation((String) null);
try {
cluster.hideRecord(ppos.clusterPosition);

Expand Down Expand Up @@ -4234,6 +4233,7 @@ protected void restoreAtomicUnit(List<OWALRecord> atomicUnit, OModifiableBoolean

final long pageIndex = updatePageRecord.getPageIndex();
fileId = readCache.openFile(fileId, writeCache);
String fileName = writeCache.fileNameById(fileId);

OCacheEntry cacheEntry = readCache.load(fileId, pageIndex, true, writeCache, 0);
if (cacheEntry == null) {
Expand Down
Expand Up @@ -548,6 +548,6 @@ public long getLastPosition() throws IOException {

@Override
protected OAtomicOperation startAtomicOperation() throws IOException {
return atomicOperationsManager.startAtomicOperation(this, !useWal);
return atomicOperationsManager.startAtomicOperation(this);
}
}
Expand Up @@ -201,9 +201,9 @@ protected OLogSequenceNumber copyWALToIncrementalBackup(ZipOutputStream zipOutpu
OLogSequenceNumber lastLSN;
long freezeId = getAtomicOperationsManager().freezeAtomicOperations(null, null);
try {
lastLSN = writeAheadLog.end();
writeAheadLog.newSegment();
nonActiveSegments = writeAheadLog.nonActiveSegments(startSegment);
lastLSN = writeAheadLog.end();
} finally {
getAtomicOperationsManager().releaseAtomicOperations(freezeId);
}
Expand Down
Expand Up @@ -1328,7 +1328,7 @@ private void setRecordConflictStrategy(final String stringValue) {

@Override
protected OAtomicOperation startAtomicOperation() throws IOException {
return atomicOperationsManager.startAtomicOperation(this, !config.useWal);
return atomicOperationsManager.startAtomicOperation(this);
}

private void updateClusterState(long sizeDiff, long recordsSizeDiff, OAtomicOperation atomicOperation) throws IOException {
Expand Down

0 comments on commit 53ad211

Please sign in to comment.