Search in sources :

Example 61 with CollectionAdminResponse

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

the class CollectionsAPISolrJTest method testSplitShard.

@Test
public void testSplitShard() throws Exception {
    final String collectionName = "solrj_test_splitshard";
    CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1).process(cluster.getSolrClient());
    CollectionAdminResponse response = CollectionAdminRequest.splitShard(collectionName).setShardName("shard1").process(cluster.getSolrClient());
    assertEquals(0, response.getStatus());
    assertTrue(response.isSuccess());
    Map<String, NamedList<Integer>> coresStatus = response.getCollectionCoresStatus();
    assertEquals(0, (int) coresStatus.get(Assign.buildCoreName(collectionName, "shard1_0", Replica.Type.NRT, 1)).get("status"));
    assertEquals(0, (int) coresStatus.get(Assign.buildCoreName(collectionName, "shard1_1", Replica.Type.NRT, 1)).get("status"));
    waitForState("Expected all shards to be active and parent shard to be removed", collectionName, (n, c) -> {
        if (c.getSlice("shard1").getState() == Slice.State.ACTIVE)
            return false;
        for (Replica r : c.getReplicas()) {
            if (r.isActive(n) == false)
                return false;
        }
        return true;
    });
    // Test splitting using split.key
    response = CollectionAdminRequest.splitShard(collectionName).setSplitKey("b!").process(cluster.getSolrClient());
    assertEquals(0, response.getStatus());
    assertTrue(response.isSuccess());
    waitForState("Expected 5 slices to be active", collectionName, (n, c) -> c.getActiveSlices().size() == 5);
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) NamedList(org.apache.solr.common.util.NamedList) Replica(org.apache.solr.common.cloud.Replica) Test(org.junit.Test)

Example 62 with CollectionAdminResponse

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

the class CollectionsAPISolrJTest method testList.

@Test
public void testList() throws IOException, SolrServerException {
    CollectionAdminResponse response = new CollectionAdminRequest.List().process(cluster.getSolrClient());
    assertEquals(0, response.getStatus());
    assertNotNull("collection list should not be null", response.getResponse().get("collections"));
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) Test(org.junit.Test)

Example 63 with CollectionAdminResponse

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

the class CollectionsAPISolrJTest method testCloudInfoInCoreStatus.

@Test
public void testCloudInfoInCoreStatus() throws IOException, SolrServerException {
    String collectionName = "corestatus_test";
    CollectionAdminResponse response = CollectionAdminRequest.createCollection(collectionName, "conf", 2, 2).setStateFormat(1).process(cluster.getSolrClient());
    assertEquals(0, response.getStatus());
    assertTrue(response.isSuccess());
    String nodeName = ((NamedList) response.getResponse().get("success")).getName(0);
    String corename = (String) ((NamedList) ((NamedList) response.getResponse().get("success")).getVal(0)).get("core");
    try (HttpSolrClient coreclient = getHttpSolrClient(cluster.getSolrClient().getZkStateReader().getBaseUrlForNodeName(nodeName))) {
        CoreAdminResponse status = CoreAdminRequest.getStatus(corename, coreclient);
        Map m = status.getResponse().asMap(5);
        assertEquals(collectionName, Utils.getObjectByPath(m, true, Arrays.asList("status", corename, "cloud", "collection")));
        assertNotNull(Utils.getObjectByPath(m, true, Arrays.asList("status", corename, "cloud", "shard")));
        assertNotNull(Utils.getObjectByPath(m, true, Arrays.asList("status", corename, "cloud", "replica")));
    }
}
Also used : HttpSolrClient(org.apache.solr.client.solrj.impl.HttpSolrClient) CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) NamedList(org.apache.solr.common.util.NamedList) CoreAdminResponse(org.apache.solr.client.solrj.response.CoreAdminResponse) Map(java.util.Map) Test(org.junit.Test)

Example 64 with CollectionAdminResponse

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

the class CollectionsAPISolrJTest method testOverseerStatus.

@Test
public void testOverseerStatus() throws IOException, SolrServerException {
    CollectionAdminResponse response = new CollectionAdminRequest.OverseerStatus().process(cluster.getSolrClient());
    assertEquals(0, response.getStatus());
    assertNotNull("overseer_operations shouldn't be null", response.getResponse().get("overseer_operations"));
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) Test(org.junit.Test)

Example 65 with CollectionAdminResponse

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

the class DeleteStatusTest method testDeletingNonExistentRequests.

@Test
public void testDeletingNonExistentRequests() throws Exception {
    final CloudSolrClient client = cluster.getSolrClient();
    CollectionAdminResponse rsp = CollectionAdminRequest.deleteAsyncId("foo").process(client);
    assertEquals("[foo] not found in stored responses", rsp.getResponse().get("status"));
}
Also used : CollectionAdminResponse(org.apache.solr.client.solrj.response.CollectionAdminResponse) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) Test(org.junit.Test)

Aggregations

CollectionAdminResponse (org.apache.solr.client.solrj.response.CollectionAdminResponse)71 CollectionAdminRequest (org.apache.solr.client.solrj.request.CollectionAdminRequest)40 Test (org.junit.Test)21 SolrServerException (org.apache.solr.client.solrj.SolrServerException)13 NamedList (org.apache.solr.common.util.NamedList)13 SolrClient (org.apache.solr.client.solrj.SolrClient)9 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)9 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)9 ArrayList (java.util.ArrayList)8 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)8 IOException (java.io.IOException)7 Replica (org.apache.solr.common.cloud.Replica)7 QueryRequest (org.apache.solr.client.solrj.request.QueryRequest)6 Map (java.util.Map)5 SolrRequest (org.apache.solr.client.solrj.SolrRequest)5 ZkStateReader (org.apache.solr.common.cloud.ZkStateReader)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