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