List of usage examples for org.apache.solr.client.solrj.embedded JettySolrRunner getLocalPort
public int getLocalPort()
From source file:com.shaie.solr.MiniSolrCloudCluster.java
License:Apache License
/** Returns the base URL of the give node. */ public String getBaseUrl(String nodeId) { final JettySolrRunner solrRunner = getJettySolrRunner(nodeId); return "http://127.0.0.1:" + solrRunner.getLocalPort() + SOLR_CONTEXT; }
From source file:com.yahoo.ycsb.db.solr.SolrClientTest.java
License:Open Source License
@Override protected DB getDB(Properties props) { instance = new SolrClient(); // Use the first Solr server in the cluster. // Doesn't matter if there are more since requests will be forwarded properly by Solr. JettySolrRunner jettySolrRunner = miniSolrCloudCluster.getJettySolrRunners().get(0); String solrBaseUrl = String.format("http://localhost:%s%s", jettySolrRunner.getLocalPort(), jettySolrRunner.getBaseUrl()); props.setProperty("solr.base.url", solrBaseUrl); instance.setProperties(props);//from w ww . ja v a 2 s .co m try { instance.init(); } catch (Exception error) { assumeNoException(error); } return instance; }
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 ww. j a v a2 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(); }