Search in sources :

Example 6 with ConfigDumpEvent

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);
    }
}
Also used : ConfigDumpEvent(com.alibaba.nacos.config.server.model.event.ConfigDumpEvent) HashMap(java.util.HashMap)

Example 7 with ConfigDumpEvent

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);
    }
}
Also used : ConfigDumpEvent(com.alibaba.nacos.config.server.model.event.ConfigDumpEvent) HashMap(java.util.HashMap)

Example 8 with ConfigDumpEvent

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);
        }
    }
}
Also used : ConfigDumpEvent(com.alibaba.nacos.config.server.model.event.ConfigDumpEvent) GenericType(com.alibaba.nacos.core.utils.GenericType) NotifyCenter(com.alibaba.nacos.common.notify.NotifyCenter) ByteString(com.google.protobuf.ByteString)

Aggregations

ConfigDumpEvent (com.alibaba.nacos.config.server.model.event.ConfigDumpEvent)8 HashMap (java.util.HashMap)7 NotifyCenter (com.alibaba.nacos.common.notify.NotifyCenter)1 ConfigInfo (com.alibaba.nacos.config.server.model.ConfigInfo)1 GenericType (com.alibaba.nacos.core.utils.GenericType)1 ByteString (com.google.protobuf.ByteString)1 ArrayList (java.util.ArrayList)1