Java Code Examples for org.apache.solr.core.CoreDescriptor#getCollectionName()

The following examples show how to use org.apache.solr.core.CoreDescriptor#getCollectionName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZkController.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * If in SolrCloud mode, upload config sets for each SolrCore in solr.xml.
 */
public static void bootstrapConf(SolrZkClient zkClient, CoreContainer cc) throws IOException {

  ZkConfigManager configManager = new ZkConfigManager(zkClient);

  //List<String> allCoreNames = cfg.getAllCoreNames();
  List<CoreDescriptor> cds = cc.getCoresLocator().discover(cc);

  if (log.isInfoEnabled()) {
    log.info("bootstrapping config for {} cores into ZooKeeper using solr.xml from {}", cds.size(), cc.getSolrHome());
  }

  for (CoreDescriptor cd : cds) {
    String coreName = cd.getName();
    String confName = cd.getCollectionName();
    if (StringUtils.isEmpty(confName))
      confName = coreName;
    Path udir = cd.getInstanceDir().resolve("conf");
    log.info("Uploading directory {} with name {} for solrCore {}", udir, confName, coreName);
    configManager.uploadConfigDir(udir, confName);
  }
}
 
Example 2
Source File: RoutedAliasUpdateProcessorTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("WeakerAccess")
Set<String> getLeaderCoreNames(ClusterState clusterState) {
  Set<String> leaders = new TreeSet<>(); // sorted just to make it easier to read when debugging...
  List<JettySolrRunner> jettySolrRunners = cluster.getJettySolrRunners();
  for (JettySolrRunner jettySolrRunner : jettySolrRunners) {
    List<CoreDescriptor> coreDescriptors = jettySolrRunner.getCoreContainer().getCoreDescriptors();
    for (CoreDescriptor core : coreDescriptors) {
      String nodeName = jettySolrRunner.getNodeName();
      String collectionName = core.getCollectionName();
      DocCollection collectionOrNull = clusterState.getCollectionOrNull(collectionName);
      List<Replica> leaderReplicas = collectionOrNull.getLeaderReplicas(nodeName);
      if (leaderReplicas != null) {
        for (Replica leaderReplica : leaderReplicas) {
          leaders.add(leaderReplica.getCoreName());
        }
      }
    }
  }
  return leaders;
}
 
Example 3
Source File: SchemaManager.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private void waitForOtherReplicasToUpdate(TimeOut timeOut, int latestVersion) {
  SolrCore core = req.getCore();
  CoreDescriptor cd = core.getCoreDescriptor();
  String collection = cd.getCollectionName();
  if (collection != null) {
    if (timeOut.hasTimedOut()) {
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
          "Not enough time left to update replicas. However, the schema is updated already.");
    }
    ManagedIndexSchema.waitForSchemaZkVersionAgreement(collection, cd.getCloudDescriptor().getCoreNodeName(),
        latestVersion, core.getCoreContainer().getZkController(), (int) timeOut.timeLeft(TimeUnit.SECONDS));
  }
}
 
Example 4
Source File: RoutedAliasUpdateProcessorTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
protected void waitCoreCount(String collection, int count) {
  long start = System.nanoTime();
  int coreFooCount;
  List<JettySolrRunner> jsrs = cluster.getJettySolrRunners();
  do {
    coreFooCount = 0;
    // have to check all jetties... there was a very confusing bug where we only checked one and
    // thus might pick a jetty without a core for the collection and succeed if count = 0 when we
    // should have failed, or at least waited longer
    for (JettySolrRunner jsr : jsrs) {
      List<CoreDescriptor> coreDescriptors = jsr.getCoreContainer().getCoreDescriptors();
      for (CoreDescriptor coreDescriptor : coreDescriptors) {
        String collectionName = coreDescriptor.getCollectionName();
        if (collection.equals(collectionName)) {
          coreFooCount ++;
        }
      }
    }
    if (NANOSECONDS.toSeconds(System.nanoTime() - start) > 60) {
      fail("took over 60 seconds after collection creation to update aliases:"+collection + " core count=" + coreFooCount + " was looking for " + count);
    } else {
      try {
        Thread.sleep(500);
      } catch (InterruptedException e) {
        e.printStackTrace();
        fail(e.getMessage());
      }
    }
  } while(coreFooCount != count);
}