DirectoryReader reader = DirectoryReader.open(FSDirectory.open(Paths.get(args[0]))); int docs = reader.maxDoc(); SolrClient solr = new ConcurrentUpdateSolrClient.Builder(args[1]).withQueueSize(2000).withThreadCount(2).build(); Set<SolrInputDocument> batch = new HashSet<SolrInputDocument>(1000);
DirectoryReader reader = DirectoryReader.open(FSDirectory.open(Paths.get(args[0]))); int docs = reader.maxDoc(); SolrClient solr = new ConcurrentUpdateSolrClient.Builder(args[1]).withQueueSize(10000).withThreadCount(2).build(); Set<SolrInputDocument> batch = new HashSet<SolrInputDocument>(1000);
if (cloudServer == null) { HttpSolrClient solrServer = new HttpSolrClient.Builder(url).build(); ConcurrentUpdateSolrClient solrStreamingServer = new ConcurrentUpdateSolrClient.Builder(url).withQueueSize(streamingQueueSize).withThreadCount(streamingThreadCount).build();
public static SolrClient getClient(Map stormConf, String boltType) { String zkHost = ConfUtils.getString(stormConf, "solr." + boltType + ".zkhost", null); String solrUrl = ConfUtils.getString(stormConf, "solr." + boltType + ".url", null); String collection = ConfUtils.getString(stormConf, "solr." + boltType + ".collection", null); int queueSize = ConfUtils.getInt(stormConf, "solr." + boltType + ".queueSize", -1); SolrClient client; if (StringUtils.isNotBlank(zkHost)) { client = new CloudSolrClient.Builder().withZkHost(zkHost).build(); if (StringUtils.isNotBlank(collection)) { ((CloudSolrClient) client).setDefaultCollection(collection); } } else if (StringUtils.isNotBlank(solrUrl)) { if (queueSize == -1) { client = new HttpSolrClient.Builder(solrUrl).build(); } else { client = new ConcurrentUpdateSolrClient.Builder(solrUrl) .withQueueSize(queueSize).build(); } } else { throw new RuntimeException( "SolrClient should have zk or solr URL set up"); } return client; }
/** * Uses the supplied HttpClient to send documents to the Solr server. * * @deprecated use {@link ConcurrentUpdateSolrClient#ConcurrentUpdateSolrClient(Builder)} instead, as it is a more extension/subclassing-friendly alternative */ @Deprecated protected ConcurrentUpdateSolrClient(String solrServerUrl, HttpClient client, int queueSize, int threadCount, ExecutorService es, boolean streamDeletes) { this((streamDeletes) ? new Builder(solrServerUrl) .withHttpClient(client) .withQueueSize(queueSize) .withThreadCount(threadCount) .withExecutorService(es) .alwaysStreamDeletes() : new Builder(solrServerUrl) .withHttpClient(client) .withQueueSize(queueSize) .withThreadCount(threadCount) .withExecutorService(es) .neverStreamDeletes()); }
@Override public SolrClient create() throws Exception { // SolrCloud if (args.solrCloud) { List<String> urls = Splitter.on(',').splitToList(args.solrUrl); if (StringUtils.isNotEmpty(args.solrZkChroot)) { return new CloudSolrClient.Builder(urls, Optional.of(args.solrZkChroot)).build(); // Connect to ZooKeeper } else { return new CloudSolrClient.Builder(urls).build(); // Connect to list of Solr servers } } // Standlone return new ConcurrentUpdateSolrClient.Builder(args.solrUrl) .withQueueSize(args.solrBatch) .withThreadCount(args.threads) .build(); }
public FileLoader(String solrURL) throws MalformedURLException { solr = new ConcurrentUpdateSolrClient.Builder(solrURL).withQueueSize(10000).withThreadCount(2).build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.Builder} class directly */ public static ConcurrentUpdateSolrClient getConcurrentUpdateSolrClient(String baseSolrUrl, int queueSize, int threadCount, int connectionTimeoutMillis) { return new ConcurrentUpdateSolrClient.Builder(baseSolrUrl) .withQueueSize(queueSize) .withThreadCount(threadCount) .withConnectionTimeout(connectionTimeoutMillis) .build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.Builder} class directly */ public static ConcurrentUpdateSolrClient getConcurrentUpdateSolrClient(String baseSolrUrl, int queueSize, int threadCount) { return new ConcurrentUpdateSolrClient.Builder(baseSolrUrl) .withQueueSize(queueSize) .withThreadCount(threadCount) .build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.Builder} class directly */ public static ConcurrentUpdateSolrClient getConcurrentUpdateSolrClient(String baseSolrUrl, HttpClient httpClient, int queueSize, int threadCount) { return new ConcurrentUpdateSolrClient.Builder(baseSolrUrl) .withHttpClient(httpClient) .withQueueSize(queueSize) .withThreadCount(threadCount) .build(); }