【问题标题】:Error while creating cluster using MiniSolrCloudCluster使用 MiniSolrCloudCluster 创建集群时出错
【发布时间】:2019-11-07 14:59:33
【问题描述】:

我们使用的是 solr6.2 版本,现在我们正在将其迁移到最新的 solr8.2 版本。在创建集群时,我们所有的测试用例都失败了。我们使用 MiniSolrCloudCluster 创建集群,但它在内部使用 JettySolrRunner 类,其中很少有方法和类被弃用。因此,我们收到以下错误:

Java.lang.Exception:启动 MiniSolrCloudCluster 时出错 在 org.apache.solr.cloud.MiniSolrCloudCluster.checkForExceptions(MiniSolrCloudCluster.java:652) 在 org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:306) 在 org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:239) 在 org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:219) 在 org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:146) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 抑制:java.lang.NoSuchMethodError:org.eclipse.jetty.util.thread.QueuedThreadPool.setReservedThreads(I)V 在 org.apache.solr.client.solrj.embedded.JettySolrRunner.init(JettySolrRunner.java:265) 在 org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:257) 在 org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:229) 在 org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:216) 在 org.apache.solr.cloud.MiniSolrCloudCluster.startJettySolrRunner(MiniSolrCloudCluster.java:465) 在 org.apache.solr.cloud.MiniSolrCloudCluster.lambda$new$0(MiniSolrCloudCluster.java:300) 在 java.util.concurrent.FutureTask.run(FutureTask.java:266) 在 org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:209) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 在 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ... 1 更多

 public MiniSolrCloudCluster cluster() throws Exception {
        JettyConfig jettyConfig = JettyConfig.builder().setContext("/").build();
        return new MiniSolrCloudCluster(3, Paths.get("build/cluster"), jettyConfig);
    }

请建议是否有任何方法可以使用 solr-core-8.2.0 创建 solr 集群

【问题讨论】:

    标签: junit solrj solrcloud solr8


    【解决方案1】:

    你可以像我一样尝试创建 solr 集群。

    import org.apache.solr.client.solrj.SolrServerException;
    import org.apache.solr.client.solrj.embedded.JettyConfig;
    import org.apache.solr.client.solrj.request.CollectionAdminRequest;
    import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.List;
    import org.apache.solr.client.solrj.response.CollectionAdminResponse;
    import org.apache.solr.client.solrj.response.ConfigSetAdminResponse;
    import org.apache.solr.cloud.MiniSolrCloudCluster;
    
    import java.io.File;
    import java.io.IOException;
    import java.nio.file.Path;
    
    public class MiniSolrCloudClusterUtil {
        private MiniSolrCloudCluster miniSolrCloudCluster;
    
        public MiniSolrCloudClusterUtil(String fileLoc, int numServers) {
            Path baseDir = (new File(fileLoc)).toPath();
            JettyConfig jettyConfig = JettyConfig.builder().setPort(0).build();
    
            try {
                this.miniSolrCloudCluster = new MiniSolrCloudCluster(numServers, baseDir, jettyConfig);
            } catch (Exception var6) {
                throw new IllegalArgumentException("MiniSolrCloudCluster cannot be created. ", var6);
            }
        }
    
        public MiniSolrCloudCluster getMiniSolrCloudCluster() {
            return this.miniSolrCloudCluster;
        }
    
        public ConfigSetAdminResponse listConfigSets() {
            try {
                return (new List()).process(this.miniSolrCloudCluster.getSolrClient());
            } catch (IOException | SolrServerException var2) {
                throw new IllegalArgumentException("Unable to pull config set", var2);
            }
        }
    
        public CollectionAdminResponse getSolrClusterStatus() {
            try {
                return CollectionAdminRequest.getClusterStatus().process(this.miniSolrCloudCluster.getSolrClient());
            } catch (IOException | SolrServerException var2) {
                throw new IllegalArgumentException("Unable to pull config set", var2);
            }
        }
    }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2021-04-13
      • 2016-03-28
      • 2022-10-24
      • 2019-11-06
      • 2021-09-18
      相关资源
      最近更新 更多