mirror of https://github.com/apache/lucene.git
SOLR-7599: Inline startCloudJetty method into ShardRoutingCustomTest
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1682340 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
225e4a5803
commit
8ea0d522ed
|
@ -17,6 +17,10 @@ package org.apache.solr.cloud;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.apache.solr.client.solrj.SolrClient;
|
||||||
|
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -51,7 +55,31 @@ public class ShardRoutingCustomTest extends AbstractFullDistribZkTestBase {
|
||||||
private void doCustomSharding() throws Exception {
|
private void doCustomSharding() throws Exception {
|
||||||
printLayout();
|
printLayout();
|
||||||
|
|
||||||
startCloudJetty(collection, "shardA");
|
int totalReplicas = getTotalReplicas(collection);
|
||||||
|
|
||||||
|
File jettyDir = createTempDir("jetty").toFile();
|
||||||
|
jettyDir.mkdirs();
|
||||||
|
setupJettySolrHome(jettyDir);
|
||||||
|
JettySolrRunner j = createJetty(jettyDir, createTempDir().toFile().getAbsolutePath(), "shardA", "solrconfig.xml", null);
|
||||||
|
jettys.add(j);
|
||||||
|
SolrClient client = createNewSolrClient(j.getLocalPort());
|
||||||
|
clients.add(client);
|
||||||
|
|
||||||
|
int retries = 60;
|
||||||
|
while (--retries >= 0) {
|
||||||
|
// total replicas changed.. assume it was us
|
||||||
|
if (getTotalReplicas(collection) != totalReplicas) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retries <= 0) {
|
||||||
|
fail("Timeout waiting for " + j + " to appear in clusterstate");
|
||||||
|
printLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateMappingsFromZk(this.jettys, this.clients);
|
||||||
|
|
||||||
printLayout();
|
printLayout();
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,42 +419,6 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected SolrClient startCloudJetty(String collection, String shard) throws Exception {
|
|
||||||
// TODO: use the collection string!!!!
|
|
||||||
collection = DEFAULT_COLLECTION;
|
|
||||||
|
|
||||||
int totalReplicas = getTotalReplicas(collection);
|
|
||||||
|
|
||||||
|
|
||||||
int cnt = this.jettyIntCntr.incrementAndGet();
|
|
||||||
|
|
||||||
File jettyDir = createTempDir("jetty").toFile();
|
|
||||||
jettyDir.mkdirs();
|
|
||||||
setupJettySolrHome(jettyDir);
|
|
||||||
JettySolrRunner j = createJetty(jettyDir, testDir + "/jetty" + cnt, shard, "solrconfig.xml", null);
|
|
||||||
jettys.add(j);
|
|
||||||
SolrClient client = createNewSolrClient(j.getLocalPort());
|
|
||||||
clients.add(client);
|
|
||||||
|
|
||||||
int retries = 60;
|
|
||||||
while (--retries >= 0) {
|
|
||||||
// total replicas changed.. assume it was us
|
|
||||||
if (getTotalReplicas(collection) != totalReplicas) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Thread.sleep(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retries <= 0) {
|
|
||||||
fail("Timeout waiting for " + j + " to appear in clusterstate");
|
|
||||||
printLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateMappingsFromZk(this.jettys, this.clients);
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Total number of replicas (number of cores serving an index to the collection) shown by the cluster state */
|
/* Total number of replicas (number of cores serving an index to the collection) shown by the cluster state */
|
||||||
protected int getTotalReplicas(String collection) {
|
protected int getTotalReplicas(String collection) {
|
||||||
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
|
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
|
||||||
|
|
Loading…
Reference in New Issue