hanishakoneru commented on a change in pull request #1480:
URL: https://github.com/apache/ozone/pull/1480#discussion_r516997457
##########
File path:
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
##########
@@ -524,6 +535,48 @@ public static OmKeyInfo prepareKeyForRecover(OmKeyInfo
keyInfo,
}
}
+ public static int getOMEpoch(boolean isRatisEnabled) {
+ return isRatisEnabled ? EPOCH_WHEN_RATIS_ENABLED :
+ EPOCH_WHEN_RATIS_NOT_ENABLED;
+ }
+
+ /**
+ * Get the valid base object id given the transaction id.
+ * @param epoch a 2 bit epoch number. The 2 most significant bits of the
+ * object will be set to this epoch.
+ * @param id of the transaction. This value cannot exceed 2^54 - 1 as
+ * out of the 64 bits for a long, 2 are reserved for the epoch
+ * and 8 for recursive directory creation.
+ * @return base object id allocated against the transaction
+ */
+ public static long getObjectIdFromTxId(long epoch, long id) {
+ Preconditions.checkArgument(id <= MAX_TRXN_ID, "TransactionID " +
+ "exceeds max limit of " + MAX_TRXN_ID);
+ return addEpochToObjectId(epoch, id);
Review comment:
Done.
##########
File path:
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
##########
@@ -76,6 +78,17 @@
private static final SecureRandom SRAND = new SecureRandom();
private static byte[] randomBytes = new byte[32];
+ private static final long TRANSACTION_ID_SHIFT = 8;
+ // from the 64 bits of ObjectID (long variable), 2 bits are reserved for
+ // epoch and 8 bits for recursive directory creation, if required. This
+ // leaves 54 bits for the transaction ID. Also, the last transaction ID is
+ // reserved for creating S3G volume on OM start {@link
+ // OzoneManager#addS3GVolumeToDB()}.
+ public static final long EPOCH_ID_SHIFT = 62; // 64 - 2
+ public static final long MAX_TRXN_ID = (long) (Math.pow(2, 54) - 2);
Review comment:
Done.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]