Search in sources :

Example 1 with NotifyService

use of com.actiontech.dble.config.loader.zkprocess.comm.NotifyService 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)

Aggregations

NotifyService (com.actiontech.dble.config.loader.zkprocess.comm.NotifyService)1 DirectoryInf (com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf)1 ConfStatus (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ConfStatus)1 ZkDataImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)1 ZkDirectoryImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl)1