Package org.hibernate.search.exception

Examples of org.hibernate.search.exception.ErrorHandler


    return new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
  }

  @Override
  public void run() {
    ErrorHandler errorHandler = searchFactory.getErrorHandler();
    try {
      final EntityKeyMetadata keyMetadata = getEntityKeyMetadata();
      final SessionAwareRunnable consumer = new TupleIndexer( indexedType, monitor, sessionFactory, searchFactory, cacheMode, batchBackend, errorHandler );
      gridDialect.forEachTuple( new OptionallyWrapInJTATransaction( sessionFactory, errorHandler, consumer ), keyMetadata );
    }
    catch ( RuntimeException re ) {
      // being this an async thread we want to make sure everything is somehow reported
      errorHandler.handleException( log.massIndexerUnexpectedErrorMessage(), re );
    }
    finally {
      endAllSignal.countDown();
    }
  }
View Full Code Here


    this.searchFactoryImplementor = context.getUninitializedSearchFactory();
    int maxThreadsPerIndex = ConfigurationParseHelper.getIntValue( cfg, "concurrent_writers", 2 );
    if ( maxThreadsPerIndex < 1 ) {
      throw new SearchException( "concurrent_writers for batch backend must be at least 1." );
    }
    ErrorHandler errorHandler = searchFactoryImplementor.getErrorHandler();
    for ( DirectoryProvider<?> dp : context.getDirectoryProviders() ) {
      DirectoryProviderWorkspace resources = new DirectoryProviderWorkspace( context, dp, monitor, maxThreadsPerIndex, errorHandler );
      resourcesMap.put( dp, resources );
    }
  }
View Full Code Here

    return new EntityKeyMetadata( persister.getTableName(), persister.getRootTableIdentifierColumnNames() );
  }

  @Override
  public void run() {
    ErrorHandler errorHandler = searchFactory.getErrorHandler();
    try {
      final EntityKeyMetadata keyMetadata = getEntityKeyMetadata();
      final SessionAwareRunnable consumer = new TupleIndexer( indexedType, monitor, sessionFactory, searchFactory, cacheMode, batchBackend, errorHandler );
      gridDialect.forEachTuple( new OptionallyWrapInJTATransaction( sessionFactory, errorHandler, consumer ), keyMetadata );
    }
    catch ( RuntimeException re ) {
      // being this an async thread we want to make sure everything is somehow reported
      errorHandler.handleException( log.massIndexerUnexpectedErrorMessage(), re );
    }
    finally {
      endAllSignal.countDown();
    }
  }
View Full Code Here

    this.monitor = monitor;
    this.objectsLimit = objectsLimit;
  }

  public void run() {
    ErrorHandler errorHandler = searchFactory.getErrorHandler();
    try {

      //first start the consumers, then the producers (reverse order):
      for ( int i = 0; i < luceneWorkerBuildingThreadNum; i++ ) {
        //from entity to LuceneWork:
        final EntityConsumerLuceneWorkProducer producer = new EntityConsumerLuceneWorkProducer(
            fromEntityToAddwork, monitor,
            sessionFactory, producerEndSignal, searchFactory,
            cacheMode, backend, errorHandler
        );
        execDocBuilding.execute( new OptionallyWrapInJTATransaction( sessionFactory, errorHandler, producer ) );
      }
      for ( int i = 0; i < objectLoadingThreadNum; i++ ) {
        //from primary key to loaded entity:
        final IdentifierConsumerEntityProducer producer = new IdentifierConsumerEntityProducer(
            fromIdentifierListToEntities, fromEntityToAddwork, monitor,
            sessionFactory, cacheMode, indexedType, idNameOfIndexedType, errorHandler
        );
        execFirstLoader.execute( new OptionallyWrapInJTATransaction( sessionFactory, errorHandler, producer ) );
      }
      //from class definition to all primary keys:
      final IdentifierProducer producer = new IdentifierProducer(
          fromIdentifierListToEntities, sessionFactory,
          objectLoadingBatchSize, indexedType, monitor,
          objectsLimit, errorHandler
      );
      execIdentifiersLoader.execute( new OptionallyWrapInJTATransaction( sessionFactory, errorHandler, producer ) );

      //shutdown all executors:
      execIdentifiersLoader.shutdown();
      execFirstLoader.shutdown();
      execDocBuilding.shutdown();
      try {
        producerEndSignal.await(); //await for all work being sent to the backend
        log.debugf( "All work for type %s has been produced", indexedType.getName() );
      }
      catch ( InterruptedException e ) {
        //restore interruption signal:
        Thread.currentThread().interrupt();
        throw new SearchException( "Interrupted on batch Indexing; index will be left in unknown state!", e );
      }
    }
    catch ( RuntimeException re ) {
      //being this an async thread we want to make sure everything is somehow reported
      errorHandler.handleException( log.massIndexerUnexpectedErrorMessage() , re );
    }
    finally {
      endAllSignal.countDown();
    }
  }
