Java Code Examples for org.apache.solr.client.solrj.SolrRequest#process()

The following examples show how to use org.apache.solr.client.solrj.SolrRequest#process() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SolrSchemaFieldDao.java    From ambari-logsearch with Apache License 2.0 5 votes vote down vote up
private void populateSchemaFields(CloudSolrClient solrClient, Map<String, String> schemaFieldNameMap,
    Map<String, String> schemaFieldTypeMap) {
  if (solrClient != null) {
    logger.debug("Started thread to get fields for collection=" + solrClient.getDefaultCollection());
    List<LukeResponse> lukeResponses = null;
    SchemaResponse schemaResponse = null;
    try {
      lukeResponses = getLukeResponsesForCores(solrClient);

      SolrRequest<SchemaResponse> schemaRequest = new SchemaRequest();
      schemaRequest.setMethod(SolrRequest.METHOD.GET);
      schemaRequest.setPath("/schema");
      schemaResponse = schemaRequest.process(solrClient);
      
      logger.debug("populateSchemaFields() collection=" + solrClient.getDefaultCollection() + ", luke=" + lukeResponses +
          ", schema= " + schemaResponse);
    } catch (SolrException | SolrServerException | IOException e) {
      logger.error("Error occured while popuplating field. collection=" + solrClient.getDefaultCollection(), e);
    }

    if (schemaResponse != null) {
      extractSchemaFieldsName(lukeResponses, schemaResponse, schemaFieldNameMap, schemaFieldTypeMap);
      logger.debug("Populate fields for collection " + solrClient.getDefaultCollection()+ " was successful, next update it after " +
          solrMetadataPropsConfig.getPopulateIntervalMins() + " minutes");
      retryCount = 0;
      skipCount = (solrMetadataPropsConfig.getPopulateIntervalMins() * 60) / RETRY_SECOND - 1;
    }
    else {
      retryCount++;
      logger.error("Error while populating fields for collection " + solrClient.getDefaultCollection() + ", retryCount=" + retryCount);
    }
  }
}
 
Example 2
Source File: SolrClientCloudManager.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public SolrResponse request(@SuppressWarnings({"rawtypes"})SolrRequest req) throws IOException {
  try {
    return req.process(solrClient);
  } catch (SolrServerException e) {
    throw new IOException(e);
  }
}
 
Example 3
Source File: SolrCLI.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private static boolean runningSolrIsCloud(String url) throws Exception {
  try (final HttpSolrClient client = new HttpSolrClient.Builder(url).build()) {
    final SolrRequest<CollectionAdminResponse> request = new CollectionAdminRequest.ClusterStatus();
    final CollectionAdminResponse response = request.process(client);
    return response != null;
  } catch (Exception e) {
    if (exceptionIsAuthRelated(e)) {
      throw e;
    }
    return false;
  }
}
 
Example 4
Source File: BasicAuthIntegrationTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private QueryResponse executeQuery(ModifiableSolrParams params, String user, String pass) throws IOException, SolrServerException {
  @SuppressWarnings({"rawtypes"})
  SolrRequest req = new QueryRequest(params);
  req.setBasicAuthCredentials(user, pass);
  QueryResponse resp = (QueryResponse) req.process(cluster.getSolrClient(), COLLECTION);
  assertNull(resp.getException());
  assertEquals(0, resp.getStatus());
  return resp;
}
 
Example 5
Source File: TestDistribPackageStore.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public static NavigableObject assertResponseValues(int repeats, SolrClient client,
                                                   @SuppressWarnings({"rawtypes"})SolrRequest req,
                                                   @SuppressWarnings({"rawtypes"})Map vals) throws Exception {
  Callable<NavigableObject> callable = () -> req.process(client);

  return assertResponseValues(repeats, callable,vals);
}
 
Example 6
Source File: AuthorizedSolrClient.java    From beam with Apache License 2.0 4 votes vote down vote up
<ResponseT extends SolrResponse> ResponseT process(
    String collection, SolrRequest<ResponseT> request) throws IOException, SolrServerException {
  request.setBasicAuthCredentials(username, password);
  return request.process(solrClient, collection);
}