Saving parition id in the backing store
621488Mar 14 2008 — edited Apr 19 2010Hi,
We would like to add the partition id into our database backing store.
We would like to do this so that we can re-load only the partion that has been lost if we recieve a PARTITION_LOST PartitionEvent.
The only way that we can see to get thet partition id from a key is to get the KeyPartitioningStrategy from the PartitionedService in our CahceStore.store() method.
Something like this:
void store(Object key, Object value) {
PartitionedService service = (PartitionedService) CacheFactory.getService("distributed-service");
KeyPartitioningStrategy kps = service.getKeyPartitioningStrategy();
int partition = kps.getKeyPartition(key);
jdbc.update("insert into backing_store (key, partition, value) values (?,?,?)", key, partition, value);
}
Is doing this safe? Is there any other way that this could be implemented? Is there a large overhead in calling back to the KeyPartitioningStrategy within CahceStore.store()? (We are using write-through to the backing store so don't want the store() call to be slow.)
Thanks,
Alex