sanpwc commented on code in PR #4049:
URL: https://github.com/apache/ignite-3/pull/4049#discussion_r1728786399
##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/PersistentPageMemoryMvPartitionStorage.java:
##########
@@ -322,6 +376,72 @@ public long leaseStartTime() {
});
}
+ @Override
+ public @Nullable String primaryReplicaNodeId() {
+ return busy(() -> {
+ throwExceptionIfStorageNotInRunnableState();
+
+ try {
+ primaryReplicaMetaReadWriteLock.readLock().lock();
+
+ try {
+ if (primaryReplicaNodeId == null) {
+ long primaryReplicaNodeIdFirstPageId =
meta.primaryReplicaNodeIdFirstPageId();
+
+ // It's possible to face BlobStorage.NO_PAGE_ID if a
lease information has not yet been recorded in storage,
+ // for example, if the lease itself has not yet been
elected.
+ if (primaryReplicaNodeIdFirstPageId !=
BlobStorage.NO_PAGE_ID) {
+ primaryReplicaNodeId =
ByteUtils.stringFromBytes(blobStorage.readBlob(primaryReplicaNodeIdFirstPageId));
+ }
+ }
+
+ return primaryReplicaNodeId;
+ } finally {
+ primaryReplicaMetaReadWriteLock.readLock().unlock();
+ }
+ } catch (IgniteInternalCheckedException e) {
+ throw new StorageException(
+ "Failed to read primary replica node id: [tableId={},
partitionId={}]",
+ e,
+ tableStorage.getTableId(), partitionId
+ );
+ }
+ });
+ }
+
+ @Override
+ public @Nullable String primaryReplicaNodeName() {
+ return busy(() -> {
+ throwExceptionIfStorageNotInRunnableState();
+
+ try {
+ primaryReplicaMetaReadWriteLock.readLock().lock();
+
+ try {
+ if (primaryReplicaNodeName == null) {
+ long primaryReplicaNodeNameFirstPageId =
meta.primaryReplicaNodeNameFirstPageId();
+
+ // It's possible to face BlobStorage.NO_PAGE_ID if a
lease information has not yet been recorded in storage,
+ // for example, if the lease itself has not yet been
elected.
+ if (primaryReplicaNodeNameFirstPageId !=
BlobStorage.NO_PAGE_ID) {
+ primaryReplicaNodeName =
ByteUtils.stringFromBytes(blobStorage.readBlob(primaryReplicaNodeNameFirstPageId));
+ }
+ }
+
+ return primaryReplicaNodeName;
+ } finally {
+ primaryReplicaMetaReadWriteLock.readLock().unlock();
+ }
+ } catch (IgniteInternalCheckedException e) {
+ throw new StorageException(
+ "Failed to read primary replica node id: [tableId={},
partitionId={}]",
Review Comment:
> Node name should be here.
Fixed.
> Did you consider the option of writing a wrapper method for this logic of
reading string from storage?
Yes I did, however SE guys told me that they are going to change nodeId type
from String to UUID, in that case nodeId will be stored in meta directly and
blob storage will be used for nodeName only. TODO with an explanation added.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]