Merge pull request #2990 from alibaba/hotfix_standalone_notify

[ISSUE 2989] where config publish could not trigger horizontal notification i…
This commit is contained in:
yanlinly 2020-06-08 13:57:27 +08:00 committed by GitHub
commit 5203ee348b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,18 +38,20 @@ import com.alibaba.nacos.config.server.model.Page;
import com.alibaba.nacos.config.server.model.SameConfigPolicy;
import com.alibaba.nacos.config.server.model.SubInfo;
import com.alibaba.nacos.config.server.model.TenantInfo;
import com.alibaba.nacos.config.server.model.event.ConfigDataChangeEvent;
import com.alibaba.nacos.config.server.service.datasource.DataSourceService;
import com.alibaba.nacos.config.server.service.datasource.DynamicDataSource;
import com.alibaba.nacos.config.server.service.sql.EmbeddedStorageContextUtils;
import com.alibaba.nacos.config.server.utils.LogUtil;
import com.alibaba.nacos.config.server.utils.ParamUtils;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import com.alibaba.nacos.core.distributed.id.IdGeneratorManager;
import com.alibaba.nacos.core.utils.ApplicationUtils;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Conditional;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.support.TransactionTemplate;
@ -384,6 +386,12 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
else {
updateConfigInfo4Beta(configInfo, betaIps, srcIp, null, time, notify);
}
if (ApplicationUtils.getStandaloneMode()) {
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(true, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
}
}
public void insertOrUpdateTag(final ConfigInfo configInfo, final String tag,
@ -396,6 +404,12 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
else {
updateConfigInfo4Tag(configInfo, tag, srcIp, null, time, notify);
}
if (ApplicationUtils.getStandaloneMode()) {
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(), tag,
time.getTime()));
}
}
public void updateMd5(String dataId, String group, String tenant, String md5,
@ -434,6 +448,12 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
else {
updateConfigInfo(configInfo, srcIp, srcUser, time, configAdvanceInfo, notify);
}
if (ApplicationUtils.getStandaloneMode()) {
EventDispatcher.fireEvent(
new ConfigDataChangeEvent(false, configInfo.getDataId(),
configInfo.getGroup(), configInfo.getTenant(),
time.getTime()));
}
}
public void insertOrUpdateSub(SubInfo subInfo) {
@ -2610,3 +2630,4 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
}
}