本文整理汇总了Java中org.apache.solr.client.solrj.impl.LBHttpSolrClient类的典型用法代码示例。如果您正苦于以下问题:Java LBHttpSolrClient类的具体用法?Java LBHttpSolrClient怎么用?Java LBHttpSolrClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LBHttpSolrClient类属于org.apache.solr.client.solrj.impl包,在下文中一共展示了LBHttpSolrClient类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cloneCloudSolrClient
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
private static SolrClient cloneCloudSolrClient(SolrClient solrClient, String core) {
if (VersionUtil.isSolr3XAvailable() || solrClient == null) {
return null;
}
CloudSolrClient cloudServer = (CloudSolrClient) solrClient;
String zkHost = readField(solrClient, "zkHost");
Constructor<? extends SolrClient> constructor = (Constructor<? extends SolrClient>) ClassUtils
.getConstructorIfAvailable(solrClient.getClass(), String.class, LBHttpSolrClient.class);
CloudSolrClient clone = (CloudSolrClient) BeanUtils.instantiateClass(constructor, zkHost,
cloneLBHttpSolrClient(cloudServer.getLbClient(), core));
if (org.springframework.util.StringUtils.hasText(core)) {
clone.setDefaultCollection(core);
}
return clone;
}
示例2: cloneLBHttpSolrClient
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
private static LBHttpSolrClient cloneLBHttpSolrClient(SolrClient solrClient, String core) {
if (solrClient == null) {
return null;
}
LBHttpSolrClient clone = null;
try {
if (VersionUtil.isSolr3XAvailable()) {
clone = cloneSolr3LBHttpServer(solrClient, core);
} else if (VersionUtil.isSolr4XAvailable()) {
clone = cloneSolr4LBHttpServer(solrClient, core);
}
} catch (Exception e) {
throw new BeanInstantiationException(solrClient.getClass(), "Cannot create instace of " + solrClient.getClass()
+ ". ", e);
}
Object o = readField(solrClient, "interval");
if (o != null) {
clone.setAliveCheckInterval(Integer.valueOf(o.toString()).intValue());
}
return clone;
}
示例3: cloneSolr4LBHttpServer
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
private static LBHttpSolrClient cloneSolr4LBHttpServer(SolrClient solrClient, String core)
throws MalformedURLException, InstantiationException, IllegalAccessException, IllegalArgumentException,
InvocationTargetException {
Map<String, ?> map = readField(solrClient, "aliveServers");
String[] servers = new String[map.size()];
int i = 0;
for (String key : map.keySet()) {
servers[i] = appendCoreToBaseUrl(key, core);
i++;
}
Boolean isInternalCient = readField(solrClient, "clientIsInternal");
if (isInternalCient != null && !isInternalCient) {
HttpClient clientToUse = readAndCloneHttpClient(solrClient);
return new LBHttpSolrClient(clientToUse, servers);
}
return new LBHttpSolrClient(servers);
}
示例4: build
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
/**
* Builds a new SolRDF proxy instance.
*
* @return a new SolRDF proxy instance.
* @throws UnableToBuildSolRDFClientException in case of build failure.
*/
public SolRDF build() throws UnableToBuildSolRDFClientException {
if (endpoints.isEmpty()) {
endpoints.add(DEFAULT_ENDPOINT);
}
// FIXME: for DatasetAccessor and (HTTP) query execution service we also need something like LBHttpSolrServer
final String firstEndpointAddress = endpoints.iterator().next();
try {
return new SolRDF(
DatasetAccessorFactory.createHTTP(
firstEndpointAddress +
graphStoreProtocolEndpointPath),
firstEndpointAddress + sparqlEndpointPath,
zkHost != null
? new CloudSolrClient(zkHost)
: (endpoints.size() == 1)
? new HttpSolrClient(endpoints.iterator().next(), httpClient)
: new LBHttpSolrClient(httpClient, endpoints.toArray(new String[endpoints.size()])));
} catch (final Exception exception) {
throw new UnableToBuildSolRDFClientException(exception);
}
}
示例5: checkResponseWriter
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
private static boolean checkResponseWriter(SolrClient sc) {
if (sc instanceof HttpSolrClient && !(((HttpSolrClient) sc).getParser() instanceof InputStreamResponseParser)) {
return false;
} else if (sc instanceof LBHttpSolrClient
&& !(((LBHttpSolrClient) sc).getParser() instanceof InputStreamResponseParser)) {
return false;
} else if (sc instanceof CloudSolrClient
&& !(((CloudSolrClient) sc).getParser() instanceof InputStreamResponseParser)) {
return false;
}
return true;
}
示例6: fromSolrHosts
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
public static SolrClient fromSolrHosts(String solrHostsCommaSeparated) {
String[] hostArr = solrHostsCommaSeparated.split(",");
if (hostArr.length == 1) {
return new HttpSolrClient.Builder(hostArr[0]).withResponseParser(new InputStreamResponseParser("json"))
.build();
}
return new LBHttpSolrClient.Builder().withBaseSolrUrls(hostArr)
.withResponseParser(new InputStreamResponseParser("json")).build();
}
示例7: destroy
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
/**
* @param client
*/
protected void destroy(SolrClient client) {
if (client instanceof HttpSolrClient) {
((HttpSolrClient) client).shutdown();
} else if (client instanceof LBHttpSolrClient) {
((LBHttpSolrClient) client).shutdown();
} else {
if (VersionUtil.isSolr4XAvailable()) {
if (client instanceof CloudSolrClient) {
((CloudSolrClient) client).shutdown();
}
}
}
}
示例8: cloneSolr3LBHttpServer
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
private static LBHttpSolrClient cloneSolr3LBHttpServer(SolrClient solrClient, String core)
throws MalformedURLException {
CopyOnWriteArrayList<?> list = readField(solrClient, "aliveServers");
String[] servers = new String[list.size()];
for (int i = 0; i < list.size(); i++) {
servers[i] = appendCoreToBaseUrl(list.get(i).toString(), core);
}
return new LBHttpSolrClient(servers);
}
示例9: createLoadbalancer
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
@Override
protected LBHttpSolrClient createLoadbalancer(HttpClient httpClient) {
try {
return new BackupRequestLBHttpSolrClient(
httpClient, getThreadPoolExecutor(),
maximumConcurrentRequests, backupRequestDelay, tryDeadServers, registryName, defaultPercentile);
} catch (MalformedURLException e) {
// should be impossible since we're not passing any URLs here
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
}
}
示例10: buildSolr
import org.apache.solr.client.solrj.impl.LBHttpSolrClient; //导入依赖的package包/类
public SolrClient buildSolr() {
Preconditions.checkNotNull(serverType, "Solr server type is required");
switch (serverType) {
case EMBEDDED:
LOG.info("Using embedded solr server {} with collection {}", serverHome, collection);
return new EmbeddedServerBuilder()
.withServerHomeDir(serverHome)
.withDeleteOnExit(deleteOnExit)
.withCoreName(collection)
.build();
case HTTP:
LOG.info("Using remote solr server {}", serverHome);
return new HttpSolrClient(serverHome);
case LBHTTP:
try {
LOG.info("Using remote load-balanced solr server {}", serverHome);
return new LBHttpSolrClient(serverHome);
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e);
}
case CLOUD:
LOG.info("Using cloud solr server {} with collection {} and idField {}", serverHome, collection, idField);
return new CloudSolrServerBuilder()
.withZkHost(serverHome)
.withDefaultCollection(collection)
.withIdField(idField)
.build();
default:
// should never get here...
throw new IllegalArgumentException("Unknown server type " + serverType);
}
}