Help

Emmanuel mentioned in his previous Search post the new Statistics interface which is new in Hibernate search 3.3 (latest version 3.3.0.Beta1). I thought it is time to write a little bit more about it. The API is actually self-explanatory:

package org.hibernate.search.stat;
...
public interface Statistics {
    /**
     * Reset all statistics.
     */
    void clear();

    /**
     * Get global number of executed search queries
     *
     * @return search query execution count
     */
    long getSearchQueryExecutionCount();

    /**
     * Get the total search time in nanoseconds.
     */
    long getSearchQueryTotalTime();

    /**
     * Get the time in nanoseconds of the slowest search.
     */
    long getSearchQueryExecutionMaxTime();

    /**
     * Get the average search time in nanoseconds.
     */
    long getSearchQueryExecutionAvgTime();

    /**
     * Get the query string for the slowest query.
     */
    String getSearchQueryExecutionMaxTimeQueryString();

    /**
     * Get the total object loading in nanoseconds.
     */
    long getObjectLoadingTotalTime();

    /**
     * Get the time in nanoseconds for the slowest object load.
     */
    long getObjectLoadingExecutionMaxTime();

    /**
     * Get the average object loading time in nanoseconds.
     */
    long getObjectLoadingExecutionAvgTime();

    /**
     * Gets the total number of objects loaded
     */
    long getObjectsLoadedCount();

    /**
     * Are statistics logged
     */
    public boolean isStatisticsEnabled();

    /**
     * Enable statistics logs (this is a dynamic parameter)
     */
    public void setStatisticsEnabled(boolean b);

    /**
     * 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 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);

    /**
     * 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();
}

Access to the statistics is via SearchFactory.getStatistics(). The information about which classes are indexed and how many entities are in the index will always be available. However, the query and object loading timings will only be collected if the property hibernate.search.generate_statistics is set in your configuration. I am thinking about introducing an additional interface in order to make this separation more obvious. WDYT?

The new statistic and monitoring functionality does not end here. You can also enable access to the statistics via JMX. Setting the property hibernate.search.jmx_enabled will automatically register the StatisticsInfoMBean with the MBeanServer. On top of this MBean there are two more MBeans - IndexControlMBean and IndexingProgressMonitorMBean - which will or will not be available depending on your configuration and the state of the application.

The IndexControlMBean allows you to build, optimize and purge the index for a given entity. Indexing occurs via the mass indexing API. A requirement for this bean to be registered in JMX is, that the Hibernate SessionFactory is bound to JNDI via the hibernate.session_factory_name property. Refer to the Hibernate Core manual for more information on how to configure JNDI. The IndexControlMBean API are for now just experimental.

Last but not least, the IndexingProgressMonitorMBean. This MBean is an implementation of the MassIndexerProgressMonitor interface. If hibernate.search.jmx_enabled is set and the mass indexer API is used the indexing progress can be followed via this MBean. The bean will only be bound to JMX while indexing is in progress. Once indexing is completed the MBean is not longer available. Again, this API is for now experimental.

Do you think this new monitoring and statistic API it is valuable? Are you missing any functionality? Let us know and use the Search forum or Jira to suggest new features or to report a bug.

Enjoy!

4 comments:
 
24. Sep 2010, 13:46 CET | Link
Sanne

great job! I didn't know you where working on such a complete API. Would it make sense to be able to ask the API about which queries where slow? maybe you could collect the top-10 slowest.

javadoc of isStatisticsEnabled() states logged, I'm a bit confused on that; you mean that stats will be logged or collected?

ReplyQuote
 
21. Jun 2014, 16:11 CET | Link

Could it be true that its nearly unattainable a vehicle loan nowadays in case your credit is anything under perfect? This is actually the common perception with many people, however with the next poor credit vehicle financing tips, you may still obtain a loan with reasonable terms vehicle vehicle For those who have a low credit score history you might be thinking about you choices for poor credit finance. It might want to purchase a vehicle, or perhaps a home, but arent sure whether you will get the finance needed for that purchase. poor credit

 
17. Jul 2014, 19:28 CET | Link
Natural Crytsal x

Here Sell Natural Herbs to your sex organs. get the low price and high quality. guaranteed safe to use and has been selling certified immediately get Crystal x Asli

01. Aug 2014, 13:19 CET | Link

Includes a collection of Jon Hildebrandt Superhandles reviews, video download information, basketball drills and workouts, and tips on how to become a better basketball player from around the web.visit rebelmouse.com for super moves dribbling

Post Comment