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


Java CoreAdminRequest类代码示例

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


CoreAdminRequest类属于org.apache.solr.client.solrj.request包,在下文中一共展示了CoreAdminRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: execute

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
@Override
public RepeatStatus execute(StepContribution contribution,
		ChunkContext chunkContext) throws Exception {

	CoreAdminResponse coreAdminResponse = CoreAdminRequest.getStatus(core, solrServer);
	NamedList<Object> index = (NamedList<Object>)coreAdminResponse.getCoreStatus(core).get("index");
	Integer segmentCount = (Integer)index.get("segmentCount");

	if(segmentCount < maxSegments) {
		logger.debug("Core " + core + " only has " + segmentCount + " segments, skipping optimization");
	} else {
		logger.debug("Core " + core + " has " + segmentCount + " segments, starting optimization");
		solrServer.optimize(true, true);
		logger.debug("Core " + core + " optimized");
	}

	return RepeatStatus.FINISHED;
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:19,代码来源:SolrOptimizingTasklet.java

示例5: execute

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public RepeatStatus execute(StepContribution contribution,
		ChunkContext chunkContext) throws Exception {

	CoreAdminResponse coreAdminResponse = CoreAdminRequest.getStatus(core, solrClient);
	NamedList<Object> index = (NamedList<Object>)coreAdminResponse.getCoreStatus(core).get("index");
	Integer segmentCount = (Integer)index.get("segmentCount");

	if(segmentCount < maxSegments) {
		logger.debug("Core " + core + " only has " + segmentCount + " segments, skipping optimization");
	} else {
		logger.debug("Core " + core + " has " + segmentCount + " segments, starting optimization");
		solrClient.optimize(true, true);
		logger.debug("Core " + core + " optimized");
	}

	return RepeatStatus.FINISHED;
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:20,代码来源:SolrOptimizingTasklet.java

示例6: handleSyncShardAction

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的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());
  server.setConnectionTimeout(15000);
  server.setSoTimeout(30000);
  RequestSyncShard reqSyncShard = new CoreAdminRequest.RequestSyncShard();
  reqSyncShard.setCollection(collection);
  reqSyncShard.setShard(shard);
  reqSyncShard.setCoreName(nodeProps.getCoreName());
  server.request(reqSyncShard);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:CollectionsHandler.java

示例7: handleSyncShardAction

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的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:yintaoxue,项目名称:read-open-source-code,代码行数:24,代码来源:CollectionsHandler.java

示例8: dropIndex

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
public void dropIndex() throws IOException, SolrServerException, NdexException {
	try {
		client.setBaseURL(solrUrl);
	//	CollectionAdminRequest.deleteCollection(collectionName).process(client);
		
		CoreAdminRequest.unloadCore(collectionName, true, true, client);
	} catch (HttpSolrClient.RemoteSolrException e4) {
		System.out.println(e4.code() + " - " + e4.getMessage());
		if ( e4.getMessage().indexOf("Cannot unload non-existent core") == -1) {
			e4.printStackTrace();
			throw new NdexException("Unexpected Solr Exception: " + e4.getMessage());
		}	
	} 
	
	/**
	 * One reference implementation to check if a core exists
	 * CommonsHttpSolrServer adminServer = new
		CommonsHttpSolrServer(solrRootUrl);
		CoreAdminResponse status =
		CoreAdminRequest.getStatus(coreName, adminServer);

		return status.getCoreStatus(coreName).get("instanceDir") != null;
	 */
}
 
开发者ID:ndexbio,项目名称:ndex-rest,代码行数:25,代码来源:SingleNetworkSolrIdxManager.java

示例9: createIndex

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
public void createIndex() throws SolrServerException, IOException, NdexException {
	CoreAdminRequest.Create creator = new CoreAdminRequest.Create(); 
	creator.setCoreName(coreName);
	creator.setConfigSet(
			"ndex-nodes"); 
//	"data_driven_schema_configs");
	CoreAdminResponse foo = creator.process(client);	
		
	if ( foo.getStatus() != 0 ) {
		throw new NdexException ("Failed to create solrIndex for network " + coreName + ". Error: " + foo.getResponseHeader().toString());
	}
	counter = 0;
	docs = new ArrayList<>(batchSize);
	
	client.setBaseURL(solrUrl + "/" + coreName);
}
 
开发者ID:ndexbio,项目名称:ndex-common,代码行数:17,代码来源:SingleNetworkSolrIdxManager.java

示例10: create

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
/**
 * @param solrHome the Solr home directory to use
 * @param configSetHome the directory containing config sets
 * @param coreName the name of the core, must have a matching directory in configHome
 * @param cleanSolrHome if true the directory for solrHome will be deleted and re-created if it already exists
 * @return an EmbeddedSolrServer with a core created for the given coreName
 */
public static SolrClient create(final String solrHome, final String configSetHome, final String coreName, final boolean cleanSolrHome)
        throws IOException, SolrServerException {

    final File solrHomeDir = new File(solrHome);
    if (solrHomeDir.exists()) {
        FileUtils.deleteDirectory(solrHomeDir);
        solrHomeDir.mkdirs();
    } else {
        solrHomeDir.mkdirs();
    }

    final SolrResourceLoader loader = new SolrResourceLoader(solrHomeDir.toPath());
    final Path configSetPath = Paths.get(configSetHome).toAbsolutePath();

    final NodeConfig config = new NodeConfig.NodeConfigBuilder("embeddedSolrServerNode", loader)
            .setConfigSetBaseDirectory(configSetPath.toString())
            .build();

    final EmbeddedSolrServer embeddedSolrServer = new EmbeddedSolrServer(config, coreName);

    final CoreAdminRequest.Create createRequest = new CoreAdminRequest.Create();
    createRequest.setCoreName(coreName);
    createRequest.setConfigSet(coreName);
    embeddedSolrServer.request(createRequest);

    return embeddedSolrServer;
}
 
开发者ID:bbende,项目名称:tripod,代码行数:35,代码来源:EmbeddedSolrServerFactory.java

示例11: createSchema

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
@Override
public void createSchema() {
  try {
    if (!schemaExists())
      CoreAdminRequest.createCore(mapping.getCoreName(),
          mapping.getCoreName(), adminServer, solrConfig, solrSchema);
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
  }
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:11,代码来源:SolrStore.java

示例12: schemaExists

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
@Override
public boolean schemaExists() {
  boolean exists = false;
  try {
    CoreAdminResponse rsp = CoreAdminRequest.getStatus(mapping.getCoreName(),
        adminServer);
    exists = rsp.getUptime(mapping.getCoreName()) != null;
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
  }
  return exists;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:13,代码来源:SolrStore.java

示例13: testMergeIndexesByDirName

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
public void testMergeIndexesByDirName() throws Exception {
  UpdateRequest up = setupCores();

  // Now get the index directory of core1 and merge with core0
  CoreAdminRequest.mergeIndexes("core0", new String[] {getIndexDirCore1()}, new String[0], getSolrAdmin());

  // Now commit the merged index
  up.clear(); // just do commit
  up.process(getSolrCore0());

  assertEquals(1,
      getSolrCore0().query(new SolrQuery("id:AAA")).getResults().size());
  assertEquals(1,
      getSolrCore0().query(new SolrQuery("id:BBB")).getResults().size());
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:MergeIndexesExampleTestBase.java

示例14: testMergeIndexesByCoreName

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
public void testMergeIndexesByCoreName() throws Exception {
  UpdateRequest up = setupCores();
  CoreAdminRequest.mergeIndexes("core0", new String[0], new String[] {"core1"}, getSolrAdmin());

  // Now commit the merged index
  up.clear(); // just do commit
  up.process(getSolrCore0());

  assertEquals(1,
      getSolrCore0().query(new SolrQuery("id:AAA")).getResults().size());
  assertEquals(1,
      getSolrCore0().query(new SolrQuery("id:BBB")).getResults().size());
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:MergeIndexesExampleTestBase.java

示例15: testMergeMultipleRequest

import org.apache.solr.client.solrj.request.CoreAdminRequest; //导入依赖的package包/类
public void testMergeMultipleRequest() throws Exception {
  CoreAdminRequest.MergeIndexes req = new CoreAdminRequest.MergeIndexes();
  req.setCoreName("core0");
  req.setIndexDirs(Arrays.asList("/path/1", "/path/2"));
  req.setSrcCores(Arrays.asList("core1", "core2"));
  SolrParams params = req.getParams();
  assertEquals(2, params.getParams(CoreAdminParams.SRC_CORE).length);
  assertEquals(2, params.getParams(CoreAdminParams.INDEX_DIR).length);
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:MergeIndexesExampleTestBase.java


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