You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozhera.apache.org by wa...@apache.org on 2026/03/19 03:10:56 UTC
(ozhera) branch master updated: feat: Business Decomposition (#636)
This is an automated email from the ASF dual-hosted git repository.
wangtao29 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozhera.git
The following commit(s) were added to refs/heads/master by this push:
new 8a78e767 feat: Business Decomposition (#636)
8a78e767 is described below
commit 8a78e7673831a508d909cd687d9e91ee4e2a780e
Author: Reol2020 <51...@users.noreply.github.com>
AuthorDate: Thu Mar 19 11:10:51 2026 +0800
feat: Business Decomposition (#636)
* Business Decomposition
---
ozhera-log/log-manager/pom.xml | 1 -
.../service/impl/MilogConfigNacosServiceImpl.java | 60 ++++++++++++++++++++--
.../nacos/impl/SpaceConfigNacosPublisher.java | 14 +++--
ozhera-log/log-stream/pom.xml | 2 +-
.../ozhera/log/stream/config/ConfigManager.java | 27 +++++++++-
.../src/main/resources/config.properties | 1 +
6 files changed, 93 insertions(+), 12 deletions(-)
diff --git a/ozhera-log/log-manager/pom.xml b/ozhera-log/log-manager/pom.xml
index ff229d8f..5b258966 100644
--- a/ozhera-log/log-manager/pom.xml
+++ b/ozhera-log/log-manager/pom.xml
@@ -30,7 +30,6 @@ http://www.apache.org/licenses/LICENSE-2.0
<artifactId>log-manager</artifactId>
<version>2.3.1-SNAPSHOT</version>
-
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
diff --git a/ozhera-log/log-manager/src/main/java/org/apache/ozhera/log/manager/service/impl/MilogConfigNacosServiceImpl.java b/ozhera-log/log-manager/src/main/java/org/apache/ozhera/log/manager/service/impl/MilogConfigNacosServiceImpl.java
index f3bc6d45..e24b820c 100644
--- a/ozhera-log/log-manager/src/main/java/org/apache/ozhera/log/manager/service/impl/MilogConfigNacosServiceImpl.java
+++ b/ozhera-log/log-manager/src/main/java/org/apache/ozhera/log/manager/service/impl/MilogConfigNacosServiceImpl.java
@@ -243,8 +243,60 @@ public class MilogConfigNacosServiceImpl implements MilogConfigNacosService {
Assert.notNull(spaceId, "logSpaceId not empty");
Assert.notNull(storeId, "storeId not empty");
//send msg
- getSpaceConfigNacosPublisher(motorRoomEn).publish(spaceId,
- dealSpaceConfigByRule(motorRoomEn, spaceId, storeId, tailId, type, changeType));
+ MilogSpaceData spaceData = dealSpaceConfigByRule(motorRoomEn, spaceId, storeId, tailId, type, changeType);
+ getSpaceConfigNacosPublisher(motorRoomEn).publish(spaceId, spaceData);
+
+ // Publish split configs
+ if (spaceData != null) {
+ publishSplitSpaceData(motorRoomEn, spaceId, spaceData);
+ }
+ }
+
+ private void publishSplitSpaceData(String motorRoomEn, Long spaceId, MilogSpaceData spaceData) {
+ String baseDataId = CommonExtensionServiceFactory.getCommonExtensionService().getLogManagePrefix() + TAIL_CONFIG_DATA_ID + spaceId;
+ try {
+ // Clone spaceData for type 0
+ MilogSpaceData spaceData0 = copySpaceData(spaceData);
+ filterLogtailConfigs(spaceData0, 0);
+ getSpaceConfigNacosPublisher(motorRoomEn).publish(baseDataId + ":0", spaceData0);
+ } catch (Exception e) {
+ log.error("publishSplitSpaceData type 0 error, spaceId:{}", spaceId, e);
+ }
+
+ try {
+ // Clone spaceData for type 1 (non-0)
+ MilogSpaceData spaceData1 = copySpaceData(spaceData);
+ filterLogtailConfigs(spaceData1, 1);
+ getSpaceConfigNacosPublisher(motorRoomEn).publish(baseDataId + ":not0", spaceData1);
+ } catch (Exception e) {
+ log.error("publishSplitSpaceData type 1 error, spaceId:{}", spaceId, e);
+ }
+ }
+
+ private MilogSpaceData copySpaceData(MilogSpaceData source) {
+ String json = GSON.toJson(source);
+ return GSON.fromJson(json, MilogSpaceData.class);
+ }
+
+ private void filterLogtailConfigs(MilogSpaceData data, int type) {
+ if (data.getSpaceConfig() != null) {
+ for (SinkConfig sinkConfig : data.getSpaceConfig()) {
+ if (sinkConfig.getLogtailConfigs() != null) {
+ List<LogtailConfig> filtered = sinkConfig.getLogtailConfigs().stream()
+ .filter(config -> {
+ Integer appType = config.getAppType() == null ? 0 : config.getAppType();
+ if (type == 0) {
+ return appType == 0;
+ } else {
+ return appType != 0;
+ }
+ })
+ .collect(Collectors.toList());
+ sinkConfig.setLogtailConfigs(filtered);
+ }
+ }
+ data.getSpaceConfig().removeIf(sinkConfig -> CollectionUtils.isEmpty(sinkConfig.getLogtailConfigs()));
+ }
}
/**
@@ -329,7 +381,9 @@ public class MilogConfigNacosServiceImpl implements MilogConfigNacosService {
if (CollectionUtils.isEmpty(logtailConfigs)) {
logtailConfigs = Lists.newArrayList();
}
- logtailConfigs.add(assembleLogTailConfigs(tailId));
+ if (null != tailId) {
+ logtailConfigs.add(assembleLogTailConfigs(tailId));
+ }
currentStoreConfig.setLogtailConfigs(logtailConfigs);
} else {
//New addition to the log Store
diff --git a/ozhera-log/log-manager/src/main/java/org/apache/ozhera/log/manager/service/nacos/impl/SpaceConfigNacosPublisher.java b/ozhera-log/log-manager/src/main/java/org/apache/ozhera/log/manager/service/nacos/impl/SpaceConfigNacosPublisher.java
index b82efba4..e9f6bd18 100644
--- a/ozhera-log/log-manager/src/main/java/org/apache/ozhera/log/manager/service/nacos/impl/SpaceConfigNacosPublisher.java
+++ b/ozhera-log/log-manager/src/main/java/org/apache/ozhera/log/manager/service/nacos/impl/SpaceConfigNacosPublisher.java
@@ -43,18 +43,22 @@ public class SpaceConfigNacosPublisher implements DynamicConfigPublisher<MilogSp
@Override
public void publish(Long uniqueSpace, MilogSpaceData config) {
- String configJson = gson.toJson(config);
- log.info("write the creation namespace configuration:{}", configJson);
String dataId = CommonExtensionServiceFactory.getCommonExtensionService().getLogManagePrefix() + TAIL_CONFIG_DATA_ID + uniqueSpace;
+ this.publish(dataId, config);
+ }
+
+ public void publish(String dataId, MilogSpaceData config) {
+ String configJson = gson.toJson(config);
+ log.info("write the creation namespace configuration,dataId:{},config:{}", dataId, configJson);
try {
if (null != configService) {
if (StringUtils.isBlank(dataId)) {
- log.error("dataId is null,uniqueSpace:{},config:{}", uniqueSpace, configJson);
+ log.error("dataId is null,config:{}", configJson);
return;
}
- configService.publishConfig(dataId, DEFAULT_GROUP_ID, gson.toJson(config));
+ configService.publishConfig(dataId, DEFAULT_GROUP_ID, configJson);
} else {
- log.warn("configService is null,uniqueSpace:{},config:{}", uniqueSpace, configJson);
+ log.warn("configService is null,dataId:{},config:{}", dataId, configJson);
}
} catch (Exception e) {
log.error(String.format("Write the creation namespace configuration...,dataId:%s,data:%s", dataId, configJson), e);
diff --git a/ozhera-log/log-stream/pom.xml b/ozhera-log/log-stream/pom.xml
index a5daea21..505de02e 100644
--- a/ozhera-log/log-stream/pom.xml
+++ b/ozhera-log/log-stream/pom.xml
@@ -28,7 +28,7 @@ http://www.apache.org/licenses/LICENSE-2.0
<modelVersion>4.0.0</modelVersion>
<artifactId>log-stream</artifactId>
- <version>2.2.6-SNAPSHOT</version>
+ <version>2.2.7-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
diff --git a/ozhera-log/log-stream/src/main/java/org/apache/ozhera/log/stream/config/ConfigManager.java b/ozhera-log/log-stream/src/main/java/org/apache/ozhera/log/stream/config/ConfigManager.java
index 833b3961..8f2b0667 100644
--- a/ozhera-log/log-stream/src/main/java/org/apache/ozhera/log/stream/config/ConfigManager.java
+++ b/ozhera-log/log-stream/src/main/java/org/apache/ozhera/log/stream/config/ConfigManager.java
@@ -62,6 +62,9 @@ public class ConfigManager {
@Value("$hera.stream.type")
private String streamType;
+ @Value("$hera.stream.config.suffix")
+ private String configSuffix;
+
//final String spaceDataId = LOG_MANAGE_PREFIX + NAMESPACE_CONFIG_DATA_ID;
/**
@@ -85,6 +88,13 @@ public class ConfigManager {
private final ReentrantLock spaceLock = new ReentrantLock();
+ private String resolveDataId(String originalDataId) {
+ if (StringUtils.isNotEmpty(configSuffix)) {
+ return originalDataId + configSuffix;
+ }
+ return originalDataId;
+ }
+
/**
* Executed once when the service starts
*
@@ -109,7 +119,8 @@ public class ConfigManager {
Map<Long, String> milogStreamDataMap = config.get(uniqueMark);
log.info("[ConfigManager.initConfigManager] uniqueMark:{},data:{}", uniqueMark, objectMapper.writeValueAsString(milogStreamDataMap));
for (Long spaceId : milogStreamDataMap.keySet()) {
- final String dataId = milogStreamDataMap.get(spaceId);
+ final String originalDataId = milogStreamDataMap.get(spaceId);
+ final String dataId = resolveDataId(originalDataId);
// init spaceData config
String logSpaceDataStr = nacosConfig.getConfigStr(dataId, DEFAULT_GROUP_ID, DEFAULT_TIME_OUT_MS);
if (StringUtils.isNotEmpty(logSpaceDataStr)) {
@@ -120,6 +131,10 @@ public class ConfigManager {
milogSpaceDataMap.put(spaceId, milogSpaceData);
log.info("[ConfigManager.initStream] added log config listener for spaceId:{},dataId:{}", spaceId, dataId);
}
+ } else {
+ if (StringUtils.isNotEmpty(configSuffix)) {
+ log.info("[ConfigManager.initStream] config not found for dataId:{}, skipping", dataId);
+ }
}
}
} else {
@@ -291,14 +306,22 @@ public class ConfigManager {
*
*/
public void startNewListenerAndJob(Map<Long, String> milogStreamDataMap) {
- milogStreamDataMap.forEach((spaceId, dataId) -> {
+ milogStreamDataMap.forEach((spaceId, originalDataId) -> {
// there is no listener corresponding to the spaceId in memory
try {
if (!milogSpaceDataMap.containsKey(spaceId)) {
log.info("startNewListenerAndJob for spaceId start:{}", spaceId);
// Get a copy of the spaceData configuration through the dataID and put it in the configListener cache
+ final String dataId = resolveDataId(originalDataId);
MilogSpaceData milogSpaceData = getMilogSpaceData(dataId);
+ if (milogSpaceData == null || milogSpaceData.getMilogSpaceId() == null) {
+ if (StringUtils.isNotEmpty(configSuffix)) {
+ log.info("startNewListenerAndJob config not found for dataId:{}, skipping", dataId);
+ return;
+ }
+ }
+
// Listen configuration
MilogConfigListener configListener = new MilogConfigListener(spaceId, dataId, DEFAULT_GROUP_ID, milogSpaceData, nacosConfig);
addListener(spaceId, configListener);
diff --git a/ozhera-log/log-stream/src/main/resources/config.properties b/ozhera-log/log-stream/src/main/resources/config.properties
index a73e3569..d2cbff36 100644
--- a/ozhera-log/log-stream/src/main/resources/config.properties
+++ b/ozhera-log/log-stream/src/main/resources/config.properties
@@ -40,6 +40,7 @@ hera.stream.compensate.mq=${hera.stream.compensate.mq}
# monitor nacos data id
hera.stream.monitor_space_data_id=${hera.stream.monitor_space_data_id}
+hera.stream.config.suffix=${hera.stream.config.suffix}
# normal log or backup log
sink_job_type=${sink_job_type}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozhera.apache.org
For additional commands, e-mail: commits-help@ozhera.apache.org