Search in sources :

Example 1 with ConcurrentUpdateSolrClient

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;
}
Also used : BinaryResponseParser(org.apache.solr.client.solrj.impl.BinaryResponseParser) BinaryRequestWriter(org.apache.solr.client.solrj.impl.BinaryRequestWriter) ConcurrentUpdateSolrClient(org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient)

Example 2 with ConcurrentUpdateSolrClient

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));
    }
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) UpdateRequest(org.apache.solr.client.solrj.request.UpdateRequest) ArrayList(java.util.ArrayList) ConcurrentUpdateSolrClient(org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient)

Example 3 with ConcurrentUpdateSolrClient

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;
}
Also used : QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) ConcurrentUpdateSolrClient(org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient)

Example 4 with ConcurrentUpdateSolrClient

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()!!!
}
Also used : ConcurrentUpdateSolrClient(org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient) RTimer(org.apache.solr.util.RTimer) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException)

Example 5 with ConcurrentUpdateSolrClient

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());
}
Also used : HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) ConcurrentUpdateSolrClient(org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient)

Aggregations

ConcurrentUpdateSolrClient (org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient)13 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)5 SolrClient (org.apache.solr.client.solrj.SolrClient)4 ArrayList (java.util.ArrayList)3 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)3 IOException (java.io.IOException)2 BinaryRequestWriter (org.apache.solr.client.solrj.impl.BinaryRequestWriter)2 BinaryResponseParser (org.apache.solr.client.solrj.impl.BinaryResponseParser)2 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)2 UpdateResponse (org.apache.solr.client.solrj.response.UpdateResponse)2 SolrInputDocument (org.apache.solr.common.SolrInputDocument)2 HashSet (java.util.HashSet)1 List (java.util.List)1 CheckForNull (javax.annotation.CheckForNull)1 GoraException (org.apache.gora.util.GoraException)1 SolrServerException (org.apache.solr.client.solrj.SolrServerException)1 LBHttpSolrClient (org.apache.solr.client.solrj.impl.LBHttpSolrClient)1 XMLResponseParser (org.apache.solr.client.solrj.impl.XMLResponseParser)1 RequestWriter (org.apache.solr.client.solrj.request.RequestWriter)1 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)1