当前位置: 首页>>代码示例>>Java>>正文


Java SolrServer.shutdown方法代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.SolrServer.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java SolrServer.shutdown方法的具体用法?Java SolrServer.shutdown怎么用?Java SolrServer.shutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.client.solrj.SolrServer的用法示例。


在下文中一共展示了SolrServer.shutdown方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAlias

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private void createAlias(String alias, String collections)
    throws SolrServerException, IOException {
  SolrServer server = createNewSolrServer("",
      getBaseUrl((HttpSolrServer) clients.get(0)));
  if (random().nextBoolean()) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("collections", collections);
    params.set("name", alias);
    params.set("action", CollectionAction.CREATEALIAS.toString());
    QueryRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");
    server.request(request);
  } else {
    CollectionAdminRequest.CreateAlias.createAlias(alias, collections, server);
  }
  server.shutdown();
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:AliasIntegrationTest.java

示例2: testSearchByCollectionName

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private void testSearchByCollectionName() throws SolrServerException {
  log.info("### STARTING testSearchByCollectionName");
  SolrServer client = clients.get(0);
  final String baseUrl = ((HttpSolrServer) client).getBaseURL().substring(
      0,
      ((HttpSolrServer) client).getBaseURL().length()
          - DEFAULT_COLLECTION.length() - 1);
  
  // the cores each have different names, but if we add the collection name to the url
  // we should get mapped to the right core
  SolrServer client1 = createNewSolrServer(oneInstanceCollection, baseUrl);
  SolrQuery query = new SolrQuery("*:*");
  long oneDocs = client1.query(query).getResults().getNumFound();
  assertEquals(3, oneDocs);
  client1.shutdown();
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:BasicDistributedZkTest.java

示例3: tearDown

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Override
public void tearDown() throws Exception {
  super.tearDown();
  if (commondCloudSolrServer != null) {
    commondCloudSolrServer.shutdown();
  }
  if (otherCollectionClients != null) {
    for (List<SolrServer> clientList : otherCollectionClients.values()) {
      for (SolrServer client : clientList) {
        client.shutdown();
      }
    }
  }
  otherCollectionClients = null;
  List<Runnable> tasks = executor.shutdownNow();
  assertTrue(tasks.isEmpty());
  
  System.clearProperty("numShards");
  System.clearProperty("zkHost");
  System.clearProperty("solr.xml.persist");
  
  // insurance
  DirectUpdateHandler2.commitOnClose = true;
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:BasicDistributedZkTest.java

示例4: deleteAlias

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private void deleteAlias(String alias) throws SolrServerException,
    IOException {
  SolrServer server = createNewSolrServer("",
      getBaseUrl((HttpSolrServer) clients.get(0)));
  if (random().nextBoolean()) {
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("name", alias);
    params.set("action", CollectionAction.DELETEALIAS.toString());
    QueryRequest request = new QueryRequest(params);
    request.setPath("/admin/collections");
    server.request(request);
  } else {
    CollectionAdminRequest.deleteAlias(alias,server);
  }
  server.shutdown();
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:AliasIntegrationTest.java

示例5: createCollection

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
protected CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos,
                                                   String collectionName, int numShards, int numReplicas, int maxShardsPerNode, SolrServer client, String createNodeSetStr) throws SolrServerException, IOException {
  // TODO: Use CollectionAdminRequest for this test
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionAction.CREATE.toString());

  params.set(OverseerCollectionProcessor.NUM_SLICES, numShards);
  params.set(ZkStateReader.REPLICATION_FACTOR, numReplicas);
  params.set(ZkStateReader.MAX_SHARDS_PER_NODE, maxShardsPerNode);
  if (createNodeSetStr != null) params.set(OverseerCollectionProcessor.CREATE_NODE_SET, createNodeSetStr);

  int clientIndex = clients.size() > 1 ? random().nextInt(2) : 0;
  List<Integer> list = new ArrayList<>();
  list.add(numShards);
  list.add(numReplicas);
  if (collectionInfos != null) {
    collectionInfos.put(collectionName, list);
  }
  params.set("name", collectionName);
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");

  CollectionAdminResponse res = new CollectionAdminResponse();
  if (client == null) {
    final String baseUrl = ((HttpSolrServer) clients.get(clientIndex)).getBaseURL().substring(
        0,
        ((HttpSolrServer) clients.get(clientIndex)).getBaseURL().length()
            - DEFAULT_COLLECTION.length() - 1);
    
    SolrServer aClient = createNewSolrServer("", baseUrl);
    res.setResponse(aClient.request(request));
    aClient.shutdown();
  } else {
    res.setResponse(client.request(request));
  }
  return res;
}
 
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:BasicDistributedZkTest.java

示例6: testUpdateByCollectionName

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private void testUpdateByCollectionName() throws SolrServerException, IOException {
  log.info("### STARTING testUpdateByCollectionName");
  SolrServer client = clients.get(0);
  final String baseUrl = ((HttpSolrServer) client).getBaseURL().substring(
      0,
      ((HttpSolrServer) client).getBaseURL().length()
          - DEFAULT_COLLECTION.length() - 1);
  
  // the cores each have different names, but if we add the collection name to the url
  // we should get mapped to the right core
  // test hitting an update url
  SolrServer client1 = createNewSolrServer(oneInstanceCollection, baseUrl);
  client1.commit();
  client1.shutdown();
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:BasicDistributedZkTest.java

示例7: testCustomUlogDir

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Test
public void testCustomUlogDir() throws Exception {
  
  SolrServer server = getSolrAdmin();
  
  File dataDir = createTempDir("data");
  
  File newCoreInstanceDir = createTempDir("instance");
  
  File instanceDir = new File(cores.getSolrHome());
  FileUtils.copyDirectory(instanceDir, new File(newCoreInstanceDir,
      "newcore"));

  CoreAdminRequest.Create req = new CoreAdminRequest.Create();
  req.setCoreName("newcore");
  req.setInstanceDir(newCoreInstanceDir.getAbsolutePath() + File.separator + "newcore");
  req.setDataDir(dataDir.getAbsolutePath());
  req.setUlogDir(new File(dataDir, "ulog").getAbsolutePath());

  // These should be the inverse of defaults.
  req.setIsLoadOnStartup(false);
  req.setIsTransient(true);
  req.process(server);

  // Show that the newly-created core has values for load on startup and transient different than defaults due to the
  // above.
  File logDir;
  try (SolrCore coreProveIt = cores.getCore("collection1");
       SolrCore core = cores.getCore("newcore")) {

    assertTrue(core.getCoreDescriptor().isTransient());
    assertFalse(coreProveIt.getCoreDescriptor().isTransient());

    assertFalse(core.getCoreDescriptor().isLoadOnStartup());
    assertTrue(coreProveIt.getCoreDescriptor().isLoadOnStartup());

    logDir = new File(core.getUpdateHandler().getUpdateLog().getLogDir());
  }

  assertEquals(new File(dataDir, "ulog" + File.separator + "tlog").getAbsolutePath(), logDir.getAbsolutePath());
  server.shutdown();
  
}
 
开发者ID:europeana,项目名称:search,代码行数:44,代码来源:TestCoreAdmin.java

示例8: createCollection

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
protected CollectionAdminResponse createCollection(Map<String, List<Integer>> collectionInfos, String collectionName, Map<String, Object> collectionProps, SolrServer client, String confSetName)  throws SolrServerException, IOException{
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("action", CollectionAction.CREATE.toString());
  for (Map.Entry<String, Object> entry : collectionProps.entrySet()) {
    if(entry.getValue() !=null) params.set(entry.getKey(), String.valueOf(entry.getValue()));
  }
  Integer numShards = (Integer) collectionProps.get(NUM_SLICES);
  if(numShards==null){
    String shardNames = (String) collectionProps.get(SHARDS_PROP);
    numShards = StrUtils.splitSmart(shardNames,',').size();
  }
  Integer replicationFactor = (Integer) collectionProps.get(REPLICATION_FACTOR);
  if(replicationFactor==null){
    replicationFactor = (Integer) OverseerCollectionProcessor.COLL_PROPS.get(REPLICATION_FACTOR);
  }

  if (confSetName != null) {
    params.set("collection.configName", confSetName);
  }

  int clientIndex = random().nextInt(2);
  List<Integer> list = new ArrayList<>();
  list.add(numShards);
  list.add(replicationFactor);
  if (collectionInfos != null) {
    collectionInfos.put(collectionName, list);
  }
  params.set("name", collectionName);
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");

  CollectionAdminResponse res = new CollectionAdminResponse();
  if (client == null) {
    final String baseUrl = getBaseUrl((HttpSolrServer) clients.get(clientIndex));
    SolrServer server = createNewSolrServer("", baseUrl);
    try {
      res.setResponse(server.request(request));
    } finally {
      if (server != null) server.shutdown();
    }
  } else {
    res.setResponse(client.request(request));
  }
  return res;
}
 
开发者ID:europeana,项目名称:search,代码行数:46,代码来源:AbstractFullDistribZkTestBase.java

示例9: submit

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
@Override
public void submit(final ShardRequest sreq, final String shard, final ModifiableSolrParams params) {
  // do this outside of the callable for thread safety reasons
  final List<String> urls = getURLs(shard);

  Callable<ShardResponse> task = new Callable<ShardResponse>() {
    @Override
    public ShardResponse call() throws Exception {

      ShardResponse srsp = new ShardResponse();
      if (sreq.nodeName != null) {
        srsp.setNodeName(sreq.nodeName);
      }
      srsp.setShardRequest(sreq);
      srsp.setShard(shard);
      SimpleSolrResponse ssr = new SimpleSolrResponse();
      srsp.setSolrResponse(ssr);
      long startTime = System.nanoTime();

      try {
        params.remove(CommonParams.WT); // use default (currently javabin)
        params.remove(CommonParams.VERSION);

        // SolrRequest req = new QueryRequest(SolrRequest.METHOD.POST, "/select");
        // use generic request to avoid extra processing of queries
        QueryRequest req = new QueryRequest(params);
        req.setMethod(SolrRequest.METHOD.POST);

        // no need to set the response parser as binary is the default
        // req.setResponseParser(new BinaryResponseParser());

        // if there are no shards available for a slice, urls.size()==0
        if (urls.size()==0) {
          // TODO: what's the right error code here? We should use the same thing when
          // all of the servers for a shard are down.
          throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "no servers hosting shard: " + shard);
        }

        if (urls.size() <= 1) {
          String url = urls.get(0);
          srsp.setShardAddress(url);
          SolrServer server = new HttpSolrServer(url, httpClient);
          try {
            ssr.nl = server.request(req);
          } finally {
            server.shutdown();
          }
        } else {
          LBHttpSolrServer.Rsp rsp = httpShardHandlerFactory.makeLoadBalancedRequest(req, urls);
          ssr.nl = rsp.getResponse();
          srsp.setShardAddress(rsp.getServer());
        }
      }
      catch( ConnectException cex ) {
        srsp.setException(cex); //????
      } catch (Exception th) {
        srsp.setException(th);
        if (th instanceof SolrException) {
          srsp.setResponseCode(((SolrException)th).code());
        } else {
          srsp.setResponseCode(-1);
        }
      }

      ssr.elapsedTime = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);

      return srsp;
    }
  };

  pending.add( completionService.submit(task) );
}
 
