private void performShardAwareOperation(IndexedTypeSet entityTypes, BiConsumer<IndexManager, IndexedTypeIdentifier> operation) { for (IndexedTypeIdentifier type : entityTypes) { EntityIndexBinding indexBindingForEntity = integrator.getIndexBinding(type); if (indexBindingForEntity != null) { Set<IndexManager> indexManagers = indexBindingForEntity.getIndexManagerSelector().forExisting(type, null, null); indexManagers.forEach(im -> operation.accept(im, type)); } } } }
private void performShardAwareOperation(IndexedTypeSet entityTypes, BiConsumer<IndexManager, IndexedTypeIdentifier> operation) { for (IndexedTypeIdentifier type : entityTypes) { EntityIndexBinding indexBindingForEntity = integrator.getIndexBinding(type); if (indexBindingForEntity != null) { Set<IndexManager> indexManagers = indexBindingForEntity.getIndexManagerSelector().forExisting(type, null, null); indexManagers.forEach(im -> operation.accept(im, type)); } } } }
/** * Check that the indexable classes declared by the user are really indexable. */ private void checkIndexableClasses(SearchIntegrator searchFactory, Set<Class<?>> indexedEntities) { for (Class<?> c : indexedEntities) { if (searchFactory.getIndexBinding(new PojoIndexedTypeIdentifier(c)) == null) { throw log.classNotIndexable(c.getName()); } } }
private EntityIndexBinding getIndexBinding(SearchIntegrator searchFactory, Class<?> type) { EntityIndexBinding entityIndexBinding = searchFactory.getIndexBinding( new PojoIndexedTypeIdentifier( type ) ); if ( entityIndexBinding == null ) { throw log.getNoIndexedEntityException( type.getCanonicalName() ); } return entityIndexBinding; } }
/** * Check that the indexable classes declared by the user are really indexable. */ private void checkIndexableClasses(SearchIntegrator searchFactory, Set<Class<?>> indexedEntities) { for (Class<?> c : indexedEntities) { if (searchFactory.getIndexBinding(new PojoIndexedTypeIdentifier(c)) == null) { throw log.classNotIndexable(c.getName()); } } }
private IndexManager getIndexManagerByName(LuceneWork luceneWork, String name, SearchIntegrator searchFactory) { IndexedTypeIdentifier entityClass = luceneWork.getEntityType(); Set<IndexManager> indexManagersForAllShards = searchFactory.getIndexBinding(entityClass).getIndexManagerSelector().all(); return indexManagersForAllShards.stream().filter(im -> im.getIndexName().equals(name)).iterator().next(); }
private IndexManager getIndexManagerByName(LuceneWork luceneWork, String name, SearchIntegrator searchFactory) { IndexedTypeIdentifier entityClass = luceneWork.getEntityType(); Set<IndexManager> indexManagersForAllShards = searchFactory.getIndexBinding(entityClass).getIndexManagerSelector().all(); return indexManagersForAllShards.stream().filter(im -> im.getIndexName().equals(name)).iterator().next(); }
public static void flush(SearchIntegrator si, IndexedTypeIdentifier typeId) { for ( IndexManager indexManager : si.getIndexBinding( typeId ).getIndexManagerSelector().all() ) { indexManager.performStreamOperation( new FlushLuceneWork( null, typeId ), null, false ); } }
private Iterable<IndexManager> getIndexManagerForModifications(LuceneWork luceneWork) { IndexedTypeIdentifier type = luceneWork.getEntityType(); Serializable id = luceneWork.getId(); if (id != null) { String idInString = luceneWork.getIdInString(); Document document = luceneWork.getDocument(); return Collections.singleton(searchFactory.getIndexBinding(type) .getIndexManagerSelector() .forNew(type, id, idInString, document)); } else { return searchFactory.getIndexBinding(type) .getIndexManagerSelector() .forExisting(type, null, null); } }
private Iterable<IndexManager> getIndexManagerForModifications(LuceneWork luceneWork) { IndexedTypeIdentifier type = luceneWork.getEntityType(); Serializable id = luceneWork.getId(); if (id != null) { String idInString = luceneWork.getIdInString(); Document document = luceneWork.getDocument(); return Collections.singleton(searchFactory.getIndexBinding(type) .getIndexManagerSelector() .forNew(type, id, idInString, document)); } else { return searchFactory.getIndexBinding(type) .getIndexManagerSelector() .forExisting(type, null, null); } }
private void executeWork(LuceneWork work, IndexingMonitor progressMonitor) { final IndexedTypeIdentifier entityType = work.getEntityType(); EntityIndexBinding entityIndexBinding = integrator.getIndexBinding( entityType ); IndexManagerSelector selector = entityIndexBinding.getIndexManagerSelector(); StreamingOperationExecutor executor = work.acceptIndexWorkVisitor( StreamingOperationExecutorSelector.INSTANCE, null ); executor.performStreamOperation( work, selector, progressMonitor, forceAsync ); }
private void executeWork(LuceneWork work, IndexingMonitor progressMonitor) { final IndexedTypeIdentifier entityType = work.getEntityType(); EntityIndexBinding entityIndexBinding = integrator.getIndexBinding( entityType ); IndexManagerSelector selector = entityIndexBinding.getIndexManagerSelector(); StreamingOperationExecutor executor = work.acceptIndexWorkVisitor( StreamingOperationExecutorSelector.INSTANCE, null ); executor.performStreamOperation( work, selector, progressMonitor, forceAsync ); }
/** * Counts the number of nodes in the cluster on this node * * @param node the FullTextSessionBuilder representing the current node * @return */ protected int clusterSize(FullTextSessionBuilder node, Class<?> entityType) { SearchIntegrator integrator = node.getSearchFactory().unwrap(SearchIntegrator.class); EntityIndexBinding indexBinding = integrator.getIndexBinding(TOASTER_TYPE); DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager) indexBinding.getIndexManagerSelector().all().iterator().next(); InfinispanDirectoryProvider directoryProvider = (InfinispanDirectoryProvider) indexManager.getDirectoryProvider(); EmbeddedCacheManager cacheManager = directoryProvider.getCacheManager(); List<Address> members = cacheManager.getMembers(); return members.size(); } }
/** * Counts the number of nodes in the cluster on this node * * @param node the FullTextSessionBuilder representing the current node * @return the number of nodes as seen by the current node */ public static int clusterSize(FullTextSessionBuilder node, IndexedTypeIdentifier entityType) { SearchIntegrator integrator = node.getSearchFactory().unwrap(SearchIntegrator.class); EntityIndexBinding indexBinding = integrator.getIndexBinding(entityType); DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager) indexBinding.getIndexManagerSelector().all().iterator().next(); InfinispanDirectoryProvider directoryProvider = (InfinispanDirectoryProvider) indexManager.getDirectoryProvider(); EmbeddedCacheManager cacheManager = directoryProvider.getCacheManager(); List<Address> members = cacheManager.getMembers(); return members.size(); }
@Benchmark @GroupThreads(3 * AbstractBookEntity.TYPE_COUNT) public void write(StreamWriteEngineHolder eh, StreamAddEntityGenerator generator, StreamWriteCounters counters, Blackhole blackhole) { SearchIntegrator si = eh.getSearchIntegrator(); OperationDispatcher streamingDispatcher = new StreamingOperationDispatcher( si, true /* forceAsync */ ); IndexedTypeIdentifier typeId = generator.getTypeId(); DocumentBuilderIndexedEntity docBuilder = si.getIndexBinding( typeId ).getDocumentBuilder(); InstanceInitializer initializer = SimpleInitializer.INSTANCE; ConversionContext conversionContext = new ContextualExceptionBridgeHelper(); IndexingMonitor monitor = blackhole::consume; generator.stream().forEach( book -> { Long id = book.getId(); AddLuceneWork addWork = docBuilder.createAddWork( null, docBuilder.getTypeIdentifier(), book, id, docBuilder.getIdBridge().objectToString( id ), initializer, conversionContext ); streamingDispatcher.dispatch( addWork, monitor ); ++counters.add; } ); // Ensure that we'll block until all works have been performed SearchIntegratorHelper.flush( si, typeId ); }