Re: inter-process mutexes
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
---910079544-438228979-1237658745=:11731
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8BIT
On Fri, 20 Mar 2009, ed.peschko@gmail.com wrote:
hmm.. that explains why there isn't a standard, but I would think that
you could have something close by deciding that you will implement your
mutex/semaphore based on something lowest common denominator like files
(which would be fine for my purposes). Scalability and multiple box
handlings could be done by relying on a SAN or other such high speed
network.
I realize that this would be relatively slow, but it would be effective.
Using an RDBMS would be fine too.
Anyways, I'm hesitant to program anything like this if it exists, so let
me rephrase the question - is there a pragmatic, open platform that does
something like this, which is mostly free of warts and supports a large
subset of OSes?
You may want a lock manager:
http://en.wikipedia.org/wiki/Distributed_lock_manager
There are a couple in Linux, but i can't vouch for their suitability for
your purposes. In particular, i have no idea if there's a java interface.
If you wanted to work on a single machine, and didn't need the complex
behaviour you mentioned (like being able to see where you were in the
queue), then i'd say use file locks; file locks vary a lot across systems,
but all modern OSs, including Windows, support lock semantics sufficient
to implement read/write locks between cooperating processes. A solution
using file locks would be simple, efficient and robust.
As soon as you want to go over a network, though, you're shafted. You
could do file locks on an NFS-shared volume, but i wouldn't want to rely
on it. I guess you could use the same approach on a WebDAV server, using
its file locks as mutexes.
As Mark mentioned, there's Terracotta:
http://javathink.blogspot.com/2008/12/java-distributed-lock-manager.html
Which looks a bit scary.
tom
On Mar 20, 3:26?pm, Mark Rafn <da...@dagon.net> wrote:
<horo...@gmail.com> wrote:
I was wondering if there was a nice, standard, open, inter-process
mutex that I could grab for java (rather than needing to programming
it myself).
Can't be done in pure Java - there's too much OS variation. ?You're looking at
JNI, and picking a system that works for the set of OSs you care about.
HOWEVER, this is very often the wrong granularity; almost as soon as
you've got inter-process working on the same box, you'll be asking to
synchronize across machines in a network. ?
Which leads to using even heavier-weight solutions, very often a transactional
RDBMS or something like terracotta. ?Most of the time, I'd recommend starting
with a multi-machine plan rather than coding up a multi-VM-one-machine
solution and realizing later you need to scrap it.
--
Big Bang. No god. Fadeout. End. -- Stephen Baxter
---910079544-438228979-1237658745=:11731--