Re: Inserting single semaphore into the JavaSpace
Gregg Wonderly <[email protected]> Fri, 17 Oct 2008 09:39:08 -0500
| Newsgroups | gmane.comp.java.sun.javaspaces |
|---|---|
| Message-ID | <[email protected]> |
You said without another service... Dan Creswell has a distributed lock = manager=20 on his web site that works. I have one as well that is a little differen= t in=20 design, using Jeri for communications instead jgroups. But, in the end, = its=20 something that is generally useful. I had some thoughts about how to do= this=20 using Javaspaces, but have never had a chance to explore the ideas to see= if=20 they'd work. Gregg Wonderly Oliver Plohmann wrote: > Hello, >=20 > thanks for the link. The article explains the idea of a token used as a= =20 > semaphore. This is what I saw in Freeman's book and that's how I intend= =20 > to do synchronization. Problem is that someone must be the first one to= =20 > insert the >single< semaphore entry into the space since it is empty to= =20 > begin with. Now there might be several clients using the space and ther= e=20 > must be one of them who will insert the initial semaphore. How do they=20 > agree on who will do this when an initial semaphore not yet exists in=20 > the space to prevent race conditions from happening when working out th= e=20 > agreement who will be the one? >=20 > As explained I use the RMI registry as a workaround to determine who is= =20 > the first one (everyone that comes second faces a AlreadyExistsExceptio= n=20 > when binding a remote object to the registry that already exists there=20 > with the same name) and thus is allowed to write the initial semaphore=20 > to the space. >=20 > I feel a method like >=20 > writeOnce(Entry entry, Transaction trx, long timeout) throws=20 > EntryAlreadyExistsException >=20 > would be a nice thing to have in the JavaSpace interface. Many=20 > concurrency issues could be solved easily this way and efficiently.=20 > Maybe there is still someone who has had this problem as well and found= =20 > a simple quick solution. >=20 > Thanks, Oliver Plohmann >=20 > Holger Hoffst=E4tte wrote: >> Oliver Plohmann wrote: >> =20 >>> I need to have for certain operations exclusive access to the JavaSpa= ce >>> or at least part of it. [..] >>> =20 >> >> There is a "discussion" with a pointer to an article on TSS: >> http://www.theserverside.com/common/printthread.tss?thread_id=3D45418 >> >> This should do what you want. >> >> -h >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=20 >> >> To unsubscribe, send email to [email protected] and include in the= =20 >> body >> of the message "signoff JAVASPACES-USERS". For general help, send=20 >> email to >> [email protected] and include in the body of the message "help". >> >> To view past JAVASPACES-USERS postings, please see: >> http://archives.java.sun.com/archives/javaspaces-users.html >> >> =20 >=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D To unsubscribe, send email to [email protected] and include in the bo= dy of the message "signoff JAVASPACES-USERS". For general help, send email = to [email protected] and include in the body of the message "help". To view past JAVASPACES-USERS postings, please see: http://archives.java.sun.com/archives/javaspaces-users.html