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

CoreContainer level custom requesthandlers

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 8.6
    • packages
    • None

    Description

      caveats:

      • The class should be annotated with  org.apache.solr.api.EndPoint. Which means only V2 APIs are supported
      • The path should have prefix /api/plugin

      add a plugin

      curl -X POST -H 'Content-type:application/json' --data-binary '
      {
        "add": {
        "name":"myplugin",
        "class": "full.ClassName", 
        "path-prefix" : "some-path-prefix"    
        }
      }' http://localhost:8983/api/cluster/plugins
      

      add a plugin from a package

      curl -X POST -H 'Content-type:application/json' --data-binary '
      {
        "add": {
        "name":"myplugin", 
        "class": "pkgName:full.ClassName" ,
        "path-prefix" : "some-path-prefix"  ,  
        "version: "1.0"   
        }
      }' http://localhost:8983/api/cluster/plugins
      

      remove a plugin

      curl -X POST -H 'Content-type:application/json' --data-binary '
      {
        "remove": "myplugin"
      }' http://localhost:8983/api/cluster/plugins
      

      The configuration will be stored in the clusterprops.json
      as

      {
      "plugins" : {
      "myplugin" : {"class": "full.ClassName", "path-prefix" : "some-path-prefix" }
      }
      }
      

      example plugin

      public class MyPlugin {
      
        private final CoreContainer coreContainer;
      
        public MyPlugin(CoreContainer coreContainer) {
          this.coreContainer = coreContainer;
        }
      
      
        @EndPoint(path = "/$path-prefix/path1",
          method = METHOD.GET,
          permission = READ)
        public void call(SolrQueryRequest req, SolrQueryResponse rsp){
          rsp.add("myplugin.version", "2.0");
        }
      }
      

      This plugin will be accessible on all nodes at /api/some-path-prefix/path1. It's possible to add more methods at different paths. Ensure that all paths start with $path-prefix because that is the prefix in which the plugin is registered with. So /some-path-prefix/path2 , /some-path-prefix/my/deeply/nested/path are all valid paths. 

      It's possible that the user chooses to register the plugin with a different name. In that case , use a template variable as follows in paths /cluster/some/other/path

      Attachments

        1. 670.zip
          18 kB
          Erick Erickson
        2. 555.zip
          17 kB
          Erick Erickson
        3. 291.zip
          18 kB
          Erick Erickson

        Issue Links

          Activity

            People

              noble.paul Noble Paul
              noble.paul Noble Paul
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 5h 40m
                  5h 40m