use of org.apache.solr.client.solrj.SolrRequest in project storm by apache.
the class SolrUpdateBolt method process.
@Override
protected void process(Tuple tuple) {
try {
SolrRequest request = solrMapper.toSolrRequest(tuple);
solrClient.request(request, solrMapper.getCollection());
ack(tuple);
} catch (Exception e) {
fail(tuple, e);
}
}
use of org.apache.solr.client.solrj.SolrRequest in project lucene-solr by apache.
the class CollectionsAPIDistributedZkTest method testZeroNumShards.
@Test
public void testZeroNumShards() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionAction.CREATE.toString());
params.set("name", "acollection");
params.set(REPLICATION_FACTOR, 10);
params.set("numShards", 0);
params.set("collection.configName", "conf");
final SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
expectThrows(Exception.class, () -> {
cluster.getSolrClient().request(request);
});
}
use of org.apache.solr.client.solrj.SolrRequest in project lucene-solr by apache.
the class CollectionsAPIDistributedZkTest method testMissingNumShards.
@Test
public void testMissingNumShards() {
// No numShards should fail
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionAction.CREATE.toString());
params.set("name", "acollection");
params.set(REPLICATION_FACTOR, 10);
params.set("collection.configName", "conf");
final SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
expectThrows(Exception.class, () -> {
cluster.getSolrClient().request(request);
});
}
use of org.apache.solr.client.solrj.SolrRequest in project lucene-solr by apache.
the class TestCollectionAPI method testCollectionCreationShardNameValidation.
private void testCollectionCreationShardNameValidation() throws Exception {
try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CREATE.toString());
params.set("name", "valid_collection_name");
params.set("router.name", "implicit");
params.set("numShards", "1");
params.set("shards", "invalid@name#with$weird%characters");
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid shard"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
assertTrue(errorMessage.contains("shard names must consist entirely of"));
}
}
}
use of org.apache.solr.client.solrj.SolrRequest in project lucene-solr by apache.
the class TestCollectionAPI method clusterStatusNoCollection.
private void clusterStatusNoCollection() throws Exception {
try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
NamedList<Object> rsp = client.request(request);
NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
assertNotNull("Cluster state should not be null", cluster);
NamedList<Object> collections = (NamedList<Object>) cluster.get("collections");
assertNotNull("Collections should not be null in cluster state", collections);
assertNotNull(collections.get(COLLECTION_NAME1));
assertEquals(4, collections.size());
List<String> liveNodes = (List<String>) cluster.get("live_nodes");
assertNotNull("Live nodes should not be null", liveNodes);
assertFalse(liveNodes.isEmpty());
}
}
Aggregations