Search in sources :

Example 6 with ZkDirectoryImpl

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

the class SequenceTopropertiesLoader method sequenceZkToProperties.

/**
 * sequenceZkToProperties
 *
 * @param name schema
 * @throws Exception
 */
private void sequenceZkToProperties(String name, DirectoryInf seqDirectory) throws Exception {
    ZkDirectoryImpl zkDirectory = (ZkDirectoryImpl) this.getZkDirectory(seqDirectory, KVPathUtil.SEQUENCE_COMMON);
    if (null != zkDirectory) {
        String writeFile = name + PROPERTIES_SUFFIX;
        ZkDataImpl commData = (ZkDataImpl) this.getZkData(zkDirectory, writeFile);
        if (commData != null) {
            ConfFileRWUtils.writeFile(commData.getName(), commData.getValue());
        }
        String sequenceWatchPath = KVPathUtil.getSequencesCommonPath() + writeFile;
        this.zookeeperListen.addWatch(sequenceWatchPath, this);
        LOGGER.info("SequenceTozkLoader notifyProcess " + name + " to local properties success");
    }
}
Also used : ZkDirectoryImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl) ZkDataImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)

Example 7 with ZkDirectoryImpl

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

the class SequenceTopropertiesLoader method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    DirectoryInf sequenceDirectory = new ZkDirectoryImpl(currZkPath, null);
    this.getTreeDirectory(currZkPath, KVPathUtil.SEQUENCES, sequenceDirectory);
    sequenceDirectory = (DirectoryInf) sequenceDirectory.getSubordinateInfo().get(0);
    this.sequenceZkToProperties(PROPERTIES_SEQUENCE_CONF, sequenceDirectory);
    this.sequenceZkToProperties(PROPERTIES_SEQUENCE_DB_CONF, sequenceDirectory);
    this.sequenceZkToProperties(PROPERTIES_SEQUENCE_DISTRIBUTED_CONF, sequenceDirectory);
    return true;
}
Also used : DirectoryInf(com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf) ZkDirectoryImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl)

Example 8 with ZkDirectoryImpl

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

ZkDirectoryImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDirectoryImpl)8 DirectoryInf (com.actiontech.dble.config.loader.zkprocess.zookeeper.DirectoryInf)7 ZkDataImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)3 File (java.io.File)3 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