Search in sources :

Example 11 with UKvBean

use of com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean in project dble by actiontech.

the class UPropertySequenceLoader 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;
    }
    if (configValue.getValue() != null && !"".equals(configValue.getValue())) {
        JSONObject jsonObj = JSONObject.parseObject(configValue.getValue());
        if (jsonObj.get(PROPERTIES_SEQUENCE_CONF) != null) {
            String sequenceConf = jsonObj.getString(PROPERTIES_SEQUENCE_CONF);
            ConfFileRWUtils.writeFile(PROPERTIES_SEQUENCE_CONF + PROPERTIES_SUFFIX, sequenceConf);
        }
        if (jsonObj.get(PROPERTIES_SEQUENCE_DB_CONF) != null) {
            String sequenceConf = jsonObj.getString(PROPERTIES_SEQUENCE_DB_CONF);
            ConfFileRWUtils.writeFile(PROPERTIES_SEQUENCE_DB_CONF + PROPERTIES_SUFFIX, sequenceConf);
        }
        if (jsonObj.get(PROPERTIES_SEQUENCE_DISTRIBUTED_CONF) != null) {
            String sequenceConf = jsonObj.getString(PROPERTIES_SEQUENCE_DISTRIBUTED_CONF);
            ConfFileRWUtils.writeFile(PROPERTIES_SEQUENCE_DISTRIBUTED_CONF + PROPERTIES_SUFFIX, sequenceConf);
        }
        if (jsonObj.get(PROPERTIES_CACHESERVER_NAME) != null) {
            String sequenceConf = jsonObj.getString(PROPERTIES_CACHESERVER_NAME);
            ConfFileRWUtils.writeFile(PROPERTIES_CACHESERVER_NAME + PROPERTIES_SUFFIX, sequenceConf);
        }
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) UKvBean(com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean)

Example 12 with UKvBean

use of com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean in project dble by actiontech.

the class UOffLineListener method checkBinlogStatusRelease.

private void checkBinlogStatusRelease(String serverId) {
    try {
        // check the lastest binglog status
        UKvBean lock = ClusterUcoreSender.getKey(UcorePathUtil.getBinlogPauseLockPath());
        if ("".equals(lock.getValue()) || serverId.equals(lock.getValue())) {
            DbleServer.getInstance().getBackupLocked().compareAndSet(true, false);
        }
        UKvBean status = ClusterUcoreSender.getKey(UcorePathUtil.getBinlogPauseStatus());
        if (!"".equals(status.getValue())) {
            BinlogPause pauseInfo = new BinlogPause(status.getValue());
            if (pauseInfo.getStatus() == BinlogPause.BinlogPauseStatus.ON && serverId.equals(pauseInfo.getFrom())) {
                ClusterUcoreSender.deleteKVTree(UcorePathUtil.getBinlogPauseStatus() + "/");
                ClusterUcoreSender.sendDataToUcore(UcorePathUtil.getBinlogPauseStatus(), (new BinlogPause("", BinlogPause.BinlogPauseStatus.OFF)).toString());
                ClusterUcoreSender.deleteKV(UcorePathUtil.getBinlogPauseLockPath());
            }
        }
    } catch (Exception e) {
        LOGGER.warn(AlarmCode.CORE_CLUSTER_WARN + " server offline binlog status check error");
    }
}
Also used : BinlogPause(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.BinlogPause) UKvBean(com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean)

Example 13 with UKvBean

use of com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean in project dble by actiontech.

the class UcoreClearKeyListener method getDiffMap.

