[ 
https://issues.apache.org/jira/browse/HBASE-13686?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14553757#comment-14553757
 ] 

Ashish Singhi commented on HBASE-13686:
---------------------------------------

Thanks [~mbertozzi] for reviewing the patch.

bq. what is the point of the AtomicLong in refill strategy we are under lock 
when we call that code.
Will address this in my next patch.

bq. can we go back to external times? otherwise tests must sleep, and aside the 
slowness they will be always flaky
Yes, I can create a api visible only for testing and avoid sleep.

bq. we are going to have tons of those objects around if you starting 
configuring it by user.
As per the patch, one RateLimiter will have one RefillStartegy object based on 
the configuration. Can you give more details on this.

bq. can we lose one level and maybe some fields? having the RateLimiter 
extended by RefillStrategy or similar.
RateLimiter uses RefillStrategy to find the new refill amount and calculate the 
new available amount based on it. Or may be what other thing I can think off is 
to have RateLimiter a abstract class and then have other two class 
AverageIntervalRateLimiter and FixdIntervalRateLimiter extending this class. 
Then user can decide which RateLimiter he/she wants to use.

In this patch the refill strategy conf is at system level. I think we should 
allow user to configure this for each quota setting, I will do this in a 
separate jira and can discuss more on this in that jira.

I have uploaded the existing patch in the RB 
https://reviews.apache.org/r/34531/, to capture other comments you have on this 
patch in my next patch.

> Fail to limit rate in RateLimiter
> ---------------------------------
>
>                 Key: HBASE-13686
>                 URL: https://issues.apache.org/jira/browse/HBASE-13686
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 2.0.0, 1.1.0
>            Reporter: Guanghao Zhang
>            Assignee: Ashish Singhi
>             Fix For: 2.0.0, 1.2.0, 1.1.1
>
>         Attachments: HBASE-13686.patch
>
>
> While using the patch in HBASE-11598 , I found that RateLimiter can't to 
> limit the rate right.
> {code} 
>  /**
>    * given the time interval, are there enough available resources to allow 
> execution?
>    * @param now the current timestamp
>    * @param lastTs the timestamp of the last update
>    * @param amount the number of required resources
>    * @return true if there are enough available resources, otherwise false
>    */
>   public synchronized boolean canExecute(final long now, final long lastTs, 
> final long amount) {
>     return avail >= amount ? true : refill(now, lastTs) >= amount;
>   }
> {code}
> When avail >= amount, avail can't be refill. But in the next time to call 
> canExecute, lastTs maybe update. So avail will waste some time to refill. 
> Even we use smaller rate than the limit, the canExecute will return false. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to