Author: sannegrinovero
Date: 2009-10-30 09:58:05 -0400 (Fri, 30 Oct 2009)
New Revision: 17884
Modified:
search/trunk/src/main/docbook/en-US/modules/batchindex.xml
search/trunk/src/main/docbook/en-US/modules/configuration.xml
search/trunk/src/main/java/org/hibernate/search/Environment.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPResources.java
search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java
search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderFactory.java
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/ReaderPerformance.java
Log:
HSEARCH-327 Capability to reuse IndexWriter instances across transactions - name changes
and documentation fix
Modified: search/trunk/src/main/docbook/en-US/modules/batchindex.xml
===================================================================
--- search/trunk/src/main/docbook/en-US/modules/batchindex.xml 2009-10-30 13:00:07 UTC
(rev 17883)
+++ search/trunk/src/main/docbook/en-US/modules/batchindex.xml 2009-10-30 13:58:05 UTC
(rev 17884)
@@ -261,7 +261,7 @@
<itemizedlist>
<listitem>
-
<literal>hibernate.search.[default|<indexname>].enable_greedy_locking</literal>
+
<literal>hibernate.search.[default|<indexname>].exclusive_index_use</literal>
</listitem>
<listitem>
Modified: search/trunk/src/main/docbook/en-US/modules/configuration.xml
===================================================================
--- search/trunk/src/main/docbook/en-US/modules/configuration.xml 2009-10-30 13:00:07 UTC
(rev 17883)
+++ search/trunk/src/main/docbook/en-US/modules/configuration.xml 2009-10-30 13:58:05 UTC
(rev 17884)
@@ -764,10 +764,10 @@
<tbody>
<row>
-
<entry><literal>hibernate.search.[default|<indexname>].enable_greedy_locking</literal></entry>
+
<entry><literal>hibernate.search.[default|<indexname>].exclusive_index_use</literal></entry>
<entry><para>Set to <literal>true</literal> when no
other
- application uses the same index, this will enable
+ process will need to write to the same index: this will enable
Hibernate Search to work in exlusive mode on the index and
improve performance in writing changes to the
index.</para></entry>
@@ -892,7 +892,7 @@
</table>
<tip><para>When your architecture permits it, always set
- <literal>hibernate.search.default.enable_greedy_locking=true</literal>
+ <literal>hibernate.search.default.exclusive_index_use=true</literal>
as it greatly improves efficiency in index writing.</para>
</tip>
Modified: search/trunk/src/main/java/org/hibernate/search/Environment.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/Environment.java 2009-10-30 13:00:07
UTC (rev 17883)
+++ search/trunk/src/main/java/org/hibernate/search/Environment.java 2009-10-30 13:58:05
UTC (rev 17884)
@@ -109,6 +109,6 @@
* can access the index in write mode while Hibernate Search is running.
* This is an index-scoped property and defaults to false.
*/
- public static final String ENABLE_GREEDY_LOCKING = "enable_greedy_locking";
+ public static final String EXCLUSIVE_INDEX_USE = "exclusive_index_use";
}
Modified:
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java
===================================================================
---
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java 2009-10-30
13:00:07 UTC (rev 17883)
+++
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPQueueProcessor.java 2009-10-30
13:58:05 UTC (rev 17884)
@@ -50,7 +50,7 @@
private final Workspace workspace;
private final LuceneWorkVisitor worker;
private final ExecutorService executor;
- private final boolean useGreedyLocks;
+ private final boolean exclusiveIndexUsage;
private final List<LuceneWork> workOnWriter = new ArrayList<LuceneWork>();
// if any work needs batchmode, set corresponding flag to true:
@@ -64,7 +64,7 @@
this.worker = resources.getVisitor();
this.workspace = resources.getWorkspace();
this.executor = resources.getExecutor();
- this.useGreedyLocks = resources.isLockingGreedy();
+ this.exclusiveIndexUsage = resources.isExclusiveIndexUsageEnabled();
}
/**
@@ -96,7 +96,7 @@
performOptimizations();
}
finally {
- if ( ! useGreedyLocks )
+ if ( ! exclusiveIndexUsage )
workspace.closeIndexWriter();
}
}
Modified:
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPResources.java
===================================================================
---
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPResources.java 2009-10-30
13:00:07 UTC (rev 17883)
+++
search/trunk/src/main/java/org/hibernate/search/backend/impl/lucene/PerDPResources.java 2009-10-30
13:58:05 UTC (rev 17884)
@@ -43,13 +43,13 @@
private final ExecutorService executor;
private final LuceneWorkVisitor visitor;
private final Workspace workspace;
- private final boolean lockingIsGreedy;
+ private final boolean exclusiveIndexUsage;
PerDPResources(SearchFactoryImplementor searchFactoryImp, DirectoryProvider<?> dp)
{
workspace = new Workspace( searchFactoryImp, dp );
visitor = new LuceneWorkVisitor( workspace );
executor = Executors.newFixedThreadPool( 1 );
- lockingIsGreedy = searchFactoryImp.isLockingGreedy( dp );
+ exclusiveIndexUsage = searchFactoryImp.isExclusiveIndexUsageEnabled( dp );
}
public ExecutorService getExecutor() {
@@ -64,13 +64,13 @@
return workspace;
}
- public boolean isLockingGreedy() {
- return lockingIsGreedy;
+ public boolean isExclusiveIndexUsageEnabled() {
+ return exclusiveIndexUsage;
}
public void shutdown() {
//sets the index to be closed after all current jobs are processed:
- if ( lockingIsGreedy ) {
+ if ( exclusiveIndexUsage ) {
executor.execute( new CloseIndexRunnable( workspace ) );
}
executor.shutdown();
Modified:
search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java
===================================================================
---
search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2009-10-30
13:00:07 UTC (rev 17883)
+++
search/trunk/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2009-10-30
13:58:05 UTC (rev 17884)
@@ -74,7 +74,7 @@
void close();
- void addClassToDirectoryProvider(Class<?> clazz, DirectoryProvider<?>
directoryProvider, boolean useGreedyLocking);
+ void addClassToDirectoryProvider(Class<?> clazz, DirectoryProvider<?>
directoryProvider, boolean exclusiveIndexUsage);
Set<Class<?>> getClassesInDirectoryProvider(DirectoryProvider<?>
directoryProvider);
@@ -82,7 +82,7 @@
ReentrantLock getDirectoryProviderLock(DirectoryProvider<?> dp);
- void addDirectoryProvider(DirectoryProvider<?> provider, boolean
usesGreedyLocking);
+ void addDirectoryProvider(DirectoryProvider<?> provider, boolean
exclusiveIndexUsage);
int getFilterCacheBitResultsSize();
@@ -92,5 +92,5 @@
Similarity getSimilarity(DirectoryProvider<?> directoryProvider);
- boolean isLockingGreedy(DirectoryProvider<?> provider);
+ boolean isExclusiveIndexUsageEnabled(DirectoryProvider<?> provider);
}
Modified: search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java 2009-10-30
13:00:07 UTC (rev 17883)
+++ search/trunk/src/main/java/org/hibernate/search/impl/SearchFactoryImpl.java 2009-10-30
13:58:05 UTC (rev 17884)
@@ -252,7 +252,7 @@
}
}
- public void addClassToDirectoryProvider(Class<?> clazz, DirectoryProvider<?>
directoryProvider, boolean useGreedyLocking) {
+ public void addClassToDirectoryProvider(Class<?> clazz, DirectoryProvider<?>
directoryProvider, boolean exclusiveIndexUsage) {
//no need to set a read barrier, we only use this class in the init thread
DirectoryProviderData data = dirProviderData.get( directoryProvider );
if ( data == null ) {
@@ -260,7 +260,7 @@
dirProviderData.put( directoryProvider, data );
}
data.classes.add( clazz );
- data.usesGreedyLocking = useGreedyLocking;
+ data.exclusiveIndexUsage = exclusiveIndexUsage;
}
public Set<Class<?>>
getClassesInDirectoryProvider(DirectoryProvider<?> directoryProvider) {
@@ -557,7 +557,7 @@
public OptimizerStrategy optimizerStrategy;
public final Set<Class<?>> classes = new HashSet<Class<?>>( 2
);
public Similarity similarity = null;
- private boolean usesGreedyLocking;
+ private boolean exclusiveIndexUsage;
}
public ReentrantLock getDirectoryProviderLock(DirectoryProvider<?> dp) {
@@ -566,10 +566,10 @@
return this.dirProviderData.get( dp ).dirLock;
}
- public void addDirectoryProvider(DirectoryProvider<?> provider, boolean
usesGreedyLocking) {
+ public void addDirectoryProvider(DirectoryProvider<?> provider, boolean
exclusiveIndexUsage) {
//no need to set a barrier we use this method in the init thread
DirectoryProviderData dirConfiguration = new DirectoryProviderData();
- dirConfiguration.usesGreedyLocking = usesGreedyLocking;
+ dirConfiguration.exclusiveIndexUsage = exclusiveIndexUsage;
this.dirProviderData.put( provider, dirConfiguration );
}
@@ -657,10 +657,10 @@
return similarity;
}
- public boolean isLockingGreedy(DirectoryProvider<?> provider) {
+ public boolean isExclusiveIndexUsageEnabled(DirectoryProvider<?> provider) {
if ( barrier != 0 ) {
} //read barrier
- return dirProviderData.get( provider ).usesGreedyLocking;
+ return dirProviderData.get( provider ).exclusiveIndexUsage;
}
}
Modified:
search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
---
search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderFactory.java 2009-10-30
13:00:07 UTC (rev 17883)
+++
search/trunk/src/main/java/org/hibernate/search/store/DirectoryProviderFactory.java 2009-10-30
13:58:05 UTC (rev 17884)
@@ -132,18 +132,18 @@
throw new SearchException( "Unable to initialize directory provider: " +
directoryProviderName, e );
}
int index = providers.indexOf( provider );
- boolean useGreedyLocking = isGreedyLockingEnabled( directoryProviderName, indexProps
);
+ boolean exclusiveIndexUsage = isExclusiveIndexUsageEnabled( directoryProviderName,
indexProps );
if ( index != -1 ) {
//share the same Directory provider for the same underlying store
final DirectoryProvider<?> directoryProvider = providers.get( index );
- searchFactoryImplementor.addClassToDirectoryProvider( entity, directoryProvider,
useGreedyLocking);
+ searchFactoryImplementor.addClassToDirectoryProvider( entity, directoryProvider,
exclusiveIndexUsage);
return directoryProvider;
}
else {
configureOptimizerStrategy( searchFactoryImplementor, indexProps, provider );
configureIndexingParameters( searchFactoryImplementor, indexProps, provider );
providers.add( provider );
- searchFactoryImplementor.addClassToDirectoryProvider( entity, provider,
useGreedyLocking );
+ searchFactoryImplementor.addClassToDirectoryProvider( entity, provider,
exclusiveIndexUsage );
return provider;
}
}
@@ -265,11 +265,11 @@
}
}
- private static boolean isGreedyLockingEnabled(String directoryProviderName, Properties
indexProps) {
- String usesGreedyLockingProperty = indexProps.getProperty(
Environment.ENABLE_GREEDY_LOCKING, "false" );
- boolean usesGreedyLocking = ConfigurationParseHelper.parseBoolean(
usesGreedyLockingProperty,
- "Illegal value for property " + Environment.ENABLE_GREEDY_LOCKING + "
on index " + directoryProviderName );
- return usesGreedyLocking;
+ private static boolean isExclusiveIndexUsageEnabled(String directoryProviderName,
Properties indexProps) {
+ String exclusiveIndexUsageProperty = indexProps.getProperty(
Environment.EXCLUSIVE_INDEX_USE, "false" );
+ boolean exclusiveIndexUsage = ConfigurationParseHelper.parseBoolean(
exclusiveIndexUsageProperty,
+ "Illegal value for property " + Environment.EXCLUSIVE_INDEX_USE + " on
index " + directoryProviderName );
+ return exclusiveIndexUsage;
}
}
Modified:
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/ReaderPerformance.java
===================================================================
---
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/ReaderPerformance.java 2009-10-30
13:00:07 UTC (rev 17883)
+++
search/trunk/src/test/java/org/hibernate/search/test/reader/performance/ReaderPerformance.java 2009-10-30
13:58:05 UTC (rev 17884)
@@ -107,7 +107,7 @@
cfg.setProperty( "hibernate.search.default.directory_provider",
FSDirectoryProvider.class.getName() );
cfg.setProperty( "hibernate.search.default.indexBase",
getBaseIndexDir().getAbsolutePath() );
cfg.setProperty( "hibernate.search.default.optimizer.transaction_limit.max",
"10" ); // workaround too many open files
- cfg.setProperty( "hibernate.search.default." +
Environment.ENABLE_GREEDY_LOCKING, "true" );
+ cfg.setProperty( "hibernate.search.default." +
Environment.EXCLUSIVE_INDEX_USE, "true" );
cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
cfg.setProperty( Environment.READER_STRATEGY, getReaderStrategyName() );
}