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


Java HttpSolrServer.setSoTimeout方法代碼示例

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


在下文中一共展示了HttpSolrServer.setSoTimeout方法的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
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

示例3: invokeCollectionApi

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
protected NamedList<Object> invokeCollectionApi(String... args) throws SolrServerException, IOException {
  ModifiableSolrParams params = new ModifiableSolrParams();
  SolrRequest request = new QueryRequest(params);
  for (int i = 0; i < args.length - 1; i+=2) {
    params.add(args[i], args[i+1]);
  }
  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);
  NamedList r = baseServer.request(request);
  baseServer.shutdown();
  return r;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:20,代碼來源:AbstractFullDistribZkTestBase.java

示例4: addDocumentsToSolr

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
private void addDocumentsToSolr(List<Map<String,Object>> docs) throws SolrServerException, IOException {
  List<SolrInputDocument> sidl = new ArrayList<>();
  for (Map<String,Object> doc : docs) {
    SolrInputDocument sd = new SolrInputDocument();
    for (Entry<String,Object> entry : doc.entrySet()) {
      sd.addField(entry.getKey(), entry.getValue());
    }
    sidl.add(sd);
  }
  
  HttpSolrServer solrServer = new HttpSolrServer(getSourceUrl());
  try {
    solrServer.setConnectionTimeout(15000);
    solrServer.setSoTimeout(30000);
    solrServer.add(sidl);
    solrServer.commit(true, true);
  } finally {
    solrServer.shutdown();
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:21,代碼來源:TestSolrEntityProcessorEndToEnd.java

示例5: 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

示例6: getDetails

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
NamedList getDetails() throws IOException, SolrServerException {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(COMMAND, CMD_DETAILS);
  params.set("slave", false);
  params.set(CommonParams.QT, "/replication");
  HttpSolrServer server = new HttpSolrServer(masterUrl, myHttpClient); //XXX use shardhandler
  NamedList rsp;
  try {
    server.setSoTimeout(60000);
    server.setConnectionTimeout(15000);
    QueryRequest request = new QueryRequest(params);
    rsp = server.request(request);
  } finally {
    server.shutdown();
  }
  return rsp;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:18,代碼來源:SnapPuller.java

示例7: 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

示例8: getSolrServer

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
public static synchronized SolrServer getSolrServer(String url) {
	SolrServer server = servers.get(url);
	if(server == null) {
		logger.info("Connecting to Solr: " + url);
		HttpSolrServer httpServer = new HttpSolrServer(url);
		httpServer.setSoTimeout(Integer.parseInt(SolrMeterConfiguration.getProperty("solr.server.configuration.soTimeout", "60000"))); // socket read timeout
		httpServer.setConnectionTimeout(Integer.parseInt(SolrMeterConfiguration.getProperty("solr.server.configuration.connectionTimeout", "60000")));
		httpServer.setDefaultMaxConnectionsPerHost(Integer.parseInt(SolrMeterConfiguration.getProperty("solr.server.configuration.defaultMaxConnectionsPerHost", "100000")));
		httpServer.setMaxTotalConnections(Integer.parseInt(SolrMeterConfiguration.getProperty("solr.server.configuration.maxTotalConnections", "1000000")));
		httpServer.setFollowRedirects(Boolean.parseBoolean(SolrMeterConfiguration.getProperty("solr.server.configuration.followRedirect", "false"))); // defaults to false
		httpServer.setAllowCompression(Boolean.parseBoolean(SolrMeterConfiguration.getProperty("solr.server.configuration.allowCompression", "true")));
		httpServer.setMaxRetries(Integer.parseInt(SolrMeterConfiguration.getProperty("solr.server.configuration.maxRetries", "1"))); // defaults to 0. > 1 not recommended.
		setAuthentication(httpServer);
		servers.put(url, httpServer);
		return httpServer;

	}
	return server;
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:20,代碼來源:SolrServerRegistry.java

示例9: 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

示例10: 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

示例11: 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

示例12: handleSyncShardAction

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
private void handleSyncShardAction(SolrQueryRequest req, SolrQueryResponse rsp) throws KeeperException, InterruptedException, SolrServerException, IOException {
  log.info("Syncing shard : " + req.getParamString());
  String collection = req.getParams().required().get("collection");
  String shard = req.getParams().required().get("shard");
  
  ClusterState clusterState = coreContainer.getZkController().getClusterState();
  
  ZkNodeProps leaderProps = clusterState.getLeader(collection, shard);
  ZkCoreNodeProps nodeProps = new ZkCoreNodeProps(leaderProps);
  
  HttpSolrServer server = new HttpSolrServer(nodeProps.getBaseUrl());
  try {
    server.setConnectionTimeout(15000);
    server.setSoTimeout(60000);
    RequestSyncShard reqSyncShard = new CoreAdminRequest.RequestSyncShard();
    reqSyncShard.setCollection(collection);
    reqSyncShard.setShard(shard);
    reqSyncShard.setCoreName(nodeProps.getCoreName());
    server.request(reqSyncShard);
  } finally {
    server.shutdown();
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:24,代碼來源:CollectionsHandler.java

示例13: fetchFileList

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
/**
 * Fetches the list of files in a given index commit point and updates internal list of files to download.
 */
private void fetchFileList(long gen) throws IOException {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(COMMAND,  CMD_GET_FILE_LIST);
  params.set(GENERATION, String.valueOf(gen));
  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
  try {
    server.setSoTimeout(60000);
    server.setConnectionTimeout(15000);
    NamedList response = server.request(req);

    List<Map<String, Object>> files = (List<Map<String,Object>>) response.get(CMD_GET_FILE_LIST);
    if (files != null)
      filesToDownload = Collections.synchronizedList(files);
    else {
      filesToDownload = Collections.emptyList();
      LOG.error("No files to download for index generation: "+ gen);
    }

    files = (List<Map<String,Object>>) response.get(CONF_FILES);
    if (files != null)
      confFilesToDownload = Collections.synchronizedList(files);

  } catch (SolrServerException e) {
    throw new IOException(e);
  } finally {
    server.shutdown();
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:35,代碼來源:SnapPuller.java

示例14: requestRecovery

import org.apache.solr.client.solrj.impl.HttpSolrServer; //導入方法依賴的package包/類
private void requestRecovery(final ZkNodeProps leaderProps, final String baseUrl, final String coreName) throws SolrServerException, IOException {
  Thread thread = new Thread() {
    {
      setDaemon(true);
    }
    @Override
    public void run() {
      RequestRecovery recoverRequestCmd = new RequestRecovery();
      recoverRequestCmd.setAction(CoreAdminAction.REQUESTRECOVERY);
      recoverRequestCmd.setCoreName(coreName);
      
      HttpSolrServer server = new HttpSolrServer(baseUrl, client);
      try {
        server.setConnectionTimeout(30000);
        server.setSoTimeout(120000);
        server.request(recoverRequestCmd);
      } catch (Throwable t) {
        SolrException.log(log, ZkCoreNodeProps.getCoreUrl(leaderProps) + ": Could not tell a replica to recover", t);
        if (t instanceof Error) {
          throw (Error) t;
        }
      } finally {
        server.shutdown();
      }
    }
  };
  updateExecutor.execute(thread);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:29,代碼來源:SyncStrategy.java

示例15: createNewSolrServer

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


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