Search in sources :

Example 11 with CollectionAdminResponse

use of org.apache.solr.client.solrj.response.CollectionAdminResponse in project lucene-solr by apache.

the class TestBlobHandler method createSystemCollection.

public static void createSystemCollection(SolrClient client) throws SolrServerException, IOException {
    CollectionAdminResponse response1;
    CollectionAdminRequest.Create createCollectionRequest = CollectionAdminRequest.createCollection(".system", 1, 2);
    response1 = createCollectionRequest.process(client);
    assertEquals(0, response1.getStatus());
    assertTrue(response1.isSuccess());
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest)

Example 12 with CollectionAdminResponse

use of org.apache.solr.client.solrj.response.CollectionAdminResponse in project lucene-solr by apache.

the class TestBlobHandler method doBlobHandlerTest.

@Test
public void doBlobHandlerTest() throws Exception {
    try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
        CollectionAdminResponse response1;
        CollectionAdminRequest.Create createCollectionRequest = CollectionAdminRequest.createCollection(".system", 1, 2);
        response1 = createCollectionRequest.process(client);
        assertEquals(0, response1.getStatus());
        assertTrue(response1.isSuccess());
        DocCollection sysColl = cloudClient.getZkStateReader().getClusterState().getCollection(".system");
        Replica replica = sysColl.getActiveSlicesMap().values().iterator().next().getLeader();
        String baseUrl = replica.getStr(ZkStateReader.BASE_URL_PROP);
        String url = baseUrl + "/.system/config/requestHandler";
        Map map = TestSolrConfigHandlerConcurrent.getAsMap(url, cloudClient);
        assertNotNull(map);
        assertEquals("solr.BlobHandler", getObjectByPath(map, true, Arrays.asList("config", "requestHandler", "/blob", "class")));
        map = TestSolrConfigHandlerConcurrent.getAsMap(baseUrl + "/.system/schema/fields/blob", cloudClient);
        assertNotNull(map);
        assertEquals("blob", getObjectByPath(map, true, Arrays.asList("field", "name")));
        assertEquals("bytes", getObjectByPath(map, true, Arrays.asList("field", "type")));
        checkBlobPost(baseUrl, cloudClient);
    }
}
Also used : HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) SolrClient(org.apache.solr.client.solrj.SolrClient) HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) DocCollection(org.apache.solr.common.cloud.DocCollection) Replica(org.apache.solr.common.cloud.Replica) Map(java.util.Map) Test(org.junit.Test)

Example 13 with CollectionAdminResponse

use of org.apache.solr.client.solrj.response.CollectionAdminResponse in project lucene-solr by apache.

the class CreateCollectionCleanupTest method testCreateCollectionCleanup.

@Test
public void testCreateCollectionCleanup() throws Exception {
    final CloudSolrClient cloudClient = cluster.getSolrClient();
    // Create a collection that would fail
    CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection("foo", "conf1", 1, 1);
    Properties properties = new Properties();
    properties.put(CoreAdminParams.DATA_DIR, "/some_invalid_dir/foo");
    create.setProperties(properties);
    CollectionAdminResponse rsp = create.process(cloudClient);
    assertFalse(rsp.isSuccess());
    // Confirm using LIST that the collection does not exist
    assertFalse(CollectionAdminRequest.listCollections(cloudClient).contains("foo"));
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) Properties(java.util.Properties) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) Test(org.junit.Test)

Example 14 with CollectionAdminResponse

use of org.apache.solr.client.solrj.response.CollectionAdminResponse in project lucene-solr by apache.

the class DeleteStatusTest method testAsyncIdsMayBeDeleted.

@Test
public void testAsyncIdsMayBeDeleted() throws Exception {
    final CloudSolrClient client = cluster.getSolrClient();
    final String collection = "deletestatus";
    final String asyncId = CollectionAdminRequest.createCollection(collection, "conf1", 1, 1).processAsync(client);
    waitForRequestState(asyncId, client, MAX_WAIT_TIMEOUT);
    assertEquals(RequestStatusState.COMPLETED, CollectionAdminRequest.requestStatus(asyncId).process(client).getRequestStatus());
    CollectionAdminResponse rsp = CollectionAdminRequest.deleteAsyncId(asyncId).process(client);
    assertEquals("successfully removed stored response for [" + asyncId + "]", rsp.getResponse().get("status"));
    assertEquals(RequestStatusState.NOT_FOUND, CollectionAdminRequest.requestStatus(asyncId).process(client).getRequestStatus());
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) Test(org.junit.Test)

Example 15 with CollectionAdminResponse

use of org.apache.solr.client.solrj.response.CollectionAdminResponse in project lucene-solr by apache.

the class CollectionsAPISolrJTest method testCreateAndDeleteCollection.

@Test
public void testCreateAndDeleteCollection() throws Exception {
    String collectionName = "solrj_test";
    CollectionAdminResponse response = CollectionAdminRequest.createCollection(collectionName, "conf", 2, 2).setStateFormat(1).process(cluster.getSolrClient());
    assertEquals(0, response.getStatus());
    assertTrue(response.isSuccess());
    Map<String, NamedList<Integer>> coresStatus = response.getCollectionCoresStatus();
    assertEquals(4, coresStatus.size());
    for (int i = 0; i < 4; i++) {
        NamedList<Integer> status = coresStatus.get(Assign.buildCoreName(collectionName, "shard" + (i / 2 + 1), Replica.Type.NRT, (i % 2 + 1)));
        assertEquals(0, (int) status.get("status"));
        assertTrue(status.get("QTime") > 0);
    }
    response = CollectionAdminRequest.deleteCollection(collectionName).process(cluster.getSolrClient());
    assertEquals(0, response.getStatus());
    assertTrue(response.isSuccess());
    Map<String, NamedList<Integer>> nodesStatus = response.getCollectionNodesStatus();
    assertEquals(4, nodesStatus.size());
    waitForState("Expected " + collectionName + " to disappear from cluster state", collectionName, (n, c) -> c == null);
    // Test Creating a collection with new stateformat.
    collectionName = "solrj_newstateformat";
    response = CollectionAdminRequest.createCollection(collectionName, "conf", 2, 2).setStateFormat(2).process(cluster.getSolrClient());
    assertEquals(0, response.getStatus());
    assertTrue(response.isSuccess());
    waitForState("Expected " + collectionName + " to appear in cluster state", collectionName, (n, c) -> c != null);
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) NamedList(org.apache.solr.common.util.NamedList) Test(org.junit.Test)

Aggregations

CollectionAdminResponse (org.apache.solr.client.solrj.response.CollectionAdminResponse)59 CollectionAdminRequest (org.apache.solr.client.solrj.request.CollectionAdminRequest)30 Test (org.junit.Test)21 NamedList (org.apache.solr.common.util.NamedList)11 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)9 SolrClient (org.apache.solr.client.solrj.SolrClient)8 SolrServerException (org.apache.solr.client.solrj.SolrServerException)8 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)8 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)8 ArrayList (java.util.ArrayList)7 Replica (org.apache.solr.common.cloud.Replica)7 QueryRequest (org.apache.solr.client.solrj.request.QueryRequest)6 IOException (java.io.IOException)5 Map (java.util.Map)5 SolrRequest (org.apache.solr.client.solrj.SolrRequest)5 HttpResponse (org.apache.http.HttpResponse)4 HttpGet (org.apache.http.client.methods.HttpGet)4 HttpPost (org.apache.http.client.methods.HttpPost)4 StringEntity (org.apache.http.entity.StringEntity)4 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)4