File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed 
hbase-server/src/test/java/org/apache/hadoop/hbase/quotas Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,27 @@ public void testLargeBatchSaturatesReadNumLimit()
163163    quota .checkBatchQuota (0 , limit );
164164  }
165165
166+   @ Test 
167+   public  void  testLargeBatchSaturatesReadWriteLimit ()
168+     throws  RpcThrottlingException , InterruptedException  {
169+     int  limit  = 10 ;
170+     QuotaProtos .Throttle  throttle  =
171+       QuotaProtos .Throttle .newBuilder ().setWriteNum (QuotaProtos .TimedQuota .newBuilder ()
172+         .setSoftLimit (limit ).setTimeUnit (HBaseProtos .TimeUnit .SECONDS ).build ()).build ();
173+     QuotaLimiter  limiter  = TimeBasedLimiter .fromThrottle (throttle );
174+     DefaultOperationQuota  quota  = new  DefaultOperationQuota (new  Configuration (), 65536 , limiter );
175+ 
176+     // use the whole limit 
177+     quota .checkBatchQuota (limit , 0 );
178+ 
179+     // the next request should be rejected 
180+     assertThrows (RpcThrottlingException .class , () -> quota .checkBatchQuota (1 , 0 ));
181+ 
182+     envEdge .incValue (1000 );
183+     // after the TimeUnit, the limit should be refilled 
184+     quota .checkBatchQuota (limit , 0 );
185+   }
186+ 
166187  @ Test 
167188  public  void  testTooLargeReadBatchIsNotBlocked ()
168189    throws  RpcThrottlingException , InterruptedException  {
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments