@Override public void performOperations(List<LuceneWork> queue, IndexingMonitor monitor) { backend.applyWork( queue, monitor ); }
@Override @SuppressWarnings("deprecation") public BackendQueueProcessor createQueueProcessor(IndexManager indexManager, WorkerBuildContext context) { BackendQueueProcessor queueProcessor = new JndiJMSBackendQueueProcessor(); queueProcessor.initialize( properties, context, indexManager ); return queueProcessor; }
@Override public void performStreamOperation(LuceneWork singleOperation, IndexingMonitor monitor, boolean forceAsync) { backend.applyStreamWork( singleOperation, monitor ); }
@Override public synchronized void close() { if ( delegate != null ) { delegate.close(); } }
@Override public void destroy() { if ( indexManagementStrategy == IndexManagementStrategy.CREATE_DELETE ) { deleteIndexIfExisting(); } backend.close(); clientReference.close(); }
/** * Send all operations stored so far to the backend to be performed, atomically and/or transactionally * if supported/enabled by each specific backend. * * @param monitor a {@link org.hibernate.search.backend.IndexingMonitor} object. */ public void commitOperations(IndexingMonitor monitor) { // FIXME move executor here to parallel work - optionally? See HSEARCH-826 for ( WorkPlan plan : queues.values() ) { plan.backendQueueProcessor.applyWork( plan.queue, monitor ); } }
@Override @SuppressWarnings("deprecation") public BackendQueueProcessor createQueueProcessor(IndexManager indexManager, WorkerBuildContext context) { BackendQueueProcessor backendQueueProcessor = ClassLoaderHelper.instanceFromClass( BackendQueueProcessor.class, backendQueueProcessorClass, "Backend queue processor " ); backendQueueProcessor.initialize( properties, context, indexManager ); return backendQueueProcessor; }
@Override public void applyStreamWork(LuceneWork singleOperation, IndexingMonitor monitor) { if ( selectionStrategy.isIndexOwnerLocal() ) { getOrCreateDelegate().applyStreamWork( singleOperation, monitor ); } else { //TODO optimize for single operation? jgroupsProcessor.sendLuceneWorkList( Collections.singletonList( singleOperation ) ); } }
/** * Send all operations stored so far to the backend to be performed, atomically and/or transactionally * if supported/enabled by each specific backend. * * @param monitor a {@link org.hibernate.search.backend.IndexingMonitor} object. */ public void commitOperations(IndexingMonitor monitor) { // FIXME move executor here to parallel work - optionally? See HSEARCH-826 for ( WorkPlan plan : queues.values() ) { plan.backendQueueProcessor.applyWork( plan.queue, monitor ); } }
@Override @SuppressWarnings("deprecation") public BackendQueueProcessor createQueueProcessor(IndexManager indexManager, WorkerBuildContext context) { BackendQueueProcessor backendQueueProcessor = ClassLoaderHelper.instanceFromClass( BackendQueueProcessor.class, backendQueueProcessorClass, "Backend queue processor " ); backendQueueProcessor.initialize( properties, context, indexManager ); return backendQueueProcessor; }
@Override public void applyWork(List<LuceneWork> workList, IndexingMonitor monitor) { if ( selectionStrategy.isIndexOwnerLocal() ) { getOrCreateDelegate().applyWork( workList, monitor ); } else { if ( workList == null ) { throw new IllegalArgumentException( "workList should not be null" ); } jgroupsProcessor.sendLuceneWorkList( workList ); } }
@Override @SuppressWarnings("deprecation") public BackendQueueProcessor createQueueProcessor(IndexManager indexManager, WorkerBuildContext context) { BackendQueueProcessor queueProcessor = new JndiJMSBackendQueueProcessor(); queueProcessor.initialize( properties, context, indexManager ); return queueProcessor; }
@Test public void testCheckingForNullWork() { try { BackendQueueProcessor backend = new JndiJMSBackendQueueProcessor(); backend.applyWork( null, null ); } catch (IllegalArgumentException e2) { // this is ok, we just want to avoid other exceptions or NPEs } } }
private void checkBackendBehaviour(Backend backend) { try { WorkerBuildContext context = EasyMock.createNiceMock( WorkerBuildContext.class ); IndexManager indexManager = EasyMock.createNiceMock( IndexManager.class ); backend.initialize( new Properties(), context ); BackendQueueProcessor processor = backend.createQueueProcessor( indexManager, context ); processor.applyWork( null, null ); } catch (IllegalArgumentException e) { // this is ok, we just want to avoid other exceptions or NPEs } } }
@Test public void testCheckingForNullWork() { try { JGroupsBackendQueueTask queueTask = EasyMock.createNiceMock( JGroupsBackendQueueTask.class ); BackendQueueProcessor backend = new JGroupsBackendQueueProcessor( new SlaveNodeSelector(), queueTask, null ); backend.applyWork( null, null ); } catch (IllegalArgumentException e2) { // this is ok, we just want to avoid other exceptions or NPEs } }