pandaapo commented on code in PR #4622:
URL: https://github.com/apache/eventmesh/pull/4622#discussion_r1423898620


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/boot/TransformerEngine.java:
##########
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.runtime.boot;
+
+import org.apache.eventmesh.api.meta.MetaServiceListener;
+import org.apache.eventmesh.common.utils.JsonUtils;
+import org.apache.eventmesh.common.utils.LogUtils;
+import 
org.apache.eventmesh.runtime.core.protocol.http.consumer.ConsumerGroupManager;
+import 
org.apache.eventmesh.runtime.core.protocol.http.consumer.ConsumerManager;
+import org.apache.eventmesh.runtime.core.protocol.producer.EventMeshProducer;
+import org.apache.eventmesh.runtime.core.protocol.producer.ProducerManager;
+import org.apache.eventmesh.runtime.meta.MetaStorage;
+import org.apache.eventmesh.transformer.Transformer;
+import org.apache.eventmesh.transformer.TransformerBuilder;
+import org.apache.eventmesh.transformer.TransformerParam;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class TransformerEngine {
+
+    /**
+     * key:group-topic
+     **/
+    private final Map<String, Transformer> transformerMap = new HashMap<>();
+
+    private final String transformerPrefix = "transformer-";
+
+    private final MetaStorage metaStorage;
+
+    private MetaServiceListener metaServiceListener;
+
+    private final ProducerManager producerManager;
+
+    private final ConsumerManager consumerManager;
+
+    private final ScheduledExecutorService scheduledExecutorService = 
Executors.newSingleThreadScheduledExecutor();
+
+    public TransformerEngine(MetaStorage metaStorage, ProducerManager 
producerManager, ConsumerManager consumerManager) {
+        this.metaStorage = metaStorage;
+        this.producerManager = producerManager;
+        this.consumerManager = consumerManager;
+    }
+
+    public void start() {
+        Map<String, String> transformerMetaData = 
metaStorage.getMetaData(transformerPrefix, true);
+        for (Entry<String, String> transformerDataEntry : 
transformerMetaData.entrySet()) {
+            // transformer-group
+            String key = transformerDataEntry.getKey();
+            // topic-transformerParam list
+            String value = transformerDataEntry.getValue();
+            updateTransformerMap(key, value);
+        }
+        metaServiceListener = this::updateTransformerMap;

Review Comment:
   Should this step be placed before for( ), otherwise, is it possible for 
`metaServiceListener` to be null when `addTransformerListener()` in 
`updateTransformerMap()`?
   
   这一步是不是应该放到for( 
)前面,否则的话,`updateTransformerMap()`中`addTransformerListener()`时,`metaServiceListener`是不是为null?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to