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


Java CoreDescriptor类代码示例

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


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

示例1: create

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
/**
 *
 * @param solrHome
 *              path to directory where solr.xml lives
 *
 * @param coreName
 *              the name of the core to load
 * @param dataDir
 *              the data dir for the core
 *
 * @return an EmbeddedSolrServer for the given core
 */
public static SolrClient create(String solrHome, String coreHome, String coreName, String dataDir) throws IOException {
    File coreDataDir = new File(dataDir + "/" + coreName);
    if (coreDataDir.exists()) {
       FileUtils.deleteDirectory(coreDataDir);
    }

    CoreContainer coreContainer = new CoreContainer(solrHome);
    coreContainer.load();

    Properties props = new Properties();
    props.setProperty("dataDir", dataDir + "/" + coreName);

    CoreDescriptor descriptor = new CoreDescriptor(coreContainer, coreName,
            new File(coreHome, coreName).getAbsolutePath(), props);

    SolrCore solrCore = coreContainer.create(descriptor);
    //coreContainer.register(solrCore, false);
    return new EmbeddedSolrServer(coreContainer, coreName);
}
 
开发者ID:bbende,项目名称:solrj-custom-json-update,代码行数:32,代码来源:EmbeddedSolrServerFactory.java

示例2: checkIfCoreNodeNameAlreadyExists

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
private boolean checkIfCoreNodeNameAlreadyExists(CoreDescriptor dcore) {
  ZkStateReader zkStateReader = coreContainer.getZkController()
      .getZkStateReader();
  DocCollection collection = zkStateReader.getClusterState().getCollectionOrNull(dcore.getCollectionName());
  if (collection != null) {
    Collection<Slice> slices = collection.getSlices();
    
    for (Slice slice : slices) {
      Collection<Replica> replicas = slice.getReplicas();
      for (Replica replica : replicas) {
        if (replica.getName().equals(
            dcore.getCloudDescriptor().getCoreNodeName())) {
          return true;
        }
      }
    }
  }
  return false;
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:CoreAdminHandler.java

示例3: EmbeddedSolrServer

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
/**
 * Use the other constructor using a CoreContainer and a name.
 * @deprecated use {@link #EmbeddedSolrServer(CoreContainer, String)} instead.
 */
@Deprecated
public EmbeddedSolrServer( SolrCore core )
{
  if ( core == null ) {
    throw new NullPointerException("SolrCore instance required");
  }
  CoreDescriptor dcore = core.getCoreDescriptor();
  if (dcore == null)
    throw new NullPointerException("CoreDescriptor required");
  
  CoreContainer cores = dcore.getCoreContainer();
  if (cores == null)
    throw new NullPointerException("CoreContainer required");
  
  coreName = dcore.getName();
  coreContainer = cores;
  _parser = new SolrRequestParsers( null );
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:EmbeddedSolrServer.java

示例4: unregister

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
public void unregister(String coreName, CoreDescriptor cd)
    throws InterruptedException, KeeperException {
  final String coreNodeName = cd.getCloudDescriptor().getCoreNodeName();
  final String collection = cd.getCloudDescriptor().getCollectionName();
  assert collection != null;
  
  if (collection == null || collection.trim().length() == 0) {
    log.error("No collection was specified.");
    return;
  }
  
  ElectionContext context = electionContexts.remove(new ContextKey(collection, coreNodeName));
  
  if (context != null) {
    context.cancelElection();
  }
  
  CloudDescriptor cloudDescriptor = cd.getCloudDescriptor();
  
  ZkNodeProps m = new ZkNodeProps(Overseer.QUEUE_OPERATION,
      Overseer.DELETECORE, ZkStateReader.CORE_NAME_PROP, coreName,
      ZkStateReader.NODE_NAME_PROP, getNodeName(),
      ZkStateReader.COLLECTION_PROP, cloudDescriptor.getCollectionName(),
      ZkStateReader.CORE_NODE_NAME_PROP, coreNodeName);
  overseerJobQueue.offer(ZkStateReader.toJSON(m));
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:ZkController.java

示例5: waitForShardId

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
private void waitForShardId(CoreDescriptor cd) {
  log.info("waiting to find shard id in clusterstate for " + cd.getName());
  int retryCount = 320;
  while (retryCount-- > 0) {
    final String shardId = zkStateReader.getClusterState().getShardId(getNodeName(), cd.getName());
    if (shardId != null) {
      cd.getCloudDescriptor().setShardId(shardId);
      return;
    }
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
  
  throw new SolrException(ErrorCode.SERVER_ERROR,
      "Could not get shard id for core: " + cd.getName());
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:ZkController.java

示例6: checkStateInZk

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
private void checkStateInZk(CoreDescriptor cd) throws InterruptedException {
  if (!Overseer.isLegacy(zkStateReader.getClusterProps())) {
    CloudDescriptor cloudDesc = cd.getCloudDescriptor();
    String coreNodeName = cloudDesc.getCoreNodeName();
    assert coreNodeName != null;
    if (cloudDesc.getShardId() == null) throw new SolrException(ErrorCode.SERVER_ERROR ,"No shard id for :" + cd);
    long endTime = System.nanoTime() + TimeUnit.NANOSECONDS.convert(3, TimeUnit.SECONDS);
    String errMessage= null;
    for (; System.nanoTime()<endTime; ) {
      Thread.sleep(100);
      errMessage = null;
      Slice slice = zkStateReader.getClusterState().getSlice(cd.getCollectionName(), cloudDesc.getShardId());
      if (slice == null) {
        errMessage = "Invalid slice : " + cloudDesc.getShardId();
        continue;
      }
      if (slice.getReplica(coreNodeName) != null) return;
    }
    if(errMessage == null)  errMessage = " no_such_replica in clusterstate ,replicaName :  " + coreNodeName;
    throw new SolrException(ErrorCode.SERVER_ERROR,errMessage + "state : "+ zkStateReader.getClusterState().getCollection(cd.getCollectionName()));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:ZkController.java

示例7: bootstrapConf

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
/**
 * If in SolrCloud mode, upload config sets for each SolrCore in solr.xml.
 */
public static void bootstrapConf(SolrZkClient zkClient, CoreContainer cc, String solrHome) throws IOException,
    KeeperException, InterruptedException {

  //List<String> allCoreNames = cfg.getAllCoreNames();
  List<CoreDescriptor> cds = cc.getCoresLocator().discover(cc);
  
  log.info("bootstrapping config for " + cds.size() + " cores into ZooKeeper using solr.xml from " + solrHome);

  for (CoreDescriptor cd : cds) {
    String coreName = cd.getName();
    String confName = cd.getCollectionName();
    if (StringUtils.isEmpty(confName))
      confName = coreName;
    String instanceDir = cd.getInstanceDir();
    File udir = new File(instanceDir, "conf");
    log.info("Uploading directory " + udir + " with name " + confName + " for SolrCore " + coreName);
    ZkController.uploadConfigDir(zkClient, udir, confName);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:ZkController.java

示例8: startSolr

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
/**
     * Start up an embedded Solr server.
     *
     * @param home The path to the Solr home directory
     * @return EmbeddedSolrServer: The instantiated server
     * @throws Exception if any errors occur
     */
    private EmbeddedSolrServer startSolr(String home) throws Exception {
        try {
            SolrConfig solrConfig = new SolrConfig(home, SOLR_CONFIG, null);
            IndexSchema schema = new IndexSchema(solrConfig, SOLR_SCHEMA, null);

            solrContainer = new CoreContainer(new SolrResourceLoader(
                    SolrResourceLoader.locateSolrHome()));
            CoreDescriptor descriptor = new CoreDescriptor(solrContainer, "",
                    solrConfig.getResourceLoader().getInstanceDir());
            descriptor.setConfigName(solrConfig.getResourceName());
            descriptor.setSchemaName(schema.getResourceName());

            solrCore = new SolrCore(null, solrConfig.getDataDir(),
                    solrConfig, schema, descriptor);
            solrContainer.register("cheese", solrCore, false);
//            CoreAdminRequest.create
            return new EmbeddedSolrServer(solrContainer, "cheese");
        } catch(Exception ex) {
            log.error("\nFailed to start Solr server\n");
            throw ex;
        }
    }
 
开发者ID:openimaj,项目名称:openimaj,代码行数:30,代码来源:GeonamesIndexGenerator.java

示例9: joinElection

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
private void joinElection(CoreDescriptor cd, boolean afterExpiration) throws InterruptedException, KeeperException, IOException {
  
  String shardId = cd.getCloudDescriptor().getShardId();
  
  Map<String,Object> props = new HashMap<String,Object>();
  // we only put a subset of props into the leader node
  props.put(ZkStateReader.BASE_URL_PROP, getBaseUrl());
  props.put(ZkStateReader.CORE_NAME_PROP, cd.getName());
  props.put(ZkStateReader.NODE_NAME_PROP, getNodeName());
  
  final String coreZkNodeName = getCoreNodeName(cd);
  ZkNodeProps ourProps = new ZkNodeProps(props);
  String collection = cd.getCloudDescriptor()
      .getCollectionName();
  
  ElectionContext context = new ShardLeaderElectionContext(leaderElector, shardId,
      collection, coreZkNodeName, ourProps, this, cc);

  leaderElector.setup(context);
  electionContexts.put(coreZkNodeName, context);
  leaderElector.joinElection(context, false);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:23,代码来源:ZkController.java

示例10: doGetShardIdProcess

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
private String doGetShardIdProcess(String coreName, CoreDescriptor descriptor) {
  final String coreNodeName = getCoreNodeName(descriptor);
  int retryCount = 320;
  while (retryCount-- > 0) {
    final String shardId = zkStateReader.getClusterState().getShardId(coreNodeName);
    if (shardId != null) {
      return shardId;
    }
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
    }
  }
  
  throw new SolrException(ErrorCode.SERVER_ERROR,
      "Could not get shard_id for core: " + coreName + " coreNodeName:" + coreNodeName);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:ZkController.java

示例11: preRegister

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
public void preRegister(CoreDescriptor cd) throws KeeperException, InterruptedException {
  // before becoming available, make sure we are not live and active
  // this also gets us our assigned shard id if it was not specified
  publish(cd, ZkStateReader.DOWN, false);
  String coreNodeName = getCoreNodeName(cd);
  
  // make sure the node name is set on the descriptor
  if (cd.getCloudDescriptor().getCoreNodeName() == null) {
    cd.getCloudDescriptor().setCoreNodeName(coreNodeName);
  }
  
  if (cd.getCloudDescriptor().getShardId() == null && needsToBeAssignedShardId(cd, zkStateReader.getClusterState(), coreNodeName)) {
    String shardId;
    shardId = doGetShardIdProcess(cd.getName(), cd);
    cd.getCloudDescriptor().setShardId(shardId);
  } else {
    // still wait till we see us in local state
    doGetShardIdProcess(cd.getName(), cd);
  }

}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:22,代码来源:ZkController.java

示例12: create

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
/**
 *
 * @param solrHome
 *              path to directory where solr.xml lives
 *
 * @param coreName
 *              the name of the core to load
 * @param dataDir
 *              the data dir for the core
 *
 * @return an EmbeddedSolrServer for the given core
 */
public static SolrServer create(String solrHome, String coreHome, String coreName, String dataDir) {
    File coreDataDir = new File(dataDir + "/" + coreName);
    if (coreDataDir.exists()) {
        coreDataDir.delete();
    }

    CoreContainer coreContainer = new CoreContainer(solrHome);
    coreContainer.load();

    Properties props = new Properties();
    props.setProperty("dataDir", dataDir + "/" + coreName);

    CoreDescriptor descriptor = new CoreDescriptor(coreContainer, coreName,
            new File(coreHome, coreName).getAbsolutePath(), props);

    SolrCore solrCore = coreContainer.create(descriptor);
    coreContainer.register(solrCore, false);
    return new EmbeddedSolrServer(coreContainer, coreName);
}
 
开发者ID:bbende,项目名称:solr-wikipedia,代码行数:32,代码来源:EmbeddedSolrServerFactory.java

示例13: DistributedUpdateProcessor

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
public DistributedUpdateProcessor(SolrQueryRequest req,
    SolrQueryResponse rsp, UpdateRequestProcessor next) {
  super(next);
  this.rsp = rsp;
  this.next = next;
  this.idField = req.getSchema().getUniqueKeyField();
  // version init

  this.updateHandler = req.getCore().getUpdateHandler();
  this.ulog = updateHandler.getUpdateLog();
  this.vinfo = ulog == null ? null : ulog.getVersionInfo();
  versionsStored = this.vinfo != null && this.vinfo.getVersionField() != null;
  returnVersions = req.getParams().getBool(UpdateParams.VERSIONS ,false);

  // TODO: better way to get the response, or pass back info to it?
  SolrRequestInfo reqInfo = returnVersions ? SolrRequestInfo.getRequestInfo() : null;

  this.req = req;
  
  CoreDescriptor coreDesc = req.getCore().getCoreDescriptor();
  
  this.zkEnabled  = coreDesc.getCoreContainer().isZooKeeperAware();
  zkController = req.getCore().getCoreDescriptor().getCoreContainer().getZkController();
  if (zkEnabled) {
    cmdDistrib = new SolrCmdDistributor(coreDesc.getCoreContainer().getUpdateShardHandler());
  }
  //this.rsp = reqInfo != null ? reqInfo.getRsp() : null;

  cloudDesc = coreDesc.getCloudDescriptor();
  
  if (cloudDesc != null) {
    collection = cloudDesc.getCollectionName();
  } else {
    collection = null;
  }

}
 
开发者ID:europeana,项目名称:search,代码行数:38,代码来源:DistributedUpdateProcessor.java

示例14: markAllAsNotLeader

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
private void markAllAsNotLeader(
    final CurrentCoreDescriptorProvider registerOnReconnect) {
  List<CoreDescriptor> descriptors = registerOnReconnect
      .getCurrentDescriptors();
  if (descriptors != null) {
    for (CoreDescriptor descriptor : descriptors) {
      descriptor.getCloudDescriptor().setLeader(false);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:ZkController.java

示例15: joinElection

import org.apache.solr.core.CoreDescriptor; //导入依赖的package包/类
private void joinElection(CoreDescriptor cd, boolean afterExpiration) throws InterruptedException, KeeperException, IOException {
  // look for old context - if we find it, cancel it
  String collection = cd.getCloudDescriptor().getCollectionName();
  final String coreNodeName = cd.getCloudDescriptor().getCoreNodeName();
  
  ContextKey contextKey = new ContextKey(collection, coreNodeName);
  
  ElectionContext prevContext = electionContexts.get(contextKey);
  
  if (prevContext != null) {
    prevContext.cancelElection();
  }
  
  String shardId = cd.getCloudDescriptor().getShardId();
  
  Map<String,Object> props = new HashMap<>();
  // we only put a subset of props into the leader node
  props.put(ZkStateReader.BASE_URL_PROP, getBaseUrl());
  props.put(ZkStateReader.CORE_NAME_PROP, cd.getName());
  props.put(ZkStateReader.NODE_NAME_PROP, getNodeName());
  
 
  ZkNodeProps ourProps = new ZkNodeProps(props);

  
  ElectionContext context = new ShardLeaderElectionContext(leaderElector, shardId,
      collection, coreNodeName, ourProps, this, cc);

  leaderElector.setup(context);
  electionContexts.put(contextKey, context);
  leaderElector.joinElection(context, false);
}
 
开发者ID:europeana,项目名称:search,代码行数:33,代码来源:ZkController.java


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