xyuanlu commented on code in PR #2515:
URL: https://github.com/apache/helix/pull/2515#discussion_r1227211115


##########
meta-client/src/main/java/org/apache/helix/metaclient/recipes/lock/DistributedSemaphore.java:
##########
@@ -96,30 +165,40 @@ public Collection<Permit> acquire(int count, long timeout, 
TimeUnit unit) {
    * @return remaining capacity
    */
   public long getRemainingCapacity() {
-    throw new NotImplementedException("Not implemented yet.");
+    return getSemaphore().getLongField(REMAINING_CAPACITY_NAME, 
DEFAULT_REMAINING_CAPACITY);
   }
 
   /**
    * Get the semaphore data record
    * @return semaphore data record
    */
   private DataRecord getSemaphore() {
-    throw new NotImplementedException("Not implemented yet.");
+    if (_metaClient.exists(_path) == null) {
+      throw new MetaClientException("Semaphore does not exist at path: " + 
_path + ". Please create it first.");
+    }
+    return new DataRecord(_metaClient.get(_path));
   }
 
   /**
    * Return a permit. If the permit is already returned, log and return void.
    */
-  public void returnPermit(Permit permit) {
-    throw new NotImplementedException("Not implemented yet.");
+  public synchronized void returnPermit(Permit permit) {

Review Comment:
   Why we need synchronized?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to