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


Java CoreAdminAction类代码示例

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


CoreAdminAction类属于org.apache.solr.common.params.CoreAdminParams包,在下文中一共展示了CoreAdminAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: swapActiveCores

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的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

示例2: invokeOverseerOp

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
private void invokeOverseerOp(String electionNode, String op) {
  ModifiableSolrParams params = new ModifiableSolrParams();
  ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
  params.set(CoreAdminParams.ACTION, CoreAdminAction.OVERSEEROP.toString());
  params.set("op", op);
  params.set("qt", adminPath);
  params.set("electionNode", electionNode);
  ShardRequest sreq = new ShardRequest();
  sreq.purpose = 1;
  String replica = zkStateReader.getBaseUrlForNodeName(LeaderElector.getNodeName(electionNode));
  sreq.shards = new String[]{replica};
  sreq.actualShards = sreq.shards;
  sreq.params = params;
  shardHandler.submit(sreq, replica, sreq.params);
  shardHandler.takeCompletedOrError();
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:OverseerCollectionProcessor.java

示例3: requestRecovery

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
private void requestRecovery(final ZkNodeProps leaderProps, final String baseUrl, final String coreName) throws SolrServerException, IOException {
  // TODO: do this in background threads
  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);
      server.setConnectionTimeout(45000);
      server.setSoTimeout(45000);
      try {
        server.request(recoverRequestCmd);
      } catch (Throwable t) {
        SolrException.log(log, ZkCoreNodeProps.getCoreUrl(leaderProps) + ": Could not tell a replica to recover", t);
      }
    }
  };
  recoveryCmdExecutor.execute(thread);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:SyncStrategy.java

示例4: reloadCore

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
public static CoreAdminResponse reloadCore( String name, SolrServer server ) throws SolrServerException, IOException
{
  CoreAdminRequest req = new CoreAdminRequest();
  req.setCoreName( name );
  req.setAction( CoreAdminAction.RELOAD );
  return req.process( server );
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:CoreAdminRequest.java

示例5: renameCore

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
public static CoreAdminResponse renameCore(String coreName, String newName, SolrServer server ) throws SolrServerException, IOException
{
  CoreAdminRequest req = new CoreAdminRequest();
  req.setCoreName(coreName);
  req.setOtherCoreName(newName);
  req.setAction( CoreAdminAction.RENAME );
  return req.process( server );
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:CoreAdminRequest.java

示例6: getStatus

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
public static CoreAdminResponse getStatus( String name, SolrServer server ) throws SolrServerException, IOException
{
  CoreAdminRequest req = new CoreAdminRequest();
  req.setCoreName( name );
  req.setAction( CoreAdminAction.STATUS );
  return req.process( server );
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:CoreAdminRequest.java

示例7: handleRequestBody

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
  // Make sure the cores is enabled
  CoreContainer cores = getCoreContainer();
  if (cores == null) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
            "Core container instance missing");
  }
  //boolean doPersist = false;
  String taskId = req.getParams().get("async");
  TaskObject taskObject = new TaskObject(taskId);

  if(taskId != null) {
    // Put the tasks into the maps for tracking
    if (getMap(RUNNING).containsKey(taskId) || getMap(COMPLETED).containsKey(taskId) || getMap(FAILED).containsKey(taskId)) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
          "Duplicate request with the same requestid found.");
    }

    addTask(RUNNING, taskObject);
  }

  // Pick the action
  SolrParams params = req.getParams();
  CoreAdminAction action = CoreAdminAction.STATUS;
  String a = params.get(CoreAdminParams.ACTION);
  if (a != null) {
    action = CoreAdminAction.get(a);
    if (action == null) {
      this.handleCustomAction(req, rsp);
    }
  }

  if (taskId == null) {
    handleRequestInternal(req, rsp, action);
  } else {
    ParallelCoreAdminHandlerThread parallelHandlerThread = new ParallelCoreAdminHandlerThread(req, rsp, action, taskObject);
    parallelExecutor.execute(parallelHandlerThread);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:41,代码来源:CoreAdminHandler.java

示例8: ParallelCoreAdminHandlerThread

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
public ParallelCoreAdminHandlerThread (SolrQueryRequest req, SolrQueryResponse rsp,
                                       CoreAdminAction action, TaskObject taskObject){
  this.req = req;
  this.rsp = rsp;
  this.action = action;
  this.taskObject = taskObject;
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:CoreAdminHandler.java

示例9: requestRecovery

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的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

示例10: getRemoteCores

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的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

示例11: testReloadCore

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的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

示例12: checkIndexExists

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的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

示例13: invokeOverseerOp

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
private void invokeOverseerOp(String nodeName, String op) {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(CoreAdminParams.ACTION, CoreAdminAction.OVERSEEROP.toString());
  params.set("op", op);
  params.set("qt", adminPath);
  ShardRequest sreq = new ShardRequest();
  sreq.purpose = 1;
  String replica = zkStateReader.getBaseUrlForNodeName(nodeName);
  sreq.shards = new String[]{replica};
  sreq.actualShards = sreq.shards;
  sreq.params = params;
  shardHandler.submit(sreq, replica, sreq.params);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:14,代码来源:OverseerCollectionProcessor.java

示例14: verifyQueryAccess

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
private void verifyQueryAccess(CoreAdminAction action, boolean checkCollection) throws Exception {
  CoreContainer cc = getCleanCoreContainer(action);
  CoreAdminHandler handler = new SecureCoreAdminHandler(cc);
  verifyAuthorized(handler, getCoreAdminRequest("collection1", "junit", action));
  verifyAuthorized(handler, getCoreAdminRequest("queryCollection", "junit", action));
  if (!checkCollection) {
    verifyAuthorized(handler, getCoreAdminRequest("bogusCollection", "junit", action));
    verifyAuthorized(handler, getCoreAdminRequest("updateCollection", "junit", action));
  } else {
    verifyUnauthorized(handler, getCoreAdminRequest("bogusCollection", "junit", action), "bogusCollection", "junit");
    verifyUnauthorized(handler, getCoreAdminRequest("updateCollection", "junit", action), "updateCollection", "junit");
  }
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:14,代码来源:SecureCoreAdminHandlerTest.java

示例15: verifyUpdateAccess

import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction; //导入依赖的package包/类
private void verifyUpdateAccess(CoreAdminAction action, boolean checkCollection) throws Exception {
  CoreContainer cc = getCleanCoreContainer(action);
  CoreAdminHandler handler = new SecureCoreAdminHandler(cc);
  verifyAuthorized(handler, getCoreAdminRequest("collection1", "junit", action));
  verifyAuthorized(handler, getCoreAdminRequest("updateCollection", "junit", action));
  verifyUnauthorized(handler, getCoreAdminRequest("bogusCollection", "bogusUser", action), "bogusCollection", "bogusUser", true);
  if (checkCollection) {
    verifyUnauthorized(handler, getCoreAdminRequest("queryCollection", "junit", action), "queryCollection", "junit");
  }
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:11,代码来源:SecureCoreAdminHandlerTest.java


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