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


Java SolrPingResponse类代码示例

本文整理汇总了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.");
    }
}
 
开发者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


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