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);
}
}
}
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");
}
}
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;
}
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);
}
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;
}
Aggregations