Error while creating cluster using MiniSolrCloudCluster

325 Views Asked by At

We were using solr6.2 version, and we are migrating it to latest solr8.2 version now. ALl our test cases are failing while creating the cluster. We are using MiniSolrCloudCluster to create a cluster, but it internally uses JettySolrRunner class where few methods and classes are deprecated. Because of this, we are getting the following error:

Java.lang.Exception: Error starting up MiniSolrCloudCluster at org.apache.solr.cloud.MiniSolrCloudCluster.checkForExceptions(MiniSolrCloudCluster.java:652) at org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:306) at org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:239) at org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:219) at org.apache.solr.cloud.MiniSolrCloudCluster.(MiniSolrCloudCluster.java:146) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Suppressed: java.lang.NoSuchMethodError: org.eclipse.jetty.util.thread.QueuedThreadPool.setReservedThreads(I)V at org.apache.solr.client.solrj.embedded.JettySolrRunner.init(JettySolrRunner.java:265) at org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:257) at org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:229) at org.apache.solr.client.solrj.embedded.JettySolrRunner.(JettySolrRunner.java:216) at 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) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ... 1 more

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

Please suggest if there is any way to create solr cluster using solr-core-8.2.0

1

There are 1 best solutions below

0
On

You can try to create solr cluster as I did.

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);
        }
    }
}