Solr
  1. Solr
  2. SOLR-605

Programatically register SolrEventListeners

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
      None

      Description

      Currently all eventListeners need to be registered via solrconfig.xml – it would be nice to programatically register classes for these events too.

      1. SOLR-605.patch
        2 kB
        Noble Paul
      2. SOLR-605-RegisterEventListeners.patch
        1 kB
        Ryan McKinley

        Issue Links

          Activity

          Hide
          Ryan McKinley added a comment -

          this adds

          UpdateHandler.java:
            void registerCommitCallback( SolrEventListener listener )
            void registerOptimizeCallback( SolrEventListener listener )
          
          SolrCore.java:
            void registerFirstSearcherListener( SolrEventListener listener )
            void registerNewSearcherListener( SolrEventListener listener )
          
          
          Show
          Ryan McKinley added a comment - this adds UpdateHandler.java: void registerCommitCallback( SolrEventListener listener ) void registerOptimizeCallback( SolrEventListener listener ) SolrCore.java: void registerFirstSearcherListener( SolrEventListener listener ) void registerNewSearcherListener( SolrEventListener listener )
          Hide
          Noble Paul added a comment - - edited

          add a method to register response writer

          SolrCore.java
          public void registerResponseWriter(String name, QueryResponseWriter writer)
          
          Show
          Noble Paul added a comment - - edited add a method to register response writer SolrCore.java public void registerResponseWriter( String name, QueryResponseWriter writer)
          Hide
          Noble Paul added a comment -

          registerResponseWriter() method added to SolrCore

          Show
          Noble Paul added a comment - registerResponseWriter() method added to SolrCore
          Hide
          Yonik Seeley added a comment -

          I think there may be some thread safety issues here wrt commitCallbacks and optimizeCallbacks that could result in a concurrent modification exception if these new APIs are used concurrently with indexing.

          Show
          Yonik Seeley added a comment - I think there may be some thread safety issues here wrt commitCallbacks and optimizeCallbacks that could result in a concurrent modification exception if these new APIs are used concurrently with indexing.
          Hide
          Ryan McKinley added a comment -

          true – likewise with SOLR-619 – however all these calls will be safe within inform( SolrCore ) for SolrCoreAware classes.

          Options I see:
          1. add javadoc comments saying "not threadsafe, intended for use in inform()"
          2. change implementations from HashMap -> ConcurrentHashMap & List -> Collections.synchronized()
          3. (bad) remove the functionality

          Is there any way for an arbitrary thread (say in a RequestHandler) to block indexing? If so, this could be offered as an option in addition to #1 for the rare event where you need to modify the listeners/schema after startup.

          Show
          Ryan McKinley added a comment - true – likewise with SOLR-619 – however all these calls will be safe within inform( SolrCore ) for SolrCoreAware classes. Options I see: 1. add javadoc comments saying "not threadsafe, intended for use in inform()" 2. change implementations from HashMap -> ConcurrentHashMap & List -> Collections.synchronized() 3. (bad) remove the functionality Is there any way for an arbitrary thread (say in a RequestHandler) to block indexing? If so, this could be offered as an option in addition to #1 for the rare event where you need to modify the listeners/schema after startup.
          Hide
          Yonik Seeley added a comment -

          1. add javadoc comments saying "not threadsafe, intended for use in inform()"

          Since these are new methods, I think this is probably the right approach. It allows extensions to modify the schema w/o opening up the can of worms of a mutable IndexSchema.

          Show
          Yonik Seeley added a comment - 1. add javadoc comments saying "not threadsafe, intended for use in inform()" Since these are new methods, I think this is probably the right approach. It allows extensions to modify the schema w/o opening up the can of worms of a mutable IndexSchema.
          Hide
          Ryan McKinley added a comment -

          w/o opening up the can of worms of a mutable IndexSchema

          I'm afraid that can of worms has been open (at least) since solr 1.1

            public Map<String,SchemaField> getFields() { return fields; }
            public Map<String,FieldType> getFieldTypes() { return fieldTypes; }
          
          Show
          Ryan McKinley added a comment - w/o opening up the can of worms of a mutable IndexSchema I'm afraid that can of worms has been open (at least) since solr 1.1 public Map< String ,SchemaField> getFields() { return fields; } public Map< String ,FieldType> getFieldTypes() { return fieldTypes; }
          Hide
          Yonik Seeley added a comment -

          I'm afraid that can of worms has been open (at least) since solr 1.1

          Nah... just the lack of javadoc that they shouldn't be modified.

          Show
          Yonik Seeley added a comment - I'm afraid that can of worms has been open (at least) since solr 1.1 Nah... just the lack of javadoc that they shouldn't be modified.
          Hide
          Ryan McKinley added a comment -

          check the existing javadocs

          Provides direct access to the Map containing all Field Types in the index, keyed on fild type name.

          Modifying this Map (or any item in it) will affect the real schema

          Show
          Ryan McKinley added a comment - check the existing javadocs Provides direct access to the Map containing all Field Types in the index, keyed on fild type name. Modifying this Map (or any item in it) will affect the real schema
          Hide
          Ryan McKinley added a comment -

          but yes, I agree – these just need more clarification when you can modify them

          Show
          Ryan McKinley added a comment - but yes, I agree – these just need more clarification when you can modify them

            People

            • Assignee:
              Ryan McKinley
              Reporter:
              Ryan McKinley
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development