use of org.apache.solr.client.solrj.request.CoreAdminRequest.ListSnapshots in project lucene-solr by apache.
the class TestSolrCloudSnapshots method listCollectionSnapshots.
private Collection<CollectionSnapshotMetaData> listCollectionSnapshots(SolrClient adminClient, String collectionName) throws Exception {
CollectionAdminRequest.ListSnapshots listSnapshots = new CollectionAdminRequest.ListSnapshots(collectionName);
CollectionAdminResponse resp = listSnapshots.process(adminClient);
assertTrue(resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO) instanceof NamedList);
NamedList apiResult = (NamedList) resp.getResponse().get(SolrSnapshotManager.SNAPSHOTS_INFO);
Collection<CollectionSnapshotMetaData> result = new ArrayList<>();
for (int i = 0; i < apiResult.size(); i++) {
result.add(new CollectionSnapshotMetaData((NamedList<Object>) apiResult.getVal(i)));
}
return result;
}
use of org.apache.solr.client.solrj.request.CoreAdminRequest.ListSnapshots in project lucene-solr by apache.
the class TestSolrCloudSnapshots method listCoreSnapshots.
private Collection<SnapshotMetaData> listCoreSnapshots(SolrClient adminClient, String coreName) throws Exception {
ListSnapshots req = new ListSnapshots();
req.setCoreName(coreName);
NamedList resp = adminClient.request(req);
assertTrue(resp.get(SolrSnapshotManager.SNAPSHOTS_INFO) instanceof NamedList);
NamedList apiResult = (NamedList) resp.get(SolrSnapshotManager.SNAPSHOTS_INFO);
List<SnapshotMetaData> result = new ArrayList<>(apiResult.size());
for (int i = 0; i < apiResult.size(); i++) {
String commitName = apiResult.getName(i);
String indexDirPath = (String) ((NamedList) apiResult.get(commitName)).get(SolrSnapshotManager.INDEX_DIR_PATH);
long genNumber = Long.parseLong((String) ((NamedList) apiResult.get(commitName)).get(SolrSnapshotManager.GENERATION_NUM));
result.add(new SnapshotMetaData(commitName, indexDirPath, genNumber));
}
return result;
}
use of org.apache.solr.client.solrj.request.CoreAdminRequest.ListSnapshots in project lucene-solr by apache.
the class TestSolrCoreSnapshots method deleteSnapshot.
private void deleteSnapshot(SolrClient adminClient, String coreName, String commitName) throws Exception {
DeleteSnapshot req = new DeleteSnapshot(commitName);
req.setCoreName(coreName);
adminClient.request(req);
Collection<SnapshotMetaData> snapshots = listSnapshots(adminClient, coreName);
assertFalse(snapshots.stream().filter(x -> commitName.equals(x.getName())).findFirst().isPresent());
}
use of org.apache.solr.client.solrj.request.CoreAdminRequest.ListSnapshots in project lucene-solr by apache.
the class TestSolrCoreSnapshots method createSnapshot.
private SnapshotMetaData createSnapshot(SolrClient adminClient, String coreName, String commitName) throws Exception {
CreateSnapshot req = new CreateSnapshot(commitName);
req.setCoreName(coreName);
adminClient.request(req);
Collection<SnapshotMetaData> snapshots = listSnapshots(adminClient, coreName);
Optional<SnapshotMetaData> metaData = snapshots.stream().filter(x -> commitName.equals(x.getName())).findFirst();
assertTrue(metaData.isPresent());
return metaData.get();
}
use of org.apache.solr.client.solrj.request.CoreAdminRequest.ListSnapshots in project lucene-solr by apache.
the class TestSolrCoreSnapshots method listSnapshots.
private Collection<SnapshotMetaData> listSnapshots(SolrClient adminClient, String coreName) throws Exception {
ListSnapshots req = new ListSnapshots();
req.setCoreName(coreName);
NamedList resp = adminClient.request(req);
assertTrue(resp.get("snapshots") instanceof NamedList);
NamedList apiResult = (NamedList) resp.get("snapshots");
List<SnapshotMetaData> result = new ArrayList<>(apiResult.size());
for (int i = 0; i < apiResult.size(); i++) {
String commitName = apiResult.getName(i);
String indexDirPath = (String) ((NamedList) apiResult.get(commitName)).get("indexDirPath");
long genNumber = Long.parseLong((String) ((NamedList) apiResult.get(commitName)).get("generation"));
result.add(new SnapshotMetaData(commitName, indexDirPath, genNumber));
}
return result;
}
Aggregations