0

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

Java.lang.Exception :在 org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:306) 的 org.apache.solr.cloud.MiniSolrCloudCluster.checkForExceptions(MiniSolrCloudCluster.java:652) 处启动 MiniSolrCloudCluster 时出错。 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) at org.apache.solr.cloud.MiniSolrCloudCluster.lambda$new$0(MiniSolrCloudCluster.java:300) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at 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 集群

4

1 回答 1

0

您可以像我一样尝试创建 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);
        }
    }
}

于 2020-03-16T15:55:00.957 回答