本文整理汇总了Java中org.apache.solr.client.solrj.response.QueryResponse.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java QueryResponse.getStatus方法的具体用法?Java QueryResponse.getStatus怎么用?Java QueryResponse.getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.response.QueryResponse
的用法示例。
在下文中一共展示了QueryResponse.getStatus方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import org.apache.solr.client.solrj.response.QueryResponse; //导入方法依赖的package包/类
public QueryResponse query(ModifiableSolrParams params) throws SolrServerException
{
try
{
QueryResponse response = server.query(params);
if(response.getStatus() != 0)
{
solrTracker.setSolrActive(false);
}
return response;
}
catch(SolrServerException e)
{
solrTracker.setSolrActive(false);
throw e;
}
}
示例2: testThatSpellCheckerShouldNotAcceptAnInexistingSpellCheckerDictionaryName
import org.apache.solr.client.solrj.response.QueryResponse; //导入方法依赖的package包/类
@Test
public void testThatSpellCheckerShouldNotAcceptAnInexistingSpellCheckerDictionaryName() {
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQueryType(Constants.SolrQueryType.spellcheck.toString());
solrQuery.add(Constants.SPELLCHECKER_DICTIONARY_NAME_PARAMETER,
"notExistingInSolrConfig.xml");
solrQuery.add(Constants.SPELLCHECKER_BUILD_PARAMETER, "true");
solrQuery.add(Constants.SPELLCHECKER_ENABLED_PARAMETER, "true");
solrQuery.setQuery("spell");
try {
QueryResponse response = solrClient.getServer().query(solrQuery);
if (response.getStatus() != 0) {
fail("Status should not be 0 when the name of the dictionnary name is not defined in solrConfig.xml");
}
fail("dictionnary name that are not defined in solrConfig.xml should not be accepted");
} catch (Exception e) {
logger.error(e);
}
}
示例3: pingSolr
import org.apache.solr.client.solrj.response.QueryResponse; //导入方法依赖的package包/类
protected void pingSolr()
{
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/admin/cores");
params.set("action", "STATUS");
QueryResponse response = basicQuery(params);
if(response != null && response.getStatus() == 0)
{
NamedList<Object> results = response.getResponse();
@SuppressWarnings("unchecked")
NamedList<Object> report = (NamedList<Object>)results.get("status");
Iterator<Map.Entry<String, Object>> coreIterator = report.iterator();
List<String> cores = new ArrayList<String>(report.size());
while(coreIterator.hasNext())
{
Map.Entry<String, Object> core = coreIterator.next();
cores.add(core.getKey());
}
registerCores(cores);
setSolrActive(true);
}
else
{
setSolrActive(false);
}
}
示例4: buildIndex
import org.apache.solr.client.solrj.response.QueryResponse; //导入方法依赖的package包/类
public boolean buildIndex(
SpellCheckerDictionaryNames spellCheckerDictionaryName) {
if (!SpellCheckerConfig.isEnabled()) {
return false;
}
SolrQuery solrQuery = new SolrQuery();
solrQuery.setQueryType(Constants.SolrQueryType.spellcheck.toString());
solrQuery.add(Constants.SPELLCHECKER_DICTIONARY_NAME_PARAMETER,
spellCheckerDictionaryName.toString());
solrQuery.add(Constants.SPELLCHECKER_BUILD_PARAMETER, "true");
solrQuery.add(Constants.SPELLCHECKER_ENABLED_PARAMETER, "true");
solrQuery.setQuery("spell");
try {
QueryResponse response = solrClient.getServer().query(solrQuery);
if (response.getStatus() != 0) {
logger.error("Indexing dictionary "
+ spellCheckerDictionaryName.name()+" fails");
return false;
}
logger.info("Successfully indexing dictionary "
+ spellCheckerDictionaryName.name());
return true;
} catch (Exception e) {
logger.error("An error has occured when indexing spellchecker "
+ spellCheckerDictionaryName + " : " + e);
return false;
}
}
示例5: checkAZombieServer
import org.apache.solr.client.solrj.response.QueryResponse; //导入方法依赖的package包/类
/**
* Takes up one dead server and check for aliveness. The check is done in a roundrobin. Each server is checked for
* aliveness once in 'x' millis where x is decided by the setAliveCheckinterval() or it is defaulted to 1 minute
*
* @param zombieServer a server in the dead pool
*/
private void checkAZombieServer(ServerWrapper zombieServer) {
long currTime = System.currentTimeMillis();
try {
zombieServer.lastChecked = currTime;
QueryResponse resp = zombieServer.solrServer.query(solrQuery);
if (resp.getStatus() == 0) {
// server has come back up.
// make sure to remove from zombies before adding to alive to avoid a race condition
// where another thread could mark it down, move it back to zombie, and then we delete
// from zombie and lose it forever.
ServerWrapper wrapper = zombieServers.remove(zombieServer.getKey());
if (wrapper != null) {
wrapper.failedPings = 0;
if (wrapper.standard) {
addToAlive(wrapper);
}
} else {
// something else already moved the server from zombie to alive
}
}
} catch (Exception e) {
//Expected. The server is still down.
zombieServer.failedPings++;
// If the server doesn't belong in the standard set belonging to this load balancer
// then simply drop it after a certain number of failed pings.
if (!zombieServer.standard && zombieServer.failedPings >= NONSTANDARD_PING_LIMIT) {
zombieServers.remove(zombieServer.getKey());
}
}
}
示例6: run
import org.apache.solr.client.solrj.response.QueryResponse; //导入方法依赖的package包/类
@Override
public void run() {
SolrTestCaseJ4.log.info(String.format(Locale.ROOT, "Starting query thread: " + getId()));
while (Queries._keepon.get()) {
String core = OCCST.getRandomCore(random);
for (int idx = 0; idx < 3; ++idx) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/select");
params.set("q", "*:*");
try {
// sleep between 250ms and 10000 ms
Thread.sleep(100L); // Let's not go crazy here.
server.setBaseURL(baseUrl + core);
QueryResponse response = server.query(params);
if (response.getStatus() != 0) {
SolrTestCaseJ4.log.warn("Failed to query core " + core + " with status " + response.getStatus());
}
// Perhaps collect some stats here in future.
break; // retry loop
} catch (Exception e) {
if (e instanceof InterruptedException) return;
Queries._errors.incrementAndGet();
if (idx == 2) {
SolrTestCaseJ4.log.warn("Could not reach server while indexing for three tries, quitting " + e.getMessage());
} else {
SolrTestCaseJ4.log.info("Querying thread: " + Thread.currentThread().getId() + " swallowed exception: " + e.getMessage());
try {
Thread.sleep(250L);
} catch (InterruptedException tex) {
return;
}
}
}
}
}
SolrTestCaseJ4.log.info(String.format(Locale.ROOT, "Leaving query thread: " + getId()));
}