Refine search
/** * Initialize any state for this DB. Called once per DB instance; there is one DB instance per * client thread. */ @Override public void init() throws DBException { Properties props = getProperties(); commitTime = Integer .parseInt(props.getProperty("solr.commit.within.time", DEFAULT_COMMIT_WITHIN_TIME)); batchMode = Boolean.parseBoolean(props.getProperty("solr.batch.mode", DEFAULT_BATCH_MODE)); String jaasConfPath = props.getProperty("solr.jaas.conf.path"); if(jaasConfPath != null) { System.setProperty("java.security.auth.login.config", jaasConfPath); HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer()); } // Check if Solr cluster is running in SolrCloud or Stand-alone mode Boolean cloudMode = Boolean.parseBoolean(props.getProperty("solr.cloud", DEFAULT_CLOUD_MODE)); System.err.println("Solr Cloud Mode = " + cloudMode); if (cloudMode) { System.err.println("Solr Zookeeper Remote Hosts = " + props.getProperty("solr.zookeeper.hosts", DEFAULT_ZOOKEEPER_HOSTS)); client = new CloudSolrClient.Builder().withZkHost( Arrays.asList(props.getProperty("solr.zookeeper.hosts", DEFAULT_ZOOKEEPER_HOSTS).split(","))).build(); } else { client = new HttpSolrClient.Builder(props.getProperty("solr.base.url", DEFAULT_SOLR_BASE_URL)).build(); } }
this.server = new Builder().withInvariantParams(params).build(); this.server.setSoTimeout(config.getSoTimeout()); this.server.setConnectionTimeout(config.getConnTimeout()); this.server.setMaxTotalConnections(config.getMaxConns());
/** * Creates the datastore. * * @param url The URL of SOLR server * @param layerMapper The document loader. */ public SolrDataStore(URL url, SolrLayerMapper layerMapper) { // TODO: make connection timeouts configurable this.url = url; this.layerMapper = layerMapper; this.solrServer = new HttpSolrClient.Builder() .withBaseSolrUrl(url.toString()) .allowCompression(true) .build(); this.solrServer.setConnectionTimeout(10000); this.solrServer.setFollowRedirects(true); this.solrServer.setSoTimeout(10000); }
HttpSolrClient solr = new HttpSolrClient.Builder(solrServer).build(); solr.deleteByQuery("*:*"); solr.add(solrDocumentList); solr.commit(); SolrQuery query = new SolrQuery("*:*"); QueryResponse response = solr.query(query);
protected void logReplicationDetails(Replica replica, StringBuilder builder) throws IOException { try (HttpSolrClient client = new HttpSolrClient.Builder(replica.getCoreUrl()).build()) { ModifiableSolrParams params = new ModifiableSolrParams(); params.set("qt", "/replication"); params.set(ReplicationHandler.COMMAND, ReplicationHandler.CMD_DETAILS); try { QueryResponse response = client.query(params); builder.append(String.format(Locale.ROOT, "%s: %s%s", replica.getName(), response.getResponse(), System.lineSeparator())); } catch (SolrServerException e) { log.warn("Unable to ger replication details for replica {}", replica.getName(), e); } } }
for (String url : urls) { HttpSolrClient server = new HttpSolrClient.Builder(url).build(); server.commit(); server.close();
@Override public Request call() { Request req = new Request(); LOG.info("Live merge " + dir.getPath() + " into " + mergeUrl); final HttpSolrClient server = new HttpSolrClient.Builder(mergeUrl).build(); try { CoreAdminRequest.MergeIndexes mergeRequest = new CoreAdminRequest.MergeIndexes(); mergeRequest.setCoreName(name); mergeRequest.setIndexDirs(Arrays.asList(dir.getPath().toString() + "/data/index")); try { mergeRequest.process(server); req.success = true; } catch (SolrServerException e) { req.e = e; return req; } catch (IOException e) { req.e = e; return req; } } finally { try { server.close(); } catch (java.io.IOException e) { throw new RuntimeException(e); } } return req; } };
for (String url : urls) { try (HttpSolrClient server = new HttpSolrClient.Builder(url).build()) { server.commit();
protected ConcurrentUpdateSolrClient(Builder builder) { this.internalHttpClient = (builder.httpClient == null); this.client = new HttpSolrClient.Builder(builder.baseSolrUrl) .withHttpClient(builder.httpClient) .build(); this.client.setFollowRedirects(false); this.queue = new LinkedBlockingQueue<>(builder.queueSize); this.threadCount = builder.threadCount; this.runners = new LinkedList<>(); this.streamDeletes = builder.streamDeletes; this.connectionTimeout = builder.connectionTimeoutMillis; this.soTimeout = builder.socketTimeoutMillis; if (builder.executorService != null) { this.scheduler = builder.executorService; this.shutdownExecutor = false; } else { this.scheduler = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrjNamedThreadFactory("concurrentUpdateScheduler")); this.shutdownExecutor = true; } if (log.isDebugEnabled()) { this.pollInterrupts = new AtomicInteger(); this.pollExits = new AtomicInteger(); this.blockLoops = new AtomicInteger(); this.emptyQueueLoops = new AtomicInteger(); } }
synchronized (this) { httpSolrClientBuilder .withBaseSolrUrl(server) .withHttpClient(httpClient); if (connectionTimeout != null) { httpSolrClientBuilder.withConnectionTimeout(connectionTimeout); httpSolrClientBuilder.withSocketTimeout(soTimeout); client = httpSolrClientBuilder.build(); final HttpSolrClient.Builder clientBuilder = new HttpSolrClient.Builder(server) .withHttpClient(httpClient) .withResponseParser(parser); if (connectionTimeout != null) { clientBuilder.withConnectionTimeout(connectionTimeout); clientBuilder.withSocketTimeout(soTimeout); client = clientBuilder.build(); client.setRequestWriter(requestWriter); client.setQueryParams(queryParams);
public SimpleSolrResponse invoke(String solrNode, String path, SolrParams params) throws IOException, SolrServerException { String url = zkClientClusterStateProvider.getZkStateReader().getBaseUrlForNodeName(solrNode); GenericSolrRequest request = new GenericSolrRequest(SolrRequest.METHOD.POST, path, params); try (HttpSolrClient client = new HttpSolrClient.Builder() .withHttpClient(solrClient.getHttpClient()) .withBaseSolrUrl(url) .withResponseParser(new BinaryResponseParser()) .build()) { NamedList<Object> rsp = client.request(request); request.response.nl = rsp; return request.response; } }
private void createHttpSolrClient() { HttpSolrClient.Builder builder = new HttpSolrClient.Builder().withBaseSolrUrl(this.url); if (timeout != null) { builder = builder.withConnectionTimeout(timeout); } if (maxConnections != null) { ModifiableSolrParams params = new ModifiableSolrParams(); params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections); builder.withHttpClient(HttpClientUtil.createClient(params)); } this.setSolrClient(builder.build()); }
/** * @deprecated use {@link HttpSolrClient#HttpSolrClient(Builder)} instead, as it is a more extension/subclassing-friendly alternative */ @Deprecated protected HttpSolrClient(String baseURL, HttpClient client, ResponseParser parser, boolean allowCompression) { this(new Builder(baseURL) .withHttpClient(client) .withResponseParser(parser) .allowCompression(allowCompression)); }
private SolrClient getSolrServer () { if (solrServer == null) { } String urlString = "http://" + systemConfig.getSolrHostColonPort() + "/solr/collection1"; solrServer = new HttpSolrClient.Builder(urlString).build(); return solrServer; }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url, HttpClient httpClient, ResponseParser responseParser) { return new Builder(url) .withHttpClient(httpClient) .withResponseParser(responseParser) .build(); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url, HttpClient httpClient, ResponseParser responseParser, boolean compression) { return new Builder(url) .withHttpClient(httpClient) .withResponseParser(responseParser) .allowCompression(compression) .build(); }
@PostConstruct public void init() { String urlString = "http://" + systemConfig.getSolrHostColonPort() + "/solr/collection1"; solrServer = new HttpSolrClient.Builder(urlString).build(); }
@PostConstruct public void init() { String urlString = "http://" + systemConfig.getSolrHostColonPort() + "/solr/collection1"; solrServer = new HttpSolrClient.Builder(urlString).build(); }
@Override public void start(ILifecycleProgressMonitor monitor) throws SiteWhereException { getLogger().info("Solr initializing with URL: " + getSolrConfiguration().getSolrServerUrl()); setSolrClient(new HttpSolrClient.Builder(getSolrConfiguration().getSolrServerUrl()).build()); }
/** * This method <i>may</i> randomize unspecified aspects of the resulting SolrClient. * Tests that do not wish to have any randomized behavior should use the * {@link org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} class directly */ public static HttpSolrClient getHttpSolrClient(String url) { return new Builder(url) .build(); }