@TearDown(Level.Iteration) public void shutdownIndexingEngine() throws IOException { if ( si != null ) { si.close(); } }
@TearDown public void shutdownIndexingEngine() throws IOException { if ( si != null ) { si.close(); } }
@TearDown public void shutdownIndexingEngine() throws IOException { if ( si != null ) { si.close(); } super.cleanup(); }
@Override protected void after() { if ( searchIntegrator != null ) { RuntimeException exception = null; try { for ( SearchIntegrator sf : searchIntegrator ) { try { sf.close(); } catch (RuntimeException e) { if ( exception == null ) { exception = e; } else { exception.addSuppressed( e ); } } } if ( exception != null ) { throw exception; } } finally { searchIntegrator = null; } } }
@Override public void cacheStopping(ComponentRegistry cr, String cacheName) { QueryInterceptor queryInterceptor = cr.getComponent(QueryInterceptor.class); if (queryInterceptor != null) { queryInterceptor.prepareForStopping(); } SearchIntegrator searchIntegrator = cr.getComponent(SearchIntegrator.class); if (searchIntegrator != null) { searchIntegrator.close(); } unregisterQueryMBeans(cr, cacheName); }
@Override protected void after() { Collections.reverse( searchIntegrators ); RuntimeException exception = null; try { for ( SearchIntegrator sf : searchIntegrators ) { try { sf.close(); } catch (RuntimeException e) { if ( exception == null ) { exception = e; } else { exception.addSuppressed( e ); } } } if ( exception != null ) { throw exception; } } finally { searchIntegrators.clear(); } }
@Override public void cacheStopping(ComponentRegistry cr, String cacheName) { final QueryInterceptor queryInterceptor = cr.getComponent(QueryInterceptor.class); if (queryInterceptor != null) { queryInterceptor.prepareForStopping(); } //TODO move this to cacheStopped event (won't work right now as the ComponentRegistry is half empty at that point: ISPN-1006) Object searchFactoryIntegrator = cr.getComponent(SearchIntegrator.class); if (searchFactoryIntegrator != null && searchFactoryIntegrator != REMOVED_REGISTRY_COMPONENT) { ((SearchIntegrator) searchFactoryIntegrator).close(); //free some memory by de-registering the SearchFactory cr.registerComponent(REMOVED_REGISTRY_COMPONENT, SearchIntegrator.class); } // Unregister MBeans if (mbeanServer != null) { String cacheManagerName = cr.getGlobalComponentRegistry().getGlobalConfiguration().globalJmxStatistics().cacheManagerName(); String queryMBeanFilter = jmxDomain + ":" + getQueryGroupName(cacheManagerName, cacheName) + ",*"; JmxUtil.unregisterMBeans(queryMBeanFilter, mbeanServer); } }
private void expectOnConfiguration(boolean async, boolean exclusiveIndexing, String... expectedStack) { SearchConfigurationForTest cfg = new SearchConfigurationForTest(); cfg.addProperty( "hibernate.search.default.worker.execution", async ? "async" : "sync" ); cfg.addProperty( "hibernate.search.default.exclusive_index_use", exclusiveIndexing ? "true" : "false" ); cfg.addProperty( "hibernate.search.error_handler", CountingErrorHandler.class.getName() ); cfg.addClass( Quote.class ); searchIntegrator = integratorResource.create( cfg ); final CountingErrorHandler errorHandler = (CountingErrorHandler) searchIntegrator.getErrorHandler(); writeData( NUMBER_ENTITIES ); //Check no errors happened in the asynchronous threads assertEquals( 0, errorHandler.getTotalCount() ); searchIntegrator.close(); //Now the SearchIntegrator was closed, let's unwind the recorder events and compare them with expectations: for ( int i = 0; i < expectedStack.length; i++ ) { //Check the events have been fired in the expected order assertEquals( expectedStack[i], byteman.consumeNextRecordedEvent() ); } //And no more events than those expected exist assertTrue( byteman.isEventStackEmpty() ); }