当前位置: 首页>>代码示例>>Java>>正文


Java LBHttpSolrClient类代码示例

本文整理汇总了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;
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:20,代码来源:SolrClientUtils.java

示例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;
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:23,代码来源:SolrClientUtils.java

示例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);
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:21,代码来源:SolrClientUtils.java

示例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);
	}	
}
 
开发者ID:spaziocodice,项目名称:SolRDF,代码行数:29,代码来源:SolRDF.java

示例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;
}
 
开发者ID:jdyer1,项目名称:R-solr-stream,代码行数:13,代码来源:RStreamingExpressions.java

示例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();
}
 
开发者ID:jdyer1,项目名称:R-solr-stream,代码行数:10,代码来源:SolrClientFactory.java

示例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();
			}
		}
	}
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:17,代码来源:SolrClientFactoryBase.java

示例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);
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:11,代码来源:SolrClientUtils.java

示例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);
  }
}
 
开发者ID:whitepages,项目名称:SOLR-4449,代码行数:12,代码来源:HttpBackupRequestShardHandlerFactory.java

示例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);
  }
}
 
开发者ID:gbif,项目名称:common-search,代码行数:37,代码来源:SolrConfig.java


注:本文中的org.apache.solr.client.solrj.impl.LBHttpSolrClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。