[hibernate-commits] Hibernate SVN: r20174 - in search/trunk/hibernate-search/src: main/java/org/hibernate/search/impl and 3 other directories.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Thu Aug 19 07:43:20 EDT 2010
Author: hardy.ferentschik
Date: 2010-08-19 07:43:20 -0400 (Thu, 19 Aug 2010)
New Revision: 20174
Added:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/ConfigInfo.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/ConfigInfoMBean.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitorMBean.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/JMXRegistrar.java
Removed:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfo.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfoMBean.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrl.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrlMBean.java
Modified:
search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/MassIndexerImpl.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java
search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SimpleIndexingProgressMonitor.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/ConfigInfoMBeanTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/NoMBeansEnabledTest.java
Log:
HSEARCH-278 Added a MBean to monitor the mass indexing progress. Introduced JMXRegistrar and did some refactoring of existing JMX code
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -29,17 +29,16 @@
import java.util.concurrent.locks.ReentrantLock;
import org.apache.lucene.search.Similarity;
-import org.hibernate.search.SearchFactory;
+
import org.hibernate.search.backend.BackendQueueProcessorFactory;
import org.hibernate.search.backend.LuceneIndexingParameters;
-import org.hibernate.search.backend.Worker;
import org.hibernate.search.backend.impl.batchlucene.BatchBackend;
import org.hibernate.search.batchindexing.MassIndexerProgressMonitor;
+import org.hibernate.search.exception.ErrorHandler;
import org.hibernate.search.filter.FilterCachingStrategy;
import org.hibernate.search.spi.SearchFactoryIntegrator;
import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.search.store.optimization.OptimizerStrategy;
-import org.hibernate.search.exception.ErrorHandler;
/**
* Interface which gives access to the different directory providers and their configuration.
@@ -75,7 +74,7 @@
int getFilterCacheBitResultsSize();
Set<Class<?>> getIndexedTypesPolymorphic(Class<?>[] classes);
-
+
BatchBackend makeBatchBackend(MassIndexerProgressMonitor progressMonitor);
Similarity getSimilarity(DirectoryProvider<?> directoryProvider);
@@ -83,5 +82,4 @@
boolean isExclusiveIndexUsageEnabled(DirectoryProvider<?> provider);
ErrorHandler getErrorHandler();
-
}
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/MassIndexerImpl.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/MassIndexerImpl.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/MassIndexerImpl.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -29,33 +29,39 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
+import org.slf4j.Logger;
+
import org.hibernate.CacheMode;
import org.hibernate.SessionFactory;
+import org.hibernate.search.Environment;
import org.hibernate.search.MassIndexer;
import org.hibernate.search.batchindexing.BatchCoordinator;
import org.hibernate.search.batchindexing.Executors;
import org.hibernate.search.batchindexing.MassIndexerProgressMonitor;
import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.jmx.IndexingProgressMonitorMBean;
+import org.hibernate.search.jmx.IndexingProgressMonitor;
+import org.hibernate.search.jmx.JMXRegistrar;
+import org.hibernate.search.spi.internals.StateSearchFactoryImplementor;
import org.hibernate.search.util.LoggerFactory;
-import org.slf4j.Logger;
/**
* Prepares and configures a BatchIndexingWorkspace to start rebuilding
* the indexes for all entity instances in the database.
* The type of these entities is either all indexed entities or a
* subset, always including all subtypes.
- *
+ *
* @author Sanne Grinovero
*/
public class MassIndexerImpl implements MassIndexer {
-
+
private static final Logger log = LoggerFactory.make();
-
+
private final SearchFactoryImplementor searchFactoryImplementor;
private final SessionFactory sessionFactory;
protected Set<Class<?>> rootEntities = new HashSet<Class<?>>();
-
+
// default settings defined here:
private int objectLoadingThreads = 2; //loading the main entity
private int collectionLoadingThreads = 4; //also responsible for loading of lazy @IndexedEmbedded collections
@@ -68,23 +74,41 @@
private boolean optimizeAfterPurge = true;
private MassIndexerProgressMonitor monitor = new SimpleIndexingProgressMonitor();
- protected MassIndexerImpl(SearchFactoryImplementor searchFactory, SessionFactory sessionFactory, Class<?>...entities) {
+ protected MassIndexerImpl(SearchFactoryImplementor searchFactory, SessionFactory sessionFactory, Class<?>... entities) {
this.searchFactoryImplementor = searchFactory;
this.sessionFactory = sessionFactory;
rootEntities = toRootEntities( searchFactoryImplementor, entities );
+
+ if ( searchFactory instanceof StateSearchFactoryImplementor ) {
+ StateSearchFactoryImplementor stateSearchFactoryImplementor = ( StateSearchFactoryImplementor ) searchFactory;
+ String enableJMX = stateSearchFactoryImplementor.getConfigurationProperties()
+ .getProperty( Environment.JMX_ENABLED );
+ if ( "true".equalsIgnoreCase( enableJMX ) ) {
+ monitor = new IndexingProgressMonitor();
+ JMXRegistrar.registerMBean(
+ monitor, IndexingProgressMonitorMBean.INDEXING_PROGRESS_MONITOR_MBEAN_OBJECT_NAME
+ );
+ }
+ }
}
/**
* From the set of classes a new set is built containing all indexed
* subclasses, but removing then all subtypes of indexed entities.
+ *
* @param selection
+ *
* @return a new set of entities
*/
private static Set<Class<?>> toRootEntities(SearchFactoryImplementor searchFactoryImplementor, Class<?>... selection) {
Set<Class<?>> entities = new HashSet<Class<?>>();
//first build the "entities" set containing all indexed subtypes of "selection".
- for (Class<?> entityType : selection) {
- Set<Class<?>> targetedClasses = searchFactoryImplementor.getIndexedTypesPolymorphic( new Class[] {entityType} );
+ for ( Class<?> entityType : selection ) {
+ Set<Class<?>> targetedClasses = searchFactoryImplementor.getIndexedTypesPolymorphic(
+ new Class[] {
+ entityType
+ }
+ );
if ( targetedClasses.isEmpty() ) {
String msg = entityType.getName() + " is not an indexed entity or a subclass of an indexed entity";
throw new IllegalArgumentException( msg );
@@ -94,9 +118,9 @@
Set<Class<?>> cleaned = new HashSet<Class<?>>();
Set<Class<?>> toRemove = new HashSet<Class<?>>();
//now remove all repeated types to avoid duplicate loading by polymorphic query loading
- for (Class<?> type : entities) {
+ for ( Class<?> type : entities ) {
boolean typeIsOk = true;
- for (Class<?> existing : cleaned) {
+ for ( Class<?> existing : cleaned ) {
if ( existing.isAssignableFrom( type ) ) {
typeIsOk = false;
break;
@@ -115,33 +139,37 @@
}
public MassIndexer cacheMode(CacheMode cacheMode) {
- if ( cacheMode == null )
+ if ( cacheMode == null ) {
throw new IllegalArgumentException( "cacheMode must not be null" );
+ }
this.cacheMode = cacheMode;
return this;
}
public MassIndexer threadsToLoadObjects(int numberOfThreads) {
- if ( numberOfThreads < 1 )
+ if ( numberOfThreads < 1 ) {
throw new IllegalArgumentException( "numberOfThreads must be at least 1" );
+ }
this.objectLoadingThreads = numberOfThreads;
return this;
}
-
+
public MassIndexer batchSizeToLoadObjects(int batchSize) {
- if ( batchSize < 1 )
+ if ( batchSize < 1 ) {
throw new IllegalArgumentException( "batchSize must be at least 1" );
+ }
this.objectLoadingBatchSize = batchSize;
return this;
}
-
+
public MassIndexer threadsForSubsequentFetching(int numberOfThreads) {
- if ( numberOfThreads < 1 )
+ if ( numberOfThreads < 1 ) {
throw new IllegalArgumentException( "numberOfThreads must be at least 1" );
+ }
this.collectionLoadingThreads = numberOfThreads;
return this;
}
-
+
//TODO see MassIndexer interface
// public MassIndexer threadsForIndexWriter(int numberOfThreads) {
// if ( numberOfThreads < 1 )
@@ -149,7 +177,7 @@
// this.writerThreads = numberOfThreads;
// return this;
// }
-
+
public MassIndexer optimizeOnFinish(boolean optimize) {
this.optimizeAtEnd = optimize;
return this;
@@ -164,7 +192,7 @@
this.purgeAtStart = purgeAll;
return this;
}
-
+
public Future<?> start() {
BatchCoordinator coordinator = createCoordinator();
ExecutorService executor = Executors.newFixedThreadPool( 1, "batch coordinator" );
@@ -176,7 +204,7 @@
executor.shutdown();
}
}
-
+
public void startAndWait() throws InterruptedException {
BatchCoordinator coordinator = createCoordinator();
coordinator.run();
@@ -184,13 +212,15 @@
throw new InterruptedException();
}
}
-
+
protected BatchCoordinator createCoordinator() {
- return new BatchCoordinator( rootEntities, searchFactoryImplementor, sessionFactory,
+ return new BatchCoordinator(
+ rootEntities, searchFactoryImplementor, sessionFactory,
objectLoadingThreads, collectionLoadingThreads,
cacheMode, objectLoadingBatchSize, objectsLimit,
optimizeAtEnd, purgeAtStart, optimizeAfterPurge,
- monitor );
+ monitor
+ );
}
public MassIndexer limitIndexedObjectsTo(long maximum) {
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SearchFactoryBuilder.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -24,7 +24,6 @@
package org.hibernate.search.impl;
import java.beans.Introspector;
-import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
@@ -36,9 +35,6 @@
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.search.Similarity;
@@ -78,9 +74,10 @@
import org.hibernate.search.filter.FilterCachingStrategy;
import org.hibernate.search.filter.MRUFilterCachingStrategy;
import org.hibernate.search.filter.ShardSensitiveOnlyFilter;
-import org.hibernate.search.jmx.HibernateSearchConfigInfo;
-import org.hibernate.search.jmx.HibernateSearchConfigInfoMBean;
-import org.hibernate.search.jmx.HibernateSearchIndexCtrl;
+import org.hibernate.search.jmx.ConfigInfo;
+import org.hibernate.search.jmx.ConfigInfoMBean;
+import org.hibernate.search.jmx.IndexCtrl;
+import org.hibernate.search.jmx.JMXRegistrar;
import org.hibernate.search.reader.ReaderProvider;
import org.hibernate.search.reader.ReaderProviderFactory;
import org.hibernate.search.spi.WorkerBuildContext;
@@ -167,48 +164,16 @@
}
private void enableJMXStatistics(SearchFactoryImplementor searchFactoryImplementor) {
- HibernateSearchConfigInfo statsBean = new HibernateSearchConfigInfo( searchFactoryImplementor );
- ObjectName name = createObjectName( HibernateSearchConfigInfoMBean.CONFIG_MBEAN_OBJECT_NAME );
- registerMBean( statsBean, name );
+ ConfigInfo configInfoBean = new ConfigInfo( searchFactoryImplementor );
+ JMXRegistrar.registerMBean( configInfoBean, ConfigInfoMBean.CONFIG_MBEAN_OBJECT_NAME );
// if we have a JNDI bound SessionFactory we can also enable the index control bean
if ( StringHelper.isNotEmpty( configurationProperties.getProperty( "hibernate.session_factory_name" ) ) ) {
- HibernateSearchIndexCtrl indexCtrlBean = new HibernateSearchIndexCtrl( configurationProperties );
- name = createObjectName( HibernateSearchIndexCtrl.INDEX_CTRL_MBEAN_OBJECT_NAME );
- registerMBean( indexCtrlBean, name );
+ IndexCtrl indexCtrlBean = new IndexCtrl( configurationProperties );
+ JMXRegistrar.registerMBean( indexCtrlBean, IndexCtrl.INDEX_CTRL_MBEAN_OBJECT_NAME );
}
}
- private ObjectName createObjectName(String name) {
- ObjectName objectName;
- try {
- objectName = new ObjectName( name );
- }
- catch ( MalformedObjectNameException e ) {
- throw new SearchException( "Invalid JMX Bean name: " + name, e );
- }
- return objectName;
- }
-
- private void registerMBean(Object stats, ObjectName name) {
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- if ( mbs.isRegistered( name ) ) {
- try {
- mbs.unregisterMBean( name );
- }
- catch ( Exception e ) {
- log.warn( "Unable to un-register existing MBean: " + name, e );
- }
- }
-
- try {
- mbs.registerMBean( stats, name );
- }
- catch ( Exception e ) {
- throw new SearchException( "Unable to enable MBean for Hibernate Search", e );
- }
- }
-
private SearchFactoryImplementor buildIncrementalSearchFactory() {
removeClassesAlreadyManaged();
if ( classes.size() == 0 ) {
Modified: search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SimpleIndexingProgressMonitor.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SimpleIndexingProgressMonitor.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/impl/SimpleIndexingProgressMonitor.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -26,17 +26,18 @@
import java.util.concurrent.atomic.AtomicLong;
+import org.slf4j.Logger;
+
import org.hibernate.search.batchindexing.MassIndexerProgressMonitor;
import org.hibernate.search.util.LoggerFactory;
-import org.slf4j.Logger;
/**
- * A very simple implementation of MassIndexerProgressMonitor
- *
+ * A very simple implementation of {@code MassIndexerProgressMonitor}
+ *
* @author Sanne Grinovero
*/
public class SimpleIndexingProgressMonitor implements MassIndexerProgressMonitor {
-
+
private static final Logger log = LoggerFactory.make();
private final AtomicLong documentsDoneCounter = new AtomicLong();
private final AtomicLong totalCounter = new AtomicLong();
@@ -64,17 +65,16 @@
totalCounter.addAndGet( count );
log.info( "Going to reindex {} entities", count );
}
-
+
protected int getStatusMessagePeriod() {
return 50;
}
-
+
protected void printStatusMessage(long starttimems, long totalTodoCount, long doneCount) {
long elapsedMs = System.currentTimeMillis() - starttimems;
log.info( "{} documents indexed in {} ms", doneCount, elapsedMs );
- float estimateSpeed = doneCount * 1000f / elapsedMs ;
- float estimatePercentileComplete = doneCount * 100f / totalTodoCount ;
+ float estimateSpeed = doneCount * 1000f / elapsedMs;
+ float estimatePercentileComplete = doneCount * 100f / totalTodoCount;
log.info( "Indexing speed: {} documents/second; progress: {}%", estimateSpeed, estimatePercentileComplete );
}
-
}
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/ConfigInfo.java (from rev 20091, search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfo.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/ConfigInfo.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/ConfigInfo.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -0,0 +1,136 @@
+/*
+ * 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.jmx;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;
+
+import org.hibernate.search.ProjectionConstants;
+import org.hibernate.search.Version;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.reader.ReaderProvider;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.util.ReflectHelper;
+
+/**
+ * Implementation of the {@code ConfigInfoMBean} JMX attributes and operations.
+ *
+ * @author Hardy Ferentschik
+ */
+public class ConfigInfo implements ConfigInfoMBean {
+
+ private final SearchFactoryImplementor searchFactoryImplementor;
+
+ public ConfigInfo(SearchFactoryImplementor searchFactoryImplementor) {
+ this.searchFactoryImplementor = searchFactoryImplementor;
+ }
+
+ public String getSearchVersion() {
+ return Version.getVersionString();
+ }
+
+ public Set<String> getIndexedClassNames() {
+ Set<String> indexedClasses = new HashSet<String>();
+ for ( Class clazz : searchFactoryImplementor.getDocumentBuildersIndexedEntities().keySet() ) {
+ indexedClasses.add( clazz.getName() );
+ }
+ return indexedClasses;
+ }
+
+ public String getIndexingStrategy() {
+ return searchFactoryImplementor.getIndexingStrategy();
+ }
+
+ public int getNumberOfIndexedEntities(String entity) {
+ Class<?> clazz = getEntityClass( entity );
+ DirectoryProvider[] directoryProviders = searchFactoryImplementor.getDirectoryProviders( clazz );
+ ReaderProvider readerProvider = searchFactoryImplementor.getReaderProvider();
+
+ int count = 0;
+ for ( DirectoryProvider directoryProvider : directoryProviders ) {
+ IndexReader reader = readerProvider.openReader( directoryProvider );
+ IndexSearcher searcher = new IndexSearcher( reader );
+ BooleanQuery boolQuery = new BooleanQuery();
+ boolQuery.add( new MatchAllDocsQuery(), BooleanClause.Occur.MUST );
+ boolQuery.add(
+ new TermQuery( new Term( ProjectionConstants.OBJECT_CLASS, entity ) ), BooleanClause.Occur.MUST
+ );
+ try {
+ TopDocs topdocs = searcher.search( boolQuery, 1 );
+ count += topdocs.totalHits;
+ }
+ catch ( IOException e ) {
+ throw new RuntimeException( "Unable to execute count query for entity " + entity, e );
+ }
+ finally {
+ readerProvider.closeReader( reader );
+ }
+ }
+ return count;
+ }
+
+ public Map<String, Integer> indexedEntitiesCount() {
+ Map<String, Integer> countPerEntity = new HashMap<String, Integer>();
+ for ( String className : getIndexedClassNames() ) {
+ countPerEntity.put( className, getNumberOfIndexedEntities( className ) );
+ }
+ return countPerEntity;
+ }
+
+ public List<String> getIndexingParameters(String entity) {
+ Class<?> clazz = getEntityClass( entity );
+ List<String> indexingParameters = new ArrayList<String>();
+ for ( DirectoryProvider directoryProvider : searchFactoryImplementor.getDirectoryProviders( clazz ) ) {
+ indexingParameters.add( searchFactoryImplementor.getIndexingParameters( directoryProvider ).toString() );
+ }
+ return indexingParameters;
+ }
+
+ private Class<?> getEntityClass(String entity) {
+ Class<?> clazz;
+ try {
+ clazz = ReflectHelper.classForName( entity, ConfigInfo.class );
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException( entity + "not a indexed entity" );
+ }
+ return clazz;
+ }
+}
+
+
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/ConfigInfoMBean.java (from rev 20091, search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfoMBean.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/ConfigInfoMBean.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/ConfigInfoMBean.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -0,0 +1,90 @@
+/*
+ * 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.jmx;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Defines the Hibernate Search exposed JMX attributes and operations for index configuration.
+ *
+ * @author Hardy Ferentschik
+ */
+public interface ConfigInfoMBean {
+
+ public static final String CONFIG_MBEAN_OBJECT_NAME = "org.hibernate.search.jmx:type=ConfigInfoMBean";
+
+ /**
+ * Returns the Hibernate Search version.
+ *
+ * @return the Hibernate Search version
+ */
+ String getSearchVersion();
+
+ /**
+ * Returns a list of all indexed classes.
+ *
+ * @return list of all indexed classes
+ */
+ Set<String> getIndexedClassNames();
+
+ /**
+ * Returns the indexing strategy - <i>manual</i> vs. event <i>event</i>.
+ *
+ * @return the indexing strategy
+ */
+ String getIndexingStrategy();
+
+ /**
+ * Returns the number of documents for the given entity.
+ *
+ * @param entity the fqc of the entity
+ *
+ * @return number of documents for the specified entity name
+ *
+ * @throws IllegalArgumentException in case the entity name is not valid
+ */
+ int getNumberOfIndexedEntities(String entity);
+
+ /**
+ * A list of string representations of the indexing parameters for each directory of the specified entity.
+ * Defaults are not displayed, but only parameters which are explicitly set via the configuration.
+ *
+ * @param entity the fqc of the entity
+ *
+ * @return A list of string representations of the indexing parameters for each directory of the specified entity
+ *
+ * @throws IllegalArgumentException in case the entity name is not valid
+ */
+ List<String> getIndexingParameters(String entity);
+
+ /**
+ * Returns a map of all indexed entities and their document count in the index.
+ *
+ * @return a map of all indexed entities and their document count. The map key is the fqc of the entity and
+ * the map value is the document count.
+ */
+ Map<String, Integer> indexedEntitiesCount();
+}
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfo.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfo.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfo.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -1,131 +0,0 @@
-/*
- * 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.jmx;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.MatchAllDocsQuery;
-import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocs;
-
-import org.hibernate.search.ProjectionConstants;
-import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.reader.ReaderProvider;
-import org.hibernate.search.store.DirectoryProvider;
-import org.hibernate.util.ReflectHelper;
-
-/**
- * Implementation of the {@code HibernateSearchConfigInfoMBean} JMX attributes and operations.
- *
- * @author Hardy Ferentschik
- */
-public class HibernateSearchConfigInfo implements HibernateSearchConfigInfoMBean {
-
- private final SearchFactoryImplementor searchFactoryImplementor;
-
- public HibernateSearchConfigInfo(SearchFactoryImplementor searchFactoryImplementor) {
- this.searchFactoryImplementor = searchFactoryImplementor;
- }
-
- public Set<String> getIndexedClassNames() {
- Set<String> indexedClasses = new HashSet<String>();
- for ( Class clazz : searchFactoryImplementor.getDocumentBuildersIndexedEntities().keySet() ) {
- indexedClasses.add( clazz.getName() );
- }
- return indexedClasses;
- }
-
- public String getIndexingStrategy() {
- return searchFactoryImplementor.getIndexingStrategy();
- }
-
- public int getNumberOfIndexedEntities(String entity) {
- Class<?> clazz = getEntityClass( entity );
- DirectoryProvider[] directoryProviders = searchFactoryImplementor.getDirectoryProviders( clazz );
- ReaderProvider readerProvider = searchFactoryImplementor.getReaderProvider();
-
- int count = 0;
- for ( DirectoryProvider directoryProvider : directoryProviders ) {
- IndexReader reader = readerProvider.openReader( directoryProvider );
- IndexSearcher searcher = new IndexSearcher( reader );
- BooleanQuery boolQuery = new BooleanQuery();
- boolQuery.add( new MatchAllDocsQuery(), BooleanClause.Occur.MUST );
- boolQuery.add(
- new TermQuery( new Term( ProjectionConstants.OBJECT_CLASS, entity ) ), BooleanClause.Occur.MUST
- );
- try {
- TopDocs topdocs = searcher.search( boolQuery, 1 );
- count += topdocs.totalHits;
- }
- catch ( IOException e ) {
- throw new RuntimeException( "Unable to execute count query for entity " + entity, e );
- }
- finally {
- readerProvider.closeReader( reader );
- }
- }
- return count;
- }
-
- public Map<String, Integer> indexedEntitiesCount() {
- Map<String, Integer> countPerEntity = new HashMap<String, Integer>();
- for ( String className : getIndexedClassNames() ) {
- countPerEntity.put( className, getNumberOfIndexedEntities( className ) );
- }
- return countPerEntity;
- }
-
- public List<String> getIndexingParameters(String entity) {
- Class<?> clazz = getEntityClass( entity );
- List<String> indexingParameters = new ArrayList<String>();
- for ( DirectoryProvider directoryProvider : searchFactoryImplementor.getDirectoryProviders( clazz ) ) {
- indexingParameters.add( searchFactoryImplementor.getIndexingParameters( directoryProvider ).toString() );
- }
- return indexingParameters;
- }
-
- private Class<?> getEntityClass(String entity) {
- Class<?> clazz;
- try {
- clazz = ReflectHelper.classForName( entity, HibernateSearchConfigInfo.class );
- }
- catch ( ClassNotFoundException e ) {
- throw new IllegalArgumentException( entity + "not a indexed entity" );
- }
- return clazz;
- }
-}
-
-
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfoMBean.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfoMBean.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchConfigInfoMBean.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -1,83 +0,0 @@
-/*
- * 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.jmx;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Defines the Hibernate Search exposed JMX attributes and operations for index configuration.
- *
- * @author Hardy Ferentschik
- */
-public interface HibernateSearchConfigInfoMBean {
-
- public static final String CONFIG_MBEAN_OBJECT_NAME = "org.hibernate.search.jmx:type=HibernateSearchConfigInfoMBean";
-
- /**
- * Returns a list of all indexed classes.
- *
- * @return list of all indexed classes
- */
- Set<String> getIndexedClassNames();
-
- /**
- * Returns the indexing strategy - <i>manual</i> vs. event <i>event</i>.
- *
- * @return the indexing strategy
- */
- String getIndexingStrategy();
-
- /**
- * Returns the number of documents for the given entity.
- *
- * @param entity the fqc of the entity
- *
- * @return number of documents for the specified entity name
- *
- * @throws IllegalArgumentException in case the entity name is not valid
- */
- int getNumberOfIndexedEntities(String entity);
-
- /**
- * A list of string representations of the indexing parameters for each directory of the specified entity.
- * Defaults are not displayed, but only parameters which are explicitly set via the configuration.
- *
- * @param entity the fqc of the entity
- *
- * @return A list of string representations of the indexing parameters for each directory of the specified entity
- *
- * @throws IllegalArgumentException in case the entity name is not valid
- */
- List<String> getIndexingParameters(String entity);
-
- /**
- * Returns a map of all indexed entities and their document count in the index.
- *
- * @return a map of all indexed entities and their document count. The map key is the fqc of the entity and
- * the map value is the document count.
- */
- Map<String, Integer> indexedEntitiesCount();
-}
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrl.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrl.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrl.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -1,115 +0,0 @@
-/*
- * 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.jmx;
-
-import java.util.Properties;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.hibernate.CacheMode;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.util.JNDIHelper;
-import org.hibernate.util.ReflectHelper;
-
-
-/**
- * Implementation of the {@code HibernateSearchIndexCtrlMBean} JMX attributes and operations.
- *
- * @author Hardy Ferentschik
- */
-public class HibernateSearchIndexCtrl implements HibernateSearchIndexCtrlMBean {
- private static final String HIBERNATE_JNDI_PREFIX = "hibernate.jndi.";
-
- private final Properties jndiProperties;
- private final String sessionFactoryJndiName;
-
- public HibernateSearchIndexCtrl(Properties props) {
- this.sessionFactoryJndiName = props.getProperty( "hibernate.session_factory_name" );
- this.jndiProperties = JNDIHelper.getJndiProperties( props, HIBERNATE_JNDI_PREFIX );
- }
-
- public void index(String entity) {
- Class<?> clazz = getEntityClass( entity );
-
- SessionFactory factory = getSessionFactory();
- Session session = factory.openSession();
- FullTextSession fulltextSession = Search.getFullTextSession( session );
- try {
- fulltextSession.createIndexer( clazz )
- .batchSizeToLoadObjects( 25 )
- .cacheMode( CacheMode.NORMAL )
- .threadsToLoadObjects( 5 )
- .threadsForSubsequentFetching( 20 )
- .startAndWait();
- }
- catch ( InterruptedException e ) {
- throw new RuntimeException( "Unable to complete indexing" );
- }
- session.close();
- }
-
- public void purge(String entity) {
- Class<?> clazz = getEntityClass( entity );
-
- SessionFactory factory = getSessionFactory();
- Session session = factory.openSession();
- FullTextSession fullTextSession = Search.getFullTextSession( session );
- fullTextSession.beginTransaction();
- fullTextSession.purgeAll( clazz );
- fullTextSession.getTransaction().commit();
- session.close();
- }
-
- private Class<?> getEntityClass(String entity) {
- Class<?> clazz;
- try {
- clazz = ReflectHelper.classForName( entity, HibernateSearchIndexCtrl.class );
- }
- catch ( ClassNotFoundException e ) {
- throw new IllegalArgumentException( entity + "not a indexed entity" );
- }
- return clazz;
- }
-
- private SessionFactory getSessionFactory() {
- try {
- Context initialContext;
- if ( jndiProperties.isEmpty() ) {
- initialContext = new InitialContext();
- }
- else {
- initialContext = new InitialContext( jndiProperties );
- }
- return ( SessionFactory ) initialContext.lookup( sessionFactoryJndiName );
- }
- catch ( Exception e ) {
- throw new UnsupportedOperationException(
- "In order for this operation to work the SessionFactory must be bound to JNDI"
- );
- }
- }
-}
\ No newline at end of file
Deleted: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrlMBean.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrlMBean.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrlMBean.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -1,62 +0,0 @@
-/*
- * 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.jmx;
-
-/**
- * Defines the Hibernate Search exposed JMX attributes and operations for index creation and purging.
- *
- * @author Hardy Ferentschik
- */
-public interface HibernateSearchIndexCtrlMBean {
-
- public static final String INDEX_CTRL_MBEAN_OBJECT_NAME = "org.hibernate.search.jmx:type=HibernateSearchIndexCtrlMBean";
-
- /**
- * Index the specified entity using the mass indexer.
- * <p><b>Note:<br/>
- * This method is only available if the Hibernate {@code SessionFactory}
- * is available via JNDI.
- * </p>
- *
- * @param entity The fqc of the entity to index
- *
- * @throws IllegalArgumentException in case the entity name is not valid
- * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
- */
- void index(String entity);
-
- /**
- * Purge the index of the specified entity.
- * <p><b>Note:<br/>
- * This method is only available if the Hibernate {@code SessionFactory}
- * is available via JNDI.
- * </p>
- *
- * @param entity The fqc of the entity to index
- *
- * @throws IllegalArgumentException in case the entity name is not valid
- * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
- */
- void purge(String entity);
-}
\ No newline at end of file
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java (from rev 20091, search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrl.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrl.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -0,0 +1,155 @@
+/*
+ * 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.jmx;
+
+import java.util.Properties;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.hibernate.CacheMode;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.util.JNDIHelper;
+import org.hibernate.util.ReflectHelper;
+
+
+/**
+ * Implementation of the {@code IndexCtrlMBean} JMX attributes and operations.
+ *
+ * @author Hardy Ferentschik
+ */
+public class IndexCtrl implements IndexCtrlMBean {
+ private static final String HIBERNATE_JNDI_PREFIX = "hibernate.jndi.";
+
+ private final Properties jndiProperties;
+ private final String sessionFactoryJndiName;
+
+ private int batchSize = 25;
+ private int numberOfObjectLoadingThreads = 2;
+ private int numberOfFetchingThreads = 4;
+
+ public IndexCtrl(Properties props) {
+ this.sessionFactoryJndiName = props.getProperty( "hibernate.session_factory_name" );
+ this.jndiProperties = JNDIHelper.getJndiProperties( props, HIBERNATE_JNDI_PREFIX );
+ }
+
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ public int getBatchSize() {
+ return batchSize;
+ }
+
+ public void setNumberOfObjectLoadingThreads(int numberOfThreads) {
+ this.numberOfObjectLoadingThreads = numberOfThreads;
+ }
+
+ public int getNumberOfObjectLoadingThreads() {
+ return numberOfObjectLoadingThreads;
+ }
+
+ public void setNumberOfFetchingThreads(int numberOfThreads) {
+ this.numberOfFetchingThreads = numberOfThreads;
+ }
+
+ public int getNumberOfFetchingThreads() {
+ return numberOfFetchingThreads;
+ }
+
+ public void index(String entity) {
+ Class<?> clazz = getEntityClass( entity );
+
+ SessionFactory factory = getSessionFactory();
+ Session session = factory.openSession();
+ FullTextSession fulltextSession = Search.getFullTextSession( session );
+ try {
+ fulltextSession.createIndexer( clazz )
+ .batchSizeToLoadObjects( batchSize )
+ .cacheMode( CacheMode.NORMAL )
+ .threadsToLoadObjects( numberOfObjectLoadingThreads )
+ .threadsForSubsequentFetching( numberOfFetchingThreads )
+ .startAndWait();
+ }
+ catch ( InterruptedException e ) {
+ throw new RuntimeException( "Unable to complete indexing" );
+ }
+ session.close();
+ }
+
+ public void optimize(String entity) {
+ Class<?> clazz = getEntityClass( entity );
+
+ SessionFactory factory = getSessionFactory();
+ Session session = factory.openSession();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ fullTextSession.beginTransaction();
+ fullTextSession.getSearchFactory().optimize( clazz );
+ fullTextSession.getTransaction().commit();
+ session.close();
+ }
+
+ public void purge(String entity) {
+ Class<?> clazz = getEntityClass( entity );
+
+ SessionFactory factory = getSessionFactory();
+ Session session = factory.openSession();
+ FullTextSession fullTextSession = Search.getFullTextSession( session );
+ fullTextSession.beginTransaction();
+ fullTextSession.purgeAll( clazz );
+ fullTextSession.getTransaction().commit();
+ session.close();
+ }
+
+ private Class<?> getEntityClass(String entity) {
+ Class<?> clazz;
+ try {
+ clazz = ReflectHelper.classForName( entity, IndexCtrl.class );
+ }
+ catch ( ClassNotFoundException e ) {
+ throw new IllegalArgumentException( entity + "not a indexed entity" );
+ }
+ return clazz;
+ }
+
+ private SessionFactory getSessionFactory() {
+ try {
+ Context initialContext;
+ if ( jndiProperties.isEmpty() ) {
+ initialContext = new InitialContext();
+ }
+ else {
+ initialContext = new InitialContext( jndiProperties );
+ }
+ return ( SessionFactory ) initialContext.lookup( sessionFactoryJndiName );
+ }
+ catch ( Exception e ) {
+ throw new UnsupportedOperationException(
+ "In order for this operation to work the SessionFactory must be bound to JNDI"
+ );
+ }
+ }
+}
\ No newline at end of file
Added: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexCtrlMBean.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -0,0 +1,108 @@
+/*
+ * 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.jmx;
+
+/**
+ * Defines the Hibernate Search exposed JMX attributes and operations for index creation and purging.
+ *
+ * @author Hardy Ferentschik
+ */
+public interface IndexCtrlMBean {
+
+ public static final String INDEX_CTRL_MBEAN_OBJECT_NAME = "org.hibernate.search.jmx:type=IndexCtrlMBean";
+
+ /**
+ * Sets the batch size for the mass indexer.
+ *
+ * @param batchSize the new batch size
+ */
+ void setBatchSize(int batchSize);
+
+ /**
+ * @return the current batch size for (mass) indexing
+ */
+ int getBatchSize();
+
+ /**
+ * @param numberOfThreads the number of threads used for object loading during mass indexing.
+ */
+ void setNumberOfObjectLoadingThreads(int numberOfThreads);
+
+ /**
+ * @return the current number of threads during mass indexing
+ */
+ int getNumberOfObjectLoadingThreads();
+
+ /**
+ * @param numberOfThreads the number of threads used for collections fetching during mass indexing
+ */
+ void setNumberOfFetchingThreads(int numberOfThreads);
+
+ /**
+ * @return the current number of threads used for collection fetching
+ */
+ int getNumberOfFetchingThreads();
+
+ /**
+ * Index the specified entity using the mass indexer.
+ * <p><b>Note:<br/>
+ * This method is only available if the Hibernate {@code SessionFactory}
+ * is available via JNDI.
+ * </p>
+ *
+ * @param entity The fqc of the entity to index
+ *
+ * @throws IllegalArgumentException in case the entity name is not valid
+ * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
+ */
+ void index(String entity);
+
+ /**
+ * Optimizes the index for the specified entity.
+ * <p><b>Note:<br/>
+ * This method is only available if the Hibernate {@code SessionFactory}
+ * is available via JNDI.
+ * </p>
+ *
+ * @param entity The fqc of the entity to index
+ *
+ * @throws IllegalArgumentException in case the entity name is not valid
+ * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
+ */
+ void optimize(String entity);
+
+ /**
+ * Purge the index of the specified entity.
+ * <p><b>Note:<br/>
+ * This method is only available if the Hibernate {@code SessionFactory}
+ * is available via JNDI.
+ * </p>
+ *
+ * @param entity The fqc of the entity to index
+ *
+ * @throws IllegalArgumentException in case the entity name is not valid
+ * @throws UnsupportedOperationException in case the Hibernate {@code SessionFactory} is not bound via JNDI.
+ */
+ void purge(String entity);
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitor.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -0,0 +1,69 @@
+/*
+ * 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.jmx;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.hibernate.search.batchindexing.MassIndexerProgressMonitor;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class IndexingProgressMonitor implements IndexingProgressMonitorMBean, MassIndexerProgressMonitor {
+
+ private final AtomicLong documentsDoneCounter = new AtomicLong();
+ private final AtomicLong documentsBuiltCounter = new AtomicLong();
+ private final AtomicLong totalCounter = new AtomicLong();
+ private final AtomicLong entitiesLoadedCounter = new AtomicLong();
+
+ public void documentsAdded(long increment) {
+ documentsDoneCounter.addAndGet( increment );
+ }
+
+ public void documentsBuilt(int number) {
+ documentsBuiltCounter.addAndGet( number );
+ }
+
+ public void entitiesLoaded(int size) {
+ entitiesLoadedCounter.addAndGet( size );
+ }
+
+ public void addToTotalCount(long count) {
+ totalCounter.addAndGet( count );
+ }
+
+ public long getLoadedEntitiesCount() {
+ return entitiesLoadedCounter.get();
+ }
+
+ public long getDocumentsAddedCount() {
+ return documentsDoneCounter.get();
+ }
+
+ public long getNumberOfEntitiesToIndex() {
+ return totalCounter.get();
+ }
+}
+
+
Copied: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitorMBean.java (from rev 20091, search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/HibernateSearchIndexCtrlMBean.java)
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitorMBean.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/IndexingProgressMonitorMBean.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -0,0 +1,51 @@
+/*
+ * 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.jmx;
+
+/**
+ * A MBean for following the progress of mass indexing.
+ *
+ * @author Hardy Ferentschik
+ */
+public interface IndexingProgressMonitorMBean {
+
+ public static final String INDEXING_PROGRESS_MONITOR_MBEAN_OBJECT_NAME = "org.hibernate.search.jmx:type=IndexingProgressMBean";
+
+ /**
+ * @return the number of entities loaded so far
+ */
+ long getLoadedEntitiesCount();
+
+ /**
+ * @return the number of Lucene {@code Document}s added so far
+ */
+ long getDocumentsAddedCount();
+
+ /**
+ * @return the total number of entities which need indexing
+ */
+ long getNumberOfEntitiesToIndex();
+}
+
+
Added: search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/JMXRegistrar.java
===================================================================
--- search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/JMXRegistrar.java (rev 0)
+++ search/trunk/hibernate-search/src/main/java/org/hibernate/search/jmx/JMXRegistrar.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -0,0 +1,85 @@
+/*
+ * 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.jmx;
+
+import java.lang.management.ManagementFactory;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.slf4j.Logger;
+
+import org.hibernate.search.SearchException;
+import org.hibernate.search.util.LoggerFactory;
+
+/**
+ * Helper class to register JMX beans.
+ *
+ * @author Hardy Ferentschik
+ */
+public final class JMXRegistrar {
+ private static final Logger log = LoggerFactory.make();
+
+ private JMXRegistrar() {
+ }
+
+ /**
+ * Registers the specified object with the given name to the MBean server.
+ *
+ * @param object the object to register
+ * @param name the object name to register the bean under
+ */
+ public static void registerMBean(Object object, String name) {
+ ObjectName objectName = createObjectName( name );
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ if ( mbs.isRegistered( objectName ) ) {
+ try {
+ mbs.unregisterMBean( objectName );
+ }
+ catch ( Exception e ) {
+ log.warn( "Unable to un-register existing MBean: " + name, e );
+ }
+ }
+
+ try {
+ mbs.registerMBean( object, objectName );
+ }
+ catch ( Exception e ) {
+ throw new SearchException( "Unable to enable MBean for Hibernate Search", e );
+ }
+ }
+
+ private static ObjectName createObjectName(String name) {
+ ObjectName objectName;
+ try {
+ objectName = new ObjectName( name );
+ }
+ catch ( MalformedObjectNameException e ) {
+ throw new SearchException( "Invalid JMX Bean name: " + name, e );
+ }
+ return objectName;
+ }
+}
+
+
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/batchindexing/IndexingGeneratedCorpusTest.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -27,10 +27,11 @@
import java.util.List;
import junit.framework.TestCase;
-
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.Query;
+
import org.hibernate.Transaction;
+import org.hibernate.search.Environment;
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.backend.impl.batchlucene.LuceneBatchBackend;
@@ -40,15 +41,15 @@
/**
* Tests the fullTextSession.createIndexer() API
* for basic functionality.
- *
+ *
* @author Sanne Grinovero
*/
public class IndexingGeneratedCorpusTest extends TestCase {
-
+
private final int BOOK_NUM = 140;
private final int ANCIENTBOOK_NUM = 120;
- private final int DVD_NUM = 200;
-
+ private final int DVD_NUM = 10000;
+
private SentenceInventor sentenceInventor = new SentenceInventor( 7L, 4000 );
private FullTextSessionBuilder builder;
private int totalEntitiesInDB = 0;
@@ -58,36 +59,42 @@
super.setUp();
builder = new FullTextSessionBuilder();
builder
- .addAnnotatedClass( Book.class )
- .addAnnotatedClass( Dvd.class )
- .addAnnotatedClass( AncientBook.class )
- .addAnnotatedClass( Nation.class )
- .setProperty( "hibernate.show_sql", "false" ) //too verbose for this test
- .setProperty( LuceneBatchBackend.CONCURRENT_WRITERS, "4" )
- .build();
+ .addAnnotatedClass( Book.class )
+ .addAnnotatedClass( Dvd.class )
+ .addAnnotatedClass( AncientBook.class )
+ .addAnnotatedClass( Nation.class )
+ .setProperty( "hibernate.show_sql", "false" ) //too verbose for this test
+ .setProperty( LuceneBatchBackend.CONCURRENT_WRITERS, "4" )
+ .setProperty( "hibernate.session_factory_name", "java:comp/SessionFactory" )
+ .setProperty( "hibernate.jndi.class", "org.osjava.sj.SimpleContextFactory" )
+ .setProperty( "hibernate.jndi.org.osjava.sj.root", "/Users/hardy/tmp/jndi-entries" )
+ .setProperty( "hibernate.jndi.org.osjava.sj.jndi.shared", "true" )
+ .setProperty( Environment.JMX_ENABLED, "true" )
+ .build();
createMany( Book.class, BOOK_NUM );
createMany( Dvd.class, DVD_NUM );
createMany( AncientBook.class, ANCIENTBOOK_NUM );
storeAllBooksInNation();
}
-
+
@Override
protected void tearDown() {
builder.close();
}
- private void createMany(Class<? extends TitleAble> entityType, int amount ) throws InstantiationException, IllegalAccessException {
+ private void createMany(Class<? extends TitleAble> entityType, int amount)
+ throws InstantiationException, IllegalAccessException {
FullTextSession fullTextSession = builder.openFullTextSession();
try {
Transaction tx = fullTextSession.beginTransaction();
- fullTextSession.persist( new Nation("Italy", "IT") );
+ fullTextSession.persist( new Nation( "Italy", "IT" ) );
tx.commit();
tx = fullTextSession.beginTransaction();
for ( int i = 0; i < amount; i++ ) {
TitleAble instance = entityType.newInstance();
instance.setTitle( sentenceInventor.nextSentence() );
//to test for HSEARCH-512 we make all entities share some proxy
- Nation country = (Nation) fullTextSession.load( Nation.class, 1 );
+ Nation country = ( Nation ) fullTextSession.load( Nation.class, 1 );
instance.setFirstPublishedIn( country );
fullTextSession.persist( instance );
totalEntitiesInDB++;
@@ -95,7 +102,7 @@
tx.commit();
fullTextSession.clear();
System.out.println( "Test preparation: " + totalEntitiesInDB + " entities persisted" );
- tx = fullTextSession.beginTransaction();
+ tx = fullTextSession.beginTransaction();
}
}
tx.commit();
@@ -104,7 +111,7 @@
fullTextSession.close();
}
}
-
+
/**
* Adds all stored books to the Nation.
* Needed to test for HSEARCH-534 and makes the dataset to index quite bigger.
@@ -114,7 +121,7 @@
try {
Transaction tx = fullTextSession.beginTransaction();
List<Book> allBooks = fullTextSession.createCriteria( Book.class ).list();
- Nation italy = (Nation) fullTextSession.load( Nation.class, 1 );
+ Nation italy = ( Nation ) fullTextSession.load( Nation.class, 1 );
italy.getLibrariesHave().addAll( allBooks );
tx.commit();
}
@@ -122,26 +129,29 @@
fullTextSession.close();
}
}
-
+
public void testBatchIndexing() throws InterruptedException {
verifyResultNumbers(); //initial count of entities should match expectations
purgeAll(); // empty indexes
verifyIsEmpty();
reindexAll(); // rebuild the indexes
+
+ Thread.sleep( 60000 );
+
verifyResultNumbers(); // verify the count match again
reindexAll(); //tests that purgeAll is automatic:
verifyResultNumbers(); //..same numbers again
}
-
+
private void reindexAll() throws InterruptedException {
FullTextSession fullTextSession = builder.openFullTextSession();
try {
fullTextSession.createIndexer( Object.class )
- .threadsForSubsequentFetching( 8 )
- .threadsToLoadObjects( 4 )
- .batchSizeToLoadObjects( 30 )
- .startAndWait();
- }
+ .threadsForSubsequentFetching( 8 )
+ .threadsToLoadObjects( 4 )
+ .batchSizeToLoadObjects( 30 )
+ .startAndWait();
+ }
finally {
fullTextSession.close();
}
@@ -161,18 +171,28 @@
@SuppressWarnings("unchecked")
private void verifyResultNumbers() {
- assertEquals( DVD_NUM,
- countByFT( Dvd.class ) );
- assertEquals( ANCIENTBOOK_NUM + BOOK_NUM,
- countByFT( Book.class ) );
- assertEquals( ANCIENTBOOK_NUM,
- countByFT( AncientBook.class ) );
- assertEquals( DVD_NUM + ANCIENTBOOK_NUM + BOOK_NUM,
- countByFT( AncientBook.class, Book.class, Dvd.class ) );
- assertEquals( DVD_NUM + ANCIENTBOOK_NUM,
- countByFT( AncientBook.class, Dvd.class ) );
+ assertEquals(
+ DVD_NUM,
+ countByFT( Dvd.class )
+ );
+ assertEquals(
+ ANCIENTBOOK_NUM + BOOK_NUM,
+ countByFT( Book.class )
+ );
+ assertEquals(
+ ANCIENTBOOK_NUM,
+ countByFT( AncientBook.class )
+ );
+ assertEquals(
+ DVD_NUM + ANCIENTBOOK_NUM + BOOK_NUM,
+ countByFT( AncientBook.class, Book.class, Dvd.class )
+ );
+ assertEquals(
+ DVD_NUM + ANCIENTBOOK_NUM,
+ countByFT( AncientBook.class, Dvd.class )
+ );
}
-
+
@SuppressWarnings("unchecked")
private void verifyIsEmpty() {
assertEquals( 0, countByFT( Dvd.class ) );
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/ConfigInfoMBeanTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/ConfigInfoMBeanTest.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/ConfigInfoMBeanTest.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -40,7 +40,7 @@
import org.hibernate.search.Environment;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.hibernate.search.jmx.HibernateSearchConfigInfoMBean;
+import org.hibernate.search.jmx.ConfigInfoMBean;
import org.hibernate.search.test.SearchTestCase;
/**
@@ -123,7 +123,7 @@
protected void setUp() throws Exception {
super.setUp();
mbeanServer = ManagementFactory.getPlatformMBeanServer();
- configBeanObjectName = new ObjectName( HibernateSearchConfigInfoMBean.CONFIG_MBEAN_OBJECT_NAME );
+ configBeanObjectName = new ObjectName( ConfigInfoMBean.CONFIG_MBEAN_OBJECT_NAME );
}
protected void tearDown() throws Exception {
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/IndexCtrlMBeanTest.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -41,8 +41,8 @@
import org.hibernate.search.Environment;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.hibernate.search.jmx.HibernateSearchConfigInfoMBean;
-import org.hibernate.search.jmx.HibernateSearchIndexCtrlMBean;
+import org.hibernate.search.jmx.ConfigInfoMBean;
+import org.hibernate.search.jmx.IndexCtrlMBean;
import org.hibernate.search.test.SearchTestCase;
/**
@@ -111,8 +111,8 @@
protected void setUp() throws Exception {
super.setUp();
mbeanServer = ManagementFactory.getPlatformMBeanServer();
- configBeanObjectName = new ObjectName( HibernateSearchConfigInfoMBean.CONFIG_MBEAN_OBJECT_NAME );
- indexBeanObjectName = new ObjectName( HibernateSearchIndexCtrlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
+ configBeanObjectName = new ObjectName( ConfigInfoMBean.CONFIG_MBEAN_OBJECT_NAME );
+ indexBeanObjectName = new ObjectName( IndexCtrlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
}
protected void tearDown() throws Exception {
Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/NoMBeansEnabledTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/NoMBeansEnabledTest.java 2010-08-18 18:55:48 UTC (rev 20173)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/jmx/NoMBeansEnabledTest.java 2010-08-19 11:43:20 UTC (rev 20174)
@@ -30,8 +30,8 @@
import org.hibernate.cfg.Configuration;
import org.hibernate.search.Environment;
-import org.hibernate.search.jmx.HibernateSearchConfigInfoMBean;
-import org.hibernate.search.jmx.HibernateSearchIndexCtrlMBean;
+import org.hibernate.search.jmx.ConfigInfoMBean;
+import org.hibernate.search.jmx.IndexCtrlMBean;
import org.hibernate.search.test.SearchTestCase;
/**
@@ -42,13 +42,13 @@
public void testMBeanNotRegisteredWithoutExplicitProperty() throws Exception {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- ObjectName name = new ObjectName( HibernateSearchConfigInfoMBean.CONFIG_MBEAN_OBJECT_NAME );
+ ObjectName name = new ObjectName( ConfigInfoMBean.CONFIG_MBEAN_OBJECT_NAME );
assertFalse(
"Without '" + Environment.JMX_ENABLED + "' set the configuration info MBean should not be registered",
mbs.isRegistered( name )
);
- name = new ObjectName( HibernateSearchIndexCtrlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
+ name = new ObjectName( IndexCtrlMBean.INDEX_CTRL_MBEAN_OBJECT_NAME );
assertFalse(
"Without '" + Environment.JMX_ENABLED + "' set the index control MBean should not be registered",
mbs.isRegistered( name )
More information about the hibernate-commits
mailing list