Пример #1
0
  private void readModules(Config modulesConfig) {
    List<? extends ConfigObject> modulesConfigObjectList = modulesConfig.getObjectList("modules");

    for (ConfigObject o : modulesConfigObjectList) {
      ConfigObjectWrapper w = new ConfigObjectWrapper(o);
      modules.add(
          new Module(
              w.stringValue("name"), w.stringValue("namespace"), w.stringValue("shard-strategy")));
    }
  }
Пример #2
0
  private void readModuleShards(Config moduleShardsConfig) {
    List<? extends ConfigObject> moduleShardsConfigObjectList =
        moduleShardsConfig.getObjectList("module-shards");

    for (ConfigObject moduleShardConfigObject : moduleShardsConfigObjectList) {

      String moduleName = moduleShardConfigObject.get("name").unwrapped().toString();

      List<? extends ConfigObject> shardsConfigObjectList =
          moduleShardConfigObject.toConfig().getObjectList("shards");

      List<Shard> shards = new ArrayList<>();

      for (ConfigObject shard : shardsConfigObjectList) {
        String shardName = shard.get("name").unwrapped().toString();
        List<String> replicas = shard.toConfig().getStringList("replicas");
        shards.add(new Shard(shardName, replicas));
      }

      this.moduleShards.add(new ModuleShard(moduleName, shards));
    }
  }