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

Configuration registry: add ability to retreive distributed value

    XMLWordPrintableJSON

Details

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

    Description

      In some cases it's required to retrieve configuration distributed value. Currently we use meta storage manager interface for this purpose and cause configuration registry hides the keys the code of the distributed property retrieval looks horrible:

       

      //TODO This is an egregious violation of encapsulation. Current approach has to be revisited.
      private Set<String> tableNamesConfigured() {
          IgniteBiTuple<ByteArray, ByteArray> range = toRange(new ByteArray(PUBLIC_PREFIX));
      
          Set<String> tableNames = new HashSet<>();
      
          try (Cursor<Entry> cursor = metaStorageMgr.range(range.get1(), range.get2())) {
              while (cursor.hasNext()) {
                  Entry entry = cursor.next();
      
                  List<String> keySplit = ConfigurationUtil.split(entry.key().toString());
      
                  if (keySplit.size() == 5 && NamedListNode.NAME.equals(keySplit.get(4)))
                      tableNames.add(ByteUtils.fromBytes(entry.value()).toString());
              }
          }
          catch (Exception e) {
              LOG.error("Can't get table names.", e);
          }
      
          return tableNames;
      }
      

      Let's refactor it by adding distributedValue() (concrete name of the method is up to an implementator) to ConfigurationProperty. That will allow to simplify distributed retrieval:

      private Set<String> tableNamesConfigured() {
          return new HashSet<>(clusterCfgMgr.configurationRegistry().getConfiguration(TablesConfiguration.KEY).tables().
              distirbuteValue().namedListKeys());
      }
      

      Internally distributedValue() should fetch corresponding key->val from the meta storage without applying this value to local state updating localRoots.version etc.

       

      Attachments

        Issue Links

          Activity

            People

              apolovtcev Aleksandr Polovtsev
              alapin Alexander Lapin
              Semyon Danilov Semyon Danilov
              Votes:
              0 Vote for this issue
              Watchers:
              2 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 - 20m
                  20m