Search in sources :

Example 1 with HdfsBackupRepository

use of org.apache.solr.core.backup.repository.HdfsBackupRepository in project lucene-solr by apache.

the class TestHdfsCloudBackupRestore method testConfigBackupOnly.

protected void testConfigBackupOnly(String configName, String collectionName) throws Exception {
    String backupName = "configonlybackup";
    CloudSolrClient solrClient = cluster.getSolrClient();
    CollectionAdminRequest.Backup backup = CollectionAdminRequest.backupCollection(collectionName, backupName).setRepositoryName(getBackupRepoName()).setIndexBackupStrategy(CollectionAdminParams.NO_INDEX_BACKUP_STRATEGY);
    backup.process(solrClient);
    Map<String, String> params = new HashMap<>();
    params.put("location", "/backup");
    params.put("solr.hdfs.home", hdfsUri + "/solr");
    HdfsBackupRepository repo = new HdfsBackupRepository();
    repo.init(new NamedList<>(params));
    BackupManager mgr = new BackupManager(repo, solrClient.getZkStateReader());
    URI baseLoc = repo.createURI("/backup");
    Properties props = mgr.readBackupProperties(baseLoc, backupName);
    assertNotNull(props);
    assertEquals(collectionName, props.getProperty(COLLECTION_NAME_PROP));
    assertEquals(backupName, props.getProperty(BACKUP_NAME_PROP));
    assertEquals(configName, props.getProperty(COLL_CONF));
    DocCollection collectionState = mgr.readCollectionState(baseLoc, backupName, collectionName);
    assertNotNull(collectionState);
    assertEquals(collectionName, collectionState.getName());
    URI configDirLoc = repo.resolve(baseLoc, backupName, ZK_STATE_DIR, CONFIG_STATE_DIR, configName);
    assertTrue(repo.exists(configDirLoc));
    Collection<String> expected = Arrays.asList(BACKUP_PROPS_FILE, ZK_STATE_DIR);
    URI backupLoc = repo.resolve(baseLoc, backupName);
    String[] dirs = repo.listAll(backupLoc);
    for (String d : dirs) {
        assertTrue(expected.contains(d));
    }
}
Also used : HashMap(java.util.HashMap) CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) HdfsBackupRepository(org.apache.solr.core.backup.repository.HdfsBackupRepository) Properties(java.util.Properties) BackupManager(org.apache.solr.core.backup.BackupManager) URI(java.net.URI) CloudSolrClient(org.apache.solr.client.solrj.impl.CloudSolrClient) DocCollection(org.apache.solr.common.cloud.DocCollection)

Aggregations

URI (java.net.URI)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)1 CollectionAdminRequest (org.apache.solr.client.solrj.request.CollectionAdminRequest)1 DocCollection (org.apache.solr.common.cloud.DocCollection)1 BackupManager (org.apache.solr.core.backup.BackupManager)1 HdfsBackupRepository (org.apache.solr.core.backup.repository.HdfsBackupRepository)1