tkalkirill commented on code in PR #1506: URL: https://github.com/apache/ignite-3/pull/1506#discussion_r1072250057
########## modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/sorted/PageMemorySortedIndexStorage.java: ########## @@ -105,71 +102,65 @@ public SortedIndexDescriptor indexDescriptor() { @Override public Cursor<RowId> get(BinaryTuple key) throws StorageException { - if (!closeBusyLock.enterBusy()) { - throwStorageClosedException(); - } + return busy(() -> { + throwExceptionIfStorageInProgressOfRebalance(state.get(), this::createStorageInfo); - try { - SortedIndexRowKey lowerBound = toSortedIndexRow(key, lowestRowId); + try { + SortedIndexRowKey lowerBound = toSortedIndexRow(key, lowestRowId); - SortedIndexRowKey upperBound = toSortedIndexRow(key, highestRowId); + SortedIndexRowKey upperBound = toSortedIndexRow(key, highestRowId); - return convertCursor(sortedIndexTree.find(lowerBound, upperBound), SortedIndexRow::rowId); - } catch (IgniteInternalCheckedException e) { - throw new StorageException("Failed to create scan cursor", e); - } finally { - closeBusyLock.leaveBusy(); - } + return convertCursor(sortedIndexTree.find(lowerBound, upperBound), SortedIndexRow::rowId); + } catch (IgniteInternalCheckedException e) { + throw new StorageException("Failed to create scan cursor", e); + } + }); } @Override public void put(IndexRow row) { - if (!closeBusyLock.enterBusy()) { - throwStorageClosedException(); - } + busy(() -> { + try { + SortedIndexRow sortedIndexRow = toSortedIndexRow(row.indexColumns(), row.rowId()); - try { - SortedIndexRow sortedIndexRow = toSortedIndexRow(row.indexColumns(), row.rowId()); + var insert = new InsertSortedIndexRowInvokeClosure(sortedIndexRow, freeList, sortedIndexTree.inlineSize()); - var insert = new InsertSortedIndexRowInvokeClosure(sortedIndexRow, freeList, sortedIndexTree.inlineSize()); + sortedIndexTree.invoke(sortedIndexRow, null, insert); - sortedIndexTree.invoke(sortedIndexRow, null, insert); - } catch (IgniteInternalCheckedException e) { - throw new StorageException("Failed to put value into index", e); - } finally { - closeBusyLock.leaveBusy(); - } + return null; + } catch (IgniteInternalCheckedException e) { + throw new StorageException("Failed to put value into index", e); + } + }); } @Override public void remove(IndexRow row) { - if (!closeBusyLock.enterBusy()) { - throwStorageClosedException(); - } + busy(() -> { Review Comment: Tried to fix it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org