Interface ConnectionSemaphore
-
- All Known Implementing Classes:
CombinedConnectionSemaphore,MaxConnectionSemaphore,NoopConnectionSemaphore,PerHostConnectionSemaphore
public interface ConnectionSemaphoreConnections limiter.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidacquireChannelLock(Object partitionKey)default voidacquireChannelLock(Object partitionKey, boolean nonBlocking)Acquires a connection permit forpartitionKey, optionally without blocking.voidreleaseChannelLock(Object partitionKey)
-
-
-
Method Detail
-
acquireChannelLock
void acquireChannelLock(Object partitionKey) throws IOException
- Throws:
IOException
-
acquireChannelLock
default void acquireChannelLock(Object partitionKey, boolean nonBlocking) throws IOException
Acquires a connection permit forpartitionKey, optionally without blocking.When
nonBlockingistruea permit must be taken without waiting — the too-many-connections exception is thrown immediately if none is free. This is used when the caller runs on a Netty event-loop thread (a redirect / 401 / 407 / retry replay re-enters the send path on the event loop), where waiting for the configured acquire timeout would freeze the loop and stall every other connection it serves. Whenfalsethis behaves exactly likeacquireChannelLock(Object).The default implementation ignores the hint and delegates to the blocking
acquireChannelLock(Object), preserving the behaviour of custom implementations; the built-in limiters override it to honournonBlocking.- Parameters:
partitionKey- the per-host partition key the permit is scoped tononBlocking-trueto fail fast instead of waiting for a permit- Throws:
IOException- if no permit could be acquired
-
releaseChannelLock
void releaseChannelLock(Object partitionKey)
-
-