Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-15409

Configuration registry: register listener with any placeholder on NamedConfigurationTree

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-alpha3
    • None

    Description

      Ability to add listeners with "any()" placeholder will ease the logic of registering ones.

      Let's say that we want to listen to a changes of a column type within any column of any table. Now the only option is to register type listeners from within column listeners within table listeners: 

      clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables().listenElements(
          new ConfigurationNamedListListener<TableView>() {
          @Override
          public @NotNull CompletableFuture<?> onCreate(@NotNull ConfigurationNotificationEvent<TableView> tblCtx) {
              clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables().
                  get(tblCtx.newValue().name()).columns().listenElements(
                      new ConfigurationNamedListListener<ColumnView>() {
                  @Override public @NotNull CompletableFuture<?> onCreate(
                      @NotNull ConfigurationNotificationEvent<ColumnView> columnCtx) {
                      clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables().
                          get(tblCtx.newValue().name()).columns().get(columnCtx.newValue().name()).listen((typeCtx) -> null);
                      return CompletableFuture.completedFuture(null);
                  }
              });
              return CompletableFuture.completedFuture(null);
          }
      
      

      With any placeholder it will look like much simpler:

      clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables().any().columns().
          any().type().listen(ctx -> null);
      

      Besides obvious there are at least two important points here:

      • It should be possible to retrieve full context/"full configuration locator" from the listener's context. In this particular case, type().listen(ctx -> null) should provide context of the table and the column that were changed.
      • It should be possible to remove such "any" listeners.

      Attachments

        Issue Links

          Activity

            People

              ktkalenko@gridgain.com Kirill Tkalenko
              alapin Alexander Lapin
              Ivan Bessonov Ivan Bessonov
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 3h
                  3h