navinko opened a new pull request, #10211: URL: https://github.com/apache/ozone/pull/10211
## What changes were proposed in this pull request? HDDS-15145. Use enum for the ID type in SequenceIdGenerator ## Please describe your PR in detail: 1. This PR introduces "SequenceIdType" to replace String based ID type arguments in "SequenceIdGenerator". SequenceIdGenerator#getNextId now accepts "SequenceIdType" instead of String values, and its in-memory batch cache uses an EnumMap<SequenceIdType, Batch>. 2. This gives compile-time safety for supported sequence ID types while preserving the existing RocksDB key strings through "SequenceIdType#getDbKey()". 3. The existing String constants in `SequenceIdGenerator` are retained and now mapped with Enum . - localId, delTxnId, containerId, CertificateId, rootCertificateId - ROOT_CERTIFICATE_ID` remains deprecated, as it was already deprecated before this change. 4. StateManager and StateManagerImpl continue to use String parameters for allocateBatch and getLastId and did not change it to adapt Enum. 5. Added unit tests for SequenceIdType and updated existing SequenceIdGenerator and RootCARotationManager tests ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-15145 ## How was this patch tested? Validated with unit test and Also verified the change in a local Docker compose secure HA cluster. The SCM logs show enum-based allocation paths: > % docker compose logs -f scm1.org 2>&1 | grep -E "SequenceId|Allocate a batch|LOCAL_ID|CONTAINER_ID|DEL_TXN_ID|CERTIFICATE_ID" scm1.org-1 | 2026-05-07 15:16:52,658 [main] INFO ha.SequenceIdGenerator: upgrade localId to 117883640217600000 scm1.org-1 | 2026-05-07 15:16:52,659 [main] INFO ha.SequenceIdGenerator: upgrade delTxnId to 0 scm1.org-1 | 2026-05-07 15:16:52,660 [main] INFO ha.SequenceIdGenerator: upgrade containerId to 0 scm1.org-1 | 2026-05-07 15:16:52,661 [main] INFO ha.SequenceIdGenerator: upgrade CertificateId to 2 scm1.org-1 | 2026-05-07 15:16:52,661 [main] INFO ha.SequenceIdGenerator: Init the HA SequenceIdGenerator. scm1.org-1 | 2026-05-07 15:16:52,789 [main] INFO ha.SequenceIdGenerator: upgrade CertificateId to 2 scm1.org-1 | 2026-05-07 15:16:59,759 [fbb8e2fd-528a-4709-b43d-bb76bb2569e8@group-665F4C1A70A7-StateMachineUpdater] WARN ha.SequenceIdGenerator: Failed to allocate a batch for CertificateId, expected lastId is 0, actual lastId is 2. scm1.org-1 | 2026-05-07 15:16:59,762 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 2 to 3. scm1.org-1 | 2026-05-07 15:17:02,868 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 3 to 4. scm1.org-1 | 2026-05-07 15:17:03,472 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 4 to 5. scm1.org-1 | 2026-05-07 15:17:08,742 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 5 to 6. scm1.org-1 | 2026-05-07 15:17:08,774 [IPC Server handler 1 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 6 to 7. scm1.org-1 | 2026-05-07 15:17:08,804 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 7 to 8. scm1.org-1 | 2026-05-07 15:17:10,129 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 8 to 9. scm1.org-1 | 2026-05-07 15:17:10,180 [IPC Server handler 1 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 9 to 10. scm1.org-1 | 2026-05-07 15:17:10,208 [IPC Server handler 0 on default port 9961] INFO ha.SequenceIdGenerator: Allocate a batch for CERTIFICATE_ID, change lastId from 10 to 11. scm1.org-1 | 2026-05-07 15:21:35,259 [IPC Server handler 0 on default port 9860] INFO ha.SequenceIdGenerator: Allocate a batch for CONTAINER_ID, change lastId from 0 to 1000. scm1.org-1 | 2026-05-07 15:24:17,941 [fbb8e2fd-528a-4709-b43d-bb76bb2569e8@group-665F4C1A70A7-StateMachineUpdater] WARN ha.SequenceIdGenerator: Failed to allocate a batch for localId, expected lastId is 0, actual lastId is 117883640217600000. scm1.org-1 | 2026-05-07 15:24:17,944 [IPC Server handler 1 on default port 9863] INFO ha.SequenceIdGenerator: Allocate a batch for LOCAL_ID, change lastId from 117883640217600000 to 117883640217601000. scm1.org-1 | 2026-05-07 15:28:13,694 [IPC Server handler 88 on default port 9863] INFO ha.SequenceIdGenerator: Allocate a batch for DEL_TXN_ID, change lastId from 0 to 1000. Successful CI : https://github.com/navinko/ozone/actions/runs/25504128377 -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
