Search in sources :

Example 1 with Rules

use of com.actiontech.dble.config.loader.zkprocess.entity.Rules in project dble by actiontech.

the class UXmlRuleLoader method notifyProcess.

@Override
public void notifyProcess(UKvBean configValue) throws Exception {
    UKvBean lock = ClusterUcoreSender.getKey(UcorePathUtil.getConfChangeLockPath());
    if (UcoreConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID).equals(lock.getValue())) {
        return;
    }
    Rules rule = new Rules();
    // the config Value in ucore is an all in one json config of the schema.xml
    JSONObject jsonObj = JSONObject.parseObject(configValue.getValue());
    List<Function> functions = parseJsonFunctionService.parseJsonToBean(jsonObj.getJSONArray(UcorePathUtil.FUNCTION).toJSONString());
    rule.setFunction(functions);
    List<TableRule> tableRules = parseJsonTableRuleService.parseJsonToBean(jsonObj.getJSONArray(UcorePathUtil.TABLE_RULE).toJSONString());
    rule.setTableRule(tableRules);
    String path = ResourceUtil.getResourcePathFromRoot(UcorePathUtil.UCORE_LOCAL_WRITE_PATH);
    path = new File(path).getPath() + File.separator;
    path += WRITEPATH;
    LOGGER.info("SchemasLoader notifyProcess ucore to object writePath :" + path);
    writeMapFileAddFunction(functions);
    this.parseRulesXMl.parseToXmlWrite(rule, path, "rule");
    LOGGER.info("SchemasLoader notifyProcess ucore to object zk schema      write :" + path + " is success");
}
Also used : TableRule(com.actiontech.dble.config.loader.zkprocess.entity.rule.tablerule.TableRule) Function(com.actiontech.dble.config.loader.zkprocess.entity.rule.function.Function) JSONObject(com.alibaba.fastjson.JSONObject) UKvBean(com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean) Rules(com.actiontech.dble.config.loader.zkprocess.entity.Rules) File(java.io.File)

Example 2 with Rules

use of com.actiontech.dble.config.loader.zkprocess.entity.Rules in project dble by actiontech.

the class RuleszkToxmlLoader method zktoRulesBean.

/**
 * zktoRulesBean
 *
 * @param zkDirectory
 * @return
 * @Created 2016/9/17
 */
private Rules zktoRulesBean(DirectoryInf zkDirectory) {
    Rules rules = new Rules();
    // tablerule
    DataInf rulesZkData = this.getZkData(zkDirectory, KVPathUtil.TABLE_RULE);
    List<TableRule> tableRuleData = parseJsonTableRuleService.parseJsonToBean(rulesZkData.getDataValue());
    rules.setTableRule(tableRuleData);
    // function
    DataInf functionZkData = this.getZkData(zkDirectory, KVPathUtil.FUNCTION);
    List<Function> functionList = parseJsonFunctionService.parseJsonToBean(functionZkData.getDataValue());
    rules.setFunction(functionList);
    return rules;
}
Also used : TableRule(com.actiontech.dble.config.loader.zkprocess.entity.rule.tablerule.TableRule) Function(com.actiontech.dble.config.loader.zkprocess.entity.rule.function.Function) DataInf(com.actiontech.dble.config.loader.zkprocess.zookeeper.DataInf) Rules(com.actiontech.dble.config.loader.zkprocess.entity.Rules)

Example 3 with Rules

use of com.actiontech.dble.config.loader.zkprocess.entity.Rules in project dble by actiontech.

the class UXmlRuleLoader method notifyCluster.

@Override
public void notifyCluster() throws Exception {
    Rules rules = this.parseRulesXMl.parseXmlToBean(UcorePathUtil.UCORE_LOCAL_WRITE_PATH + WRITEPATH);
    JSONObject rule = new JSONObject();
    readMapFileAddFunction(rules.getFunction());
    rule.put(UcorePathUtil.TABLE_RULE, rules.getTableRule());
    rule.put(UcorePathUtil.FUNCTION, rules.getFunction());
    ClusterUcoreSender.sendDataToUcore(CONFIG_PATH, rule.toJSONString());
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Rules(com.actiontech.dble.config.loader.zkprocess.entity.Rules)

Example 4 with Rules

use of com.actiontech.dble.config.loader.zkprocess.entity.Rules in project dble by actiontech.

the class RuleszkToxmlLoader method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    DirectoryInf rulesDirectory = new ZkDirectoryImpl(currZkPath, null);
    this.getTreeDirectory(currZkPath, KVPathUtil.RULES, rulesDirectory);
    ZkDirectoryImpl zkDirectory = (ZkDirectoryImpl) rulesDirectory.getSubordinateInfo().get(0);
    Rules rules = this.zktoRulesBean(zkDirectory);
    LOGGER.info("RuleszkToxmlLoader notifyProcess zk to object  zk Rules Object  :" + rules);
    writeMapFileAddFunction(rules.getFunction());
    LOGGER.info("RuleszkToxmlLoader notifyProcess write mapFile is success ");
    String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey());
    path = new File(path).getPath() + File.separator;
    path = path + WRITEPATH;
    LOGGER.info("RuleszkToxmlLoader notifyProcess zk to object writePath :" + path);
    this.parseRulesXMl.parseToXmlWrite(rules, path, "rule");
    LOGGER.info("RuleszkToxmlLoader notifyProcess zk to object zk Rules      write :" + path + " is success");
    return true;
}
Also used : DirectoryInf(com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf) ZkDirectoryImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl) Rules(com.actiontech.dble.config.loader.zkprocess.entity.Rules) File(java.io.File)

Example 5 with Rules

use of com.actiontech.dble.config.loader.zkprocess.entity.Rules in project dble by actiontech.

the class RulesxmlTozkLoader method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    Rules rules = this.parseRulesXMl.parseXmlToBean(RULE_PATH);
    LOGGER.info("RulesxmlTozkLoader notifyProcess xml to zk Rules Object  :" + rules);
    this.xmlTozkRulesJson(currZkPath, rules);
    LOGGER.info("RulesxmlTozkLoader notifyProcess xml to zk is success");
    return true;
}
Also used : Rules(com.actiontech.dble.config.loader.zkprocess.entity.Rules)

Aggregations

Rules (com.actiontech.dble.config.loader.zkprocess.entity.Rules)5 Function (com.actiontech.dble.config.loader.zkprocess.entity.rule.function.Function)2 TableRule (com.actiontech.dble.config.loader.zkprocess.entity.rule.tablerule.TableRule)2 JSONObject (com.alibaba.fastjson.JSONObject)2 File (java.io.File)2 UKvBean (com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean)1 DataInf (com.actiontech.dble.config.loader.zkprocess.zookeeper.DataInf)1 DirectoryInf (com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf)1 ZkDirectoryImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl)1