use of org.apache.solr.common.cloud.Replica in project lucene-solr by apache.
the class TestPullReplica method assertUlogPresence.
/**
* Asserts that Update logs don't exist for replicas of type {@link org.apache.solr.common.cloud.Replica.Type#PULL}
*/
private void assertUlogPresence(DocCollection collection) {
for (Slice s : collection.getSlices()) {
for (Replica r : s.getReplicas()) {
if (r.getType() == Replica.Type.NRT) {
continue;
}
SolrCore core = null;
try {
core = cluster.getReplicaJetty(r).getCoreContainer().getCore(r.getCoreName());
assertNotNull(core);
assertFalse("Update log should not exist for replicas of type Passive but file is present: " + core.getUlogDir(), new java.io.File(core.getUlogDir()).exists());
} finally {
core.close();
}
}
}
}
use of org.apache.solr.common.cloud.Replica in project lucene-solr by apache.
the class TestSolrConfigHandlerCloud method getRandomServer.
public static String getRandomServer(CloudSolrClient cloudClient, String collName) {
DocCollection coll = cloudClient.getZkStateReader().getClusterState().getCollection(collName);
List<String> urls = new ArrayList<>();
for (Slice slice : coll.getSlices()) {
for (Replica replica : slice.getReplicas()) urls.add("" + replica.get(ZkStateReader.BASE_URL_PROP) + "/" + replica.get(ZkStateReader.CORE_NAME_PROP));
}
return urls.get(random().nextInt(urls.size()));
}
use of org.apache.solr.common.cloud.Replica in project lucene-solr by apache.
the class BasicAuthIntegrationTest method getRandomReplica.
public static Replica getRandomReplica(DocCollection coll, Random random) {
ArrayList<Replica> l = new ArrayList<>();
for (Slice slice : coll.getSlices()) {
for (Replica replica : slice.getReplicas()) {
l.add(replica);
}
}
Collections.shuffle(l, random);
return l.isEmpty() ? null : l.get(0);
}
use of org.apache.solr.common.cloud.Replica in project lucene-solr by apache.
the class FeaturesSelectionStream method getShardUrls.
private List<String> getShardUrls() throws IOException {
try {
ZkStateReader zkStateReader = cloudSolrClient.getZkStateReader();
Collection<Slice> slices = CloudSolrStream.getSlices(this.collection, zkStateReader, false);
ClusterState clusterState = zkStateReader.getClusterState();
Set<String> liveNodes = clusterState.getLiveNodes();
List<String> baseUrls = new ArrayList<>();
for (Slice slice : slices) {
Collection<Replica> replicas = slice.getReplicas();
List<Replica> shuffler = new ArrayList<>();
for (Replica replica : replicas) {
if (replica.getState() == Replica.State.ACTIVE && liveNodes.contains(replica.getNodeName())) {
shuffler.add(replica);
}
}
Collections.shuffle(shuffler, new Random());
Replica rep = shuffler.get(0);
ZkCoreNodeProps zkProps = new ZkCoreNodeProps(rep);
String url = zkProps.getCoreUrl();
baseUrls.add(url);
}
return baseUrls;
} catch (Exception e) {
throw new IOException(e);
}
}
use of org.apache.solr.common.cloud.Replica in project lucene-solr by apache.
the class ShardSplitTest method assertConsistentReplicas.
private int assertConsistentReplicas(Slice shard) throws SolrServerException, IOException {
long numFound = Long.MIN_VALUE;
int count = 0;
for (Replica replica : shard.getReplicas()) {
HttpSolrClient client = new HttpSolrClient.Builder(replica.getCoreUrl()).withHttpClient(cloudClient.getLbClient().getHttpClient()).build();
QueryResponse response = client.query(new SolrQuery("q", "*:*", "distrib", "false"));
log.info("Found numFound={} on replica: {}", response.getResults().getNumFound(), replica.getCoreUrl());
if (numFound == Long.MIN_VALUE) {
numFound = response.getResults().getNumFound();
} else {
assertEquals("Shard " + shard.getName() + " replicas do not have same number of documents", numFound, response.getResults().getNumFound());
}
count++;
}
return count;
}
Aggregations