View Full Code Here

    this.searchFactoryImplementor = searchFactoryImplementor;
  }

  @Override
  public final void run() {
    ErrorHandler errorHandler = searchFactoryImplementor.getErrorHandler();
    try {
      runWithErrorHandler();
    }
    catch (Exception re) {
      //being this an async thread we want to make sure everything is somehow reported
      errorHandler.handleException( log.massIndexerUnexpectedErrorMessage() , re );
      cleanUpOnError();
    }
  }
View Full Code Here

  }

  @Override
  public void runWithErrorHandler() {
    try {
      final ErrorHandler errorHandler = searchFactoryImplementor.getErrorHandler();
      final BatchTransactionalContext transactionalContext = new BatchTransactionalContext( searchFactoryImplementor, sessionFactory, errorHandler );
      //first start the consumers, then the producers (reverse order):
      //from primary keys to LuceneWork ADD operations:
      startTransformationToLuceneWork( transactionalContext, errorHandler );
      //from class definition to all primary keys:
View Full Code Here

   }

   public static void assertAllGood(Cache cache) {
      SearchManager searchManager = Search.getSearchManager(cache);
      SearchFactoryIntegrator searchFactory = (SearchFactoryIntegrator) searchManager.getSearchFactory();
      ErrorHandler errorHandler = searchFactory.getErrorHandler();
      Assert.assertNotNull(errorHandler);
      Assert.assertTrue(errorHandler instanceof StaticTestingErrorHandler);
      StaticTestingErrorHandler instance = (StaticTestingErrorHandler) errorHandler;
      Object fault = instance.getAndReset();
      if (fault!=null) {
View Full Code Here

  }

  @Override
  public void runWithErrorHandler() {
    try {
      final ErrorHandler errorHandler = searchFactoryImplementor.getErrorHandler();
      final BatchTransactionalContext transactionalContext = new BatchTransactionalContext( searchFactoryImplementor, sessionFactory, errorHandler );
      //first start the consumers, then the producers (reverse order):
      //from primary keys to LuceneWork ADD operations:
      startTransformationToLuceneWork( transactionalContext, errorHandler );
      //from class definition to all primary keys:
View Full Code Here

    this.searchFactoryImplementor = searchFactoryImplementor;
  }

  @Override
  public final void run() {
    ErrorHandler errorHandler = searchFactoryImplementor.getErrorHandler();
    try {
      runWithErrorHandler();
    }
    catch (Exception re) {
      //being this an async thread we want to make sure everything is somehow reported
      errorHandler.handleException( log.massIndexerUnexpectedErrorMessage() , re );
      cleanUpOnError();
    }
  }
View Full Code Here

    Assert.assertTrue( exception instanceof NullPointerException );
    Assert.assertEquals( "Byteman created NPE", exception.getMessage() );
  }

  static MockErrorHandler getErrorHandler(SearchFactoryImplementor searchFactory) {
    ErrorHandler errorHandler = searchFactory.getErrorHandler();
    Assert.assertTrue( errorHandler instanceof MockErrorHandler );
    MockErrorHandler mockErrorHandler = (MockErrorHandler) errorHandler;
    return mockErrorHandler;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.search.exception.ErrorHandler

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.