private Map<String, UKvBean> getDiffMap(UcoreInterface.SubscribeKvPrefixOutput output) {
    Map<String, UKvBean> diffMap = new HashMap<String, UKvBean>();
    Map<String, String> newKeyMap = new HashMap<String, String>();
    // find out the new key & changed key
    for (int i = 0; i < output.getKeysCount(); i++) {
        newKeyMap.put(output.getKeys(i), output.getValues(i));
        if (cache.get(output.getKeys(i)) != null) {
            if (!cache.get(output.getKeys(i)).equals(output.getValues(i))) {
                diffMap.put(output.getKeys(i), new UKvBean(output.getKeys(i), output.getValues(i), UKvBean.UPDATE));
            }
        } else {
            diffMap.put(output.getKeys(i), new UKvBean(output.getKeys(i), output.getValues(i), UKvBean.ADD));
        }
    }
    // find out the deleted Key
    for (Map.Entry<String, String> entry : cache.entrySet()) {
        if (!newKeyMap.containsKey(entry.getKey())) {
            diffMap.put(entry.getKey(), new UKvBean(entry.getKey(), entry.getValue(), UKvBean.DELETE));
        }
    }
    cache = newKeyMap;
    return diffMap;
}
Also used : HashMap(java.util.HashMap) UKvBean(com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with UKvBean

use of com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean in project dble by actiontech.

the class UcoreClearKeyListener method initForXml.

public void initForXml() {
    UcoreInterface.SubscribeKvPrefixInput input = UcoreInterface.SubscribeKvPrefixInput.newBuilder().setIndex(0).setDuration(60).setKeyPrefix(UcorePathUtil.BASE_PATH).build();
    UcoreInterface.SubscribeKvPrefixOutput output = stub.subscribeKvPrefix(input);
    Map<String, UKvBean> diffMap = new HashMap<String, UKvBean>();
    for (int i = 0; i < output.getKeysCount(); i++) {
        diffMap.put(output.getKeys(i), new UKvBean(output.getKeys(i), output.getValues(i), UKvBean.ADD));
    }
    handle(diffMap);
}
Also used : HashMap(java.util.HashMap) UcoreInterface(com.actiontech.dble.log.alarm.UcoreInterface) UKvBean(com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean)

Example 15 with UKvBean

use of com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean in project dble by actiontech.

the class UcoreSingleKeyListener method getDiffMap.

private Map<String, UKvBean> getDiffMap(UcoreInterface.SubscribeKvPrefixOutput output) {
    Map<String, UKvBean> diffMap = new HashMap<String, UKvBean>();
    Map<String, String> newKeyMap = new HashMap<String, String>();
    // find out the new key & changed key
    for (int i = 0; i < output.getKeysCount(); i++) {
        newKeyMap.put(output.getKeys(i), output.getValues(i));
        if (cache.get(output.getKeys(i)) != null) {
            if (!cache.get(output.getKeys(i)).equals(output.getValues(i))) {
                diffMap.put(output.getKeys(i), new UKvBean(output.getKeys(i), output.getValues(i), UKvBean.UPDATE));
            }
        } else {
            diffMap.put(output.getKeys(i), new UKvBean(output.getKeys(i), output.getValues(i), UKvBean.ADD));
        }
    }
    // find out the deleted Key
    for (Map.Entry<String, String> entry : cache.entrySet()) {
        if (!newKeyMap.containsKey(entry.getKey())) {
            diffMap.put(entry.getKey(), new UKvBean(entry.getKey(), entry.getValue(), UKvBean.DELETE));
        }
    }
    cache = newKeyMap;
    return diffMap;
}
Also used : HashMap(java.util.HashMap) UKvBean(com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

UKvBean (com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean)16 JSONObject (com.alibaba.fastjson.JSONObject)5 File (java.io.File)4 HashMap (java.util.HashMap)4 UcoreInterface (com.actiontech.dble.log.alarm.UcoreInterface)3 Map (java.util.Map)3 BinlogPause (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.BinlogPause)2 UDistributeLock (com.actiontech.dble.config.loader.ucoreprocess.UDistributeLock)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 Ehcache (com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache)1 Function (com.actiontech.dble.config.loader.zkprocess.entity.rule.function.Function)1 TableRule (com.actiontech.dble.config.loader.zkprocess.entity.rule.tablerule.TableRule)1 DataHost (com.actiontech.dble.config.loader.zkprocess.entity.schema.datahost.DataHost)1 DataNode (com.actiontech.dble.config.loader.zkprocess.entity.schema.datanode.DataNode)1 Schema (com.actiontech.dble.config.loader.zkprocess.entity.schema.schema.Schema)1 DDLInfo (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.DDLInfo)1 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)1 ArrayList (java.util.ArrayList)1