List of usage examples for org.apache.lucene.util NamedThreadFactory NamedThreadFactory
public NamedThreadFactory(String threadNamePrefix)
From source file:com.sindicetech.siren.util.SirenTestCase.java
License:Open Source License
/** * Create a new searcher over the reader. This searcher might randomly use * threads.//from w ww.ja v a 2s. c o m * <p> * Override the original {@link LuceneTestCase#newSearcher(IndexReader)} * implementation in order to avoid getting {@link org.apache.lucene.search.AssertingIndexSearcher} * which is incompatible with SIREn. * <p> * TODO: Implement our own {@link AssertingIndexSearcher} and {@link org.apache.lucene.search.AssertingScorer} */ public static IndexSearcher newSearcher(final IndexReader r) { final Random random = random(); if (usually()) { // compared to the original implementation, we do not wrap to avoid // wrapping into an AssertingAtomicReader return random.nextBoolean() ? new IndexSearcher(r) : new IndexSearcher(r.getContext()); } else { int threads = 0; final ThreadPoolExecutor ex; if (random.nextBoolean()) { ex = null; } else { threads = TestUtil.nextInt(random, 1, 8); ex = new ThreadPoolExecutor(threads, threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("LuceneTestCase")); } if (ex != null) { if (VERBOSE) { System.out.println("NOTE: newSearcher using ExecutorService with " + threads + " threads"); } r.addReaderClosedListener(new ReaderClosedListener() { @Override public void onClose(final IndexReader reader) { TestUtil.shutdownExecutorService(ex); } }); } final IndexSearcher ret = random.nextBoolean() ? new IndexSearcher(r, ex) : new IndexSearcher(r.getContext(), ex); return ret; } }
From source file:org.apache.nifi.provenance.store.PartitionedEventStore.java
License:Apache License
@Override public void initialize() throws IOException { maintenanceExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Provenance Repository Maintenance")); maintenanceExecutor.scheduleWithFixedDelay(() -> performMaintenance(), 1, 1, TimeUnit.MINUTES); for (final EventStorePartition partition : getPartitions()) { partition.initialize();/* w w w .j av a 2 s.c o m*/ } }
From source file:org.apache.nifi.provenance.store.PartitionedWriteAheadEventStore.java
License:Apache License
public PartitionedWriteAheadEventStore(final RepositoryConfiguration repoConfig, final RecordWriterFactory recordWriterFactory, final RecordReaderFactory recordReaderFactory, final EventReporter eventReporter, final EventFileManager fileManager) { super(repoConfig, eventReporter); this.repoConfig = repoConfig; this.eventReporter = eventReporter; this.filesToCompress = new LinkedBlockingQueue<>(100); final AtomicLong idGenerator = new AtomicLong(0L); this.partitions = createPartitions(repoConfig, recordWriterFactory, recordReaderFactory, idGenerator); this.fileManager = fileManager; // Creates tasks to compress data on rollover if (repoConfig.isCompressOnRollover()) { compressionExecutor = Executors.newFixedThreadPool(repoConfig.getIndexThreadPoolSize(), new NamedThreadFactory("Compress Provenance Logs")); } else {/* w w w .j a v a 2s.co m*/ compressionExecutor = null; } }
From source file:org.sindice.siren.util.SirenTestCase.java
License:Apache License
/** * Create a new searcher over the reader. This searcher might randomly use * threads.//ww w.ja va2s . com * <p> * Override the original {@link LuceneTestCase#newSearcher(IndexReader)} * implementation in order to avoid getting {@link AssertingIndexSearcher} * which is incompatible with SIREn. */ public static IndexSearcher newSearcher(final IndexReader r) throws IOException { final Random random = random(); if (usually()) { // compared to the original implementation, we do not wrap to avoid // wrapping into an AssertingAtomicReader return random.nextBoolean() ? new IndexSearcher(r) : new IndexSearcher(r.getContext()); } else { int threads = 0; final ThreadPoolExecutor ex; if (random.nextBoolean()) { ex = null; } else { threads = _TestUtil.nextInt(random, 1, 8); ex = new ThreadPoolExecutor(threads, threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("LuceneTestCase")); } if (ex != null) { if (VERBOSE) { System.out.println("NOTE: newSearcher using ExecutorService with " + threads + " threads"); } r.addReaderClosedListener(new ReaderClosedListener() { @Override public void onClose(final IndexReader reader) { _TestUtil.shutdownExecutorService(ex); } }); } final IndexSearcher ret = random.nextBoolean() ? new IndexSearcher(r, ex) : new IndexSearcher(r.getContext(), ex); return ret; } }
From source file:uk.co.flax.biosolr.elasticsearch.mapper.ontology.ElasticOntologyHelperFactory.java
License:Apache License
public OntologyHelper buildOntologyHelper() throws OntologyHelperException { return new OntologyHelperBuilder().ontologyUri(settings.getOntologyUri()) .labelPropertyUris(convertListToArray(settings.getLabelPropertyUris())) .synonymPropertyUris(convertListToArray(settings.getSynonymPropertyUris())) .definitionPropertyUris(convertListToArray(settings.getDefinitionPropertyUris())) .olsBaseUrl(settings.getOlsBaseUrl()).ontology(settings.getOlsOntology()) .threadpoolSize(settings.getThreadpoolSize()).pageSize(settings.getPageSize()) .threadFactory(new NamedThreadFactory("olsOntologyHelper")).build(); }