本文整理汇总了Java中org.apache.solr.client.solrj.response.SolrPingResponse类的典型用法代码示例。如果您正苦于以下问题:Java SolrPingResponse类的具体用法?Java SolrPingResponse怎么用?Java SolrPingResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolrPingResponse类属于org.apache.solr.client.solrj.response包,在下文中一共展示了SolrPingResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.");
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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());
}
}
示例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());
}
示例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"));
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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();
}
});
}
示例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;
}
示例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();
}
});
}