• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java LBHttpSolrServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.solr.client.solrj.impl.LBHttpSolrServer的典型用法代码示例。如果您正苦于以下问题:Java LBHttpSolrServer类的具体用法?Java LBHttpSolrServer怎么用?Java LBHttpSolrServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LBHttpSolrServer类属于org.apache.solr.client.solrj.impl包,在下文中一共展示了LBHttpSolrServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testReliability

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
public void testReliability() throws Exception {
  String[] s = new String[solr.length];
  for (int i = 0; i < solr.length; i++) {
    s[i] = solr[i].getUrl();
  }
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, 250);
  params.set(HttpClientUtil.PROP_SO_TIMEOUT, 250);
  HttpClient myHttpClient = HttpClientUtil.createClient(params);

  LBHttpSolrServer lbHttpSolrServer = new LBHttpSolrServer(myHttpClient, s);
  lbHttpSolrServer.setAliveCheckInterval(500);

  // Kill a server and test again
  solr[1].jetty.stop();
  solr[1].jetty = null;

  // query the servers
  for (String value : s)
    lbHttpSolrServer.query(new SolrQuery("*:*"));

  // Start the killed server once again
  solr[1].startJetty();
  // Wait for the alive check to complete
  waitForServer(30000, lbHttpSolrServer, 3, "solr1");
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:TestLBHttpSolrServer.java


