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

Chia-Ping Tsai edited comment on HBASE-20611 at 6/7/18 2:24 AM:
----------------------------------------------------------------

{code:java}
+      if (lastModifyCount != modifyCount) { // structure has been modified 
since #iterator called
+        throw new ConcurrentModificationException();
+      }{code}
The queue is changed frequently so the error may happen frequently also. Could 
we do the snapshot of objects? If it is impossible to do the snapshot, we have 
to handle the error on RSDumpServlet#dumpCallQueues. Otherwise, user will be 
scared by our web UI.
{code:java}
+  @Override
+  public Iterator<CallRunner> iterator(){
+    return new AdaptiveLifoCoDelCallQueue.Itr();
+  }
+
+  private final class Itr implements Iterator<CallRunner> {
+    private int index = 0;
+    private Object[] crArray = AdaptiveLifoCoDelCallQueue.this.queue.toArray();
+    int size = crArray.length;
+    public boolean hasNext() {
+      return index < size;
+    }
+
+    @SuppressWarnings("unchecked")
+    public CallRunner next() {
+      if (index < size) {
+        return (CallRunner) crArray[index++];
+      }
+      throw new NoSuchElementException();
+    }
+  }{code}
BTW, if the Itr is not fat, we can use anonymous class instead. Also, please 
make the fields final as much as possible.

 


was (Author: chia7712):
{code:java}
+      if (lastModifyCount != modifyCount) { // structure has been modified 
since #iterator called
+        throw new ConcurrentModificationException();
+      }{code}
The queue is changed frequently so the error may happen frequently also. Could 
we do the snapshot of objects? If it is impossible to do the snapshot, we have 
to handle the error on RSDumpServlet#dumpCallQueues. Otherwise, user will be 
scared by our web UI.
{code:java}
+  @Override
+  public Iterator<CallRunner> iterator(){
+    return new AdaptiveLifoCoDelCallQueue.Itr();
+  }
+
+  private final class Itr implements Iterator<CallRunner> {
+    private int index = 0;
+    private Object[] crArray = AdaptiveLifoCoDelCallQueue.this.queue.toArray();
+    int size = crArray.length;
+    public boolean hasNext() {
+      return index < size;
+    }
+
+    @SuppressWarnings("unchecked")
+    public CallRunner next() {
+      if (index < size) {
+        return (CallRunner) crArray[index++];
+      }
+      throw new NoSuchElementException();
+    }
+  }{code}
BTW, if the Itr is not fat, we can use inner class instead. Also, please make 
the fields final as much as possible.

 

> UnsupportedOperationException may thrown when calling getCallQueueInfo()
> ------------------------------------------------------------------------
>
>                 Key: HBASE-20611
>                 URL: https://issues.apache.org/jira/browse/HBASE-20611
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Allan Yang
>            Assignee: Xu Cang
>            Priority: Major
>         Attachments: HBASE-20611.master.002.patch, 
> HBASE-20611.master.003.patch, HBASE-20611.master.004.patch, 
> HBASE-20611.master.005.patch, HBASE-20611.master.006.patch, 
> HBASE-20611.master.007.patch
>
>
> HBASE-16290 added a new feature to dump queue info,  the method 
> getCallQueueInfo() need to iterate the queue to get the elements in the 
> queue.  But, except the Java's LinkedBlockingQueue, the other queue 
> implementations like BoundedPriorityBlockingQueue and 
> AdaptiveLifoCoDelCallQueue don't implement the method iterator(). If those 
> queues are used, a UnsupportedOperationException  will be thrown.
> This can be easily be reproduced by the UT testCallQueueInfo while adding a 
> conf: conf.set("hbase.ipc.server.callqueue.type", "deadline")
> {code}
> java.lang.UnsupportedOperationException
>       at 
> org.apache.hadoop.hbase.util.BoundedPriorityBlockingQueue.iterator(BoundedPriorityBlockingQueue.java:285)
>       at 
> org.apache.hadoop.hbase.ipc.RpcExecutor.getCallQueueCountsSummary(RpcExecutor.java:166)
>       at 
> org.apache.hadoop.hbase.ipc.SimpleRpcScheduler.getCallQueueInfo(SimpleRpcScheduler.java:241)
>       at 
> org.apache.hadoop.hbase.ipc.TestSimpleRpcScheduler.testCallQueueInfo(TestSimpleRpcScheduler.java:164)
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to