use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project lucene-solr by apache.
the class SolrExampleStreamingBinaryTest method createNewSolrClient.
@Override
public SolrClient createNewSolrClient() {
ConcurrentUpdateSolrClient client = (ConcurrentUpdateSolrClient) super.createNewSolrClient();
client.setParser(new BinaryResponseParser());
client.setRequestWriter(new BinaryRequestWriter());
return client;
}
use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project lucene-solr by apache.
the class SolrExampleStreamingTest method testWaitOptions.
public void testWaitOptions() throws Exception {
// SOLR-3903
final List<Throwable> failures = new ArrayList<>();
final String serverUrl = jetty.getBaseUrl().toString() + "/collection1";
try (ConcurrentUpdateSolrClient concurrentClient = new FailureRecordingConcurrentUpdateSolrClient(serverUrl, 2, 2)) {
int docId = 42;
for (UpdateRequest.ACTION action : EnumSet.allOf(UpdateRequest.ACTION.class)) {
for (boolean waitSearch : Arrays.asList(true, false)) {
for (boolean waitFlush : Arrays.asList(true, false)) {
UpdateRequest updateRequest = new UpdateRequest();
SolrInputDocument document = new SolrInputDocument();
document.addField("id", docId++);
updateRequest.add(document);
updateRequest.setAction(action, waitSearch, waitFlush);
concurrentClient.request(updateRequest);
}
}
}
concurrentClient.commit();
concurrentClient.blockUntilFinished();
}
if (0 != failures.size()) {
assertEquals(failures.size() + " Unexpected Exception, starting with...", null, failures.get(0));
}
}
use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project lucene-solr by apache.
the class FullSolrCloudDistribCmdsTest method testConcurrentIndexing.
private long testConcurrentIndexing(long docId) throws Exception {
QueryResponse results = query(cloudClient);
long beforeCount = results.getResults().getNumFound();
int cnt = TEST_NIGHTLY ? 2933 : 313;
try (ConcurrentUpdateSolrClient concurrentClient = getConcurrentUpdateSolrClient(((HttpSolrClient) clients.get(0)).getBaseURL(), 10, 2)) {
concurrentClient.setConnectionTimeout(120000);
for (int i = 0; i < cnt; i++) {
index_specific(concurrentClient, id, docId++, "text_t", "some text so that it not's negligent work to parse this doc, even though it's still a pretty short doc");
}
concurrentClient.blockUntilFinished();
commit();
checkShardConsistency();
assertDocCounts(VERBOSE);
}
results = query(cloudClient);
assertEquals(beforeCount + cnt, results.getResults().getNumFound());
return docId;
}
use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project lucene-solr by apache.
the class TestSolrJ method main.
public static void main(String[] args) throws Exception {
// String addr = "http://odin.local:80/solr";
// String addr = "http://odin.local:8983/solr";
String addr = "http://127.0.0.1:8983/solr";
int i = 0;
final int nDocs = Integer.parseInt(args[i++]);
final int nProducers = Integer.parseInt(args[i++]);
final int nConnections = Integer.parseInt(args[i++]);
final int maxSleep = Integer.parseInt(args[i++]);
ConcurrentUpdateSolrClient concurrentClient = null;
// server = concurrentClient = new ConcurrentUpdateSolrServer(addr,32,8);
client = concurrentClient = getConcurrentUpdateSolrClient(addr, 64, nConnections);
client.deleteByQuery("*:*");
client.commit();
final RTimer timer = new RTimer();
final int docsPerThread = nDocs / nProducers;
Thread[] threads = new Thread[nProducers];
for (int threadNum = 0; threadNum < nProducers; threadNum++) {
final int base = threadNum * docsPerThread;
threads[threadNum] = new Thread("add-thread" + i) {
@Override
public void run() {
try {
indexDocs(base, docsPerThread, maxSleep);
} catch (Exception e) {
System.out.println("###############################CAUGHT EXCEPTION");
e.printStackTrace();
ex = e;
}
}
};
threads[threadNum].start();
}
for (int threadNum = 0; threadNum < nProducers; threadNum++) {
threads[threadNum].join();
}
if (concurrentClient != null) {
concurrentClient.blockUntilFinished();
}
double elapsed = timer.getTime();
System.out.println("time=" + elapsed + " throughput=" + (nDocs * 1000 / elapsed) + " Exception=" + ex);
// should server threads be marked as daemon?
// need a server.close()!!!
}
use of org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient in project camel by apache.
the class SolrEndpoint method createProducer.
@Override
public Producer createProducer() throws Exception {
// do we have servers?
SolrComponent.SolrServerReference ref = getComponent().getSolrServers(this);
if (ref == null) {
// no then create new servers
ref = new SolrComponent.SolrServerReference();
CloudSolrClient cloudServer = getCloudServer();
if (cloudServer == null) {
HttpSolrClient solrServer = new HttpSolrClient(url);
ConcurrentUpdateSolrClient solrStreamingServer = new ConcurrentUpdateSolrClient(url, streamingQueueSize, streamingThreadCount);
// set the properties on the solr server
if (maxRetries != null) {
solrServer.setMaxRetries(maxRetries);
}
if (soTimeout != null) {
solrServer.setSoTimeout(soTimeout);
}
if (connectionTimeout != null) {
solrServer.setConnectionTimeout(connectionTimeout);
}
if (defaultMaxConnectionsPerHost != null) {
solrServer.setDefaultMaxConnectionsPerHost(defaultMaxConnectionsPerHost);
}
if (maxTotalConnections != null) {
solrServer.setMaxTotalConnections(maxTotalConnections);
}
if (followRedirects != null) {
solrServer.setFollowRedirects(followRedirects);
}
if (allowCompression != null) {
solrServer.setAllowCompression(allowCompression);
}
ref.setSolrServer(solrServer);
ref.setUpdateSolrServer(solrStreamingServer);
}
ref.setCloudSolrServer(cloudServer);
getComponent().addSolrServers(this, ref);
}
ref.addReference();
return new SolrProducer(this, ref.getSolrServer(), ref.getUpdateSolrServer(), ref.getCloudSolrServer());
}
Aggregations