@@ -204,6 +204,7 @@ public static Object getExternalHandler() {
204
204
private final byte [] clientId ;
205
205
private final int maxAsyncCalls ;
206
206
private final AtomicInteger asyncCallCounter = new AtomicInteger (0 );
207
+ private final int asyncCalllPermitsTimeoutMs ;
207
208
private final ConcurrentMap <ConnectionId , Semaphore > asyncCallCounters =
208
209
new ConcurrentHashMap <>();
209
210
@@ -1382,6 +1383,9 @@ public Client(Class<? extends Writable> valueClass, Configuration conf,
1382
1383
this .maxAsyncCalls = conf .getInt (
1383
1384
CommonConfigurationKeys .IPC_CLIENT_ASYNC_CALLS_MAX_KEY ,
1384
1385
CommonConfigurationKeys .IPC_CLIENT_ASYNC_CALLS_MAX_DEFAULT );
1386
+ this .asyncCalllPermitsTimeoutMs = conf .getInt (
1387
+ CommonConfigurationKeys .IPC_CLIENT_ASYNC_CALLS_PERMITS_ACQUIRE_TIMEOUT_MS_KEY ,
1388
+ CommonConfigurationKeys .IPC_CLIENT_ASYNC_CALLS_PERMITS_ACQUIRE_TIMEOUT_MS_DEFAULT );
1385
1389
}
1386
1390
1387
1391
/**
@@ -1479,8 +1483,8 @@ private void checkAsyncCall(ConnectionId remoteId) throws IOException {
1479
1483
if (LOG .isDebugEnabled ()) {
1480
1484
LOG .debug ("Acquiring lock for connectionId {}" , remoteId );
1481
1485
}
1482
- // TODO timeout param configurable.
1483
- boolean isAcquired = asyncPermits . tryAcquire ( 1000 , TimeUnit .MILLISECONDS );
1486
+ boolean isAcquired = asyncPermits . tryAcquire ( asyncCalllPermitsTimeoutMs ,
1487
+ TimeUnit .MILLISECONDS );
1484
1488
if (!isAcquired ) {
1485
1489
String errMsg = String .format (
1486
1490
"Exceeded limit of max asynchronous calls: %d, " +
0 commit comments