You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "epugh (via GitHub)" <gi...@apache.org> on 2025/01/14 13:42:04 UTC

[PR] Migrate schema designer to filestoreapi part deux [solr]

epugh opened a new pull request, #3031:
URL: https://github.com/apache/solr/pull/3031

   https://issues.apache.org/jira/browse/SOLR-XXXXX
   
   # Description
   
   Migrate Schema Designer calls from using Blob store to FileStore
   
   # Solution
   
   Swap implementation methods.   
   
   
   # Tests
   
   So far, just using existing tests.
   
   


-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r1915959864


##########
solr/core/src/java/org/apache/solr/filestore/FileStore.java:
##########
@@ -38,8 +42,13 @@ public interface FileStore {
    */
   void put(FileEntry fileEntry) throws IOException;
 
-  /** read file content from a given path */
-  void get(String path, Consumer<FileEntry> filecontent, boolean getMissing) throws IOException;
+  /**
+   * Read file content from a given path.
+   *
+   * <p>TODO: Is fetchMissing actually used? I don't see it being used, but the IDE doesn't flag it
+   * not being used!

Review Comment:
   Lucene/Solr devs use a "nocommit" comment for something like this.  Precommit will fail so we remember to address it.  I also configure IntelliJ's "TODO" feature to consider "nocommit" and thus it shows in blood red (gets my attention)



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -494,62 +498,59 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    List<SolrInputDocument> docs = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
 
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(BLOB_STORE_ID, "blob", configSet + "_sample")
-              .setParameter(CommonParams.WT, "filestream")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
 
-    HttpGet httpGet = new HttpGet(uri);
     try {
-      HttpResponse entity =
-          ((CloudLegacySolrClient) cloudClient()).getHttpClient().execute(httpGet);
-      int statusCode = entity.getStatusLine().getStatusCode();
-      if (statusCode == HttpStatus.SC_OK) {
-        byte[] bytes = readAllBytes(() -> entity.getEntity().getContent());
-        if (bytes.length > 0) {
-          docs = (List<SolrInputDocument>) Utils.fromJavabin(bytes);
-        }
-      } else if (statusCode != HttpStatus.SC_NOT_FOUND) {
-        byte[] bytes = readAllBytes(() -> entity.getEntity().getContent());
-        throw new IOException(
-            "Failed to lookup stored docs for "
-                + configSet
-                + " due to: "
-                + new String(bytes, StandardCharsets.UTF_8));
-      } // else not found is ok
-    } finally {
-      httpGet.releaseConnection();
+      cc.getFileStore()
+          .get(
+              path,
+              entry -> {
+                try (InputStream is = entry.getInputStream()) {
+                  byte[] bytes = is.readAllBytes();
+                  if (bytes.length > 0) {
+                    docs = (List<SolrInputDocument>) Utils.fromJavabin(bytes);
+                  }
+                  // Do something with content...
+                } catch (IOException e) {
+                  log.error("Error reading file content", e);
+                }
+              },
+              true);
+    } catch (java.io.FileNotFoundException e) {

Review Comment:
   not sure why fully qualified



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -494,62 +498,59 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    List<SolrInputDocument> docs = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
 
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(BLOB_STORE_ID, "blob", configSet + "_sample")
-              .setParameter(CommonParams.WT, "filestream")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
 
-    HttpGet httpGet = new HttpGet(uri);
     try {
-      HttpResponse entity =
-          ((CloudLegacySolrClient) cloudClient()).getHttpClient().execute(httpGet);
-      int statusCode = entity.getStatusLine().getStatusCode();
-      if (statusCode == HttpStatus.SC_OK) {
-        byte[] bytes = readAllBytes(() -> entity.getEntity().getContent());
-        if (bytes.length > 0) {
-          docs = (List<SolrInputDocument>) Utils.fromJavabin(bytes);
-        }
-      } else if (statusCode != HttpStatus.SC_NOT_FOUND) {
-        byte[] bytes = readAllBytes(() -> entity.getEntity().getContent());
-        throw new IOException(
-            "Failed to lookup stored docs for "
-                + configSet
-                + " due to: "
-                + new String(bytes, StandardCharsets.UTF_8));
-      } // else not found is ok
-    } finally {
-      httpGet.releaseConnection();
+      cc.getFileStore()
+          .get(
+              path,
+              entry -> {
+                try (InputStream is = entry.getInputStream()) {
+                  byte[] bytes = is.readAllBytes();
+                  if (bytes.length > 0) {
+                    docs = (List<SolrInputDocument>) Utils.fromJavabin(bytes);
+                  }

Review Comment:
   I suggest a little comment `// TODO stream it; no byte array`



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -559,29 +560,12 @@ static byte[] readAllBytes(IOSupplier<InputStream> hasStream) throws IOException
     }
   }
 
-  protected void postDataToBlobStore(CloudSolrClient cloudClient, String blobName, byte[] bytes)
-      throws IOException {
-    final URI uri;
-    try {
-      uri = collectionApiEndpoint(BLOB_STORE_ID, "blob", blobName).build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+  protected void storeSampleDocs(String blobName, byte[] bytes) throws IOException {
+    String filePath = "blob" + "/" + blobName;
 
-    HttpPost httpPost = new HttpPost(uri);
-    try {
-      httpPost.setHeader("Content-Type", "application/octet-stream");
-      httpPost.setEntity(new ByteArrayEntity(bytes));
-      HttpResponse resp = ((CloudLegacySolrClient) cloudClient).getHttpClient().execute(httpPost);
-      int statusCode = resp.getStatusLine().getStatusCode();
-      if (statusCode != HttpStatus.SC_OK) {
-        throw new SolrException(
-            SolrException.ErrorCode.getErrorCode(statusCode),
-            EntityUtils.toString(resp.getEntity(), StandardCharsets.UTF_8));
-      }
-    } finally {
-      httpPost.releaseConnection();
-    }
+    FileStoreAPI.MetaData meta = ClusterFileStore._createJsonMetaData(bytes, null);

Review Comment:
   is the meta necessary in general for the FileStoreAPI -- 2 step?  Sad if so.



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -494,62 +498,59 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    List<SolrInputDocument> docs = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
 
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(BLOB_STORE_ID, "blob", configSet + "_sample")
-              .setParameter(CommonParams.WT, "filestream")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+    String path =
+        "blob" + "/" + configSet

Review Comment:
   Definitely.  I don't even think we should use "blob" prefix.  Maybe "schema_designer" since this is for this tool.



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -494,62 +498,59 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    List<SolrInputDocument> docs = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
 
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(BLOB_STORE_ID, "blob", configSet + "_sample")
-              .setParameter(CommonParams.WT, "filestream")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+    String path =
+        "blob" + "/" + configSet

Review Comment:
   If the format of this data is "javabin", lets name the file with that suffix.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2265419027


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -466,44 +469,62 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
+  String getSampleDocsPathFromConfigSet(String configSet) {
+    String path = "schemadesigner" + "/" + configSet + "_sampledocs.javabin";
+    return path;
+  }
+
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path = getSampleDocsPathFromConfigSet(configSet);
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    var request = new GenericSolrRequest(SolrRequest.METHOD.GET, "/blob/" + configSet + "_sample");
-    request.setRequiresCollection(true);
-    request.setResponseParser(new InputStreamResponseParser("filestream"));
-    InputStream inputStream = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
+
+    String path = getSampleDocsPathFromConfigSet(configSet);
+
     try {
-      var resp = request.process(cloudClient(), BLOB_STORE_ID).getResponse();
-      inputStream = (InputStream) resp.get("stream");
-      var bytes = inputStream.readAllBytes();
-      if (bytes.length > 0) {
-        return (List<SolrInputDocument>) Utils.fromJavabin(bytes);
-      } else return Collections.emptyList();
-    } catch (SolrServerException e) {
-      throw new IOException("Failed to lookup stored docs for " + configSet + " due to: " + e);
-    } finally {
-      IOUtils.closeQuietly(inputStream);
+      cc.getFileStore()
+          .get(
+              path,
+              entry -> {
+                try (InputStream is = entry.getInputStream()) {
+                  docs = (List<SolrInputDocument>) Utils.fromJavabin(is);
+                } catch (IOException e) {
+                  log.error("Error reading file content", e);

Review Comment:
   I couldn't quite figure out the signature handling, so I instead improved the error message and left it as is.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2250959573


##########
solr/solrj/src/java/org/apache/solr/common/util/Utils.java:
##########
@@ -215,6 +215,11 @@ public static Object fromJavabin(byte[] bytes) throws IOException {
       return jbc.unmarshal(bytes);
     }
   }
+  public static Object fromJavabin(InputStream is) throws IOException {

Review Comment:
   worth creating a JIRA to remind us about refactoring?   I wish there was a nice way for us to track refactoring opportunities...   I often discover a refactoring opportunity that is adjacent to what I am working on, and then either forget, or if I do it immediately, then it blows up the PR!



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2265419132


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -466,44 +469,62 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
+  String getSampleDocsPathFromConfigSet(String configSet) {
+    String path = "schemadesigner" + "/" + configSet + "_sampledocs.javabin";
+    return path;
+  }
+
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path = getSampleDocsPathFromConfigSet(configSet);
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();

Review Comment:
   Redoing where he is defined avoids this issue!



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on PR #3031:
URL: https://github.com/apache/solr/pull/3031#issuecomment-3170489131

   Okay, I think I'm done... I would love a review and a +1 ....


-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2265361649


##########
solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSortRandom.java:
##########
@@ -266,23 +266,26 @@ public int compare(BytesRef a, BytesRef b) {
       }
 
       // For both STRING and STRING_VAL types in Lucene 10+, the internal sorting behavior
-      // has changed and can return different types (String vs BytesRef) depending on load conditions.
-      // The manual BytesRef.compareTo() used in this test doesn't reliably match the actual Lucene sort
+      // has changed and can return different types (String vs BytesRef) depending on load
+      // conditions.
+      // The manual BytesRef.compareTo() used in this test doesn't reliably match the actual Lucene
+      // sort
       // order under all conditions.

Review Comment:
   Christos fixed this lint issue in main...



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r1914833957


##########
solr/core/src/java/org/apache/solr/filestore/DistribFileStore.java:
##########
@@ -534,7 +534,6 @@ public void refresh(String path) {
         @SuppressWarnings({"rawtypes"})
         List myFiles = list(path, s -> true);
         for (Object f : l) {
-          // TODO: https://issues.apache.org/jira/browse/SOLR-15426

Review Comment:
   @madrob you opened up this JIRA, and I *think* this TODO is incorrect or otherwise overcome by events TODO.  Regardless, it doesn't appear connected to SOLR-15426...   Can you confirm?



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2265050567


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -466,44 +469,62 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
+  String getSampleDocsPathFromConfigSet(String configSet) {
+    String path = "schemadesigner" + "/" + configSet + "_sampledocs.javabin";
+    return path;
+  }
+
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path = getSampleDocsPathFromConfigSet(configSet);
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    var request = new GenericSolrRequest(SolrRequest.METHOD.GET, "/blob/" + configSet + "_sample");
-    request.setRequiresCollection(true);
-    request.setResponseParser(new InputStreamResponseParser("filestream"));
-    InputStream inputStream = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
+
+    String path = getSampleDocsPathFromConfigSet(configSet);
+
     try {
-      var resp = request.process(cloudClient(), BLOB_STORE_ID).getResponse();
-      inputStream = (InputStream) resp.get("stream");
-      var bytes = inputStream.readAllBytes();
-      if (bytes.length > 0) {
-        return (List<SolrInputDocument>) Utils.fromJavabin(bytes);
-      } else return Collections.emptyList();
-    } catch (SolrServerException e) {
-      throw new IOException("Failed to lookup stored docs for " + configSet + " due to: " + e);
-    } finally {
-      IOUtils.closeQuietly(inputStream);
+      cc.getFileStore()
+          .get(
+              path,
+              entry -> {
+                try (InputStream is = entry.getInputStream()) {
+                  docs = (List<SolrInputDocument>) Utils.fromJavabin(is);
+                } catch (IOException e) {
+                  log.error("Error reading file content", e);

Review Comment:
   logging instead of propagating the error?  I'd think this is exception-worthy.



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -466,44 +469,62 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
+  String getSampleDocsPathFromConfigSet(String configSet) {
+    String path = "schemadesigner" + "/" + configSet + "_sampledocs.javabin";
+    return path;
+  }
+
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path = getSampleDocsPathFromConfigSet(configSet);
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();

Review Comment:
   Nowadays use `List.of()`



##########
solr/core/src/java/org/apache/solr/filestore/FileStore.java:
##########
@@ -71,12 +80,12 @@ public interface FileStore {
   /** Delete file from local file system */
   void deleteLocal(String path);
 
-  public class FileEntry {
+  class FileEntry {

Review Comment:
   record?



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -466,44 +469,62 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
+  String getSampleDocsPathFromConfigSet(String configSet) {
+    String path = "schemadesigner" + "/" + configSet + "_sampledocs.javabin";
+    return path;

Review Comment:
   just one line please



##########
solr/core/src/test/org/apache/solr/uninverting/TestFieldCacheSortRandom.java:
##########
@@ -266,23 +266,26 @@ public int compare(BytesRef a, BytesRef b) {
       }
 
       // For both STRING and STRING_VAL types in Lucene 10+, the internal sorting behavior
-      // has changed and can return different types (String vs BytesRef) depending on load conditions.
-      // The manual BytesRef.compareTo() used in this test doesn't reliably match the actual Lucene sort
+      // has changed and can return different types (String vs BytesRef) depending on load
+      // conditions.
+      // The manual BytesRef.compareTo() used in this test doesn't reliably match the actual Lucene
+      // sort
       // order under all conditions.

Review Comment:
   join lines



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerAPI.java:
##########
@@ -87,7 +87,7 @@
 public class SchemaDesignerAPI implements SchemaDesignerConstants {
 
   private static final Set<String> excludeConfigSetNames =
-      new HashSet<>(Arrays.asList(DEFAULT_CONFIGSET_NAME, BLOB_STORE_ID));
+      new HashSet<>(Arrays.asList(DEFAULT_CONFIGSET_NAME));

Review Comment:
   This should use `Set.of` as it's declared as a constant and thus needs to be immutable



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -466,44 +469,62 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
+  String getSampleDocsPathFromConfigSet(String configSet) {
+    String path = "schemadesigner" + "/" + configSet + "_sampledocs.javabin";
+    return path;
+  }
+
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path = getSampleDocsPathFromConfigSet(configSet);
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.

Review Comment:
   IMO comments of this nature should be TODO.
   I don't like this guy either.



##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -466,44 +469,62 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
+  String getSampleDocsPathFromConfigSet(String configSet) {
+    String path = "schemadesigner" + "/" + configSet + "_sampledocs.javabin";
+    return path;
+  }
+
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path = getSampleDocsPathFromConfigSet(configSet);
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    var request = new GenericSolrRequest(SolrRequest.METHOD.GET, "/blob/" + configSet + "_sample");
-    request.setRequiresCollection(true);
-    request.setResponseParser(new InputStreamResponseParser("filestream"));
-    InputStream inputStream = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
+
+    String path = getSampleDocsPathFromConfigSet(configSet);
+
     try {
-      var resp = request.process(cloudClient(), BLOB_STORE_ID).getResponse();
-      inputStream = (InputStream) resp.get("stream");
-      var bytes = inputStream.readAllBytes();
-      if (bytes.length > 0) {
-        return (List<SolrInputDocument>) Utils.fromJavabin(bytes);
-      } else return Collections.emptyList();
-    } catch (SolrServerException e) {
-      throw new IOException("Failed to lookup stored docs for " + configSet + " due to: " + e);
-    } finally {
-      IOUtils.closeQuietly(inputStream);
+      cc.getFileStore()
+          .get(
+              path,
+              entry -> {
+                try (InputStream is = entry.getInputStream()) {
+                  docs = (List<SolrInputDocument>) Utils.fromJavabin(is);
+                } catch (IOException e) {
+                  log.error("Error reading file content", e);
+                }
+              },
+              true);
+    } catch (FileNotFoundException e) {
+      log.info("File at path {} not found.", path);
     }
+
+    return docs != null ? docs : Collections.emptyList();

Review Comment:
   `List.of()` again



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2265364462


##########
solr/core/src/java/org/apache/solr/filestore/FileStore.java:
##########
@@ -71,12 +80,12 @@ public interface FileStore {
   /** Delete file from local file system */
   void deleteLocal(String path);
 
-  public class FileEntry {
+  class FileEntry {

Review Comment:
   I am giving this a stab.   Feels like it should be in it's own PR, but I'll give it a stab in this one!   We probably should convert all classes into records in one migration versus piece meal, but I can five it a stab.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2265364817


##########
solr/core/src/java/org/apache/solr/filestore/FileStore.java:
##########
@@ -71,12 +80,12 @@ public interface FileStore {
   /** Delete file from local file system */
   void deleteLocal(String path);
 
-  public class FileEntry {
+  class FileEntry {

Review Comment:
   this started changing some other things, so I'm going to skip the Record conversion for now.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2250403098


##########
solr/solrj/src/java/org/apache/solr/common/util/Utils.java:
##########
@@ -215,6 +215,11 @@ public static Object fromJavabin(byte[] bytes) throws IOException {
       return jbc.unmarshal(bytes);
     }
   }
+  public static Object fromJavabin(InputStream is) throws IOException {

Review Comment:
   I see you are just adding another overload... but Utils classes can be a disappointed dumping ground of orphans that ought to find better homes.  In this case, the right home is obviously JavaBinCodec.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2250404252


##########
solr/solrj/src/java/org/apache/solr/common/util/Utils.java:
##########
@@ -215,6 +215,11 @@ public static Object fromJavabin(byte[] bytes) throws IOException {
       return jbc.unmarshal(bytes);
     }
   }
+  public static Object fromJavabin(InputStream is) throws IOException {

Review Comment:
   assuming this PR just adds them here then it's fine but it'd be nice if 10.0 could move these.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2250108350


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -494,62 +498,59 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    List<SolrInputDocument> docs = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
 
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(BLOB_STORE_ID, "blob", configSet + "_sample")
-              .setParameter(CommonParams.WT, "filestream")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
 
-    HttpGet httpGet = new HttpGet(uri);
     try {
-      HttpResponse entity =
-          ((CloudLegacySolrClient) cloudClient()).getHttpClient().execute(httpGet);
-      int statusCode = entity.getStatusLine().getStatusCode();
-      if (statusCode == HttpStatus.SC_OK) {
-        byte[] bytes = readAllBytes(() -> entity.getEntity().getContent());
-        if (bytes.length > 0) {
-          docs = (List<SolrInputDocument>) Utils.fromJavabin(bytes);
-        }
-      } else if (statusCode != HttpStatus.SC_NOT_FOUND) {
-        byte[] bytes = readAllBytes(() -> entity.getEntity().getContent());
-        throw new IOException(
-            "Failed to lookup stored docs for "
-                + configSet
-                + " due to: "
-                + new String(bytes, StandardCharsets.UTF_8));
-      } // else not found is ok
-    } finally {
-      httpGet.releaseConnection();
+      cc.getFileStore()
+          .get(
+              path,
+              entry -> {
+                try (InputStream is = entry.getInputStream()) {
+                  byte[] bytes = is.readAllBytes();
+                  if (bytes.length > 0) {
+                    docs = (List<SolrInputDocument>) Utils.fromJavabin(bytes);
+                  }

Review Comment:
   I think I figured this out, and the tests pass...



-- 
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


Re: [PR] SOLR-17852: Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh merged PR #3031:
URL: https://github.com/apache/solr/pull/3031


-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r1914833957


##########
solr/core/src/java/org/apache/solr/filestore/DistribFileStore.java:
##########
@@ -534,7 +534,6 @@ public void refresh(String path) {
         @SuppressWarnings({"rawtypes"})
         List myFiles = list(path, s -> true);
         for (Object f : l) {
-          // TODO: https://issues.apache.org/jira/browse/SOLR-15426

Review Comment:
   @madrob you opened up this JIRA, and I *think* this TODO is incorrect or otherwise overcome by events.  Regardless, it doesn't appear connected to SOLR-15426...   Can you confirm?



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "madrob (via GitHub)" <gi...@apache.org>.
madrob commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r1915252465


##########
solr/core/src/java/org/apache/solr/filestore/DistribFileStore.java:
##########
@@ -534,7 +534,6 @@ public void refresh(String path) {
         @SuppressWarnings({"rawtypes"})
         List myFiles = list(path, s -> true);
         for (Object f : l) {
-          // TODO: https://issues.apache.org/jira/browse/SOLR-15426

Review Comment:
   I think it was actually related to SOLR-15385, I must have made a copy/paste error here. Reading my comments and surface-level tracing the code suggests that this is still an issue.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on PR #3031:
URL: https://github.com/apache/solr/pull/3031#issuecomment-2589942671

   Progress so far @gerlowskija ....


-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #3031:
URL: https://github.com/apache/solr/pull/3031#issuecomment-2590329199

   Looks good to me so far.  I notice this is still "Draft"; curious what else is remaining here?


-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2254420611


##########
solr/solrj/src/java/org/apache/solr/common/util/Utils.java:
##########
@@ -215,6 +215,11 @@ public static Object fromJavabin(byte[] bytes) throws IOException {
       return jbc.unmarshal(bytes);
     }
   }
+  public static Object fromJavabin(InputStream is) throws IOException {

Review Comment:
   Up to you.  It's not a big deal.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2250101353


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -559,29 +560,12 @@ static byte[] readAllBytes(IOSupplier<InputStream> hasStream) throws IOException
     }
   }
 
-  protected void postDataToBlobStore(CloudSolrClient cloudClient, String blobName, byte[] bytes)
-      throws IOException {
-    final URI uri;
-    try {
-      uri = collectionApiEndpoint(BLOB_STORE_ID, "blob", blobName).build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+  protected void storeSampleDocs(String blobName, byte[] bytes) throws IOException {
+    String filePath = "blob" + "/" + blobName;
 
-    HttpPost httpPost = new HttpPost(uri);
-    try {
-      httpPost.setHeader("Content-Type", "application/octet-stream");
-      httpPost.setEntity(new ByteArrayEntity(bytes));
-      HttpResponse resp = ((CloudLegacySolrClient) cloudClient).getHttpClient().execute(httpPost);
-      int statusCode = resp.getStatusLine().getStatusCode();
-      if (statusCode != HttpStatus.SC_OK) {
-        throw new SolrException(
-            SolrException.ErrorCode.getErrorCode(statusCode),
-            EntityUtils.toString(resp.getEntity(), StandardCharsets.UTF_8));
-      }
-    } finally {
-      httpPost.releaseConnection();
-    }
+    FileStoreAPI.MetaData meta = ClusterFileStore._createJsonMetaData(bytes, null);

Review Comment:
   tried nulling it out, and i got errors...



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r1915099312


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -494,62 +498,59 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    List<SolrInputDocument> docs = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
 
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(BLOB_STORE_ID, "blob", configSet + "_sample")
-              .setParameter(CommonParams.WT, "filestream")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+    String path =
+        "blob" + "/" + configSet

Review Comment:
   [0] Might be nice to make the "blob/" bit here and other similar path segments constants, that can be reused on both the storage and retrieval side of this helper code.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r1922581308


##########
solr/core/src/java/org/apache/solr/filestore/DistribFileStore.java:
##########
@@ -534,7 +534,6 @@ public void refresh(String path) {
         @SuppressWarnings({"rawtypes"})
         List myFiles = list(path, s -> true);
         for (Object f : l) {
-          // TODO: https://issues.apache.org/jira/browse/SOLR-15426

Review Comment:
   I think what I am hearing is that I should update the JIRA that we are pointing to, but otherwise KEEP the todo.



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on PR #3031:
URL: https://github.com/apache/solr/pull/3031#issuecomment-3148584610

   Finally go this up to date with main, I still need to look at some of the comments in here.  One thing I would love eyes on is my change in `DistribFileStore`.


-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2250108435


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -494,62 +498,59 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.
+  List<SolrInputDocument> docs = Collections.emptyList();
+
   @SuppressWarnings("unchecked")
-  List<SolrInputDocument> getStoredSampleDocs(final String configSet) throws IOException {
-    List<SolrInputDocument> docs = null;
+  List<SolrInputDocument> retrieveSampleDocs(final String configSet) throws IOException {
 
-    final URI uri;
-    try {
-      uri =
-          collectionApiEndpoint(BLOB_STORE_ID, "blob", configSet + "_sample")
-              .setParameter(CommonParams.WT, "filestream")
-              .build();
-    } catch (URISyntaxException e) {
-      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
-    }
+    String path =
+        "blob" + "/" + configSet
+            + "_sample"; //  needs to be made unique to support multiple uploads.  Maybe hash the
+    // docs?
 
-    HttpGet httpGet = new HttpGet(uri);
     try {
-      HttpResponse entity =
-          ((CloudLegacySolrClient) cloudClient()).getHttpClient().execute(httpGet);
-      int statusCode = entity.getStatusLine().getStatusCode();
-      if (statusCode == HttpStatus.SC_OK) {
-        byte[] bytes = readAllBytes(() -> entity.getEntity().getContent());
-        if (bytes.length > 0) {
-          docs = (List<SolrInputDocument>) Utils.fromJavabin(bytes);
-        }
-      } else if (statusCode != HttpStatus.SC_NOT_FOUND) {
-        byte[] bytes = readAllBytes(() -> entity.getEntity().getContent());
-        throw new IOException(
-            "Failed to lookup stored docs for "
-                + configSet
-                + " due to: "
-                + new String(bytes, StandardCharsets.UTF_8));
-      } // else not found is ok
-    } finally {
-      httpGet.releaseConnection();
+      cc.getFileStore()
+          .get(
+              path,
+              entry -> {
+                try (InputStream is = entry.getInputStream()) {
+                  byte[] bytes = is.readAllBytes();
+                  if (bytes.length > 0) {
+                    docs = (List<SolrInputDocument>) Utils.fromJavabin(bytes);
+                  }
+                  // Do something with content...
+                } catch (IOException e) {
+                  log.error("Error reading file content", e);
+                }
+              },
+              true);
+    } catch (java.io.FileNotFoundException e) {

Review Comment:
   fixed...



-- 
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


Re: [PR] Migrate schema designer to filestoreapi part deux [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on code in PR #3031:
URL: https://github.com/apache/solr/pull/3031#discussion_r2265371587


##########
solr/core/src/java/org/apache/solr/handler/designer/SchemaDesignerConfigSetHelper.java:
##########
@@ -466,44 +469,62 @@ protected void validateTypeChange(String configSet, SchemaField field, FieldType
           SolrException.ErrorCode.BAD_REQUEST,
           "Cannot change type of the _version_ field; it must be a plong.");
     }
-    List<SolrInputDocument> docs = getStoredSampleDocs(configSet);
+    List<SolrInputDocument> docs = retrieveSampleDocs(configSet);
     if (!docs.isEmpty()) {
       schemaSuggester.validateTypeChange(field, toType, docs);
     }
   }
 
+  String getSampleDocsPathFromConfigSet(String configSet) {
+    String path = "schemadesigner" + "/" + configSet + "_sampledocs.javabin";
+    return path;
+  }
+
   void deleteStoredSampleDocs(String configSet) {
-    try {
-      cloudClient().deleteByQuery(BLOB_STORE_ID, "id:" + configSet + "_sample/*", 10);
-    } catch (IOException | SolrServerException | SolrException exc) {
-      final String excStr = exc.toString();
-      log.warn("Failed to delete sample docs from blob store for {} due to: {}", configSet, excStr);
-    }
+    String path = getSampleDocsPathFromConfigSet(configSet);
+    // why do I have to do this in two stages?
+    DistribFileStore.deleteZKFileEntry(cc.getZkController().getZkClient(), path);
+    cc.getFileStore().delete(path);
   }
 
+  // I don't like this guy just hanging out here to support retrieveSampleDocs.

Review Comment:
   I made him local to the method, and followed the refactoring suggestion that INtelliJ gave me.



-- 
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