Package org.hibernate.search.indexes.spi

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


      super(cacheName);
   }

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      IndexManager indexManager = searchFactory.getIndexManagerHolder().getIndexManager(indexName);
      if (indexManager == null) {
         throw new SearchException("Unknown index referenced : " + indexName);
      }
      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


  private static class AddSelectionDelegate implements StreamingOperationSelectionDelegate {

    public final void performStreamOperation(LuceneWork work,
        IndexShardingStrategy shardingStrategy, IndexingMonitor monitor, boolean forceAsync) {
      IndexManager indexManager = shardingStrategy.getIndexManagerForAddition(
          work.getEntityClass(),
          work.getId(),
          work.getIdInString(),
          work.getDocument()
      );
      indexManager.performStreamOperation( work, monitor, forceAsync );
    }
View Full Code Here

  private static class AddSelectionDelegate implements ContextAwareSelectionDelegate {

    @Override
    public final void performOperation(LuceneWork work, IndexShardingStrategy shardingStrategy,
        WorkQueuePerIndexSplitter context) {
      IndexManager indexManager = shardingStrategy.getIndexManagerForAddition(
          work.getEntityClass(),
          work.getId(),
          work.getIdInString(),
          work.getDocument()
      );
View Full Code Here

    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 );
          return;
View Full Code Here

    Assert.assertTrue( "Backend not using JGroups!", backendQueueProcessor instanceof JGroupsBackendQueueProcessor );
    return (JGroupsBackendQueueProcessor) backendQueueProcessor;
  }

  private static BackendQueueProcessor extractBackendQueue(SearchFactoryHolder node, String indexName) {
    IndexManager indexManager = node.getSearchFactory().getIndexManagerHolder().getIndexManager( indexName );
    Assert.assertNotNull( indexManager );
    DirectoryBasedIndexManager dbi = (DirectoryBasedIndexManager) indexManager;
    return dbi.getBackendQueueProcessor();
  }
View Full Code Here

    builder.close();
  }

  private void checkIndexManagerType(IndexManagerHolder allIndexesManager, String name, Class expectedType) {
    IndexManager indexManager = allIndexesManager.getIndexManager( name );
    Assert.assertEquals( expectedType, indexManager.getClass() );
  }
View Full Code Here

    ObjectMessage objectMessage = (ObjectMessage) message;

    List<LuceneWork> queue;
    try {
      String indexName = objectMessage.getStringProperty( Environment.INDEX_NAME_JMS_PROPERTY );
      IndexManager indexManager = searchFactory.getIndexManagerHolder().getIndexManager( indexName );
      queue = indexManager.getSerializer().toLuceneWorks( (byte[]) objectMessage.getObject() );
    }
    catch (JMSException e) {
      return;
    }
    catch (ClassCastException e) {
View Full Code Here

    ObjectMessage message = getQueueSession().createObjectMessage();
    final String indexName = org.hibernate.search.test.jms.master.TShirt.class.getName();
    message.setStringProperty(
        Environment.INDEX_NAME_JMS_PROPERTY,
        indexName );
    IndexManager indexManager = getSearchFactoryImpl().getIndexManagerHolder().getIndexManager( indexName );
    byte[] data = indexManager.getSerializer().toSerializedModel( queue );
    message.setObject( data );
    QueueSender sender = getQueueSession().createSender( getMessageQueue() );
    sender.send( message );
  }
View Full Code Here

      .withService( SerializationProvider.class, countingServiceInstance );

  @Test
  public void testPropertiesIndexing() {
    SearchFactoryImplementor searchFactory = factoryHolder.getSearchFactory();
    IndexManager indexManager = searchFactory.getIndexManagerHolder().getIndexManager( "books" );
    Assert.assertNotNull( indexManager );
    Assert.assertEquals( 0, countingServiceInstance.serializerGetCount.get() );
    Assert.assertEquals( 0, countingServiceInstance.deserializerGetCount.get() );

    //Serialize some work:
    indexManager.getSerializer().toSerializedModel( makeSomeWork() );
    Assert.assertEquals( 1, countingServiceInstance.serializerGetCount.get() );
    Assert.assertEquals( 0, countingServiceInstance.deserializerGetCount.get() );

    //Serialize again, note the point of the test is to request all references again:
    indexManager.getSerializer().toSerializedModel( makeSomeWork() );
    Assert.assertEquals( 2, countingServiceInstance.serializerGetCount.get() );
    Assert.assertEquals( 0, countingServiceInstance.deserializerGetCount.get() );

    //Now Deserialize:
    indexManager.getSerializer().toLuceneWorks( makeSomeSerializedWork() );
    Assert.assertEquals( 2, countingServiceInstance.serializerGetCount.get() );
    Assert.assertEquals( 1, countingServiceInstance.deserializerGetCount.get() );

    //Now Deserialize again:
    indexManager.getSerializer().toLuceneWorks( makeSomeSerializedWork() );
    Assert.assertEquals( 2, countingServiceInstance.serializerGetCount.get() );
    Assert.assertEquals( 2, countingServiceInstance.deserializerGetCount.get() );
  }
View Full Code Here

    //The first write operation is going to fail, simulating a lock acquisition timeout:
    writeABook( 1l, "lock contention" );
    //The second write will be successful:
    writeABook( 2l, "no contention" );
    //Now verify the index lock was properly released, not having the backend counters fooled by the initial failure:
    IndexManager indexManager = sfHolder.getSearchFactory().getIndexManagerHolder().getIndexManager( "books" );
    DirectoryBasedIndexManager dbim = (DirectoryBasedIndexManager) indexManager;
    Directory directory = dbim.getDirectoryProvider().getDirectory();
    Assert.assertFalse( "Index lock leaked!", IndexWriter.isLocked( directory ) );
  }
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.