Re: Queue code

2009-07-17 Thread Patrick Hunt
Thanks for the report, looks like something we need to address, would 
you mind going the extra step and adding a JIRA on this?


https://issues.apache.org/jira/browse/ZOOKEEPER

Thanks,

Patrick

kishore g wrote:

Hi All,

Zookeeper recipe queue code has a bug.

byte[] b = zk.getData(root + /element + min,
false, stat);
zk.delete(root + /element + min, 0);

It throws an error saying the node element0 does not exists.

Node actually created  by producer was element00. So along with min
minNodeName must be stored.

Here is the consume method that works.

public int consume() throws KeeperException, InterruptedException{
int retvalue = -1;
Stat stat = null;

// Get the first element available
while (true) {
synchronized (mutex) {
ListString list = zk.getChildren(root, true);
if (list.size() == 0) {
System.out.println(Going to wait);
mutex.wait();
} else {
Integer min = new Integer(list.get(0).substring(7));
String name = list.get(0);
for(String s : list){
Integer tempValue = new Integer(s.substring(7));
//System.out.println(Temporary value:  + s);
if(tempValue  min) {
min = tempValue;
name = s;
}
}
String zNode = root + / + name;
System.out.println(Temporary value:  + zNode);
byte[] b = zk.getData(zNode,false, stat);
zk.delete(zNode, 0);
ByteBuffer buffer = ByteBuffer.wrap(b);
retvalue = buffer.getInt();

return retvalue;
}
}
}
}


Also are there any performance numbers of zookeeeper based queues. How does
it compare with JMS.

thanks
Kishore G



Re: Queue code

2009-07-17 Thread Mahadev Konar
 Also are there any performance numbers of zookeeeper based queues. How does
 it compare with JMS.
 
 thanks
 Kishore G
Hi Kishore,
 We do not have any performance number fr queues on zookeeper. I think you
can get a rough idea of  those numbers from your usage of zookeeper (number
of reads/writes per second) and  zookeeper performance numbers on
http://hadoop.apache.org/zookeeper/docs/r3.2.0/zookeeperOver.html

Hope that helps.
Thanks
mahadev



Re: Queue code

2009-07-17 Thread Ted Dunning
Depending on your needs, there may be other recipes as well that would give
higher performance.

For example, it might be preferable to keep the queue itself in a small-ish
set of files that each hold many task items.

Different implementations will give different trade-offs on speed,
especially for extremely large queues of pending tasks.

On Fri, Jul 17, 2009 at 1:20 PM, Mahadev Konar maha...@yahoo-inc.comwrote:

  Also are there any performance numbers of zookeeeper based queues. How
 does
  it compare with JMS.




-- 
Ted Dunning, CTO
DeepDyve