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


Java CoreAdminRequest.setAction方法代码示例

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


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

示例1: getCores

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
/**
 * Get target cores via CoreAdminAPI.
 *
 * @param httpSolrClient
 * @return
 */
public static List<String> getCores(HttpSolrClient httpSolrClient) throws SolrServerException, IOException {
    List<String> cores = new ArrayList<>();

    NoOpResponseParser responseParser = new NoOpResponseParser();
    responseParser.setWriterType("json");

    httpSolrClient.setParser(responseParser);

    CoreAdminRequest coreAdminRequest = new CoreAdminRequest();
    coreAdminRequest.setAction(CoreAdminParams.CoreAdminAction.STATUS);
    coreAdminRequest.setIndexInfoNeeded(false);

    NamedList<Object> coreAdminResponse = httpSolrClient.request(coreAdminRequest);

    JsonNode statusJsonNode = om.readTree((String) coreAdminResponse.get("response")).get("status");

    for (Iterator<JsonNode> i = statusJsonNode.iterator(); i.hasNext(); ) {
        String core = i.next().get("name").textValue();
        if (!cores.contains(core)) {
            cores.add(core);
        }
    }

    return cores;
}
 
开发者ID:mosuka,项目名称:solr-exporter,代码行数:32,代码来源:SolrCollector.java

示例2: getEstimatedSizeOfShard

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
private long getEstimatedSizeOfShard(ReplicaInfo replica) throws IOException {
  try (AuthorizedSolrClient solrClient =
      spec.getConnectionConfiguration().createClient(replica.baseUrl())) {
    CoreAdminRequest req = new CoreAdminRequest();
    req.setAction(CoreAdminParams.CoreAdminAction.STATUS);
    req.setIndexInfoNeeded(true);
    CoreAdminResponse response;
    try {
      response = solrClient.process(req);
    } catch (SolrServerException e) {
      throw new IOException("Can not get core status from " + replica, e);
    }
    NamedList<Object> coreStatus = response.getCoreStatus(replica.coreName());
    NamedList<Object> indexStats = (NamedList<Object>) coreStatus.get("index");
    return (long) indexStats.get("sizeInBytes");
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:18,代码来源:SolrIO.java

示例3: swapActiveCores

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
@Override
public void swapActiveCores() throws ServiceException {
    if (SolrContext.isSingleCoreMode()) {
        LOG.debug("In single core mode. There are no cores to swap.");
    } else {
        LOG.debug("Swapping active cores");

        CoreAdminRequest car = new CoreAdminRequest();
        car.setCoreName(SolrContext.PRIMARY);
        car.setOtherCoreName(SolrContext.REINDEX);
        car.setAction(CoreAdminAction.SWAP);

        try {
            SolrContext.getAdminServer().request(car);
        } catch (Exception e) {
            LOG.error(e);
            throw new ServiceException("Unable to swap cores", e);
        }
    }
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:21,代码来源:SolrHelperServiceImpl.java

示例4: getRemoteCores

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
/**
 * Get list of cores from the remote Solr server.
 * 
 * @return Map of cores attributes keyed by core name.
 * @throws SophieException
 *             If the list of cores cannot be fetched.
 */
@SuppressWarnings("unchecked")
public static Map<String, NamedList<Object>> getRemoteCores() throws SophieException {
    CoreAdminRequest request = new CoreAdminRequest();
    request.setAction(CoreAdminAction.STATUS);
    try {
        CoreAdminResponse response = request.process(Sophie.client);
        return response.getCoreStatus().asMap(-1);
    } catch (SolrServerException | IOException | SolrException e) {
        throw new SophieException("Unable to fetch list of Solr cores", e);
    }
}
 
开发者ID:fengtan,项目名称:sophie,代码行数:19,代码来源:SolrUtils.java

示例5: testReloadCore

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
@Test
public void testReloadCore() throws Exception {
  SolrInputDocument doc = new SolrInputDocument();
  doc.addField("uri", "/doc/1");
  doc.addField(TITLE_FIELD, TITLE);
  doc.addField(TEXT_FIELD, TEXT);
  solr.add(doc);
  solr.commit(false, true, true);

  CoreAdminRequest reload = new CoreAdminRequest();
  reload.setAction(CoreAdminAction.RELOAD);
  reload.setCoreName("collection1");
  reload.process(solr);
}
 
开发者ID:safarijv,项目名称:ifpress-solr-plugin,代码行数:15,代码来源:MultiSuggesterTest.java

示例6: getCoreList

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
public List<String> getCoreList() throws IOException, SolrServerException {
    SolrClient solrClient = getSolrclient(null);
    CoreAdminRequest coreAdminRequest = new CoreAdminRequest();
    coreAdminRequest.setAction(CoreAdminParams.CoreAdminAction.STATUS);
    CoreAdminResponse cores = coreAdminRequest.process(solrClient);

    List<String> coreList = new ArrayList<String>();
    for (int i = 0; i < cores.getCoreStatus().size(); i++) {
        coreList.add(cores.getCoreStatus().getName(i));
    }
    return coreList;
}
 
开发者ID:Stratio,项目名称:Decision,代码行数:13,代码来源:SolrOperationsService.java

示例7: checkIndexExists

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入方法依赖的package包/类
private boolean checkIndexExists(IndexConfiguration indexConfiguration) {
    CoreAdminResponse cores = null;
    
    try {
        CoreAdminRequest request = new CoreAdminRequest();
        request.setAction(CoreAdminAction.STATUS);
        cores = request.process(solrServer);
    } catch (SolrServerException | IOException e) {
        throw new SolrConfigurationException("Unable to check solr indexes status", e);
    }
    
    NamedList<Object> indexStatus = cores.getCoreStatus(indexConfiguration.getName());
    
    return indexStatus != null;
}
 
开发者ID:CeON,项目名称:saos,代码行数:16,代码来源:SolrIndexReloader.java


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