tkalkirill commented on code in PR #1506: URL: https://github.com/apache/ignite-3/pull/1506#discussion_r1072249213
########## modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/hash/PageMemoryHashIndexStorage.java: ########## @@ -97,100 +93,88 @@ public HashIndexDescriptor indexDescriptor() { @Override public Cursor<RowId> get(BinaryTuple key) throws StorageException { - if (!closeBusyLock.enterBusy()) { - throwStorageClosedException(); - } + return busy(() -> { Review Comment: Tried to fix it. ########## modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/index/hash/PageMemoryHashIndexStorage.java: ########## @@ -97,100 +93,88 @@ public HashIndexDescriptor indexDescriptor() { @Override public Cursor<RowId> get(BinaryTuple key) throws StorageException { - if (!closeBusyLock.enterBusy()) { - throwStorageClosedException(); - } + return busy(() -> { + throwExceptionIfStorageInProgressOfRebalance(state.get(), this::createStorageInfo); - try { - IndexColumns indexColumns = new IndexColumns(partitionId, key.byteBuffer()); + try { + IndexColumns indexColumns = new IndexColumns(partitionId, key.byteBuffer()); - HashIndexRow lowerBound = new HashIndexRow(indexColumns, lowestRowId); - HashIndexRow upperBound = new HashIndexRow(indexColumns, highestRowId); + HashIndexRow lowerBound = new HashIndexRow(indexColumns, lowestRowId); + HashIndexRow upperBound = new HashIndexRow(indexColumns, highestRowId); - Cursor<HashIndexRow> cursor = hashIndexTree.find(lowerBound, upperBound); + Cursor<HashIndexRow> cursor = hashIndexTree.find(lowerBound, upperBound); - return new Cursor<>() { - @Override - public void close() { - cursor.close(); - } - - @Override - public boolean hasNext() { - if (!closeBusyLock.enterBusy()) { - throwStorageClosedException(); + return new Cursor<RowId>() { + @Override + public void close() { + cursor.close(); } - try { - return cursor.hasNext(); - } finally { - closeBusyLock.leaveBusy(); - } - } + @Override + public boolean hasNext() { + return busy(() -> { + throwExceptionIfStorageInProgressOfRebalance(state.get(), PageMemoryHashIndexStorage.this::createStorageInfo); - @Override - public RowId next() { - if (!closeBusyLock.enterBusy()) { - throwStorageClosedException(); + return cursor.hasNext(); + }); } - try { - return cursor.next().rowId(); - } finally { - closeBusyLock.leaveBusy(); + @Override + public RowId next() { + return busy(() -> { + throwExceptionIfStorageInProgressOfRebalance(state.get(), PageMemoryHashIndexStorage.this::createStorageInfo); + + return cursor.next().rowId(); + }); } - } - }; - } catch (IgniteInternalCheckedException e) { - throw new StorageException("Failed to create scan cursor", e); - } finally { - closeBusyLock.leaveBusy(); - } + }; + } catch (Throwable e) { + throw new StorageException("Failed to create scan cursor", e); + } + }); } @Override public void put(IndexRow row) throws StorageException { - 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