Package org.hibernate.search.indexes.spi

Examples of org.hibernate.search.indexes.spi.IndexManager


    final String indexName = MessageSerializationHelper.extractIndexName( rawBuffer );
    final NodeSelectorStrategy nodeSelector = selector.getMasterNodeSelector( indexName );
    try {
      if ( nodeSelector.isIndexOwnerLocal() ) {
        byte[] serializedQueue = MessageSerializationHelper.extractSerializedQueue( rawBuffer );
        final IndexManager indexManager = context.getAllIndexesManager().getIndexManager( indexName );
        if ( indexManager != null ) {
          final List<LuceneWork> queue = indexManager.getSerializer().toLuceneWorks( serializedQueue );
          applyLuceneWorkLocally( queue, indexManager, message );
        }
        else {
          log.messageReceivedForUndefinedIndex( indexName );
        }
View Full Code Here


    if ( StringHelper.isEmpty( indexManagerImplementationName ) ) {
      return createDefaultIndexManager();
    }
    else {
      String implName = indexManagerImplementationName.trim();
      IndexManager im = fromAlias( implName );
      if ( im == null ) {
        implName = aliasToFQN( implName );
        im = ClassLoaderHelper.instanceFromName( IndexManager.class, implName,
            IndexManagerHolder.class, "index manager" );
      }
      log.indexManagerAliasResolved( indexManagerImplementationName, im.getClass() );
      return im;
    }
  }
View Full Code Here

    IndexManager[] providers = new IndexManager[nbrOfProviders];
    for ( int index = 0; index < nbrOfProviders; index++ ) {
      String providerName = nbrOfProviders > 1 ?
          directoryProviderName + "." + index :
          directoryProviderName;
      IndexManager indexManager = indexManagersRegistry.get( providerName );
      if ( indexManager == null ) {
        indexManager = createIndexManager( providerName, indexProps[index], context, cfg );
        indexManagersRegistry.put( providerName, indexManager );
      }
      indexManager.addContainedEntity( mappedClass );
      providers[index] = indexManager;
    }

    //define sharding strategy for this entity:
    IndexShardingStrategy shardingStrategy;
View Full Code Here

    manager.setSimilarity( newSimilarity );
  }

  private IndexManager createIndexManager(String indexName, Properties indexProps, WorkerBuildContext context, SearchConfiguration cfg) {
    String indexManagerImplementationName = indexProps.getProperty( Environment.INDEX_MANAGER_IMPL_NAME );
    final IndexManager manager;
    if ( StringHelper.isEmpty( indexManagerImplementationName ) ) {
      manager = cfg.getIndexManagerFactory().createDefaultIndexManager();
    }
    else {
      manager = cfg.getIndexManagerFactory().createIndexManagerByName( indexManagerImplementationName );
    }
    try {
      manager.initialize( indexName, indexProps, context );
      return manager;
    } catch (Exception e) {
      throw log.unableToInitializeIndexManager( indexName, e );
    }
  }
View Full Code Here

    String indexName = indexBaseName;
    if ( shardName != null ) {
      indexName += INDEX_SHARD_ID_SEPARATOR + shardName;
    }

    IndexManager indexManager = indexManagersRegistry.get( indexName );
    if ( indexManager != null ) {
      indexManager.addContainedEntity( entityIndexBinding.getDocumentBuilder().getBeanClass() );
      return indexManager;
    }
    SearchFactoryImplementor searchFactory = entityIndexBinding.getSearchFactory();
    WorkerBuildContext context;
    //known implementations of SearchFactory passed are MutableSearchFactory and ImmutableSearchFactory
    if ( WorkerBuildContext.class.isAssignableFrom( searchFactory.getClass() ) ) {
      context = (WorkerBuildContext) searchFactory;
    }
    else {
      throw log.assertionFailureCannotCastToWorkerBuilderContext( searchFactory.getClass() );
    }

    Properties properties = entityIndexBinding.getProperties();
    if ( shardName != null ) {
      properties = new MaskedProperty( properties, shardName, properties );
    }

    indexManager = createIndexManager(
        indexName,
        entityIndexBinding.getDocumentBuilder().getBeanClass(),
        entityIndexBinding.getSimilarity(),
        properties,
        entityIndexBinding.getIndexManagerFactory(),
        context
    );
    indexManager.setSearchFactory( searchFactory );
    return indexManager;
  }
