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


Java HttpSolrServer.setConnectionTimeout方法代碼示例

本文整理匯總了Java中org.apache.solr.client.solrj.impl.HttpSolrServer.setConnectionTimeout方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpSolrServer.setConnectionTimeout方法的具體用法?Java HttpSolrServer.setConnectionTimeout怎麽用?Java HttpSolrServer.setConnectionTimeout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.solr.client.solrj.impl.HttpSolrServer的用法示例。


在下文中一共展示了HttpSolrServer.setConnectionTimeout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNewHttpSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
/**
 * 
 * @param indexUrl
 * @return
 */
public static HttpSolrServer getNewHttpSolrServer(String indexUrl) {
    if (indexUrl == null) {
        throw new IllegalArgumentException("indexUrl may not be null");
    }
    HttpSolrServer server = new HttpSolrServer(indexUrl);
    server.setSoTimeout(TIMEOUT_SO); // socket read timeout
    server.setConnectionTimeout(TIMEOUT_CONNECTION);
    server.setDefaultMaxConnectionsPerHost(100);
    server.setMaxTotalConnections(100);
    server.setFollowRedirects(false); // defaults to false
    server.setAllowCompression(true);
    server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
    // server.setParser(new XMLResponseParser()); // binary parser is used by default
    server.setRequestWriter(new BinaryRequestWriter());

    return server;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-connector,代碼行數:23,代碼來源:SolrSearchIndex.java

示例2: createNewSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
@Override
public SolrServer createNewSolrServer()
{
  try {
    // setup the server...
    String url = jetty.getBaseUrl().toString() + "/collection1";
    HttpSolrServer s = new HttpSolrServer( url );
    s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
    s.setDefaultMaxConnectionsPerHost(100);
    s.setMaxTotalConnections(100);
    s.setUseMultiPartPost(random().nextBoolean());

    // where the magic happens
    s.setParser(new BinaryResponseParser());
    s.setRequestWriter(new BinaryRequestWriter());

    return s;
  }
  catch( Exception ex ) {
    throw new RuntimeException( ex );
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:23,代碼來源:SolrExampleBinaryTest.java

示例3: createNewSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
@Override
public SolrServer createNewSolrServer() {
  try {
    // setup the server...
    String url = jetty.getBaseUrl().toString() + "/collection1";
    HttpSolrServer s = new HttpSolrServer(url);
    s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
    s.setDefaultMaxConnectionsPerHost(100);
    s.setMaxTotalConnections(100);
    s.setUseMultiPartPost(random().nextBoolean());
    
    if (random().nextBoolean()) {
      s.setParser(new BinaryResponseParser());
      s.setRequestWriter(new BinaryRequestWriter());
    }
    
    return s;
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:22,代碼來源:SolrSchemalessExampleTests.java

示例4: createNewSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
@Override
public SolrServer createNewSolrServer() {
  try {
    String url = jetty.getBaseUrl().toString() + "/collection1";
    HttpSolrServer s = new HttpSolrServer(url);
    s.setUseMultiPartPost(random().nextBoolean());
    s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
    s.setDefaultMaxConnectionsPerHost(100);
    s.setMaxTotalConnections(100);
    s.setParser(new XMLResponseParser());
    s.setRequestWriter(new RequestWriter());
    return s;
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:17,代碼來源:SolrExampleXMLTest.java

示例5: createNewSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
/**
 * Create a new solr server.
 * If createJetty was called, an http implementation will be created,
 * otherwise an embedded implementation will be created.
 * Subclasses should override for other options.
 */
public SolrServer createNewSolrServer() {
  if (jetty != null) {
    try {
      // setup the server...
      String url = jetty.getBaseUrl().toString() + "/" + "collection1";
      HttpSolrServer s = new HttpSolrServer( url );
      s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
      s.setDefaultMaxConnectionsPerHost(100);
      s.setMaxTotalConnections(100);
      return s;
    }
    catch( Exception ex ) {
      throw new RuntimeException( ex );
    }
  } else {
    return new EmbeddedSolrServer( h.getCoreContainer(), "" );
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:25,代碼來源:SolrJettyTestBase.java

示例6: createNewSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
@Override
protected SolrServer createNewSolrServer(int port) {
  try {
    // setup the server...
    String baseUrl = buildUrl(port);
    String url = baseUrl + (baseUrl.endsWith("/") ? "" : "/") + DEFAULT_COLLECTION;
    HttpSolrServer s = new HttpSolrServer(url);
    s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
    s.setSoTimeout(60000);
    s.setDefaultMaxConnectionsPerHost(100);
    s.setMaxTotalConnections(100);
    return s;
  } catch (Exception ex) {
    throw new RuntimeException(ex);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:17,代碼來源:AbstractFullDistribZkTestBase.java

示例7: deleteShard

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
protected void deleteShard(String shard) throws SolrServerException, IOException,
    KeeperException, InterruptedException {

  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionParams.CollectionAction.DELETESHARD.toString());
  params.set("collection", AbstractFullDistribZkTestBase.DEFAULT_COLLECTION);
  params.set("shard", shard);
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");

  String baseUrl = ((HttpSolrServer) shardToJetty.get(SHARD1).get(0).client.solrClient)
      .getBaseURL();
  baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());

  HttpSolrServer baseServer = new HttpSolrServer(baseUrl);
  baseServer.setConnectionTimeout(15000);
  baseServer.setSoTimeout(60000);
  baseServer.request(request);
  baseServer.shutdown();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:21,代碼來源:DeleteShardTest.java

示例8: getLatestVersion

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
/**
 * Gets the latest commit version and generation from the master
 */
@SuppressWarnings("unchecked")
NamedList getLatestVersion() throws IOException {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(COMMAND, CMD_INDEX_VERSION);
  params.set(CommonParams.WT, "javabin");
  params.set(CommonParams.QT, "/replication");
  QueryRequest req = new QueryRequest(params);
  HttpSolrServer server = new HttpSolrServer(masterUrl, myHttpClient); //XXX modify to use shardhandler
  NamedList rsp;
  try {
    server.setSoTimeout(60000);
    server.setConnectionTimeout(15000);
    
    rsp = server.request(req);
  } catch (SolrServerException e) {
    throw new SolrException(ErrorCode.SERVER_ERROR, e.getMessage(), e);
  } finally {
    server.shutdown();
  }
  return rsp;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:25,代碼來源:SnapPuller.java

示例9: getNumCommits

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
private Long getNumCommits(HttpSolrServer solrServer) throws
    SolrServerException, IOException {
  HttpSolrServer server = new HttpSolrServer(solrServer.getBaseURL());
  server.setConnectionTimeout(15000);
  server.setSoTimeout(60000);
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("qt", "/admin/mbeans?key=updateHandler&stats=true");
  // use generic request to avoid extra processing of queries
  QueryRequest req = new QueryRequest(params);
  NamedList<Object> resp = server.request(req);
  NamedList mbeans = (NamedList) resp.get("solr-mbeans");
  NamedList uhandlerCat = (NamedList) mbeans.get("UPDATEHANDLER");
  NamedList uhandler = (NamedList) uhandlerCat.get("updateHandler");
  NamedList stats = (NamedList) uhandler.get("stats");
  Long commits = (Long) stats.get("commits");
  server.shutdown();
  return commits;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:19,代碼來源:BasicDistributedZkTest.java

示例10: sendPrepRecoveryCmd

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
private void sendPrepRecoveryCmd(String leaderBaseUrl, String leaderCoreName, Slice slice)
    throws SolrServerException, IOException, InterruptedException, ExecutionException {
  HttpSolrServer server = new HttpSolrServer(leaderBaseUrl);
  try {
    server.setConnectionTimeout(30000);
    WaitForState prepCmd = new WaitForState();
    prepCmd.setCoreName(leaderCoreName);
    prepCmd.setNodeName(zkController.getNodeName());
    prepCmd.setCoreNodeName(coreZkNodeName);
    prepCmd.setState(ZkStateReader.RECOVERING);
    prepCmd.setCheckLive(true);
    prepCmd.setOnlyIfLeader(true);
    if (!Slice.CONSTRUCTION.equals(slice.getState()) && !Slice.RECOVERY.equals(slice.getState())) {
      prepCmd.setOnlyIfLeaderActive(true);
    }
    HttpUriRequestResponse mrr = server.httpUriRequest(prepCmd);
    prevSendPreRecoveryHttpUriRequest = mrr.httpUriRequest;
    
    log.info("Sending prep recovery command to {}; {}", leaderBaseUrl, prepCmd.toString());
    
    mrr.future.get();
  } finally {
    server.shutdown();
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:26,代碼來源:RecoveryStrategy.java

示例11: getNewHttpSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
public static HttpSolrServer getNewHttpSolrServer(String confFilename) throws FatalIndexerException {
    HttpSolrServer server = new HttpSolrServer(Configuration.getInstance(confFilename).getConfiguration("solrUrl"));
    server.setSoTimeout(TIMEOUT_SO); // socket read timeout
    server.setConnectionTimeout(TIMEOUT_CONNECTION);
    server.setDefaultMaxConnectionsPerHost(100);
    server.setMaxTotalConnections(100);
    server.setFollowRedirects(false); // defaults to false
    server.setAllowCompression(true);
    server.setMaxRetries(1); // defaults to 0. > 1 not recommended.
    // server.setParser(new XMLResponseParser()); // binary parser is used by default
    server.setRequestWriter(new BinaryRequestWriter());

    return server;
}
 
開發者ID:intranda,項目名稱:goobi-viewer-indexer,代碼行數:15,代碼來源:SolrHelper.java

示例12: createSolrFixtures

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
static void createSolrFixtures() throws Exception {
    solrHttpsRunner = JettySolrFactory.createJettyTestFixture(true);
    httpsPort = solrHttpsRunner.getLocalPort();
    log.info("Started Https Test Server: " + solrHttpsRunner.getBaseUrl());
    solrHttpsServer = new HttpSolrServer("https://localhost:" + httpsPort + "/solr");
    solrHttpsServer.setConnectionTimeout(60000);

    solrRunner = JettySolrFactory.createJettyTestFixture(false);
    port = solrRunner.getLocalPort();

    solrServer = new HttpSolrServer("http://localhost:" + port + "/solr");

    log.info("Started Test Server: " + solrRunner.getBaseUrl());
    cloudFixture = new SolrCloudFixture("src/test/resources/solr");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:16,代碼來源:SolrFixtures.java

示例13: createServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
protected SolrServer createServer( String name )
{
  try {
    // setup the server...
    String url = buildUrl(port, context) + "/" + name;
    HttpSolrServer s = new HttpSolrServer( url );
    s.setConnectionTimeout(SolrTestCaseJ4.DEFAULT_CONNECTION_TIMEOUT);
    s.setDefaultMaxConnectionsPerHost(100);
    s.setMaxTotalConnections(100);
    return s;
  }
  catch( Exception ex ) {
    throw new RuntimeException( ex );
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:16,代碼來源:MultiCoreExampleJettyTest.java

示例14: createNewSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
protected SolrServer createNewSolrServer(int port) {
  try {
    // setup the server...
    HttpSolrServer s = new HttpSolrServer(buildUrl(port));
    s.setConnectionTimeout(DEFAULT_CONNECTION_TIMEOUT);
    s.setSoTimeout(90000);
    s.setDefaultMaxConnectionsPerHost(100);
    s.setMaxTotalConnections(100);
    return s;
  }
  catch (Exception ex) {
    throw new RuntimeException(ex);
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:15,代碼來源:BaseDistributedSearchTestCase.java

示例15: splitShard

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
protected void splitShard(String collection, String shardId, List<DocRouter.Range> subRanges, String splitKey) throws SolrServerException, IOException {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionParams.CollectionAction.SPLITSHARD.toString());
  params.set("collection", collection);
  if (shardId != null)  {
    params.set("shard", shardId);
  }
  if (subRanges != null)  {
    StringBuilder ranges = new StringBuilder();
    for (int i = 0; i < subRanges.size(); i++) {
      DocRouter.Range subRange = subRanges.get(i);
      ranges.append(subRange.toString());
      if (i < subRanges.size() - 1)
        ranges.append(",");
    }
    params.set("ranges", ranges.toString());
  }
  if (splitKey != null) {
    params.set("split.key", splitKey);
  }
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");

  String baseUrl = ((HttpSolrServer) shardToJetty.get(SHARD1).get(0).client.solrClient)
      .getBaseURL();
  baseUrl = baseUrl.substring(0, baseUrl.length() - "collection1".length());

  HttpSolrServer baseServer = new HttpSolrServer(baseUrl);
  baseServer.setConnectionTimeout(15000);
  baseServer.setSoTimeout(60000 * 5);
  baseServer.request(request);
  baseServer.shutdown();
}
 
開發者ID:europeana,項目名稱:search,代碼行數:34,代碼來源:ShardSplitTest.java


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