use of com.alibaba.nacos.config.server.model.event.ConfigDumpEvent in project nacos by alibaba.
the class EmbeddedStorageContextUtils method onModifyConfigTagInfo.
/**
* In the case of the in-cluster storage mode, the logic of horizontal notification is implemented asynchronously
* via the raft state machine, along with the information.
*
* @param configInfo {@link ConfigInfo}
* @param tag tag info
* @param srcIp The IP of the operator
* @param time Operating time
*/
public static void onModifyConfigTagInfo(ConfigInfo configInfo, String tag, String srcIp, Timestamp time) {
if (!EnvUtil.getStandaloneMode()) {
ConfigDumpEvent event = ConfigDumpEvent.builder().remove(false).namespaceId(configInfo.getTenant()).dataId(configInfo.getDataId()).group(configInfo.getGroup()).isBeta(false).tag(tag).content(configInfo.getContent()).type(configInfo.getType()).handleIp(srcIp).lastModifiedTs(time.getTime()).build();
Map<String, String> extendInfo = new HashMap<>(2);
extendInfo.put(Constants.EXTEND_INFO_CONFIG_DUMP_EVENT, JacksonUtils.toJson(event));
EmbeddedStorageContextUtils.putAllExtendInfo(extendInfo);
}
}
use of com.alibaba.nacos.config.server.model.event.ConfigDumpEvent in project nacos by alibaba.
the class EmbeddedStorageContextUtils method onDeleteConfigTagInfo.
/**
* In the case of the in-cluster storage mode, the logic of horizontal notification is implemented asynchronously
* via the raft state machine, along with the information.
*
* @param namespaceId namespaceId
* @param group group
* @param dataId dataId
* @param tag tag info
* @param srcIp The IP of the operator
*/
public static void onDeleteConfigTagInfo(String namespaceId, String group, String dataId, String tag, String srcIp) {
if (!EnvUtil.getStandaloneMode()) {
ConfigDumpEvent event = ConfigDumpEvent.builder().remove(true).namespaceId(namespaceId).group(group).dataId(dataId).isBeta(true).tag(tag).handleIp(srcIp).build();
Map<String, String> extendInfo = new HashMap<>(2);
extendInfo.put(Constants.EXTEND_INFO_CONFIG_DUMP_EVENT, JacksonUtils.toJson(event));
EmbeddedStorageContextUtils.putAllExtendInfo(extendInfo);
}
}
use of com.alibaba.nacos.config.server.model.event.ConfigDumpEvent in project nacos by alibaba.
the class DistributedDatabaseOperateImpl method handleExtendInfo.
private void handleExtendInfo(Map<String, String> extendInfo) {
if (extendInfo.containsKey(Constants.EXTEND_INFO_CONFIG_DUMP_EVENT)) {
String jsonVal = extendInfo.get(Constants.EXTEND_INFO_CONFIG_DUMP_EVENT);
if (StringUtils.isNotBlank(jsonVal)) {
NotifyCenter.publishEvent(JacksonUtils.toObj(jsonVal, ConfigDumpEvent.class));
}
return;
}
if (extendInfo.containsKey(Constants.EXTEND_INFOS_CONFIG_DUMP_EVENT)) {
String jsonVal = extendInfo.get(Constants.EXTEND_INFO_CONFIG_DUMP_EVENT);
if (StringUtils.isNotBlank(jsonVal)) {
List<ConfigDumpEvent> list = JacksonUtils.toObj(jsonVal, new GenericType<List<ConfigDumpEvent>>() {
}.getType());
list.stream().filter(Objects::nonNull).forEach(NotifyCenter::publishEvent);
}
}
}
Aggregations