/** * Create a cached thread pool using a named thread factory */ public static ExecutorService newMDCAwareCachedThreadPool(String name) { return newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory(name)); }
public ConcurrentUpdateSolrClient(String solrServerUrl, HttpClient client, int queueSize, int threadCount) { this(solrServerUrl, client, queueSize, threadCount, ExecutorUtil.newMDCAwareCachedThreadPool( new SolrjNamedThreadFactory("concurrentUpdateScheduler"))); shutdownExecutor = true; }
private void startAliveCheckExecutor() { // double-checked locking, but it's OK because we don't *do* anything with aliveCheckExecutor // if it's not null. if (aliveCheckExecutor == null) { synchronized (this) { if (aliveCheckExecutor == null) { aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor( new SolrjNamedThreadFactory("aliveCheckExecutor")); aliveCheckExecutor.scheduleAtFixedRate( getAliveCheckRunner(new WeakReference<>(this)), this.interval, this.interval, TimeUnit.MILLISECONDS); } } } }
private void startAliveCheckExecutor() { // double-checked locking, but it's OK because we don't *do* anything with aliveCheckExecutor // if it's not null. if (aliveCheckExecutor == null) { synchronized (this) { if (aliveCheckExecutor == null) { aliveCheckExecutor = Executors.newSingleThreadScheduledExecutor( new SolrjNamedThreadFactory("aliveCheckExecutor")); aliveCheckExecutor.scheduleAtFixedRate( getAliveCheckRunner(new WeakReference<>(this)), this.interval, this.interval, TimeUnit.MILLISECONDS); } } } }
private void openStreams() throws IOException { ExecutorService service = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("TopicStream")); try { List<Future<TupleWrapper>> futures = new ArrayList(); for (TupleStream solrStream : solrStreams) { StreamOpener so = new StreamOpener((SolrStream) solrStream, comp); Future<TupleWrapper> future = service.submit(so); futures.add(future); } try { for (Future<TupleWrapper> f : futures) { TupleWrapper w = f.get(); if (w != null) { tuples.add(w); } } } catch (Exception e) { throw new IOException(e); } } finally { service.shutdown(); } }
private void openStreams() throws IOException { ExecutorService service = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("CloudSolrStream")); try { List<Future<TupleWrapper>> futures = new ArrayList(); for (TupleStream solrStream : solrStreams) { StreamOpener so = new StreamOpener((SolrStream) solrStream, comp); Future<TupleWrapper> future = service.submit(so); futures.add(future); } try { for (Future<TupleWrapper> f : futures) { TupleWrapper w = f.get(); if (w != null) { tuples.add(w); } } } catch (Exception e) { throw new IOException(e); } } finally { service.shutdown(); } }
public void open() throws IOException { if (cache == null) { isCloseCache = true; cache = new SolrClientCache(); } else { isCloseCache = false; } this.executorService = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("SignificantTermsStream")); }
public void open() throws IOException { executorService = ExecutorUtil.newMDCAwareFixedThreadPool(threads, new SolrjNamedThreadFactory("ExecutorStream")); stream.open(); }
private void openStreams() throws IOException { ExecutorService service = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("CloudSolrStream")); try { List<Future<TupleWrapper>> futures = new ArrayList(); for (TupleStream solrStream : solrStreams) { StreamOpener so = new StreamOpener((SolrStream) solrStream, comp); Future<TupleWrapper> future = service.submit(so); futures.add(future); } try { for (Future<TupleWrapper> f : futures) { TupleWrapper w = f.get(); if (w != null) { tuples.add(w); } } } catch (Exception e) { throw new IOException(e); } } finally { service.shutdown(); } }
/** * @lucene.experimental */ public HttpUriRequestResponse httpUriRequest(final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { HttpUriRequestResponse mrr = new HttpUriRequestResponse(); final HttpRequestBase method = createMethod(request, null); ExecutorService pool = ExecutorUtil.newMDCAwareFixedThreadPool(1, new SolrjNamedThreadFactory("httpUriRequest")); try { MDC.put("HttpSolrClient.url", baseUrl); mrr.future = pool.submit(new Callable<NamedList<Object>>(){ @Override public NamedList<Object> call() throws Exception { return executeMethod(method, processor); }}); } finally { pool.shutdown(); MDC.remove("HttpSolrClient.url"); } assert method != null; mrr.httpUriRequest = method; return mrr; }
/** * @lucene.experimental */ public HttpUriRequestResponse httpUriRequest(final SolrRequest request, final ResponseParser processor) throws SolrServerException, IOException { HttpUriRequestResponse mrr = new HttpUriRequestResponse(); final HttpRequestBase method = createMethod(request, null); ExecutorService pool = ExecutorUtil.newMDCAwareFixedThreadPool(1, new SolrjNamedThreadFactory("httpUriRequest")); try { MDC.put("HttpSolrClient.url", baseUrl); mrr.future = pool.submit(() -> executeMethod(method, processor, isV2ApiRequest(request))); } finally { pool.shutdown(); MDC.remove("HttpSolrClient.url"); } assert method != null; mrr.httpUriRequest = method; return mrr; }
protected ConcurrentUpdateSolrClient(Builder builder) { this.internalHttpClient = (builder.httpClient == null); this.client = new HttpSolrClient.Builder(builder.baseSolrUrl) .withHttpClient(builder.httpClient) .build(); this.client.setFollowRedirects(false); this.queue = new LinkedBlockingQueue<>(builder.queueSize); this.threadCount = builder.threadCount; this.runners = new LinkedList<>(); this.streamDeletes = builder.streamDeletes; this.connectionTimeout = builder.connectionTimeoutMillis; this.soTimeout = builder.socketTimeoutMillis; if (builder.executorService != null) { this.scheduler = builder.executorService; this.shutdownExecutor = false; } else { this.scheduler = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("concurrentUpdateScheduler")); this.shutdownExecutor = true; } if (log.isDebugEnabled()) { this.pollInterrupts = new AtomicInteger(); this.pollExits = new AtomicInteger(); this.blockLoops = new AtomicInteger(); this.emptyQueueLoops = new AtomicInteger(); } }
private void openStreams() throws IOException { ExecutorService service = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("ParallelListStream")); try { List<Future<StreamIndex>> futures = new ArrayList(); int i=0; for (TupleStream tupleStream : streams) { StreamOpener so = new StreamOpener(new StreamIndex(tupleStream, i++)); Future<StreamIndex> future = service.submit(so); futures.add(future); } try { for (Future<StreamIndex> f : futures) { StreamIndex streamIndex = f.get(); this.streams[streamIndex.getIndex()] = streamIndex.getTupleStream(); } } catch (Exception e) { throw new IOException(e); } } finally { service.shutdown(); } }
/** * Opens the CloudSolrStream * ***/ public void open() throws IOException { if (cache == null) { isCloseCache = true; cache = new SolrClientCache(); } else { isCloseCache = false; } this.cloudSolrClient = this.cache.getCloudSolrClient(zkHost); this.executorService = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("FeaturesSelectionStream")); }
/** * Opens the CloudSolrStream * ***/ public void open() throws IOException { if (cache == null) { isCloseCache = true; cache = new SolrClientCache(); } else { isCloseCache = false; } this.cloudSolrClient = this.cache.getCloudSolrClient(zkHost); this.executorService = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("TextLogitSolrStream")); }
threadPool = ExecutorUtil.newMDCAwareFixedThreadPool(threads, new SolrjNamedThreadFactory("ShortestPathStream"));
threadPool = ExecutorUtil.newMDCAwareFixedThreadPool(4, new SolrjNamedThreadFactory("GatherNodesStream"));