jt2594838 opened a new pull request, #18290:
URL: https://github.com/apache/iotdb/pull/18290
## Description
### Concurrent configuration storage
- Replace the mutable `TreeSet` used by `IoTConsensusServerImpl` with a
concurrent set backed by `ConcurrentHashMap.newKeySet()`.
- Accept the initial peer collection through `Collection<Peer>` and copy it
into the internal concurrent set so callers cannot supply a non-thread-safe
implementation.
### Deterministic configuration snapshots
- Sort the copied peer list in `getConfiguration()` to preserve the
deterministic iteration order previously provided by `TreeSet`.
### Concurrency coverage
- Add a unit test with four concurrent writers and four concurrent readers.
- Writers add and remove distinct peers while readers continuously obtain
configuration snapshots.
- Verify that snapshots stay duplicate-free and sorted, and that the final
membership is exact.
### Verification
- `mvn test -pl iotdb-core/consensus
-Dtest=IoTConsensusServerImplTest,ReplicateTest,StabilityTest`
- 7 tests passed; Checkstyle and Spotless passed.
<hr>
This PR has:
- [x] been self-reviewed.
- [x] concurrent read
- [x] concurrent write
- [x] concurrent read and write
- [x] added comments explaining the test scenario and expected result.
- [x] added unit tests to cover the concurrent access path.
<hr>
##### Key changed/added classes
- `IoTConsensusServerImpl`
- `IoTConsensus`
- `IoTConsensusServerImplTest`
--
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]