if (availablePorts.isEmpty()) {\r
LOG.debug(\r
"All ports are exhausted. Hence cannot allocate a port to start new netconf server.");\r
+ return null;\r
}\r
\r
String port = availablePorts.peek();\r
return port;\r
}\r
\r
+ public boolean unReserveServerPort(String port) {\r
+\r
+ try {\r
+ Semaphore semaphore = semaphoreMap.get(port);\r
+ semaphore.acquire();\r
+ availablePorts.add(port);\r
+ semaphore.release();\r
+ LOG.error("Successfully un-reserved the port " + port + " to start netconf server.");\r
+ } catch (InterruptedException e) {\r
+ LOG.warn("Failed to un-reserve the port " + port, e);\r
+ Thread.currentThread().interrupt();\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
public boolean checkAndReserveServerPort(String port) {\r
\r
try {\r