example of SolrJ client with authentication

From elyograg, 11 Months ago, written in Java, viewed 78 times. This paste will join the choir invisible in 1 Second.
URL https://paste.elyograg.org/view/e5cce5db Embed
Download Paste or View Raw
  1.     final Http2SolrClient.Builder scb = new Http2SolrClient.Builder(RequiredOpts.sourceUrl);
  2.     final Http2SolrClient.Builder thb = new Http2SolrClient.Builder();
  3.  
  4.     if (!sourceH2) {
  5.       scb.useHttp1_1(true);
  6.     }
  7.  
  8.     if (!targetH2) {
  9.       thb.useHttp1_1(true);
  10.     }
  11.  
  12.     if (sourceUser != null && !sourceUser.equals("")) {
  13.       log.info("Setting source credentials");
  14.       scb.withBasicAuthCredentials(sourceUser, sourcePass);
  15.     }
  16.     if (targetUser != null && !targetUser.equals("")) {
  17.       log.info("Setting target credentials");
  18.       thb.withBasicAuthCredentials(targetUser, targetPass);
  19.     }
  20.  
  21.     final CloudHttp2SolrClient.Builder tcb = new CloudHttp2SolrClient.Builder(targetZkHosts,
  22.         chroot);
  23.     log.info("Building Http2SolrClient for target CloudHttp2SolrClient");
  24.     final Http2SolrClient thc = thb.build();
  25.     tcb.sendDirectUpdatesToShardLeadersOnly().withHttpClient(thc);
  26.     final long nanoStart;
  27.     final ArrayBlockingQueue<SolrInputDocument> queue;
  28.     log.info("Building remaining SolrClients");
  29.     final SolrClient sourceClient = scb.build();
  30.     final SolrClient targetClient = tcb.build();
  31.  

Reply to "example of SolrJ client with authentication"

Here you can reply to the paste above