Search in sources :

Example 6 with BinlogPause

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

the class BinlogPauseStatusListener method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    DirectoryInf statusDirectory = new ZkDirectoryImpl(currZkPath, null);
    this.getTreeDirectory(currZkPath, KVPathUtil.BINLOG_PAUSE_STATUS, statusDirectory);
    ZkDataImpl zkDdata = (ZkDataImpl) statusDirectory.getSubordinateInfo().get(0);
    String strPauseInfo = zkDdata.getDataValue();
    LOGGER.info("BinlogPauseStatusListener notifyProcess zk to object  :" + strPauseInfo);
    BinlogPause pauseInfo = new BinlogPause(strPauseInfo);
    String myID = ZkConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID);
    if (pauseInfo.getFrom().equals(myID)) {
        // self node
        return true;
    }
    String instancePath = ZKPaths.makePath(KVPathUtil.getBinlogPauseInstance(), myID);
    if (pauseInfo.getStatus() == BinlogPause.BinlogPauseStatus.ON) {
        DbleServer.getInstance().getBackupLocked().compareAndSet(false, true);
        boolean isPaused = ShowBinlogStatus.waitAllSession();
        if (!isPaused) {
            cleanResource(instancePath);
        }
        try {
            ZKUtils.createTempNode(KVPathUtil.getBinlogPauseInstance(), myID, String.valueOf(isPaused).getBytes(StandardCharsets.UTF_8));
        } catch (Exception e) {
            cleanResource(instancePath);
            LOGGER.warn(AlarmCode.CORE_ZK_WARN + "create binlogPause instance failed", e);
        }
    } else if (pauseInfo.getStatus() == BinlogPause.BinlogPauseStatus.OFF) {
        cleanResource(instancePath);
    }
    return true;
}
Also used : BinlogPause(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.BinlogPause) DirectoryInf(com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf) ZkDirectoryImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl) ZkDataImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)

Aggregations

BinlogPause (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.BinlogPause)6 UKvBean (com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 UDistributeLock (com.actiontech.dble.config.loader.ucoreprocess.UDistributeLock)1 DirectoryInf (com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf)1 ZkDataImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)1 ZkDirectoryImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl)1 InterProcessMutex (org.apache.curator.framework.recipes.locks.InterProcessMutex)1