Ejemplo n.º 1
0
  public void setSolrUrl(String url) {

    LOGGER.debug("Setting solrUrl to {}", url);
    if (url != null) {
      if (solrUrl == null
          || !StringUtils.equalsIgnoreCase(url.trim(), solrUrl.getResolvedString())) {
        solrUrl = new PropertyResolver(url.trim());

        List<SolrServer> servers = new ArrayList<>(coreSolrServers.values());
        coreSolrServers.clear();
        for (SolrServer server : servers) {
          server.shutdown();
        }
      }
    } else {
      // sets to null
      solrUrl = new PropertyResolver(url);
    }
  }
Ejemplo n.º 2
0
  private SolrServer getSolrCore(String storeName) {
    if (coreSolrServers.containsKey(storeName)) {
      LOGGER.info("Returning core {} from map of coreSolrServers", storeName);
      return coreSolrServers.get(storeName);
    }

    // Must specify shard in URL so proper core is used
    SolrServer coreSolrServer = null;
    try {
      Future<SolrServer> coreSolrServerFuture =
          SolrServerFactory.getHttpSolrServer(solrUrl.getResolvedString(), storeName);
      coreSolrServer = coreSolrServerFuture.get(5, TimeUnit.SECONDS);
      coreSolrServers.put(storeName, coreSolrServer);

      LOGGER.trace("EXITING: getSolrCore");

    } catch (InterruptedException | ExecutionException | TimeoutException e) {
      LOGGER.warn("Error getting solr server from future", e);
    }
    return coreSolrServer;
  }