示例2: setUrlScheme

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
private void setUrlScheme(String value) throws Exception {
  @SuppressWarnings("rawtypes")
  Map m = makeMap("action", CollectionAction.CLUSTERPROP.toString()
      .toLowerCase(Locale.ROOT), "name", "urlScheme", "val", value);
  @SuppressWarnings("unchecked")
  SolrParams params = new MapSolrParams(m);
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");
  
  List<String> urls = new ArrayList<String>();
  for(Replica replica : getReplicas()) {
    urls.add(replica.getStr(ZkStateReader.BASE_URL_PROP));
  }
  //Create new SolrServer to configure new HttpClient w/ SSL config
  new LBHttpSolrServer(urls.toArray(new String[]{})).request(request);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SSLMigrationTest.java


示例3: createAndConfigure

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
@Override
public SolrServer createAndConfigure(final String proxyRole, final Configuration<Map<String, Object>> configuration) {
	
	final List<String> servers = new ArrayList<String>();
	for (int i = 0;; i++) {					
		final String server = configuration.getParameter(
				new StringBuilder(proxyRole)
					.append(i)
					.append(ADDRESS)
					.toString(), 
					null);
		if (server == null) {
			break;
		}
		
		servers.add(server);
	}
	
	try {
		return (!servers.isEmpty() 
			? new LBHttpSolrServer(servers.toArray(new String[servers.size()]))
			: new HttpSolrServer(DEFAULT_ADDRESS));
	} catch (final Exception exception) {
		return new HttpSolrServer(DEFAULT_ADDRESS);
	}
}
 
开发者ID:spaziocodice,项目名称:jena-nosql,代码行数:27,代码来源:SolrStorageLayerFactory.java


示例4: buildQuerySolrServer

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
/**
 * 建造查询用SolrServer
 */
private void buildQuerySolrServer() {
	this.validConf(); // 必须是已配置的对象
	Type type = this.conf.getType();
	if (this.isSingle()) { // 单服务器节点
		if (type.accept(HttpSolrServer.class)) {
			this.querySolrServer = this.buildHttpSolrServer();
			this.httpSolrServer = this.querySolrServer;
		}
	}
	if (this.querySolrServer == null) { // 负载均衡SolrServer
		if (type.accept(LBHttpSolrServer.class)) {
			this.querySolrServer = this.buildLBHttpSolrServer();
		}
	}
	this.querySolrServerBuilt = true;
}
 
开发者ID:dowenliu-xyz,项目名称:solrj-util,代码行数:20,代码来源:SolrServerFactory.java


示例5: accept

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
@Override
public boolean accept(Class<?> solrServerClass) {
	if (solrServerClass == null) {
		return false;
	}
	if (LBHttpSolrServer.class.equals(solrServerClass)) {
		return true;
	}
	if (HttpSolrServer.class.equals(solrServerClass)) {
		return true;
	}
	if (this.accept(solrServerClass.getSuperclass())) {
		return true;
	}
	return false;
}
 
开发者ID:dowenliu-xyz,项目名称:solrj-util,代码行数:17,代码来源:SolrServerConfiguration.java


示例6: testFactory

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
@Test
@Ignore
public void testFactory() {
	assertNotNull(masterFactory);
	SolrServer solrServer = this.masterFactory.getUpdateSolrServer();
	assertTrue(solrServer instanceof ConcurrentUpdateSolrServer);
	solrServer = this.masterFactory.getUpdateSolrServer(true);
	assertTrue(solrServer.getClass().equals(HttpSolrServer.class));
	solrServer = this.masterFactory.getQuerySolrServer();
	assertTrue(solrServer.getClass().equals(HttpSolrServer.class));
	assertNotNull(slavesFactory);
	solrServer = this.slavesFactory.getUpdateSolrServer();
	assertTrue(solrServer == null);
	solrServer = this.slavesFactory.getUpdateSolrServer(true);
	assertTrue(solrServer == null);
	solrServer = this.slavesFactory.getQuerySolrServer();
	assertTrue(solrServer instanceof LBHttpSolrServer);
}
 
开发者ID:dowenliu-xyz,项目名称:solrj-util,代码行数:19,代码来源:SolrServerFactoryTest.java


示例7: cloneLBHttpSolrServer

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
private static LBHttpSolrServer cloneLBHttpSolrServer(SolrServer solrServer, String core) {
	if (solrServer == null) {
		return null;
	}

	LBHttpSolrServer clone = null;
	try {
		if (VersionUtil.isSolr3XAvailable()) {
			clone = cloneSolr3LBHttpServer(solrServer, core);
		} else if (VersionUtil.isSolr4XAvailable()) {
			clone = cloneSolr4LBHttpServer(solrServer, core);
		}
	} catch (MalformedURLException e) {
		throw new BeanInstantiationException(solrServer.getClass(), "Cannot create instace of " + solrServer.getClass()
				+ ". ", e);
	}
	Object o = readField(solrServer, "interval");
	if (o != null) {
		clone.setAliveCheckInterval(Integer.valueOf(o.toString()).intValue());
	}
	return clone;
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:23,代码来源:SolrServerUtils.java


示例8: cloneCloudSolrServer

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
private static SolrServer cloneCloudSolrServer(SolrServer solrServer, String core) {
	if (VersionUtil.isSolr3XAvailable() || solrServer == null) {
		return null;
	}

	CloudSolrServer cloudServer = (CloudSolrServer) solrServer;
	String zkHost = readField(solrServer, "zkHost");

	Constructor<? extends SolrServer> constructor = (Constructor<? extends SolrServer>) ClassUtils
			.getConstructorIfAvailable(solrServer.getClass(), String.class, LBHttpSolrServer.class);

	CloudSolrServer clone = (CloudSolrServer) BeanUtils.instantiateClass(constructor, zkHost,
			cloneLBHttpSolrServer(cloudServer.getLbServer(), core));

	if (org.springframework.util.StringUtils.hasText(core)) {
		clone.setDefaultCollection(core);
	}
	return clone;
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:20,代码来源:SolrServerUtils.java


示例9: testClonesCloudSolrServerForCoreCorrectlyWhenCoreNameIsNotEmpty

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testClonesCloudSolrServerForCoreCorrectlyWhenCoreNameIsNotEmpty() throws MalformedURLException {
	LBHttpSolrServer lbSolrServer = new LBHttpSolrServer(BASE_URL, ALTERNATE_BASE_URL);
	CloudSolrServer cloudServer = new CloudSolrServer(ZOO_KEEPER_URL, lbSolrServer);

	CloudSolrServer clone = SolrServerUtils.clone(cloudServer, CORE_NAME);
	Assert.assertEquals(ZOO_KEEPER_URL, ReflectionTestUtils.getField(clone, FIELD_ZOO_KEEPER));

	LBHttpSolrServer lbClone = clone.getLbServer();
	Map<String, ?> aliveServers = (Map<String, ?>) ReflectionTestUtils.getField(lbClone, FIELD_ALIVE_SERVERS);
	Assert.assertThat(aliveServers.keySet(), hasItems(CORE_URL, ALTERNATE_CORE_URL));

	assertLBHttpSolrServerProperties(lbSolrServer, lbClone);
	Assert.assertThat(clone.getDefaultCollection(), equalTo(CORE_NAME));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:17,代码来源:SolrServerUtilTests.java


示例10: getLBHttpSolrServer

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
/**
 * create SolrProvider with LBHttpSolrServer.
 */
private static SolrProvider getLBHttpSolrServer(String solrServerUrls,
        String coreName, int commitWithinMs) {
    String[] solrURLs = solrServerUrls.split(",");
    String description = solrServerUrls;

    // handle coreName
    if (coreName != null && coreName.length() > 0) {
        description = "";
        for (int i = 0; i < solrURLs.length; i++) {
            solrURLs[i] = solrURLs[i] + "/" + coreName;
            description += "," + solrURLs[i];
        }
        description = description.replaceFirst(",", "");
    }

    try {
        return new SolrProvider(new LBHttpSolrServer(solrURLs),
                commitWithinMs, "LBHttpSolrServer(\"" + description + "\")");
    } catch (MalformedURLException murlEx) {
        // LBHttpSolrServer does not throw this exception
        return null;
    }
}
 
开发者ID:scherziglu,项目名称:log4j,代码行数:27,代码来源:SolrProvider.java


示例11: testTwoServers

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
public void testTwoServers() throws Exception {
  LBHttpSolrServer lbHttpSolrServer = new LBHttpSolrServer(httpClient, solr[0].getUrl(), solr[1].getUrl());
  lbHttpSolrServer.setAliveCheckInterval(500);
  SolrQuery solrQuery = new SolrQuery("*:*");
  QueryResponse resp = null;
  solr[0].jetty.stop();
  solr[0].jetty = null;
  resp = lbHttpSolrServer.query(solrQuery);
  String name = resp.getResults().get(0).getFieldValue("name").toString();
  Assert.assertEquals("solr/collection11", name);
  resp = lbHttpSolrServer.query(solrQuery);
  name = resp.getResults().get(0).getFieldValue("name").toString();
  Assert.assertEquals("solr/collection11", name);
  solr[1].jetty.stop();
  solr[1].jetty = null;
  solr[0].startJetty();
  Thread.sleep(1200);
  try {
    resp = lbHttpSolrServer.query(solrQuery);
  } catch(SolrServerException e) {
    // try again after a pause in case the error is lack of time to start server
    Thread.sleep(3000);
    resp = lbHttpSolrServer.query(solrQuery);
  }
  name = resp.getResults().get(0).getFieldValue("name").toString();
  Assert.assertEquals("solr/collection10", name);
}
 
开发者ID:europeana,项目名称:search,代码行数:28,代码来源:TestLBHttpSolrServer.java


示例12: waitForServer

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
private void waitForServer(int maximum, LBHttpSolrServer server, int nServers, String serverName) throws Exception {
  long endTime = System.currentTimeMillis() + maximum;
  while (System.currentTimeMillis() < endTime) {
    QueryResponse resp;
    try {
      resp = server.query(new SolrQuery("*:*"));
    } catch (Exception e) {
      log.warn("", e);
      continue;
    }
    String name = resp.getResults().get(0).getFieldValue("name").toString();
    if (name.equals(serverName))
      return;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:TestLBHttpSolrServer.java


示例13: createLoadBalancedHttpSolrServer

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
private void createLoadBalancedHttpSolrServer() {
	try {
		LBHttpSolrServer lbHttpSolrServer = new LBHttpSolrServer(StringUtils.split(this.url, SERVER_URL_SEPARATOR));
		if (timeout != null) {
			lbHttpSolrServer.setConnectionTimeout(timeout.intValue());
		}
		this.setSolrServer(lbHttpSolrServer);
	} catch (MalformedURLException e) {
		throw new IllegalArgumentException("Unable to create Load Balanced Http Solr Server", e);
	}
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:12,代码来源:HttpSolrServerFactoryBean.java


示例14: cloneSolr3LBHttpServer

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
private static LBHttpSolrServer cloneSolr3LBHttpServer(SolrServer solrServer, String core)
		throws MalformedURLException {
	CopyOnWriteArrayList<?> list = readField(solrServer, "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 LBHttpSolrServer(servers);
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:11,代码来源:SolrServerUtils.java


示例15: cloneSolr4LBHttpServer

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
private static LBHttpSolrServer cloneSolr4LBHttpServer(SolrServer solrServer, String core)
		throws MalformedURLException {
	Map<String, ?> map = readField(solrServer, "aliveServers");

	String[] servers = new String[map.size()];
	int i = 0;
	for (String key : map.keySet()) {
		servers[i] = appendCoreToBaseUrl(key, core);
		i++;
	}
	return new LBHttpSolrServer(servers);
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:13,代码来源:SolrServerUtils.java


示例16: destroy

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
/**
 * @param server
 */
protected void destroy(SolrServer server) {
	if (solrServer instanceof HttpSolrServer) {
		((HttpSolrServer) solrServer).shutdown();
	} else if (solrServer instanceof LBHttpSolrServer) {
		((LBHttpSolrServer) solrServer).shutdown();
	} else {
		if (VersionUtil.isSolr4XAvailable()) {
			if (solrServer instanceof CloudSolrServer) {
				((CloudSolrServer) solrServer).shutdown();
			}
		}
	}
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:17,代码来源:SolrServerFactoryBase.java


示例17: createsRepositoryAndEmbeddedServerCorrectly

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
@Test
public void createsRepositoryAndEmbeddedServerCorrectly() {
	assertThat(context.getBean(PersonRepository.class), is(notNullValue()));
	assertThat(context.getBean(EmbeddedSolrServer.class), is(notNullValue()));
	assertThat(context.getBean("httpSolrServer", HttpSolrServer.class), is(notNullValue()));
	assertThat(context.getBean("lbHttpSolrServer", LBHttpSolrServer.class), is(notNullValue()));
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:8,代码来源:ITestXmlNamespace.java


示例18: testClonesLBHttpSolrServerCorrectly

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
@Test
public void testClonesLBHttpSolrServerCorrectly() throws MalformedURLException {
	LBHttpSolrServer lbSolrServer = new LBHttpSolrServer(BASE_URL, ALTERNATE_BASE_URL);
	lbSolrServer.setAliveCheckInterval(10);

	LBHttpSolrServer clone = SolrServerUtils.clone(lbSolrServer);

	Assert.assertEquals(ReflectionTestUtils.getField(lbSolrServer, FIELD_ALIVE_SERVERS),
			ReflectionTestUtils.getField(clone, FIELD_ALIVE_SERVERS));
	assertLBHttpSolrServerProperties(lbSolrServer, clone);
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:12,代码来源:SolrServerUtilTests.java


示例19: testClonesLBHttpSolrServerForCoreCorrectly

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testClonesLBHttpSolrServerForCoreCorrectly() throws MalformedURLException {
	LBHttpSolrServer lbSolrServer = new LBHttpSolrServer(BASE_URL, ALTERNATE_BASE_URL);
	lbSolrServer.setAliveCheckInterval(10);

	LBHttpSolrServer clone = SolrServerUtils.clone(lbSolrServer, CORE_NAME);

	Map<String, ?> aliveServers = (Map<String, ?>) ReflectionTestUtils.getField(clone, FIELD_ALIVE_SERVERS);
	Assert.assertThat(aliveServers.keySet(), hasItems(CORE_URL, ALTERNATE_CORE_URL));

	assertLBHttpSolrServerProperties(lbSolrServer, clone);
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:14,代码来源:SolrServerUtilTests.java


示例20: testClonesCloudSolrServerCorrectly

import org.apache.solr.client.solrj.impl.LBHttpSolrServer; //导入依赖的package包/类
@Test
public void testClonesCloudSolrServerCorrectly() throws MalformedURLException {
	LBHttpSolrServer lbSolrServer = new LBHttpSolrServer(BASE_URL, ALTERNATE_BASE_URL);
	CloudSolrServer cloudServer = new CloudSolrServer(ZOO_KEEPER_URL, lbSolrServer);

	CloudSolrServer clone = SolrServerUtils.clone(cloudServer);
	Assert.assertEquals(ZOO_KEEPER_URL, ReflectionTestUtils.getField(clone, FIELD_ZOO_KEEPER));

	LBHttpSolrServer lbClone = clone.getLbServer();
	Assert.assertEquals(ReflectionTestUtils.getField(lbSolrServer, FIELD_ALIVE_SERVERS),
			ReflectionTestUtils.getField(lbClone, FIELD_ALIVE_SERVERS));

	assertLBHttpSolrServerProperties(lbSolrServer, lbClone);
}
 
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:15,代码来源:SolrServerUtilTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OAuthServlet类代码示例发布时间:2022-05-21
下一篇:
Java FileNameMapper类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap