Search in sources :

Example 1 with ReloadFunction

use of io.mycat.route.function.ReloadFunction in project Mycat_plus by coderczp.

the class RuleDataPathChildrenCacheListener method reloadRuleData.

private void reloadRuleData(String name) {
    String tableName = name.substring(name.lastIndexOf("_") + 1, name.indexOf("."));
    String ruleName = name.substring(0, name.indexOf("."));
    Map<String, SchemaConfig> schemaConfigMap = MycatServer.getInstance().getConfig().getSchemas();
    for (SchemaConfig schemaConfig : schemaConfigMap.values()) {
        TableConfig tableConfig = schemaConfig.getTables().get(tableName.toUpperCase());
        if (tableConfig == null)
            continue;
        RuleConfig rule = tableConfig.getRule();
        AbstractPartitionAlgorithm function = rule.getRuleAlgorithm();
        if (function instanceof ReloadFunction) {
            ((ReloadFunction) function).reload();
        }
    }
}
Also used : AbstractPartitionAlgorithm(io.mycat.route.function.AbstractPartitionAlgorithm) ReloadFunction(io.mycat.route.function.ReloadFunction) SchemaConfig(io.mycat.config.model.SchemaConfig) TableConfig(io.mycat.config.model.TableConfig) RuleConfig(io.mycat.config.model.rule.RuleConfig)

Example 2 with ReloadFunction

use of io.mycat.route.function.ReloadFunction in project Mycat-Server by MyCATApache.

the class RuleDataPathChildrenCacheListener method reloadRuleData.

private void reloadRuleData(String name) {
    String tableName = name.substring(name.lastIndexOf("_") + 1, name.indexOf("."));
    String ruleName = name.substring(0, name.indexOf("."));
    Map<String, SchemaConfig> schemaConfigMap = MycatServer.getInstance().getConfig().getSchemas();
    for (SchemaConfig schemaConfig : schemaConfigMap.values()) {
        TableConfig tableConfig = schemaConfig.getTables().get(tableName.toUpperCase());
        if (tableConfig == null)
            continue;
        RuleConfig rule = tableConfig.getRule();
        AbstractPartitionAlgorithm function = rule.getRuleAlgorithm();
        if (function instanceof ReloadFunction) {
            ((ReloadFunction) function).reload();
        }
    }
}
Also used : AbstractPartitionAlgorithm(io.mycat.route.function.AbstractPartitionAlgorithm) ReloadFunction(io.mycat.route.function.ReloadFunction) SchemaConfig(io.mycat.config.model.SchemaConfig) TableConfig(io.mycat.config.model.TableConfig) RuleConfig(io.mycat.config.model.rule.RuleConfig)

Aggregations

SchemaConfig (io.mycat.config.model.SchemaConfig)2 TableConfig (io.mycat.config.model.TableConfig)2 RuleConfig (io.mycat.config.model.rule.RuleConfig)2 AbstractPartitionAlgorithm (io.mycat.route.function.AbstractPartitionAlgorithm)2 ReloadFunction (io.mycat.route.function.ReloadFunction)2