开发者ID:europeana,项目名称:search,代码行数:73,代码来源:HttpShardHandler.java

示例10: testANewCollectionInOneInstance

import org.apache.solr.client.solrj.SolrServer; //导入方法依赖的package包/类
private void testANewCollectionInOneInstance() throws Exception {
    log.info("### STARTING testANewCollectionInOneInstance");
    List<SolrServer> collectionClients = new ArrayList<>();
    SolrServer client = clients.get(0);
    final String baseUrl = ((HttpSolrServer) client).getBaseURL().substring(
        0,
        ((HttpSolrServer) client).getBaseURL().length()
            - DEFAULT_COLLECTION.length() - 1);
    createCollection(oneInstanceCollection, collectionClients, baseUrl, 1);
    createCollection(oneInstanceCollection, collectionClients, baseUrl, 2);
    createCollection(oneInstanceCollection, collectionClients, baseUrl, 3);
    createCollection(oneInstanceCollection, collectionClients, baseUrl, 4);
    
   while (pending != null && pending.size() > 0) {
      
      Future<Object> future = completionService.take();
      if (future == null) return;
      pending.remove(future);
    }
   
    SolrServer client1 = collectionClients.get(0);
    SolrServer client2 = collectionClients.get(1);
    SolrServer client3 = collectionClients.get(2);
    SolrServer client4 = collectionClients.get(3);
 
    waitForRecoveriesToFinish(oneInstanceCollection, getCommonCloudSolrServer().getZkStateReader(), false);
    assertAllActive(oneInstanceCollection, getCommonCloudSolrServer().getZkStateReader());
    
    client2.add(getDoc(id, "1")); 
    client3.add(getDoc(id, "2")); 
    client4.add(getDoc(id, "3")); 
    
    client1.commit();
    SolrQuery query = new SolrQuery("*:*");
    query.set("distrib", false);
    long oneDocs = client1.query(query).getResults().getNumFound();
    long twoDocs = client2.query(query).getResults().getNumFound();
    long threeDocs = client3.query(query).getResults().getNumFound();
    long fourDocs = client4.query(query).getResults().getNumFound();
    
    query.set("collection", oneInstanceCollection);
    query.set("distrib", true);
    long allDocs = getCommonCloudSolrServer().query(query).getResults().getNumFound();
    
//    System.out.println("1:" + oneDocs);
//    System.out.println("2:" + twoDocs);
//    System.out.println("3:" + threeDocs);
//    System.out.println("4:" + fourDocs);
//    System.out.println("All Docs:" + allDocs);
    
    assertEquals(3, allDocs);
    for(SolrServer newCollectionClient:collectionClients) {
      newCollectionClient.shutdown();
    }
  }
 
开发者ID:europeana,项目名称:search,代码行数:56,代码来源:BasicDistributedZkTest.java


注:本文中的org.apache.solr.client.solrj.SolrServer.shutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。