You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/11/04 16:50:55 UTC

[GitHub] [solr] gerlowskija commented on a diff in pull request #1126: SOLR-16462: Create v2 equivalent of v1 'CREATESNAPSHOT', 'LISTSNAPSHOT' and 'DELETESNAPSHOT' (core level)

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


##########
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:
   After giving this a bit more thought, it'd be a real shame to cement this behavior, which is probably a bug in any case.  If it's an unintentional bug, then it doesn't fall under Solr's standard backcompat policy: we're allowed to fix bugs after all.
   
   I started a discussion about this on the 'dev@' mailing list.  Hopefully someone else will chime in there with agreement, at which point I'm happy to go forward with the corrected syntax your PR uses.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org