use of org.apache.solr.client.solrj.request.UpdateRequest in project lucene-solr by apache.
the class TestTlogReplica method testBasicLeaderElection.
public void testBasicLeaderElection() throws Exception {
createAndWaitForCollection(1, 0, 2, 0);
CloudSolrClient cloudClient = cluster.getSolrClient();
new UpdateRequest().deleteByQuery("*:*").commit(cluster.getSolrClient(), collectionName);
new UpdateRequest().add(sdoc("id", "1")).add(sdoc("id", "2")).process(cloudClient, collectionName);
JettySolrRunner oldLeaderJetty = getSolrRunner(true).get(0);
ChaosMonkey.kill(oldLeaderJetty);
waitForState("Replica not removed", collectionName, activeReplicaCount(0, 1, 0));
new UpdateRequest().add(sdoc("id", "3")).add(sdoc("id", "4")).process(cloudClient, collectionName);
ChaosMonkey.start(oldLeaderJetty);
waitForState("Replica not added", collectionName, activeReplicaCount(0, 2, 0));
checkRTG(1, 4, cluster.getJettySolrRunners());
new UpdateRequest().commit(cloudClient, collectionName);
waitForNumDocsInAllActiveReplicas(4, 0);
}
use of org.apache.solr.client.solrj.request.UpdateRequest in project lucene-solr by apache.
the class TestStressCloudBlindAtomicUpdates method update.
public static UpdateRequest update(SolrParams params, SolrInputDocument... docs) {
UpdateRequest r = new UpdateRequest();
if (null != params) {
r.setParams(new ModifiableSolrParams(params));
}
r.add(Arrays.asList(docs));
return r;
}
use of org.apache.solr.client.solrj.request.UpdateRequest in project lucene-solr by apache.
the class TestStressInPlaceUpdates method addDocAndGetVersion.
@SuppressWarnings("rawtypes")
protected long addDocAndGetVersion(Object... fields) throws Exception {
SolrInputDocument doc = new SolrInputDocument();
addFields(doc, fields);
ModifiableSolrParams params = new ModifiableSolrParams();
params.add("versions", "true");
UpdateRequest ureq = new UpdateRequest();
ureq.setParams(params);
ureq.add(doc);
UpdateResponse resp;
// send updates to leader, to avoid SOLR-8733
resp = ureq.process(leaderClient);
long returnedVersion = Long.parseLong(((NamedList) resp.getResponse().get("adds")).getVal(0).toString());
assertTrue("Due to SOLR-8733, sometimes returned version is 0. Let us assert that we have successfully" + " worked around that problem here.", returnedVersion > 0);
return returnedVersion;
}
use of org.apache.solr.client.solrj.request.UpdateRequest in project lucene-solr by apache.
the class TestTlogReplica method simulatedDBQ.
private UpdateRequest simulatedDBQ(String query, long version) throws SolrServerException, IOException {
String baseUrl = getBaseUrl();
UpdateRequest ur = new UpdateRequest();
ur.deleteByQuery(query);
ur.setParam("_version_", "" + version);
ur.setParam("update.distrib", "FROMLEADER");
ur.setParam("distrib.from", baseUrl);
return ur;
}
use of org.apache.solr.client.solrj.request.UpdateRequest in project lucene-solr by apache.
the class TestTlogReplica method testOutOfOrderDBQWithInPlaceUpdates.
public void testOutOfOrderDBQWithInPlaceUpdates() throws Exception {
createAndWaitForCollection(1, 0, 2, 0);
assertFalse(getSolrCore(true).get(0).getLatestSchema().getField("inplace_updatable_int").indexed());
assertFalse(getSolrCore(true).get(0).getLatestSchema().getField("inplace_updatable_int").stored());
assertTrue(getSolrCore(true).get(0).getLatestSchema().getField("inplace_updatable_int").hasDocValues());
List<UpdateRequest> updates = new ArrayList<>();
// full update
updates.add(simulatedUpdateRequest(null, "id", 1, "title_s", "title0_new", "inplace_updatable_int", 5, "_version_", 1L));
updates.add(simulatedDBQ("inplace_updatable_int:5", 3L));
updates.add(simulatedUpdateRequest(1L, "id", 1, "inplace_updatable_int", 6, "_version_", 2L));
for (JettySolrRunner solrRunner : getSolrRunner(false)) {
try (SolrClient client = solrRunner.newClient()) {
for (UpdateRequest up : updates) {
up.process(client, collectionName);
}
}
}
JettySolrRunner oldLeaderJetty = getSolrRunner(true).get(0);
ChaosMonkey.kill(oldLeaderJetty);
waitForState("Replica not removed", collectionName, activeReplicaCount(0, 1, 0));
ChaosMonkey.start(oldLeaderJetty);
waitForState("Replica not added", collectionName, activeReplicaCount(0, 2, 0));
checkRTG(1, 1, cluster.getJettySolrRunners());
SolrDocument doc = cluster.getSolrClient().getById(collectionName, "1");
assertNotNull(doc.get("title_s"));
}
Aggregations