Hi Guys,
Just trying to understand how this works at start up time. I have configured the FSSlaveDirectory in a test prototype client app and I am seeing some weird results at start up time. Ok I have two directories configured, a client directory (hibernate.search.default.indexBase) and a common shared directory (hibernate.search.default.sourceBase). Now the common directory has the latest index version in it and the client directory is completely empty at start up.
After running my app my client directory looks like so
+myindex
++com.package.Foo
+++ 0 (directory zero ) 1.1g
+++ 1 (directory one ) 2kb
+++ 2 (directory two ) 2kb
+++ current1 (marker file)
Now on inititialization of the FSSlaveDirectoryProvider copies the common directory index over into the directory zero but the marker file is set to be current1. This has the effect that any queries done are done against directory 1 which has no index file in there because it was copied over into zero. It is not until the "CopyDirectory" task kicks in that FSSSlave rectifies itself and starts querying a directory which has the an index in it.
I assume this shouldnt be happening??!!
Stepped through where this is happening
In FSSSlaveDirectoryProvider
Code:
public void start(){
.......
File destinationFile = new File( indexDir, Integer.valueOf( readCurrentState ).toString() );
readCurrentState is zero because "current" is set to zero on the initialize() call and when this is executed
Code:
try {
FileHelper.synchronize(
new File( sourceIndexDir, String.valueOf( sourceCurrent ) ),
destinationFile, true, copyChunkSize
);
}
catch ( IOException e ) {
throw new SearchException( "Unable to synchronize directory: " + indexName, e );
}
I end up with my directory structure above. It is fine for someone with a low refresh period but for someone with a long refresh period to be querying the wrong directory with no index in it is not what you want at start up ;).
Also side note, while stepping through i noticed that FSSlaveDirectoryProvider is created several times for the same index e.g For com.package.Foo i see initialise() gets called 3-4 times for this directory, please note that only start gets called once though but I was just curious as to why create it so many times???
As always, appreciate any feedback.
Cheers,
LL
p.s Please note that I am using the FSSSlaveProviderDirectory standalone , that means no JMS configuration. Dont think it makes a difference but thought it was worth mentioning.