merlimat commented on PR #25694:
URL: https://github.com/apache/pulsar/pull/25694#issuecomment-4389702469

   @lhotari thanks — restored `PortManager` and addressed both improvements you 
suggested.
   
   The new implementation in `b0e844dbab0`:
   - Allocates from a 1000-port block outside the ephemeral range. Each JVM 
claims its block by binding a "lock" `ServerSocket` on the block's base port 
for the JVM's lifetime; other JVMs that hit the same range observe the bind 
failure and walk to the next block. Default range is `[20000, 33000)` which 
gives 13 blocks before exhaustion — should be plenty for parallel test JVMs.
   - `releaseLockedPort` now moves the port to a pending-release set rather 
than returning it to the pool immediately. The next allocation rebinds and only 
reclaims pending-release ports that bind successfully, so TIME_WAIT sockets 
don't get handed out.
   
   Wired it back into the call sites that genuinely need pre-allocation: 
`ServiceUrlQuarantineTest`, 
`ExtensibleLoadManagerImplWithAdvertisedListenersTest`, 
`ModularLoadManagerImplTest.testOwnBrokerZnodeByMultipleBroker`, 
`AdvertisedListenersTest`, `SimpleProtocolHandlerTestsBase`, 
`SimpleProxyExtensionTestBase`, and `PulsarTestContext.handlePreallocatePorts` 
(the `preallocatePorts(true)` opt-in is preserved). Everything else still uses 
port 0 + read-back via `getBrokerListenPort()` / `getZookeeperPort()`.


-- 
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]

Reply via email to