Search in sources :

Example 1 with DirectoryInf

use of com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf in project dble by actiontech.

the class ConfigStatusListener method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    if (DbleServer.getInstance().getFrontProcessors() != null) {
        DirectoryInf statusDirectory = new ZkDirectoryImpl(currZkPath, null);
        this.getTreeDirectory(currZkPath, KVPathUtil.CONF_STATUS, statusDirectory);
        ZkDataImpl zkData = (ZkDataImpl) statusDirectory.getSubordinateInfo().get(0);
        ConfStatus status = new ConfStatus(zkData.getValue());
        if (status.getFrom().equals(ZkConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID))) {
            // self node
            return true;
        }
        LOGGER.info("ConfigStatusListener notifyProcess zk to object  :" + status);
        if (status.getStatus() == ConfStatus.Status.ROLLBACK) {
            try {
                RollbackConfig.rollback();
                ZKUtils.createTempNode(KVPathUtil.getConfStatusPath(), ZkConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID), SUCCESS.getBytes(StandardCharsets.UTF_8));
            } catch (Exception e) {
                String errorinfo = e.getMessage() == null ? e.toString() : e.getMessage();
                ZKUtils.createTempNode(KVPathUtil.getConfStatusPath(), ZkConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID), errorinfo.getBytes(StandardCharsets.UTF_8));
            }
            return true;
        }
        for (NotifyService service : childService) {
            try {
                service.notifyProcess();
            } catch (Exception e) {
                LOGGER.warn(AlarmCode.CORE_ZK_WARN + "ConfigStatusListener notify  error :" + service + " ,Exception info:", e);
            }
        }
        try {
            if (status.getStatus() == ConfStatus.Status.RELOAD_ALL) {
                ReloadConfig.reloadAll(Integer.parseInt(status.getParams()));
            } else {
                ReloadConfig.reload();
            }
            ZKUtils.createTempNode(KVPathUtil.getConfStatusPath(), ZkConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID), SUCCESS.getBytes(StandardCharsets.UTF_8));
        } catch (Exception e) {
            String errorinfo = e.getMessage() == null ? e.toString() : e.getMessage();
            ZKUtils.createTempNode(KVPathUtil.getConfStatusPath(), ZkConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID), errorinfo.getBytes(StandardCharsets.UTF_8));
        }
    }
    return true;
}
Also used : ConfStatus(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ConfStatus) DirectoryInf(com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf) ZkDirectoryImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl) NotifyService(com.actiontech.dble.config.loader.zkprocess.comm.NotifyService) ZkDataImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)

Example 2 with DirectoryInf

use of com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf in project dble by actiontech.

the class EcacheszkToxmlLoader method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    DirectoryInf rulesDirectory = new ZkDirectoryImpl(currZkPath, null);
    this.getTreeDirectory(currZkPath, KVPathUtil.CACHE, rulesDirectory);
    ZkDirectoryImpl zkDirectory = (ZkDirectoryImpl) rulesDirectory.getSubordinateInfo().get(0);
    zktoEhcacheWrite(zkDirectory);
    LOGGER.info("EcacheszkToxmlLoader notifyProcess   zk ehcache write success ");
    return true;
}
Also used : DirectoryInf(com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf) ZkDirectoryImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl)

Example 3 with DirectoryInf

use of com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf in project dble by actiontech.

the class ServerzkToxmlLoader method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    DirectoryInf serverDirectory = new ZkDirectoryImpl(currZkPath, null);
    this.getTreeDirectory(currZkPath, KVPathUtil.SERVER, serverDirectory);
    ZkDirectoryImpl zkDirectory = (ZkDirectoryImpl) serverDirectory.getSubordinateInfo().get(0);
    Server server = this.zktoServerBean(zkDirectory);
    LOGGER.info("ServerzkToxmlLoader notifyProcess zk to object  zk server Object  :" + server);
    String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey());
    path = new File(path).getPath() + File.separator;
    path += WRITEPATH;
    LOGGER.info("ServerzkToxmlLoader notifyProcess zk to object writePath :" + path);
    this.parseServerXMl.parseToXmlWrite(server, path, "server");
    LOGGER.info("ServerzkToxmlLoader notifyProcess zk to object zk server      write :" + path + " is success");
    return true;
}
Also used : Server(com.actiontech.dble.config.loader.zkprocess.entity.Server) DirectoryInf(com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf) ZkDirectoryImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl) File(java.io.File)

Example 4 with DirectoryInf

use of com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf 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 DirectoryInf

use of com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf in project dble by actiontech.

the class SchemaszkToxmlLoader method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    DirectoryInf schemaDirectory = new ZkDirectoryImpl(currZkPath, null);
    this.getTreeDirectory(currZkPath, KVPathUtil.SCHEMA, schemaDirectory);
    ZkDirectoryImpl zkDirectory = (ZkDirectoryImpl) schemaDirectory.getSubordinateInfo().get(0);
    Schemas schema = this.zktoSchemasBean(zkDirectory);
    LOGGER.info("SchemasLoader notifyProcess zk to object  zk schema Object  :" + schema);
    String path = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey());
    path = new File(path).getPath() + File.separator;
    path += WRITEPATH;
    LOGGER.info("SchemasLoader notifyProcess zk to object writePath :" + path);
    this.parseSchemaXmlService.parseToXmlWrite(schema, path, "schema");
    LOGGER.info("SchemasLoader notifyProcess zk to object zk schema      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) Schemas(com.actiontech.dble.config.loader.zkprocess.entity.Schemas) File(java.io.File)

Aggregations

DirectoryInf (com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf)8 ZkDirectoryImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl)7 File (java.io.File)3 ZkDataImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)2 NotifyService (com.actiontech.dble.config.loader.zkprocess.comm.NotifyService)1 Rules (com.actiontech.dble.config.loader.zkprocess.entity.Rules)1 Schemas (com.actiontech.dble.config.loader.zkprocess.entity.Schemas)1 Server (com.actiontech.dble.config.loader.zkprocess.entity.Server)1 BinlogPause (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.BinlogPause)1 ConfStatus (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ConfStatus)1