Jdurham2843 commented on code in PR #1126:
URL: https://github.com/apache/solr/pull/1126#discussion_r1007209747


##########
solr/core/src/java/org/apache/solr/handler/admin/CoreAdminOperation.java:
##########
@@ -278,31 +276,28 @@ public enum CoreAdminOperation implements CoreAdminOp {
       LISTSNAPSHOTS,
       it -> {
         final SolrParams params = it.req.getParams();
-        String cname = params.required().get(CoreAdminParams.CORE);
+        final String coreName = params.required().get(CoreAdminParams.CORE);
 
-        CoreContainer cc = it.handler.getCoreContainer();
+        final CoreContainer coreContainer = it.handler.getCoreContainer();
+        final SnapshotAPI snapshotAPI = new SnapshotAPI(coreContainer);
 
-        try (SolrCore core = cc.getCore(cname)) {
-          if (core == null) {
-            throw new SolrException(ErrorCode.BAD_REQUEST, "Unable to locate 
core " + cname);
-          }
+        final SnapshotAPI.ListSnapshotsResponse response = 
snapshotAPI.listSnapshots(coreName);
 
-          SolrSnapshotMetaDataManager mgr = core.getSnapshotMetaDataManager();
-          @SuppressWarnings({"rawtypes"})
-          NamedList result = new NamedList();
-          for (String name : mgr.listSnapshots()) {
-            Optional<SnapshotMetaData> metadata = 
mgr.getSnapshotMetaData(name);
-            if (metadata.isPresent()) {
-              NamedList<String> props = new NamedList<>();
-              props.add(
-                  SolrSnapshotManager.GENERATION_NUM,
-                  String.valueOf(metadata.get().getGenerationNumber()));
-              props.add(SolrSnapshotManager.INDEX_DIR_PATH, 
metadata.get().getIndexDirPath());
-              result.add(name, props);
-            }
-          }
-          it.rsp.add(SolrSnapshotManager.SNAPSHOTS_INFO, result);
+        final NamedList<Object> snapshotsResult = new NamedList<>();

Review Comment:
   I hadn't seen that method before, but that seems like the better approach! I 
refactored all three operations to use it with success on all but the v1 
ListSnapshots operation. From what I've seen, the original method returns a 
response with the following structure:
   ```
   {
        "responseHeader": {
                "status": 0,
                "QTime": 0
        },
        "snapshots": [
                "snapshot4",
                [
                        "generation",
                        "2",
                        "indexDirPath",
                        
"C:\\<redacted-path>\\solr\\solr\\packaging\\build\\dev\\example\\techproducts\\solr\\techproducts\\data\\index/"
                ],
                "snapshot3",
                [
                        "generation",
                        "2",
                        "indexDirPath",
                        
"C:\\<redacted-path>\\solr\\solr\\packaging\\build\\dev\\example\\techproducts\\solr\\techproducts\\data\\index/"
                ],
                "snapshot2",
                [
                        "generation",
                        "2",
                        "indexDirPath",
                        
"C:\\<redacted-path>\\solr\\solr\\packaging\\build\\dev\\example\\techproducts\\solr\\techproducts\\data\\index/"
                ],
                "snapshot6",
                [
                        "generation",
                        "2",
                        "indexDirPath",
                        
"C:\\<redacted-path>\\solr\\solr\\packaging\\build\\dev\\example\\techproducts\\solr\\techproducts\\data\\index/"
                ]
        ]
   }
   ```
   
   While using the squash method returns the following structure:
   ```
   {
        "responseHeader": {
                "status": 0,
                "QTime": 7
        },
        "snapshots": {
                "snapshot4": {
                        "generation": 2,
                        "indexDirPath": 
"C:\\<redacted-path>\\solr\\solr\\packaging\\build\\dev\\example\\techproducts\\solr\\techproducts\\data\\index/"
                },
                "snapshot3": {
                        "generation": 2,
                        "indexDirPath": 
"C:\\<redacted-path>\\solr\\solr\\packaging\\build\\dev\\example\\techproducts\\solr\\techproducts\\data\\index/"
                },
                "snapshot2": {
                        "generation": 2,
                        "indexDirPath": 
"C:\\<redacted-path>\\solr\\solr\\packaging\\build\\dev\\example\\techproducts\\solr\\techproducts\\data\\index/"
                },
                "snapshot6": {
                        "generation": 2,
                        "indexDirPath": 
"C:\\<redacted-path>\\solr\\solr\\packaging\\build\\dev\\example\\techproducts\\solr\\techproducts\\data\\index/"
                }
        }
   }
   ```
   
   Would the change in the structure of the response for the V1 endpoint be 
considered a breaking change that we should prevent?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to