--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
Join us in IRC at http://webchat.freenode.net/?channels=jpos
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/fd5be042-0627-4320-9819-6e2791b2cfd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Borna,
First a little bit of history, a long time ago (very early 2000s) we had a Sequencer class in jPOS that had a dependency on a ‘reliableLogger’ that used to come with JINI (an awesome project that lost traction once it was handed to Apache and renamed to River). In order to get rid of that dependency, I created this SpaceUtil.nextLong method that is far from efficient, if you look at how it’s implemented, it requires two space operations in order to increment a value. That’s fast on a transient space, but JE space actually commits to disk (and syncs), so it’s not fast.
I made a quick benchmark and got between 0.6ms and 1ms penalty for each nextLong operations (using 100 simultaneous threads) using JESpace. It’s slower with JDBMSpace and super fast with TSpace.
We could add an optimised Space.inc operation, but we would be loosing the Linda spirit where everything can be done on top of the three basic operations (BTW, our ‘push’ operation is a violation of that spirit).
If what you need is just a sequencer, Victor is right, you can use the database, or if your business logic can tolerate a gap in a crash event, you could have a service issuing sequence numbers and getting them in chunks (i.e incrementing by 10 or 100).
But writing Space implementations is nice, I like it at lot. Some people play Sudoku, I like to write space implementations. I’ve written a few of them that were never published using different backends, like Voldemort for example. When I first saw Redis I dove into writing a Space implementation (using JEdis as the driver). Most operations map quite well from our Space API into Redis’, i.e:
public void out(K k, V v) {
jedis.rpush(k.toString(), v.toString());
}
public V in(Object o) {
return (V) jedis.blpop(0, o.toString()).get(1);
}
public V in(Object k, long timeout) {
List l = jedis.blpop((int) (timeout/1000), k.toString());
return (V) (l != null ? l.get(1) : null);
}
public V inp(Object o) {
return (V) jedis.lpop(o.toString());
}
public V rdp(Object o) {
return (V) jedis.lindex(o.toString(), 0);
}
I remember I liked the fact that Redis has timeouts for the entries, that’s great, but it doesn’t have timeouts for the queue entries, so I found there was some friction to implement that.
When playing with Space implementations using different backends I always have mixed feelings, to give you an example, a few months ago I’ve started a ZooKeeper based implementation, and it was going well, but then I realised that ZK has a great API, with ephemeral versus persistent entries that I was missing by plugging the Space API as a front end, so instead of that I switched my attention to implement a ZK based MUX, not using the Space API but honouring the MUX API, taking advantage of ZK’s capabilities. I heard about Redisson but never got to use it, looks very interesting.
If you are keen to write a Space implementation and you’re happy to donate it to jPOS, we’ll be happy to merge it to jPOS-EE as a module initially, if it takes traction we may move it to jPOS core. I try to add stuff that requires dependencies as jPOS-EE modules, so they are optional for developers. We would just need a pull request with your CLA (https://github.com/jpos/jPOS/tree/master/legal). You can also host it in your own project and we’ll be happy to use it if the license allows.
If you choose to move forward, I suggest you join us in Slack (just sent you an invite - anyone willing to join just drop me an e-mail and I’ll send you invites right away).
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CALK1SywSv38CamTpq4hUV-VvjhsCkvdTS0uwTv_%2BqKfToHUOKw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/21d32bfb-275b-4e60-8846-671b5a9d71f0%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAAgSK%3DkMJTVDTa_nK6XV7xtquDwJ49_8CsMtVS4xKrVACz9ESA%40mail.gmail.com.