Skip to content

Commit

Permalink
Issue #5352 minor refactoring is performed, Javadoc is added.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii0lomakin committed Dec 29, 2015
1 parent f48231a commit 00a07a5
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 127 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,4 @@ private int getLocalNodeIndex(int nodeIndex) {

return (nodeIndex - ODirectoryFirstPage.NODES_PER_PAGE) % ODirectoryPage.NODES_PER_PAGE;
}

@Override
protected OAtomicOperation startAtomicOperation(boolean trackNonTxOperations) throws IOException {
return atomicOperationsManager.startAtomicOperation(this, trackNonTxOperations);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,6 @@ public void create(OBinarySerializer<K> keySerializer, OBinarySerializer<V> valu
}
}

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

@Override
public OBinarySerializer<K> getKeySerializer() {
acquireSharedLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,6 @@ public void create(OBinarySerializer<K> keySerializer, OBinarySerializer<V> valu
}
}

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

@Override
public OBinarySerializer<K> getKeySerializer() {
acquireSharedLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,11 +872,6 @@ public void flush() {
}
}

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

private void checkNullSupport(K key) {
if (key == null && !nullPointerSupport)
throw new OSBTreeException("Null keys are not supported.", this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,4 @@ public long getLastPosition() throws IOException {
completeOperation();
}
}

@Override
protected OAtomicOperation startAtomicOperation(boolean trackNonTxOperations) throws IOException {
return atomicOperationsManager.startAtomicOperation(this, trackNonTxOperations);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1466,11 +1466,6 @@ private void setRecordConflictStrategy(final String stringValue) {
storageLocal.getConfiguration().update();
}

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

private void updateClusterState(long sizeDiff, long recordsSizeDiff, OAtomicOperation atomicOperation) throws IOException {
final OCacheEntry pinnedStateEntry = loadPage(atomicOperation, fileId, pinnedStateEntryIndex, true);
pinnedStateEntry.acquireExclusiveLock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public OAtomicOperationsManager(OAbstractPaginatedStorage storage) {
this.storagePerformanceStatistic = storage.getStoragePerformanceStatistic();
}

/**
* @see #startAtomicOperation(String, boolean)
*/
public OAtomicOperation startAtomicOperation(ODurableComponent durableComponent, boolean trackNonTxOperations)
throws IOException {
if (durableComponent != null)
Expand All @@ -124,6 +127,27 @@ public OAtomicOperation startAtomicOperation(ODurableComponent durableComponent,
return startAtomicOperation((String) null, trackNonTxOperations);
}

/**
* Starts atomic operation inside of current thread.
* If atomic operation has been already started , current atomic operation instance will be returned.
* All durable components have to call this method at the beginning of any data modification operation.
* <p>
* In current implementation of atomic operation, each component which is participated in atomic operation is hold under exclusive
* lock till atomic operation will not be completed (committed or rollbacked).
* <p>
* If other thread is going to read data from component it has to acquire read lock inside of atomic operation manager {@link #acquireReadLock(ODurableComponent)}
* , otherwise data consistency will be compromised.
* <p>
* Atomic operation may be delayed if start of atomic operations is prohibited by call of {@link #freezeAtomicOperations(Class, String)}
* method. If mentioned above method is called then execution of current method will be stopped till call of {@link #releaseAtomicOperations(long)}
* method or exception will be thrown. Concrete behaviour depends on real values of parameters of {@link #freezeAtomicOperations(Class, String)} method.
*
* @param trackNonTxOperations If this flag set to <code>true</code> then special record {@link ONonTxOperationPerformedWALRecord} will be added to
* WAL in case of atomic operation is started outside of active storage transaction. During storage restore procedure
* this record is monitored and if given record is present then rebuild of all indexes is performed.
* @param fullName Name of component which is going participate in atomic operation.
* @return Instance of active atomic operation.
*/
public OAtomicOperation startAtomicOperation(String fullName, boolean trackNonTxOperations) throws IOException {
if (writeAheadLog == null)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ protected void endAtomicOperation(boolean rollback, Exception e) throws IOExcept
atomicOperationsManager.endAtomicOperation(rollback, e);
}

/**
* @see OAtomicOperationsManager#startAtomicOperation(com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurableComponent, boolean)
*/
protected OAtomicOperation startAtomicOperation(boolean trackNonTxOperations) throws IOException {
return atomicOperationsManager.startAtomicOperation(this, trackNonTxOperations);
}
Expand Down

0 comments on commit 00a07a5

Please sign in to comment.