Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-10087

StreamHandler should be able to use runtimeLib jars

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 6.5, 7.0
    • None
    • None

    Description

      StreamHandler currently can't uses jars that via the runtimeLib and Blob Store api. This is because the StreamHandler uses core.getResourceLoader() instead of core.getMemClassLoader() for loading classes.

      An example of this working with the fix is here: https://github.com/risdenk/solr_custom_streaming_expressions

      Steps:

      # Inspired by https://cwiki.apache.org/confluence/display/solr/Adding+Custom+Plugins+in+SolrCloud+Mode
      
      # Start Solr with enabling Blob Store
      ./bin/solr start -c -f -a "-Denable.runtime.lib=true"
      
      # Create test collection
      ./bin/solr create -c test
      
      # Create .system collection
      curl 'http://localhost:8983/solr/admin/collections?action=CREATE&name=.system'
      
      # Build custom streaming expression jar
      (cd custom-streaming-expression && mvn clean package)
      
      # Upload jar to .system collection using Blob Store API (https://cwiki.apache.org/confluence/display/solr/Blob+Store+API)
      curl -X POST -H 'Content-Type: application/octet-stream' --data-binary @custom-streaming-expression/target/custom-streaming-expression-1.0-SNAPSHOT.jar 'http://localhost:8983/solr/.system/blob/test'
      
      # List all blobs that are stored
      curl 'http://localhost:8983/solr/.system/blob?omitHeader=true'
      
      # Add the jar to the runtime lib
      curl 'http://localhost:8983/solr/test/config' -H 'Content-type:application/json' -d '{
         "add-runtimelib": { "name":"test", "version":1 }
      }'
      
      # Create custom streaming expression using work from SOLR-9103
      # Patch from SOLR-10087 is required for StreamHandler to load the runtimeLib jar
      curl 'http://localhost:8983/solr/test/config' -H 'Content-type:application/json' -d '{
        "create-expressible": {
          "name": "customstreamingexpression",
          "class": "com.test.solr.CustomStreamingExpression",
          "runtimeLib": true
        }
      }'
      
      # Test the custom streaming expression
      curl 'http://localhost:8983/solr/test/stream?expr=customstreamingexpression()'
      

      Attachments

        1. SOLR-10087.patch
          1 kB
          Kevin Risden

        Issue Links

          Activity

            People

              krisden Kevin Risden
              krisden Kevin Risden
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: