本文整理汇总了Java中org.apache.solr.client.solrj.response.SolrPingResponse类的典型用法代码示例。如果您正苦于以下问题:Java SolrPingResponse类的具体用法?Java SolrPingResponse怎么用?Java SolrPingResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolrPingResponse类属于org.apache.solr.client.solrj.response包,在下文中一共展示了SolrPingResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: SolrSearchServer
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
/**
* Creates an instance of SolrSearch server allowing to avoid the schema validity check.
* @param client SolrClient to connect to.
* @param check true to perform local schema validity check against remote schema, false otherwise.
*/
protected SolrSearchServer(SolrClient client, boolean check) {
solrClient = client;
//In order to perform unit tests with mocked solrClient, we do not need to do the schema check.
if(check && client != null) {
try {
final SolrPingResponse ping = solrClient.ping();
if (ping.getStatus() == 0) {
log.debug("Pinged Solr in {}", ping.getQTime());
}
} catch (SolrServerException | IOException e) {
log.error("Cannot connect to solr server", e);
throw new RuntimeException();
}
log.info("Connection to solr server successful");
checkVersionAndSchema();
} else {
log.warn("Solr ping and schema validity check has been deactivated.");
}
}
开发者ID:RBMHTechnology,项目名称:vind,代码行数:27,代码来源:SolrSearchServer.java
示例2: connect
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
/**
* Verbindung zum Solr-Server herstellen
*/
private void connect() {
solrClient = new HttpSolrClient.Builder(Configuration.SOLR_SERVER_URL + Configuration.SOLR_CORE_NAME).build();
// Verbindung zum Solr-Server prüfen
try {
SolrPing ping = new SolrPing();
ping.setBasicAuthCredentials(Configuration.USERNAME, Configuration.PASSWORD);
SolrPingResponse pingResponse = ping.process(solrClient);
if (pingResponse.getStatus() != 0) {
System.out.println("Es gab einen unerwarteten Fehler beim Ping auf den Solr-Server (Status-Code ist " + pingResponse.getStatus() + ")");
}
else {
System.out.println("Ping zum Solr-Server war erfolgreich und dauerte " + pingResponse.getQTime() + " ms");
}
} catch (SolrServerException|IOException e) {
// do something reasonable
System.err.println(e);
}
}
开发者ID:saschaszott,项目名称:suma-tech,代码行数:24,代码来源:SolrSearcher.java
示例3: isServerAlive
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
public boolean isServerAlive() {
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
XPath xpath = XPathFactory.newInstance().newXPath();
if (xpath == null || builder == null) {
throw new RuntimeException(
"Can not determine if fulltext engine is alive");
}
SolrPingResponse response = getServer().ping();
if (response == null) {
return false;
}
return ((String) response.getResponse().get("status")).equals("OK");
} catch (Exception e) {
logger.error("can not determine if fulltext engine is alive "
+ e.getMessage(),e);
return false;
}
}
开发者ID:gisgraphy,项目名称:gisgraphy,代码行数:22,代码来源:SolrClient.java
示例4: isConnected
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
/**
* Validate the connection by sending a ping request.
*
* @return true if the ping call succeeds, false otherwise.
*/
@ValidateConnection
public boolean isConnected() {
if (server == null) {
return false;
}
try {
SolrPingResponse response = server.ping();
if (logger.isDebugEnabled()) {
logger.debug("Pinged the server, response time is: " + response.getQTime());
}
if (response.getQTime() > 0) {
return true;
}
} catch (Exception ex) {
logger.error("Got exception while trying to Ping Server", ex);
return false;
}
//default answer
return false;
}
开发者ID:juancavallotti,项目名称:mule-module-solr,代码行数:30,代码来源:SolrConnector.java
示例5: init
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Override
protected final void init() {
try (SolrClient client = getClient()){
//lets ping the solrServer on initialization
log.debug("ping {}", client);
SolrPingResponse ping = client.ping();
log.debug("ping respone: {}", ping);
} catch (SolrServerException | IOException e) {
log.warn("Unable to ping SolrClient for {} during initialization ({} - {})", getName(), e.getClass().getSimpleName(), e.getMessage());
}
}
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:12,代码来源:InterestingTermExtractor.java
示例6: testPing
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
/**
* Fails: can't specify a core name to ping
*/
@Test
@Ignore("Fails: can't specify a core name to ping")
public void testPing() throws Exception {
SolrPingResponse res = solrTemplate.ping();
assertNotNull(res);
assertTrue(res.getElapsedTime() > 0);
assertEquals(0, res.getStatus());
}
开发者ID:rmap-project,项目名称:rmap,代码行数:12,代码来源:SimpleSolrIT.java
示例7: solrIsUp
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Test
public void solrIsUp() throws Exception {
SolrClient solrClient = mock(SolrClient.class);
SolrPingResponse pingResponse = new SolrPingResponse();
NamedList<Object> response = new NamedList<Object>();
response.add("status", "OK");
pingResponse.setResponse(response);
given(solrClient.ping()).willReturn(pingResponse);
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrClient);
Health health = healthIndicator.health();
assertThat(health.getStatus()).isEqualTo(Status.UP);
assertThat(health.getDetails().get("solrStatus")).isEqualTo("OK");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:SolrHealthIndicatorTests.java
示例8: solrIsUp
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Test
public void solrIsUp() throws Exception {
SolrServer solrServer = mock(SolrServer.class);
SolrPingResponse pingResponse = new SolrPingResponse();
NamedList<Object> response = new NamedList<Object>();
response.add("status", "OK");
pingResponse.setResponse(response);
given(solrServer.ping()).willReturn(pingResponse);
SolrHealthIndicator healthIndicator = new SolrHealthIndicator(solrServer);
Health health = healthIndicator.health();
assertEquals(Status.UP, health.getStatus());
assertEquals("OK", health.getDetails().get("solrStatus"));
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:15,代码来源:SolrHealthIndicatorTests.java
示例9: process
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Override
public SolrPingResponse process(SolrServer server)
throws SolrServerException, IOException {
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
SolrPingResponse res = new SolrPingResponse();
res.setResponse(server.request(this));
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
return res;
}
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:SolrPing.java
示例10: testEnabledSolrPing
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Test
public void testEnabledSolrPing() throws Exception {
SolrPing ping = new SolrPing();
SolrPingResponse rsp = null;
ping.setActionEnable();
ping.process(getSolrServer());
ping.removeAction();
rsp = ping.process(getSolrServer());
Assert.assertNotNull(rsp);
}
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:SolrPingTest.java
示例11: testDisabledSolrPing
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Test(expected = SolrException.class)
public void testDisabledSolrPing() throws Exception {
SolrPing ping = new SolrPing();
SolrPingResponse rsp = null;
ping.setActionDisable();
try {
ping.process(getSolrServer());
} catch (Exception e) {
throw new Exception("disable action failed!");
}
ping.setActionPing();
rsp = ping.process(getSolrServer());
// the above line should fail with a 503 SolrException.
Assert.assertNotNull(rsp);
}
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:SolrPingTest.java
示例12: process
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Override
public SolrResponse process(SolrServer server) throws SolrServerException,
IOException {
long startTime = System.currentTimeMillis();
SolrPingResponse res = new SolrPingResponse();
res.setResponse( server.request( this ) );
res.setElapsedTime( System.currentTimeMillis()-startTime );
return res;
}
开发者ID:lafourchette,项目名称:solrmeter,代码行数:10,代码来源:RequestHandlerConnection.java
示例13: ping
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Override
public SolrPingResponse ping() {
return execute(new SolrCallback<SolrPingResponse>() {
@Override
public SolrPingResponse doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
return solrClient.ping();
}
});
}
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:10,代码来源:SolrTemplate.java
示例14: process
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Override
public SolrPingResponse process( SolrServer server ) throws SolrServerException, IOException
{
long startTime = System.currentTimeMillis();
SolrPingResponse res = new SolrPingResponse();
res.setResponse( server.request( this ) );
res.setElapsedTime( System.currentTimeMillis()-startTime );
return res;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:10,代码来源:SolrPing.java
示例15: ping
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Override
public SolrPingResponse ping() {
return execute(new SolrCallback<SolrPingResponse>() {
@Override
public SolrPingResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
return solrServer.ping();
}
});
}
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:10,代码来源:SolrTemplate.java
示例16: testPing
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Test
public void testPing() throws SolrServerException, IOException {
Mockito.when(solrServerMock.ping()).thenReturn(new SolrPingResponse());
SolrPingResponse pingResult = solrTemplate.ping();
Assert.assertNotNull(pingResult);
Mockito.verify(solrServerMock, Mockito.times(1)).ping();
}
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:8,代码来源:SolrTemplateTests.java
示例17: ping
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Override
public SolrPingResponse ping() throws SolrServerException, IOException {
return respond(SolrPingResponse.class, new Command() {
public void process() throws Exception {
client().ping();
}
});
}
开发者ID:apache,项目名称:incubator-blur,代码行数:9,代码来源:SolrLookingBlurServer.java
示例18: isReady_nonZeroResponseStatus
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Test
public void isReady_nonZeroResponseStatus() throws Exception {
final SolrConfiguration config = mock(SolrConfiguration.class);
SolrPingResponse response = mock(SolrPingResponse.class);
when(response.getStatus()).thenReturn(1);
SolrClient server = mock(SolrClient.class);
when(server.ping()).thenReturn(response);
StorageEngine engine = new SolrStorageEngine(config, server);
assertFalse(engine.isReady());
verify(server).ping();
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:16,代码来源:SolrStorageEngineTest.java
示例19: isReady_zeroResponseStatus
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
@Test
public void isReady_zeroResponseStatus() throws Exception {
final SolrConfiguration config = mock(SolrConfiguration.class);
SolrPingResponse response = mock(SolrPingResponse.class);
when(response.getStatus()).thenReturn(SolrStorageEngine.STATUS_OK);
SolrClient server = mock(SolrClient.class);
when(server.ping()).thenReturn(response);
StorageEngine engine = new SolrStorageEngine(config, server);
assertTrue(engine.isReady());
verify(server).ping();
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:16,代码来源:SolrStorageEngineTest.java
示例20: setupSolr
import org.apache.solr.client.solrj.response.SolrPingResponse; //导入依赖的package包/类
/**
* Setup an embedded solr only for with a given solr home.
* Creates a checklistbank solr index schema, solr.xml and all other config files needed.
*
* @return the created server
*/
private EmbeddedSolrServer setupSolr(File solrHome) {
try {
// copy solr resource files
ResourcesUtil.copy(solrHome, "solr/", false, "solr.xml");
// copy default configurations
File conf = new File(solrHome, "conf");
ResourcesUtil.copy(conf, "solr/default/", false, "synonyms.txt", "protwords.txt", "stopwords.txt");
// copy specific configurations, overwriting above defaults
ResourcesUtil.copy(conf, "solr/checklistbank/conf/", false, "schema.xml", "solrconfig.xml");
// insert container
CoreContainer coreContainer = new CoreContainer(solrHome.getAbsolutePath());
coreContainer.load();
EmbeddedSolrServer solrServer = new EmbeddedSolrServer(coreContainer, "");
LOG.info("Created embedded solr server with solr dir {}", solrHome.getAbsolutePath());
// test solr
SolrPingResponse solrPingResponse = solrServer.ping();
LOG.info("Solr server configured at {}, ping response in {}", solrHome.getAbsolutePath(),
solrPingResponse.getQTime());
return solrServer;
} catch (Exception e) {
throw new IllegalStateException("Solr unavailable", e);
}
}
开发者ID:gbif,项目名称:checklistbank,代码行数:36,代码来源:SolrBackfill.java
注:本文中的org.apache.solr.client.solrj.response.SolrPingResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论