Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Some basic usage questions

Hi,
I am evaluating GS and I am slightly confused about some idioms and usage. Essentially I am looking to have a read through cache that has a number of processes running for workflow type stuff. Initially I am writing tests for the read through cache functions and there are a couple of things that are niggling me. This may be because I have missed something obvious - however:

1) I have a pojo that has a key within it that is an object (made of three fields). The use of the toString() to generate the uid from the key feels very kludgy to me - I know the doc says I can use a __getUid() method on the object - but that seems even worse as it pollutes the object. Is there another way to deal with this?

2) The DataProvider interface for the read through appears to be paired with the way I use the space as a client. So if I use the Map API I have to use the MapDataSource and if I use the space API I have to use the DataProvider - this feels very stange as I have to tie together the front and backend of the space.

3) The notification mechanism does not appear to be applicable to the Map API (as it only takes a gigaSpace) and the add listener methods on the Maps throw UnsupportedExceptions. If I add a gigaspace definition wrapping the same space that the map is pointing to I do not get any notifications - should these two wrappers be able to be used in this manner if they have the same Space?

4) If I use the space idiom I find the use of templates instead of a key always calls the iterator method on the DataProvider - the docs imply that the only time the read is called is as part of a write. Having to create an iterator for single objects is a pain and very inefficent.

I tried the ClientUIDHandler.createUIDFromName(key.toString(), AbstractTradeHistoryBucket.class.getName()); to pass as part of an entry to the read method - but this ended up calling the read method on the provider with a null value - not very useful? -

I wonder if you could offer any guidance on these points?

Maybe I am missing something obvious here - but the Map and Space usage appear to be mutually exclusive and the

This thread was imported from the previous forum.
For your reference, the original is available here

asked 2009-07-01 09:16:26 -0500

steview gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Steve,

1. The __getUid() method is relevant for the old JavaSpace Entry interface based classes.
You should not use this since the product main path is POJO. You should use annotations or gs.xml to introduce meta data attributes. You should use the @SpaceID (autogeenrate = fasle) to specify the getter field that would be used for the space UID.

See the space POJO page for details.
http://www.gigaspaces.com/wiki/display/XAP7/POJOSupport
http://www.gigaspaces.com/wiki/display/XAP7/POJOSupport-Advanced

2. If you need to Read Through - the Space API would be much more relevant. Any special reason why you need to implement the DataProvider API ? The Hibernate External Data Source fit most cases.

http://www.gigaspaces.com/wiki/display/XAP7/DirectPersistency
http://www.gigaspaces.com/wiki/display/XAP7/HibernateExternalDataSource

3. The Notification API (Notify container or Session based messaging) can work with the Map API , but it will have some restrictions. If you need notifications - the Space API would be much more relevant in your case.
http://www.gigaspaces.com/wiki/display/XAP7/SessionBasedMessagingAPI

http://www.gigaspaces.com/wiki/display/XAP7/NotifyContainer

4. There is a reason for this - you might have multiple matching records found at the database and your business logic might want to iterate these and return the one that fits the template the best back into the space. If you know you got only one matching record you should have a simple iterator implementation that will deal with one record - might be annoying , but does not involve lot of work.

5. There is not reason for you to use the ClientUIDHandler when using the GigaSpace interface or the Map API. This is an utility that been recommended in the past. There is no need to use it when using POJOs.

I think you should focus on the GigaSpace interface with your evaluation. It got more powerful options than the Map API and provides the same performance (in some cases even better). See for example the GigaSpace.readByID API comes with XAP 7.0. It basically gives you the same look & feel as the Map API. It got also very fast performance when running a local cache.

If you would like to review these question offline - please contact me at shay at gigaspaces.com

Shay

answered 2009-07-01 09:50:23 -0500

shay hassidim gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2009-07-01 09:16:26 -0500

Seen: 61 times

Last updated: Jul 01 '09