Example usage for org.apache.solr.cloud MiniSolrCloudCluster MiniSolrCloudCluster

List of usage examples for org.apache.solr.cloud MiniSolrCloudCluster MiniSolrCloudCluster

Introduction

In this page you can find the example usage for org.apache.solr.cloud MiniSolrCloudCluster MiniSolrCloudCluster.

Prototype

public MiniSolrCloudCluster(int numServers, Path baseDir, String solrXml, JettyConfig jettyConfig,
        ZkTestServer zkTestServer) throws Exception 

Source Link

Document

Create a MiniSolrCloudCluster

Usage

From source file:org.apache.camel.component.solr.SolrCloudFixture.java

License:Apache License

public SolrCloudFixture(String solrHome) throws Exception {

    miniCluster = new MiniSolrCloudCluster(1, "/solr", new File(solrHome, "solr-no-core.xml"), null, null);
    String zkAddr = miniCluster.getZkServer().getZkAddress();
    String zkHost = miniCluster.getZkServer().getZkHost();

    buildZooKeeper(zkHost, zkAddr, new File(solrHome), "solrconfig.xml", "schema.xml");
    List<JettySolrRunner> jettys = miniCluster.getJettySolrRunners();
    for (JettySolrRunner jetty : jettys) {
        if (!jetty.isRunning()) {
            log.warn("JETTY NOT RUNNING!");
        } else {/*from  w w  w . j  ava  2 s  . c  om*/
            log.info("JETTY RUNNING AT " + jetty.getBaseUrl() + " PORT " + jetty.getLocalPort());
        }
    }

    solrClient = new CloudSolrServer(zkAddr, true);
    solrClient.connect();

    createCollection(solrClient, "collection1", 1, 1, "conf1");
    Thread.sleep(1000); // takes some time to setup the collection...
                        // otherwise you'll get no live solr servers
    solrClient.setDefaultCollection("collection1");

    SolrInputDocument doc = new SolrInputDocument();
    doc.setField("id", "1");

    solrClient.add(doc);
    solrClient.commit();
}

From source file:org.apache.sentry.tests.e2e.solr.AbstractSolrSentryTestBase.java

License:Apache License

@BeforeClass
public static void beforeTestSimpleSolrEndToEnd() throws Exception {
    dfsCluster = HdfsTestUtil.setupClass(new File(Files.createTempDir(),
            AbstractSolrSentryTestBase.class.getName() + "_" + System.currentTimeMillis()).getAbsolutePath());
    File sentrySite = setupSentry();
    System.setProperty("solr.authorization.sentry.site",
            sentrySite.toURI().toURL().toString().substring("file:".length()));
    System.setProperty("solr.hdfs.home", dfsCluster.getURI().toString() + "/solr");
    extraRequestFilters = new TreeMap<Class, String>(new Comparator<Class>() {
        // There's only one class, make this as simple as possible
        public int compare(Class o1, Class o2) {
            return 0;
        }//w  w  w  .  j  ava 2  s .  c o m

        public boolean equals(Object obj) {
            return true;
        }
    });
    extraRequestFilters.put(ModifiableUserAuthenticationFilter.class, "*");
    File solrXml = new File(RESOURCES_DIR, "solr-no-core.xml");
    miniSolrCloudCluster = new MiniSolrCloudCluster(NUM_SERVERS, null, solrXml, null, extraRequestFilters);
}

From source file:org.apache.sentry.tests.e2e.solr.db.integration.AbstractSolrSentryTestWithDbProvider.java

License:Apache License

public static void startSolrWithDbProvider() throws Exception {
    LOGGER.info("starting Solr authorization via Sentry Service");
    configureWithSolr();// www .jav  a2s  .com
    miniSolrCloudCluster = new MiniSolrCloudCluster(NUM_SERVERS, null,
            new File(RESOURCES_DIR, "solr-no-core.xml"), null, extraRequestFilters);
}