-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Question: ShardAccessStrategy
PostPosted: Tue Apr 10, 2007 10:53 pm 
Newbie

Joined: Wed Mar 15, 2006 2:37 pm
Posts: 6
Hi,

I'm trying to implement an id based shard strategy for some of my
tables but cannot figure out how I should map my ids to shards.

Looking at the documentation the ShardAccessStrategy is used to
determine the shard to use during querying. What is not clear to me is
how to implement the apply() method to choose a shard(s) for the
operation (query in this case). The implementations provided don't
limit the shards rather assume any of the shards can be used. This
kinda implies that the shards applicable for the operation need to be
determined before the ShardAccessStrategy implementation is called.
That being the case I then tried creating a ShardedSessionFactory
configured with different shards based on ids but again I'm not sure
if this is the correct approach. What happens is that my DAO get a
session which will then be limited to the shards configured for the
session factory that was used. This works but appears to require me to
keep a number of session factories around.

Can anyone provider any pointers or let me know the best approach to take?

Thanks in advance

-- Kim Limbrick


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 6:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The ShardAccessStrategy determines how the shards are accessed (ie sequential vs parallel queries)

What you want is either the ShardResolutionStrategy or use an id generator that implements ShardEncodingIdentifierGenerator.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 12, 2007 7:07 pm 
Newbie

Joined: Wed Mar 15, 2006 2:37 pm
Posts: 6
Emmanuel,

Thanks for you reply but I have tried providing my own resolution strategy implementation but I never see the method selectShardIdsFromShardResolutionStrategyData() getting called.

The strategy factory I instantiate uses my resolution strategy implementation and I am using sharded sessions so I'm not sure why the method is not being called.

Any thoughts?

-- Kim


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 13, 2007 2:44 pm 
Newbie

Joined: Wed Mar 15, 2006 2:37 pm
Posts: 6
Ok I've found out why my resolution strategy is not being used by re-reading the documentation:

"The only component of your shard strategy that is consulted when executing a query (Criteria or HQL) is the ShardAccessStrategy. ShardSelectionStrategy is ignored because executing a query doesn't create any new records in the database. ShardResolutionStrategy is ignored because we currently assume that you always want your query executed on all shards. If this isn't the case, the best thing to do is just downcast your Session to a ShardedSession and dig out the shard-specific Sessions you need. Clunky, but it works. We'll come up with a better solution for this in later releases."

I'm looking at id generation but this might have a big impact on existing data.

-- Kim


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.