當前位置: 首頁>>代碼示例>>Java>>正文


Java QueryResponse.getStatus方法代碼示例

本文整理匯總了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;
	}
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:19,代碼來源:SOLRAdminClient.java

示例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);
}

   }
 
開發者ID:gisgraphy,項目名稱:gisgraphy,代碼行數:21,代碼來源:SpellCheckerIndexerTest.java

示例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);
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:29,代碼來源:SOLRAdminClient.java

示例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;
}

   }
 
開發者ID:gisgraphy,項目名稱:gisgraphy,代碼行數:32,代碼來源:SpellCheckerIndexer.java

示例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());
    }
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:38,代碼來源:LBHttpSolrServer.java

示例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()));
}
 
開發者ID:europeana,項目名稱:search,代碼行數:40,代碼來源:OpenCloseCoreStressTest.java


注:本文中的org.apache.solr.client.solrj.response.QueryResponse.getStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。