re: State transfer:
This is because the indexing interceptor is added to the chain after the cache starts and after the state has been transferred. This will be properly applied after the query API is finalised, in ISPN-194.
re: the clustered cache loader, you should create a JIRA for this. If you have a unit test that would be great.
My questions is how to hook up the InfinispanDirectory to the QueryHelper, so I can use InfinispanDirectory for the index of my cache. Based on the parameters the QueryHelper constructor takes, it seems I can only use the Properties for the hook. I can set the "hibernate.search.default.directory_provider" to "org.infinispan.lucene.InfinispanDirectory", but it's not obvious to me what property to use to pass in the cache I want to use for the index to the InfinispanDirectory.
I hope this clarifies the confustion, and would appreciate your quick response.
the classname which you set to hibernate.search.default.directory_provider has to implement the org.hibernate.search.store.DirectoryProvider interface; you should write an implementation of that and I'm sure it will be more clear: you don't point it to the InfinispanDirectory but make a factory for it.
In this factory you have total flexibility in configuration: you can start a new cache, or grab one by jndi; the interface of the DirectoryProvider has an initialize method which receives the Query configuration properties too, you might use them to configure the cache, or pass the name of the cache you use in the configuration file of Infinispan.
Sorry for this requiring to write some code, we will provide a general purpose implementation in the future but that will require some thinking and feedback to make sure it's flexible enough. Patches welcome!
We got it working but the implementation was a bit clumsy.
We created an infinispan directory provider and in the initialize method, created an InfinispanDirectory. Problem is, I need a cache to create that directory. The cache object I wanted to use is created by the caller, so I had to pass the cache in a ThreadLocal variable to it because I can't put objects in the Properties object of initialize (it only accepts strings).
Be happy to contribute what we did, but there's probably a much better way to do this. The solution with the threadlocal is a bit of a hack ;-)
right I was wondering myself what would the best way to pass the cache; I've seen some early adopters just create the cachemanager in the initialize, this works fine if you have only one Infinispan directory but it not great if you have several.
Another approach would be to expect the Infinispan cachemanager to be registered in JNDI as a severvice and look it up.
You say you created the cache in the caller, so where is it initialized?
I guess the code for this is quite simple but could need much feedback, we need to hear about more use cases; you could bring this up on the developer mailing list of Infinispan or Hibernate Search, that's also the best place to propose patches.
Right now I pass a cache, I probably could just get the cache from the cache manager instead. But, I create the cache manager (or managers could be multiple) centrally in an OSGi bundle, so I'm probably going to end up passing a CacheManager instance (have to do this thread local hack). Since I'm in OSGi, one approach would be to get my bundle that creates these managers, but I have no BundleContext and can't pass it to the provider. Basically, since the provider is not created by me, it's pretty hard to pass it references to anything.
It works now, but I'm afraid what we have is not a good general solution :-(
hi, did you consider or try registering the CacheManager in JNDI?
I was hoping to avoid JNDI since I'm not running in an EE container but in OSGi (and want to support regular Java SE runtimes).
right we must find a solution which is non-EE friendly too; I guess we need to elaborate a proposal to change the interface's contract, but avoiding to create a strong coupling to Infinispan.
It would be nice if in the properties for QueryHelper;
queryHelper = new QueryHelper(cache, p, classesToBeIndexed);
That in 'p' which is a regular Java Properties object I could put an object as a property. Properties is just a hashtable, so i can do object puts. Still not super clean, but better than thread local.
The problem is that the hibernate code grabs that property object and converts it to some type of filtered properties, which throws invalid operations if you try to use the hashtable methods :-(. So it ensures you can only pass objects around.
Thanks. Just seems a bit more complicated than just passing an instance of the CacheManager via the property object we already use though :-(