Hmmm, one hacky way might be to hold on to the grouper instance passed in via configuration, and once the cache manager has been started, set it in the grouper and use to query either the address, or the physical address (via EmbeddedCacheManager.getTransport…)?
On May 14, 2013, at 6:34 PM, cotton-ben <ben.cot...@alumni.rutgers.edu> wrote: > I am playing with the Infinispan 5.3 quick-start package to exercise my usage > of the Grouping API. As we know the quick start package is made up of > AbstractNode.java, Node0.java, Node1.java and Node2.java (plus a > util/listener). > > My ambition is to demonstrate > > 1. that any Cache<K,V>.put("DIMENSION.xxx",v) will flow through my Grouper > and "pin" that key in the Cache at @Node=0. > 2. that any Cache<K,V>.put("POSITION.xxx",v) will flow through my Grouper > and "pin" that key in the Cache at either @Node=1 or @Node=2 . > > Here is my AbstractNode#createCacheManagerProgramatically() config: > > private static EmbeddedCacheManager createCacheManagerProgramatically() { > return new DefaultCacheManager( > > GlobalConfigurationBuilder.defaultClusteredBuilder() > .transport().addProperty("configurationFile", > "jgroups.xml") > .build(), > new > org.infinispan.configuration.cache.ConfigurationBuilder() > .clustering() > .cacheMode(CacheMode.DIST_SYNC) > > .hash().numOwners(1).groups().enabled(Boolean.TRUE) > .addGrouper(new > com.jpmorgan.ct.lri.cs.ae.test.DimensionGrouper<String>()) > .build() > ); > } > > And here is my Grouper<T> implementation > > public class DimensionGrouper<T> implements Grouper<String> { > public String computeGroup(String key, String group) { > if (key.indexOf("DIMENSION.")==0) { > String groupPinned = "0"; > System.out.println("Pinning Key=["+key+"] > @Node=["+groupPinned+"]"); > //node= exactly 0 > return groupPinned; > } else if (key.indexOf("POSITION.")==0) { > String groupPinned = ""+(1+ (int)(Math.random()*2)); > System.out.println("Pinning Key=["+key+"] > @Node=["+groupPinned+"]"); > //node= {1,2} > return groupPinned; > } else { > return null; > } > } > > public Class<String> getKeyType() { > return String.class; > } > > } > > The "logic" is working correctly ... i.e. when from Node2.java I call > > for (int i = 0; i < 10; i++) { > cacheDP.put("DIMENSION." + i, "DimensionValue." > + i); > cacheDP.put("POSITION." + i, "PositionValue." + > i); > > } > > My DimensionGrouper is returning "0" from computeGroup(). My question is > how in Infinispan can I map the computeGroup() return value to a physical > Node? I.e. How can I make it so that when computeGroup() returns "0", I > will *only* add that <K,V> entry to the Cache @Node 0? > > > > > > -- > View this message in context: > http://infinispan-developer-list.980875.n3.nabble.com/Re-How-to-get-Grouper-T-computeGroup-key-return-value-to-map-to-physical-Node-tp4027134.html > Sent from the Infinispan Developer List mailing list archive at Nabble.com. > _______________________________________________ > infinispan-dev mailing list > infinispan-dev@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/infinispan-dev -- Galder Zamarreño gal...@redhat.com twitter.com/galderz Project Lead, Escalante http://escalante.io Engineer, Infinispan http://infinispan.org _______________________________________________ infinispan-dev mailing list infinispan-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/infinispan-dev