use of org.apache.solr.client.solrj.request.CollectionAdminRequest.SplitShard in project lucene-solr by apache.
the class MultiThreadedOCPTest method testLongAndShortRunningParallelApiCalls.
private void testLongAndShortRunningParallelApiCalls() throws InterruptedException, IOException, SolrServerException {
Thread indexThread = new Thread() {
@Override
public void run() {
Random random = random();
int max = atLeast(random, 200);
for (int id = 101; id < max; id++) {
try {
doAddDoc(String.valueOf(id));
} catch (Exception e) {
log.error("Exception while adding docs", e);
}
}
}
};
indexThread.start();
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
SplitShard splitShardRequest = CollectionAdminRequest.splitShard("collection1").setShardName(SHARD1);
splitShardRequest.processAsync("2000", client);
RequestStatusState state = getRequestState("2000", client);
while (state == RequestStatusState.SUBMITTED) {
state = getRequestState("2000", client);
Thread.sleep(10);
}
assertSame("SplitShard task [2000] was supposed to be in [running] but isn't. It is [" + state + "]", RequestStatusState.RUNNING, state);
// CLUSTERSTATE is always mutually exclusive, it should return with a response before the split completes
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
params.set("collection", "collection1");
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
client.request(request);
state = getRequestState("2000", client);
assertSame("After invoking OVERSEERSTATUS, SplitShard task [2000] was still supposed to be in [running] but " + "isn't. It is [" + state + "]", RequestStatusState.RUNNING, state);
} finally {
try {
indexThread.join();
} catch (InterruptedException e) {
log.warn("Indexing thread interrupted.");
}
}
}
use of org.apache.solr.client.solrj.request.CollectionAdminRequest.SplitShard in project lucene-solr by apache.
the class MultiThreadedOCPTest method testDeduplicationOfSubmittedTasks.
private void testDeduplicationOfSubmittedTasks() throws IOException, SolrServerException {
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
CollectionAdminRequest.createCollection("ocptest_shardsplit2", "conf1", 4, 1).processAsync("3000", client);
SplitShard splitShardRequest = CollectionAdminRequest.splitShard("ocptest_shardsplit2").setShardName(SHARD1);
splitShardRequest.processAsync("3001", client);
splitShardRequest = CollectionAdminRequest.splitShard("ocptest_shardsplit2").setShardName(SHARD2);
splitShardRequest.processAsync("3002", client);
// Now submit another task with the same id. At this time, hopefully the previous 3002 should still be in the queue.
expectThrows(SolrServerException.class, () -> {
CollectionAdminRequest.splitShard("ocptest_shardsplit2").setShardName(SHARD1).processAsync("3002", client);
// more helpful assertion failure
fail("Duplicate request was supposed to exist but wasn't found. De-duplication of submitted task failed.");
});
for (int i = 3001; i <= 3002; i++) {
final RequestStatusState state = getRequestStateAfterCompletion(i + "", REQUEST_STATUS_TIMEOUT, client);
assertSame("Task " + i + " did not complete, final state: " + state, RequestStatusState.COMPLETED, state);
}
}
}
Aggregations