[hibernate-commits] Hibernate SVN: r20180 - in search/trunk/hibernate-search/src/main/java/org/hibernate/search: batchindexing and 2 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Aug 19 07:51:16 EDT 2010
Author: hardy.ferentschik
Date: 2010-08-19 07:51:16 -0400 (Thu, 19 Aug 2010)
New Revision: 20180
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/MassIndexerProgressMonitor.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/WorkerBuildContext.java
Log:
HSEARCH-278 Updating javadoc, formatting and copy right information. No functional changes
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java 2010-08-19 11:50:14 UTC (rev 20179)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/backend/impl/batchlucene/BatchBackend.java 2010-08-19 11:51:16 UTC (rev 20180)
@@ -1,73 +1,79 @@
-/* $Id$
- *
+/*
* Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
*/
package org.hibernate.search.backend.impl.batchlucene;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import org.hibernate.search.spi.WorkerBuildContext;
import org.hibernate.search.backend.LuceneWork;
import org.hibernate.search.batchindexing.MassIndexerProgressMonitor;
+import org.hibernate.search.spi.WorkerBuildContext;
/**
- * Implementors of this interface are not drop-in replacements for the standard BackendQueueProcessorFactory
+ * Implementations of this interface are not drop-in replacements for the standard BackendQueueProcessorFactory,
* but are meant to be used only during batch processing.
* The order of LuceneWork(s) processed is not guaranteed as the queue is consumed by several
- * concurrent workers.
- *
+ * concurrent workers.
+ *
* @author Sanne Grinovero
*/
public interface BatchBackend {
-
+
/**
* Used at startup, called once as first method.
+ *
* @param props all configuration properties
- * @param searchFactory the client
+ * @param monitor the indexing progress monitor
+ * @param context the build context for the workers.
*/
void initialize(Properties props, MassIndexerProgressMonitor monitor, WorkerBuildContext context);
/**
* Enqueues one work to be processed asynchronously
+ *
* @param work
+ *
* @throws InterruptedException if the current thread is interrupted while
- * waiting for the work queue to have enough space.
+ * waiting for the work queue to have enough space.
*/
void enqueueAsyncWork(LuceneWork work) throws InterruptedException;
-
+
/**
* Does one work in sync
+ *
* @param work
+ *
* @throws InterruptedException
*/
void doWorkInSync(LuceneWork work);
-
+
/**
* Waits until all work is done and terminates the executors.
* IndexWriter is not closed yet: work in sync can still be processed.
+ *
* @throws InterruptedException if the current thread is interrupted
- * while waiting for the enqueued tasks to be finished.
+ * while waiting for the enqueued tasks to be finished.
*/
void stopAndFlush(long timeout, TimeUnit unit) throws InterruptedException;
@@ -76,5 +82,4 @@
* No other method should be used after this one.
*/
void close();
-
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java 2010-08-19 11:50:14 UTC (rev 20179)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/BatchCoordinator.java 2010-08-19 11:51:16 UTC (rev 20180)
@@ -1,26 +1,25 @@
-/* $Id$
- *
+/*
* Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
*/
package org.hibernate.search.batchindexing;
@@ -29,6 +28,8 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
+import org.slf4j.Logger;
+
import org.hibernate.CacheMode;
import org.hibernate.SessionFactory;
import org.hibernate.search.backend.OptimizeLuceneWork;
@@ -36,20 +37,19 @@
import org.hibernate.search.backend.impl.batchlucene.BatchBackend;
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.hibernate.search.util.LoggerFactory;
-import org.slf4j.Logger;
/**
* Makes sure that several different BatchIndexingWorkspace(s)
* can be started concurrently, sharing the same batch-backend
* and IndexWriters.
- *
+ *
* @author Sanne Grinovero
*/
public class BatchCoordinator implements Runnable {
-
+
private static final Logger log = LoggerFactory.make();
-
- private final Class<?>[] rootEntities; //entity types to reindex exluding all subtypes of each-other
+
+ private final Class<?>[] rootEntities; //entity types to reindex excluding all subtypes of each-other
private final SearchFactoryImplementor searchFactoryImplementor;
private final SessionFactory sessionFactory;
private final int objectLoadingThreads;
@@ -62,30 +62,30 @@
private final CountDownLatch endAllSignal;
private final MassIndexerProgressMonitor monitor;
private final long objectsLimit;
-
+
private BatchBackend backend;
public BatchCoordinator(Set<Class<?>> rootEntities,
- SearchFactoryImplementor searchFactoryImplementor,
- SessionFactory sessionFactory, int objectLoadingThreads,
- int collectionLoadingThreads, CacheMode cacheMode,
- int objectLoadingBatchSize, long objectsLimit,
- boolean optimizeAtEnd,
- boolean purgeAtStart, boolean optimizeAfterPurge,
- MassIndexerProgressMonitor monitor) {
- this.rootEntities = rootEntities.toArray( new Class<?>[ rootEntities.size() ] );
- this.searchFactoryImplementor = searchFactoryImplementor;
- this.sessionFactory = sessionFactory;
- this.objectLoadingThreads = objectLoadingThreads;
- this.collectionLoadingThreads = collectionLoadingThreads;
- this.cacheMode = cacheMode;
- this.objectLoadingBatchSize = objectLoadingBatchSize;
- this.optimizeAtEnd = optimizeAtEnd;
- this.purgeAtStart = purgeAtStart;
- this.optimizeAfterPurge = optimizeAfterPurge;
- this.monitor = monitor;
- this.objectsLimit = objectsLimit;
- this.endAllSignal = new CountDownLatch( rootEntities.size() );
+ SearchFactoryImplementor searchFactoryImplementor,
+ SessionFactory sessionFactory, int objectLoadingThreads,
+ int collectionLoadingThreads, CacheMode cacheMode,
+ int objectLoadingBatchSize, long objectsLimit,
+ boolean optimizeAtEnd,
+ boolean purgeAtStart, boolean optimizeAfterPurge,
+ MassIndexerProgressMonitor monitor) {
+ this.rootEntities = rootEntities.toArray( new Class<?>[rootEntities.size()] );
+ this.searchFactoryImplementor = searchFactoryImplementor;
+ this.sessionFactory = sessionFactory;
+ this.objectLoadingThreads = objectLoadingThreads;
+ this.collectionLoadingThreads = collectionLoadingThreads;
+ this.cacheMode = cacheMode;
+ this.objectLoadingBatchSize = objectLoadingBatchSize;
+ this.optimizeAtEnd = optimizeAtEnd;
+ this.purgeAtStart = purgeAtStart;
+ this.optimizeAfterPurge = optimizeAfterPurge;
+ this.monitor = monitor;
+ this.objectsLimit = objectsLimit;
+ this.endAllSignal = new CountDownLatch( rootEntities.size() );
}
public void run() {
@@ -93,10 +93,11 @@
try {
beforeBatch(); // purgeAll and pre-optimize activities
doBatchWork();
- backend.stopAndFlush( 60L*60*24, TimeUnit.SECONDS ); //1 day : enough to flush to indexes?
+ backend.stopAndFlush( 60L * 60 * 24, TimeUnit.SECONDS ); //1 day : enough to flush to indexes?
// backend.stopAndFlush( 10, TimeUnit.SECONDS );
afterBatch();
- } catch (InterruptedException e) {
+ }
+ catch ( InterruptedException e ) {
log.error( "Batch indexing was interrupted" );
Thread.currentThread().interrupt();
}
@@ -108,16 +109,20 @@
/**
* Will spawn a thread for each type in rootEntities, they will all re-join
* on endAllSignal when finished.
+ *
* @throws InterruptedException if interrupted while waiting for endAllSignal.
*/
private void doBatchWork() throws InterruptedException {
ExecutorService executor = Executors.newFixedThreadPool( rootEntities.length, "BatchIndexingWorkspace" );
for ( Class<?> type : rootEntities ) {
- executor.execute( new BatchIndexingWorkspace(
- searchFactoryImplementor, sessionFactory, type,
- objectLoadingThreads, collectionLoadingThreads,
- cacheMode, objectLoadingBatchSize,
- endAllSignal, monitor, backend, objectsLimit ) );
+ executor.execute(
+ new BatchIndexingWorkspace(
+ searchFactoryImplementor, sessionFactory, type,
+ objectLoadingThreads, collectionLoadingThreads,
+ cacheMode, objectLoadingBatchSize,
+ endAllSignal, monitor, backend, objectsLimit
+ )
+ );
}
executor.shutdown();
endAllSignal.await(); //waits for the executor to finish
@@ -142,7 +147,7 @@
Set<Class<?>> targetedClasses = searchFactoryImplementor.getIndexedTypesPolymorphic( rootEntities );
for ( Class<?> clazz : targetedClasses ) {
//needs do be in-sync work to make sure we wait for the end of it.
- backend.doWorkInSync( new PurgeAllLuceneWork( clazz ) );
+ backend.doWorkInSync( new PurgeAllLuceneWork( clazz ) );
}
if ( this.optimizeAfterPurge ) {
optimize( targetedClasses );
@@ -156,5 +161,4 @@
backend.doWorkInSync( new OptimizeLuceneWork( clazz ) );
}
}
-
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/MassIndexerProgressMonitor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/MassIndexerProgressMonitor.java 2010-08-19 11:50:14 UTC (rev 20179)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/batchindexing/MassIndexerProgressMonitor.java 2010-08-19 11:51:16 UTC (rev 20180)
@@ -1,26 +1,25 @@
-/* $Id$
- *
+/*
* Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors. All third-party contributions are
- * distributed under license by Red Hat, Inc.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02110-1301 USA
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
*/
package org.hibernate.search.batchindexing;
@@ -29,12 +28,15 @@
* a MassIndexerProgressMonitor can be defined in the configuration
* property hibernate.search.worker.indexing.monitor
* implementing this interface to track indexing performance.
- *
- * Implementors must:
- * be threadsafe
- * have a no-arg constructor.
- *
+ * <p/>
+ * Implementations must:
+ * <ul>
+ * <li> be threadsafe </li>
+ * <li> have a no-arg constructor </li>
+ * </ul>
+ *
* @author Sanne Grinovero
+ * @author Hardy Ferentschik
*/
public interface MassIndexerProgressMonitor {
@@ -42,7 +44,8 @@
* The number of documents sent to the backend;
* This is called several times during
* the indexing process.
- * @param increment
+ *
+ * @param increment number of documents sent to backend
*/
void documentsAdded(long increment);
@@ -50,7 +53,8 @@
* The number of Documents built;
* This is called several times and concurrently during
* the indexing process.
- * @param number
+ *
+ * @param number number of {@code Document}s built
*/
void documentsBuilt(int number);
@@ -58,7 +62,8 @@
* The number of entities loaded from database;
* This is called several times and concurrently during
* the indexing process.
- * @param size
+ *
+ * @param size number of entities loaded from database
*/
void entitiesLoaded(int size);
@@ -68,8 +73,9 @@
* the implementation should add them up.
* This is called several times and concurrently during
* the indexing process.
- * @param count
+ *
+ * @param count number of newly indexed entities which has to
+ * ber added to total count
*/
void addToTotalCount(long count);
-
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java 2010-08-19 11:50:14 UTC (rev 20179)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java 2010-08-19 11:51:16 UTC (rev 20180)
@@ -28,6 +28,8 @@
import org.hibernate.search.batchindexing.MassIndexerProgressMonitor;
/**
+ * A JMX based mass indexer progress monitor. This monitor will allow you to follow mass indexing progress via JMX.
+ *
* @author Hardy Ferentschik
*/
public class IndexingProgressMonitor implements IndexingProgressMonitorMBean, MassIndexerProgressMonitor {
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/WorkerBuildContext.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/WorkerBuildContext.java 2010-08-19 11:50:14 UTC (rev 20179)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/spi/WorkerBuildContext.java 2010-08-19 11:51:16 UTC (rev 20180)
@@ -1,7 +1,29 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat, Inc. and/or its affiliates or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat, Inc.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ */
package org.hibernate.search.spi;
import java.util.Set;
-import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.search.Similarity;
@@ -20,11 +42,18 @@
*/
public interface WorkerBuildContext extends BuildContext {
void setBackendQueueProcessorFactory(BackendQueueProcessorFactory backendQueueProcessorFactory);
- public OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider);
+
+ OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider);
+
Set<Class<?>> getClassesInDirectoryProvider(DirectoryProvider<?> provider);
+
LuceneIndexingParameters getIndexingParameters(DirectoryProvider<?> directoryProvider);
+
Similarity getSimilarity(DirectoryProvider<?> directoryProvider);
+
boolean isExclusiveIndexUsageEnabled(DirectoryProvider<?> directoryProvider);
+
ErrorHandler getErrorHandler();
+
<T> DocumentBuilderIndexedEntity<T> getDocumentBuilderIndexedEntity(Class<T> managedType);
}
More information about the hibernate-commits
mailing list