[
https://issues.apache.org/jira/browse/HBASE-20611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16504069#comment-16504069
]
Xu Cang commented on HBASE-20611:
---------------------------------
{code:java}
+ * Use poll() whenever possible.
{code}
Can you clarify the above - poll is not part of Iterator?
Xu: I removed this line and added some other explanations.
This 'AdaptiveLifoCoDelCallQueue" uses LinkedBlockingQueue inside. From
this class, the code cannot access LinkedBlockingQueue's internal data
structure. So I cannot implement the same algorithm as I did for
BoundedPriorityBlockingQueue.
Whish results to high space complexity for this iterator(). So I just
want to alert user using this iterator with cautions.
{code:java}
+ if (index < size())
+ return (E) BoundedPriorityBlockingQueue.this.queue.objects[index++];
{code}
Enclose return in pair of curlies.
{code:java}
+ private final class Itr implements Iterator<CallRunner> {
+ private int index = 0;
+ private Object[] crArray = AdaptiveLifoCoDelCallQueue.this.queue.toArray();
{code}
Why modification count is not involved in the above Iterator ?
Xu: Same reason as above. The iterator logic for AdaptiveCoDel queue is
different than the one I implemented for BOundedPriorityBlockingQueue. Because
the latter one I have access to its internal data structure (a fake
PriorityQueue defined as an inner class).
I uploaded a new patch which addresses your code reviews. Thanks again.
> 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-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)