Search in sources :

Example 6 with CoreStatus

use of org.apache.solr.client.solrj.request.CoreStatus in project lucene-solr by apache.

the class DeleteShardTest method testDirectoryCleanupAfterDeleteShard.

@Test
public void testDirectoryCleanupAfterDeleteShard() throws InterruptedException, IOException, SolrServerException {
    final String collection = "deleteshard_test";
    CollectionAdminRequest.createCollectionWithImplicitRouter(collection, "conf", "a,b,c", 1).setMaxShardsPerNode(2).process(cluster.getSolrClient());
    // Get replica details
    Replica leader = getCollectionState(collection).getLeader("a");
    CoreStatus coreStatus = getCoreStatus(leader);
    assertTrue("Instance directory doesn't exist", FileUtils.fileExists(coreStatus.getInstanceDirectory()));
    assertTrue("Data directory doesn't exist", FileUtils.fileExists(coreStatus.getDataDirectory()));
    assertEquals(3, getCollectionState(collection).getActiveSlices().size());
    // Delete shard 'a'
    CollectionAdminRequest.deleteShard(collection, "a").process(cluster.getSolrClient());
    assertEquals(2, getCollectionState(collection).getActiveSlices().size());
    assertFalse("Instance directory still exists", FileUtils.fileExists(coreStatus.getInstanceDirectory()));
    assertFalse("Data directory still exists", FileUtils.fileExists(coreStatus.getDataDirectory()));
    leader = getCollectionState(collection).getLeader("b");
    coreStatus = getCoreStatus(leader);
    // Delete shard 'b'
    CollectionAdminRequest.deleteShard(collection, "b").setDeleteDataDir(false).setDeleteInstanceDir(false).process(cluster.getSolrClient());
    assertEquals(1, getCollectionState(collection).getActiveSlices().size());
    assertTrue("Instance directory still exists", FileUtils.fileExists(coreStatus.getInstanceDirectory()));
    assertTrue("Data directory still exists", FileUtils.fileExists(coreStatus.getDataDirectory()));
}
Also used : CoreStatus(org.apache.solr.client.solrj.request.CoreStatus) Replica(org.apache.solr.common.cloud.Replica) Test(org.junit.Test)

Aggregations

CoreStatus (org.apache.solr.client.solrj.request.CoreStatus)6 Replica (org.apache.solr.common.cloud.Replica)5 Test (org.junit.Test)5 Path (java.nio.file.Path)3 DocCollection (org.apache.solr.common.cloud.DocCollection)3 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)2 SolrException (org.apache.solr.common.SolrException)2 Slice (org.apache.solr.common.cloud.Slice)2 File (java.io.File)1 JettySolrRunner (org.apache.solr.client.solrj.embedded.JettySolrRunner)1 CoreAdminRequest (org.apache.solr.client.solrj.request.CoreAdminRequest)1 CollectionAdminResponse (org.apache.solr.client.solrj.response.CollectionAdminResponse)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 ZkCoreNodeProps (org.apache.solr.common.cloud.ZkCoreNodeProps)1 NamedList (org.apache.solr.common.util.NamedList)1