[ 
https://issues.apache.org/jira/browse/SOLR-4503?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Steve Rowe updated SOLR-4503:
-----------------------------

    Attachment: SOLR-4503.patch

{quote}
Also related: SOLR-4210
We should aim for being able to hit any node in the cluster w/o worrying about 
which nodes are hosting which collections.
{quote}

I set up a cluster with two collections with different configurations so I 
could easily verify I was getting responses from the right collection.  Turns 
out that the schema info GET requests were being converted into POST requests 
as a side-effect of calling {{con.getOutputStream()}} in 
{{SolrDispatchFilter.remoteQuery()}}, and failing as a result.  In the patch 
snippet below, which is included in the attached patch, I skip forwarding the 
request body unless the original request's method is POST: 

{code:java}
@@ -353,13 +365,17 @@
       try {
         con.connect();
 
-        InputStream is = req.getInputStream();
-        OutputStream os = con.getOutputStream();
-        try {
-          IOUtils.copyLarge(is, os);
-        } finally {
-          IOUtils.closeQuietly(os);
-          IOUtils.closeQuietly(is);  // TODO: I thought we weren't supposed to 
explicitly close servlet streams
+        InputStream is;
+        OutputStream os;
+        if ("POST".equals(req.getMethod())) {
+          is = req.getInputStream();
+          os = con.getOutputStream(); // side effect: method is switched to 
POST
+          try {
+            IOUtils.copyLarge(is, os);
+          } finally {
+            IOUtils.closeQuietly(os);
+            IOUtils.closeQuietly(is);  // TODO: I thought we weren't supposed 
to explicitly close servlet streams
+          }
         }
         
         resp.setStatus(con.getResponseCode());
{code}

The patch also contains some fixed tests for the schema REST API (I didn't 
update the tests after I removed printing of copyField maxChars when it's zero).

'ant test' under Solr passes, as does 'ant precommit'.

If there are no objections, I'll commit this form of the patch in a day or so.
                
> Add REST API methods to get schema information: fields, dynamicFields, 
> fieldTypes, and copyFields
> -------------------------------------------------------------------------------------------------
>
>                 Key: SOLR-4503
>                 URL: https://issues.apache.org/jira/browse/SOLR-4503
>             Project: Solr
>          Issue Type: Sub-task
>          Components: Schema and Analysis
>    Affects Versions: 4.1
>            Reporter: Steve Rowe
>            Assignee: Steve Rowe
>             Fix For: 4.2
>
>         Attachments: all.dynamic.fields.json, all.dynamic.fields.json, 
> all.fields.json, all.fields.json, all.field.types.json, all.field.types.json, 
> coordinate.dynamic.field.json, coordinate.dynamic.field.json, 
> copyfields.json, date.field.type.json, date.field.type.json, 
> price.field.json, price.field.json, SOLR-4503.patch, SOLR-4503.patch, 
> SOLR-4503.patch, SOLR-4503.patch
>
>
> Add REST methods that provide properties for fields, dynamicFields, 
> fieldTypes, and copyFields, using paths:
> /solr/(corename)/schema/fields
> /solr/(corename)/schema/fields/fieldname
> /solr/(corename)/schema/dynamicfields
> /solr/(corename)/schema/dynamicfields/pattern
> /solr/(corename)/schema/fieldtypes
> /solr/(corename)/schema/fieldtypes/typename 
> /solr/(corename)/schema/copyfields

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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

Reply via email to