opensubscriber
   Find in this group all groups
 
Unknown more information…

j : javaspaces-users@java.sun.com 18 October 2008 • 12:59AM -0400

FW: Inserting single semaphore into the JavaSpace
by Tom Hobbs

REPLY TO AUTHOR
 
REPLY TO GROUP




Sorry, just realised that I failed to send this to the list.

Gregg get's two apologies because he's going to get this email twice now...

Tom


-----Original Message-----
From: Tom Hobbs
Sent: 17 October 2008 17:07
To: 'gregg.wonderly@pobo...'
Subject: RE: Inserting single semaphore into the JavaSpace

A simple solution which I've come across (and we use successfully within my company) is a two-fold solution.

The first is a flag on the JavaSpace that indicates that it is "Available", that is, it is ready to be discovered/used.  The second is the concept of a post-start operation.

For example, the code to start your JavaSpace might look something like this;

NonActivatableServiceDescriptor.Created c = (NonActivatableServiceDescriptor.Created) sd.create(javaSpaceConfig);
JavaSpace js = (JavaSpace) c.proxy;
js.write(...); //put the token in
makeAvailable(js);

Where "makeAvailable(js)" is a method which adds an initialLookupAttribute to the supplied service (in this case a space).  The attribute might be something as simple as "new Comment("Available")".

Other code changes that are required is when your other services are looking for this space the service validator they use must only return a JavaSpace which has the "Available" comment in its initialLookupAttributes.

What this gives you is that your JavaSpace is only every eligible for discovery when it is in a known good state - in this case it has the token inside it.  Your services now never have to worry about putting the first token in themselves.

We find this solution very simple and it meets our needs.  The only real overhead is the extra check in the Service Validator when discovering services - and that itself is pretty small.

Hope this makes sense.

Tom


-----Original Message-----
From: Gregg Wonderly [mailto:gregg@cyte...]
Sent: 17 October 2008 15:39
To: JAVASPACES-USERS@JAVA...
Subject: Re: Inserting single semaphore into the JavaSpace

You said without another service...  Dan Creswell has a distributed lock manager
on his web site that works.  I have one as well that is a little different in
design, using Jeri for communications instead jgroups.  But, in the end, its
something that is generally useful.   I had some thoughts about how to do this
using Javaspaces, but have never had a chance to explore the ideas to see if
they'd work.

Gregg Wonderly

Oliver Plohmann wrote:
> Hello,
>
> thanks for the link. The article explains the idea of a token used as a
> semaphore. This is what I saw in Freeman's book and that's how I intend
> to do synchronization. Problem is that someone must be the first one to
> insert the >single< semaphore entry into the space since it is empty to
> begin with. Now there might be several clients using the space and there
> must be one of them who will insert the initial semaphore. How do they
> agree on who will do this when an initial semaphore not yet exists in
> the space to prevent race conditions from happening when working out the
> agreement who will be the one?
>
> As explained I use the RMI registry as a workaround to determine who is
> the first one (everyone that comes second faces a AlreadyExistsException
> when binding a remote object to the registry that already exists there
> with the same name) and thus is allowed to write the initial semaphore
> to the space.
>
> I feel a method like
>
> writeOnce(Entry entry, Transaction trx, long timeout) throws
> EntryAlreadyExistsException
>
> would be a nice thing to have in the JavaSpace interface. Many
> concurrency issues could be solved easily this way and efficiently.
> Maybe there is still someone who has had this problem as well and found
> a simple quick solution.
>
> Thanks, Oliver Plohmann
>
> Holger Hoffstätte wrote:
>> Oliver Plohmann wrote:
>>  
>>> I need to have for certain operations exclusive access to the JavaSpace
>>> or at least part of it. [..]
>>>    
>>
>> There is a "discussion" with a pointer to an article on TSS:
>> http://www.theserverside.com/common/printthread.tss?thread_id=45418
>>
>> This should do what you want.
>>
>> -h
>>
>> ===========================================================================
>>
>> To unsubscribe, send email to listserv@java... and include in the
>> body
>> of the message "signoff JAVASPACES-USERS".  For general help, send
>> email to
>> listserv@java... 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
>>
>>  
>

===========================================================================
To unsubscribe, send email to listserv@java... and include in the body
of the message "signoff JAVASPACES-USERS".  For general help, send email to
listserv@java... 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

www.sucden.co.uk
Sucden (UK) Limited, 5 London Bridge Street, London SE1 9SG
Telephone +44 20 7940 9400

Registered in England no. 1095841
VAT registration no. GB 446 9061 33
Authorised and Regulated by the Financial Services Authority (FSA) and entered in the FSA register under no. 114239

This email, including any files transmitted with it, is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you are not the intended recipient of this message, please notify postmaster@sucd... immediately and delete it from your computer system.

We believe, but do not warrant, that this email and its attachments are virus-free, but you should check.

Sucden (UK) Ltd may monitor traffic data of both business and personal emails. By replying to this email, you consent to Sucden’s monitoring the content of any emails you send to or receive from Sucden. Sucden is not liable for any opinions expressed by the sender where this is a non-business email.
The contents of this e-mail do not constitute advice and should not be regarded as a recommendation to buy, sell or otherwise deal with any particular investment.
This message has been scanned for viruses by Mimecast.

===========================================================================
To unsubscribe, send email to listserv@java... and include in the body
of the message "signoff JAVASPACES-USERS".  For general help, send email to
listserv@java... 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

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.