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

Peter Bacsko commented on OOZIE-3160:
-------------------------------------

It's not just {{take()}}, {{put()}} does the same thing:

{noformat}
    @Override
    public void put(QueueElement<E> e) throws InterruptedException {
        while (!offer(e, true)) {
            Thread.sleep(10);
        }
    }
{noformat}

These kinds of constructs should be avoided at all costs. Basically we have two 
options here:
1) Use a single {{Condition}} object for all priority levels - we already have 
a {{ReentrantLock}} for the whole queue
2) Use {{Condition}} objects on a per priority basis

#1 is much simpler and already solves this problem, so I'd go for that.



> oozie high cpu usage problem
> ----------------------------
>
>                 Key: OOZIE-3160
>                 URL: https://issues.apache.org/jira/browse/OOZIE-3160
>             Project: Oozie
>          Issue Type: Bug
>          Components: core
>         Environment: all platforms
>            Reporter: jj
>            Assignee: Andras Piros
>            Priority: Major
>         Attachments: 11111111111111.png, 222222222222222222.png
>
>
> oozie process always  consume  high cpu. in my mechine,around 10%. 
> I check the source code,find take() method in PriorityDelayQueue class。
> code:
> {code:java}
> public QueueElement<E> take() throws InterruptedException {
>     QueueElement<E> e = poll();
>     while (e == null) {
>         Thread.sleep(10);
>         e = poll();
>     }
>     return e;
> }
> {code}
> i think it's the reason of this problem. it's keep while, not await.  



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

Reply via email to