当前位置: 首页>>代码示例>>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;未经允许,请勿转载。