Package org.hibernate.search.impl

Examples of org.hibernate.search.impl.MutableSearchFactory


@RunWith(BMUnitRunner.class)
public class ShardingConfigurationTest {

  @Test
  public void testNoShardingIsUsedPerDefault() {
    MutableSearchFactory searchFactory = getSearchFactory( Collections.<String, String>emptyMap() );

    EntityIndexBinding entityIndexBinding = searchFactory.getIndexBinding( Foo.class );

    assertEquals(
        "No sharding should be configured. Number of shards and sharding strategy are not set",
        NotShardedStrategy.class,
        entityIndexBinding.getSelectionStrategy().getClass()
View Full Code Here


  @Test
  public void testSettingNumberOfShardsOnlySelectsIdHashSharding() {
    Map<String, String> shardingProperties = new HashMap<String, String>();
    shardingProperties.put( "hibernate.search.default.sharding_strategy.nbr_of_shards", "2" );

    MutableSearchFactory searchFactory = getSearchFactory( shardingProperties );

    EntityIndexBinding entityIndexBinding = searchFactory.getIndexBinding( Foo.class );

    assertEquals(
        "IdHashShardingStrategy should be selected due to number of shards being set",
        IdHashShardingStrategy.class,
        entityIndexBinding.getSelectionStrategy().getClass()
View Full Code Here

        "hibernate.search.default.sharding_strategy",
        DummyIndexShardingStrategy.class.getName()
    );
    shardingProperties.put( "hibernate.search.default.sharding_strategy.nbr_of_shards", "2" );

    MutableSearchFactory searchFactory = getSearchFactory( shardingProperties );

    EntityIndexBinding entityIndexBinding = searchFactory.getIndexBinding( Foo.class );

    assertEquals(
        "Explicitly set sharding strategy ignored",
        DummyIndexShardingStrategy.class,
        entityIndexBinding.getSelectionStrategy().getClass()
View Full Code Here

    shardingProperties.put(
        "hibernate.search.default.sharding_strategy",
        DummyShardIdentifierProvider.class.getName()
    );

    MutableSearchFactory searchFactory = getSearchFactory( shardingProperties );

    EntityIndexBinding entityIndexBinding = searchFactory.getIndexBinding( Foo.class );

    assertEquals(
        "Explicitly set shard id provider ignored",
        DummyShardIdentifierProvider.class,
        entityIndexBinding.getShardIdentifierProvider().getClass()
View Full Code Here

    shardingProperties.put(
        "hibernate.search.foo.sharding_strategy",
        DummyShardIdentifierProvider.class.getName()
    );

    MutableSearchFactory searchFactory = getSearchFactory( shardingProperties );

    EntityIndexBinding entityIndexBinding = searchFactory.getIndexBinding( Foo.class );

    assertEquals(
        "Explicitly set shard id provider ignored",
        DummyShardIdentifierProvider.class,
        entityIndexBinding.getShardIdentifierProvider().getClass()
View Full Code Here

    shardingProperties.put( "hibernate.search.foo.snafu.directory_provider", "filesystem" );
    File indexDir = new File( TestConstants.getIndexDirectory( ShardingConfigurationTest.class ) );
    shardingProperties.put( "hibernate.search.foo.snafu.indexBase", indexDir.getAbsolutePath() );

    MutableSearchFactory searchFactory = getSearchFactory( shardingProperties );

    EntityIndexBinding entityIndexBinding = searchFactory.getIndexBinding( Foo.class );
    IndexManager indexManagers[] = entityIndexBinding.getIndexManagers();

    assertTrue( "There should be two index managers", indexManagers.length == 1 );
    assertTrue( "Unexpected index manager type", indexManagers[0] instanceof DirectoryBasedIndexManager );
View Full Code Here

    return new Class[] { Clock.class };
  }

  @Test
  public void testNothingTest() {
    MutableSearchFactory searchFactory = (MutableSearchFactory) getSearchFactory();
    EntityIndexBinding indexBindingForEntity = searchFactory.getIndexBinding( Clock.class );
    IndexManager[] indexManagers = indexBindingForEntity.getIndexManagers();
    assertEquals( 1, indexManagers.length );
    DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager) indexManagers[0];
    LuceneBackendQueueProcessor backend = (LuceneBackendQueueProcessor) indexManager.getBackendQueueProcessor();
    assertEquals( 5, backend.getIndexResources().getMaxQueueLength() );
View Full Code Here

    session.close();
  }

  private DirectoryBasedIndexManager getSingleIndexManager(Class<?> clazz) {
    MutableSearchFactory searchFactory = (MutableSearchFactory) getSearchFactory();
    EntityIndexBinding indexBindingForEntity = searchFactory.getIndexBinding( clazz );
    IndexManager[] indexManagers = indexBindingForEntity.getIndexManagers();
    assertEquals( 1, indexManagers.length );
    return (DirectoryBasedIndexManager) indexManagers[0];
  }
View Full Code Here

  }

  private void createCleanFactoryState(SearchConfiguration cfg) {
    if ( rootFactory == null ) {
      //set the mutable structure of factory state
      rootFactory = new MutableSearchFactory();
      factoryState.setDocumentBuildersIndexedEntities( new ConcurrentHashMap<Class<?>, EntityIndexBinding>() );
      factoryState.setDocumentBuildersContainedEntities( new ConcurrentHashMap<Class<?>, DocumentBuilderContainedEntity<?>>() );
      factoryState.setFilterDefinitions( new ConcurrentHashMap<String, FilterDef>() );
      factoryState.setIndexHierarchy( new PolymorphicIndexHierarchy() );
      factoryState.setConfigurationProperties( cfg.getProperties() );
View Full Code Here

  }

  private void createCleanFactoryState(SearchConfiguration cfg) {
    if ( rootFactory == null ) {
      //set the mutable structure of factory state
      rootFactory = new MutableSearchFactory();
      factoryState.setDocumentBuildersIndexedEntities( new ConcurrentHashMap<Class<?>, EntityIndexBinder>() );
      factoryState.setDocumentBuildersContainedEntities( new ConcurrentHashMap<Class<?>, DocumentBuilderContainedEntity<?>>() );
      factoryState.setFilterDefinitions( new ConcurrentHashMap<String, FilterDef>() );
      factoryState.setIndexHierarchy( new PolymorphicIndexHierarchy() );
      factoryState.setConfigurationProperties( cfg.getProperties() );
View Full Code Here

TOP

Related Classes of org.hibernate.search.impl.MutableSearchFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.