View Full Code Here

      Similarity indexSimilarity,
      IndexManagerFactory indexManagerFactory,
      Properties properties,
      WorkerBuildContext context) {
    String indexManagerImplementationName = properties.getProperty( Environment.INDEX_MANAGER_IMPL_NAME );
    final IndexManager manager;
    if ( StringHelper.isEmpty( indexManagerImplementationName ) ) {
      manager = indexManagerFactory.createDefaultIndexManager();
    }
    else {
      manager = indexManagerFactory.createIndexManagerByName( indexManagerImplementationName );
    }
    try {
      manager.initialize( indexName, properties, indexSimilarity, context );
      return manager;
    }
    catch (Exception e) {
      throw log.unableToInitializeIndexManager( indexName, e );
    }
View Full Code Here

    for ( int index = 0; index < nbrOfIndexManagers; index++ ) {
      String indexManagerName = nbrOfIndexManagers > 1 ?
          indexBaseName + INDEX_SHARD_ID_SEPARATOR + index :
          indexBaseName;
      Properties indexProp = indexProperties[index];
      IndexManager indexManager = indexManagersRegistry.get( indexManagerName );
      if ( indexManager == null ) {
        indexManager = createIndexManager(
            indexManagerName, mappedClass, similarity,
            indexProp, configuration.getIndexManagerFactory(), context
        );
      }
      else {
        if ( !indexManager.getSimilarity().getClass().equals( similarity.getClass() ) ) {
          throw log.getMultipleEntitiesShareIndexWithInconsistentSimilarityException(
              mappedClass.getName(),
              similarity.getClass().getName(),
              indexManager.getContainedTypes().iterator().next().getName(),
              indexManager.getSimilarity().getClass().getName()
          );
        }
        indexManager.addContainedEntity( mappedClass );
      }
      indexManagers[index] = indexManager;
    }
    return indexManagers;
  }
View Full Code Here

      Class<?> mappedClass,
      Similarity similarity,
      Properties indexProperties,
      IndexManagerFactory indexManagerFactory,
      WorkerBuildContext context) {
    IndexManager indexManager = indexManagersRegistry.get( indexManagerName );
    if ( indexManager == null ) {
      indexManager = createIndexManager(
          indexManagerName,
          similarity,
          indexManagerFactory,
          indexProperties,
          context
      );
      indexManagersRegistry.put( indexManagerName, indexManager );
    }
    indexManager.addContainedEntity( mappedClass );
    return indexManager;
  }
View Full Code Here

    if ( StringHelper.isEmpty( indexManagerImplementationName ) ) {
      return createDefaultIndexManager();
    }
    else {
      String implName = indexManagerImplementationName.trim();
      IndexManager im = fromAlias( implName );
      if ( im == null ) {
        implName = aliasToFQN( implName );
        im = ClassLoaderHelper.instanceFromName( IndexManager.class, implName,
            IndexManagerHolder.class, "index manager" );
      }
      log.indexManagerAliasResolved( indexManagerImplementationName, im.getClass() );
      return im;
    }
  }
View Full Code Here

   }

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      queryInterceptor.enableClasses(knownIndexedTypes);
      IndexManager indexManager = searchFactory.getAllIndexesManager().getIndexManager(indexName);
      if (indexManager == null) {
         throw new SearchException("Unknown index referenced");
      }
      List<LuceneWork> luceneWorks = indexManager.getSerializer().toLuceneWorks(this.serializedModel);
      List<LuceneWork> workToApply = transformKeysToStrings(luceneWorks);//idInString field is not serialized, we need to extract it from the key object
      indexManager.performOperations(workToApply, null);
      return Boolean.TRUE; //Return value to be ignored
   }
View Full Code Here

TOP

Related Classes of org.hibernate.search.indexes.spi.IndexManager

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.