Examples of ErrorContextBuilder


Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

   * @throws InterruptedException
   */
  private void applyUpdates() throws InterruptedException, ExecutionException {
    AbstractWorkspaceImpl workspace = resources.getWorkspace();
   
    ErrorContextBuilder errorContextBuilder = new ErrorContextBuilder();
    errorContextBuilder.allWorkToBeDone( queue );
   
    IndexWriter indexWriter = workspace.getIndexWriter( errorContextBuilder );
    if ( indexWriter == null ) {
      log.cannotOpenIndexWriterCausePreviousError();
      return;
    }
    boolean someFailureHappened = false;
    try {
      ExecutorService executor = resources.getWorkersExecutor();
      int queueSize = queue.size();
      Future[] submittedTasks = new Future[ queueSize ];
      for ( int i = 0; i < queueSize; i++ ) {
        SingleTaskRunnable task = new SingleTaskRunnable( queue.get( i ), resources, indexWriter, monitor );
        submittedTasks[i] = executor.submit( task );
      }
      // now wait for all tasks being completed before releasing our lock
      // (this thread waits even in async backend mode)
      LinkedList<LuceneWork> failedUpdates = new LinkedList<LuceneWork>();
      for ( int i = 0; i < queueSize; i++ ) {
        Future task = submittedTasks[i];
        try {
          task.get();
          errorContextBuilder.workCompleted( queue.get( i ) );
        }
        catch (ExecutionException e) {
          someFailureHappened = true;
          failedUpdates.add( queue.get( i ) );
          errorContextBuilder.errorThatOccurred( e.getCause() );
        }
      }
      if ( someFailureHappened ) {
        errorContextBuilder.addAllWorkThatFailed( failedUpdates );
        resources.getErrorHandler().handle( errorContextBuilder.createErrorContext() );
      }
      else {
        if ( !streaming ) {
          workspace.optimizerPhase();
        }
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

      modificationLock.unlock();
    }
  }

  private void handleException(Exception e) {
    ErrorContextBuilder builder = new ErrorContextBuilder();
    builder.allWorkToBeDone( workList );
    builder.errorThatOccurred( e );
    resources.getErrorHandler().handle( builder.createErrorContext() );
  }
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

   * @throws InterruptedException
   */
  private void applyUpdates() throws InterruptedException, ExecutionException {
    AbstractWorkspaceImpl workspace = resources.getWorkspace();

    ErrorContextBuilder errorContextBuilder = new ErrorContextBuilder();
    errorContextBuilder.allWorkToBeDone( workList );

    IndexWriter indexWriter = workspace.getIndexWriter( errorContextBuilder );
    if ( indexWriter == null ) {
      log.cannotOpenIndexWriterCausePreviousError();
      return;
    }

    boolean taskExecutionSuccessful = true;

    try {
      if ( workList.size() == 1 ) {
        taskExecutionSuccessful = runSingleTask( workList.get( 0 ), indexWriter, errorContextBuilder );
      }
      else {
        taskExecutionSuccessful = runMultipleTasks( indexWriter, errorContextBuilder );
      }
      if ( !taskExecutionSuccessful ) {
        resources.getErrorHandler().handle( errorContextBuilder.createErrorContext() );
      }
      else {
        workspace.optimizerPhase();
      }
    }
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

      modificationLock.unlock();
    }
  }

  private void handleException(Exception e) {
    ErrorContextBuilder builder = new ErrorContextBuilder();
    builder.allWorkToBeDone( queue );
    builder.errorThatOccurred( e );
    resources.getErrorHandler().handle( builder.createErrorContext() );
  }
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

   * @throws InterruptedException
   */
  private void applyUpdates() throws InterruptedException, ExecutionException {
    AbstractWorkspaceImpl workspace = resources.getWorkspace();

    ErrorContextBuilder errorContextBuilder = new ErrorContextBuilder();
    errorContextBuilder.allWorkToBeDone( queue );

    IndexWriter indexWriter = workspace.getIndexWriter( errorContextBuilder );
    if ( indexWriter == null ) {
      log.cannotOpenIndexWriterCausePreviousError();
      return;
    }
    LinkedList<LuceneWork> failedUpdates = null;
    try {
      ExecutorService executor = resources.getWorkersExecutor();
      int queueSize = queue.size();
      Future[] submittedTasks = new Future[ queueSize ];
      for ( int i = 0; i < queueSize; i++ ) {
        SingleTaskRunnable task = new SingleTaskRunnable( queue.get( i ), resources, indexWriter, monitor );
        submittedTasks[i] = executor.submit( task );
      }
      // now wait for all tasks being completed before releasing our lock
      // (this thread waits even in async backend mode)
      for ( int i = 0; i < queueSize; i++ ) {
        Future task = submittedTasks[i];
        try {
          task.get();
          errorContextBuilder.workCompleted( queue.get( i ) );
        }
        catch (ExecutionException e) {
          if ( failedUpdates == null ) {
            failedUpdates = new LinkedList<LuceneWork>();
          }
          failedUpdates.add( queue.get( i ) );
          errorContextBuilder.errorThatOccurred( e.getCause() );
        }
      }
      if ( failedUpdates != null ) {
        errorContextBuilder.addAllWorkThatFailed( failedUpdates );
        resources.getErrorHandler().handle( errorContextBuilder.createErrorContext() );
      }
      else {
        workspace.optimizerPhase();
      }
    }
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

  public void run() {
    if ( workOnWriter.isEmpty() ) {
      return;
    }
    log.debug( "Opening an IndexWriter for update" );
    ErrorContextBuilder builder = new ErrorContextBuilder();
    builder.allWorkToBeDone( workOnWriter );
    try {
      IndexWriter indexWriter = workspace.getIndexWriter( batchmode );
      try {
        for ( LuceneWork lw : workOnWriter ) {
          lw.getWorkDelegate( worker ).performWork( lw, indexWriter );
          builder.workCompleted( lw );
        }
        workspace.commitIndexWriter();
        performOptimizations();
      }
      finally {
        if ( ! exclusiveIndexUsage ) workspace.closeIndexWriter();
      }
    }
    catch ( Throwable tw ) {
      //needs to be attempted even for out of memory errors, therefore we catch Throwable
      log.error( "Unexpected error in Lucene Backend: ", tw );
      try {
        handler.handle( builder.errorThatOccurred( tw ).createErrorContext() );
        workspace.closeIndexWriter();
      }
      finally {
        //LockObtainFailedException is wrapped in a SearchException by the workspace
        //LockObtainFailedException should never ever release the lock
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

      modificationLock.unlock();
    }
  }

  private void handleException(Exception e) {
    ErrorContextBuilder builder = new ErrorContextBuilder();
    builder.allWorkToBeDone( queue );
    builder.errorThatOccurred( e );
    resources.getErrorHandler().handle( builder.createErrorContext() );
  }
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

   * @throws InterruptedException
   */
  private void applyUpdates() throws InterruptedException, ExecutionException {
    AbstractWorkspaceImpl workspace = resources.getWorkspace();
   
    ErrorContextBuilder errorContextBuilder = new ErrorContextBuilder();
    errorContextBuilder.allWorkToBeDone( queue );
   
    IndexWriter indexWriter = workspace.getIndexWriter( errorContextBuilder );
    if ( indexWriter == null ) {
      log.cannotOpenIndexWriterCausePreviousError();
      return;
    }
    LinkedList<LuceneWork> failedUpdates = null;
    try {
      ExecutorService executor = resources.getWorkersExecutor();
      int queueSize = queue.size();
      Future[] submittedTasks = new Future[ queueSize ];
      for ( int i = 0; i < queueSize; i++ ) {
        SingleTaskRunnable task = new SingleTaskRunnable( queue.get( i ), resources, indexWriter, monitor );
        submittedTasks[i] = executor.submit( task );
      }
      // now wait for all tasks being completed before releasing our lock
      // (this thread waits even in async backend mode)
      for ( int i = 0; i < queueSize; i++ ) {
        Future task = submittedTasks[i];
        try {
          task.get();
          errorContextBuilder.workCompleted( queue.get( i ) );
        }
        catch (ExecutionException e) {
          if ( failedUpdates == null ) {
            failedUpdates = new LinkedList<LuceneWork>();
          }
          failedUpdates.add( queue.get( i ) );
          errorContextBuilder.errorThatOccurred( e.getCause() );
        }
      }
      if ( failedUpdates != null ) {
        errorContextBuilder.addAllWorkThatFailed( failedUpdates );
        resources.getErrorHandler().handle( errorContextBuilder.createErrorContext() );
      }
      else {
        if ( !streaming ) {
          workspace.optimizerPhase();
        }
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

      modificationLock.unlock();
    }
  }

  private void handleException(Exception e) {
    ErrorContextBuilder builder = new ErrorContextBuilder();
    builder.allWorkToBeDone( queue );
    builder.errorThatOccurred( e );
    resources.getErrorHandler().handle( builder.createErrorContext() );
  }
View Full Code Here

Examples of org.hibernate.search.exception.impl.ErrorContextBuilder

   * @throws InterruptedException
   */
  private void applyUpdates() throws InterruptedException, ExecutionException {
    AbstractWorkspaceImpl workspace = resources.getWorkspace();
   
    ErrorContextBuilder errorContextBuilder = new ErrorContextBuilder();
    errorContextBuilder.allWorkToBeDone( queue );
   
    IndexWriter indexWriter = workspace.getIndexWriter( errorContextBuilder );
    if ( indexWriter == null ) {
      log.cannotOpenIndexWriterCausePreviousError();
      return;
    }
    LinkedList<LuceneWork> failedUpdates = null;
    try {
      ExecutorService executor = resources.getWorkersExecutor();
      int queueSize = queue.size();
      Future[] submittedTasks = new Future[ queueSize ];
      for ( int i = 0; i < queueSize; i++ ) {
        SingleTaskRunnable task = new SingleTaskRunnable( queue.get( i ), resources, indexWriter, monitor );
        submittedTasks[i] = executor.submit( task );
      }
      // now wait for all tasks being completed before releasing our lock
      // (this thread waits even in async backend mode)
      for ( int i = 0; i < queueSize; i++ ) {
        Future task = submittedTasks[i];
        try {
          task.get();
          errorContextBuilder.workCompleted( queue.get( i ) );
        }
        catch (ExecutionException e) {
          if ( failedUpdates == null ) {
            failedUpdates = new LinkedList<LuceneWork>();
          }
          failedUpdates.add( queue.get( i ) );
          errorContextBuilder.errorThatOccurred( e.getCause() );
        }
      }
      if ( failedUpdates != null ) {
        errorContextBuilder.addAllWorkThatFailed( failedUpdates );
        resources.getErrorHandler().handle( errorContextBuilder.createErrorContext() );
      }
      else {
        workspace.optimizerPhase();
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.