Pil0tXia commented on code in PR #55:
URL: 
https://github.com/apache/eventmesh-dashboard/pull/55#discussion_r1518616140


##########
eventmesh-dashboard-common/pom.xml:
##########
@@ -40,6 +40,17 @@
             <artifactId>fastjson2</artifactId>
             <version>2.0.40</version>
         </dependency>
+        <!-- Event Store -->
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-client</artifactId>
+            <version>4.9.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-tools</artifactId>
+            <version>4.9.5</version>
+        </dependency>

Review Comment:
   Better use a unified variable to store RocketMQ's version. By the way, the 
latest version is 4.9.8.



##########
eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/properties/RocketmqProperties.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.dashboard.common.properties;
+

Review Comment:
   Actually, this class is used as a data transfer object between `console` and 
`core`. Putting it in the properties package will make it look like some kind 
of application configuration.



##########
eventmesh-dashboard-console/src/main/java/org/apache/eventmesh/dashboard/console/entity/connection/ConnectionEntity.java:
##########
@@ -53,8 +53,7 @@ public class ConnectionEntity extends BaseEntity {
     private String sourceType;
 
     /**
-     * The id of the source.<br>
-     * It can be connectorId or clientId according to the sourceType.
+     * The id of the source.<br> It can be connectorId or clientId according 
to the sourceType.
      */

Review Comment:
   The recommanded line break in javadoc is `<p>`.



##########
eventmesh-dashboard-common/src/main/java/org/apache/eventmesh/dashboard/common/model/TopicProperties.java:
##########
@@ -17,24 +17,17 @@
 
 package org.apache.eventmesh.dashboard.common.model;
 
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.rocketmq.common.TopicConfig;
+
+import lombok.Data;
 
 /**
  * One record displayed in 'Topic' page.
  */
 
+@Data
 public class TopicProperties {
 
-    public String name;
-    public long messageCount;
+    private TopicConfig rocketmqTopicConfig;
 
-    @JsonCreator
-    public TopicProperties(
-        @JsonProperty("name") String name,
-        @JsonProperty("messageCount") long messageCount) {
-        super();
-        this.name = name;
-        this.messageCount = messageCount;
-    }
 }

Review Comment:
   Why would you keep this class when rocketmqTopicConfig is the only member?



##########
eventmesh-dashboard-core/src/main/java/org/apache/eventmesh/dashboard/core/store/RocketmqTopicCore.java:
##########
@@ -17,42 +17,57 @@
 
 package org.apache.eventmesh.dashboard.core.store;
 
+
 import org.apache.eventmesh.dashboard.common.model.TopicProperties;
-import org.apache.eventmesh.dashboard.core.config.AdminProperties;
+import org.apache.eventmesh.dashboard.common.properties.RocketmqProperties;
+import org.apache.eventmesh.dashboard.common.util.RocketmqUtils;
 import org.apache.eventmesh.dashboard.service.store.TopicCore;
 
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.TopicFilterType;
+import org.apache.rocketmq.common.constant.PermName;
+
+import java.util.ArrayList;
 import java.util.List;
 
 import org.springframework.stereotype.Service;
 
 import lombok.extern.slf4j.Slf4j;
 
-/**
- * TODO implement methods from storage-plugin.admin
- */
-
 @Slf4j
 @Service
 public class RocketmqTopicCore implements TopicCore {
 
-    AdminProperties adminProperties;
+    private final RocketmqProperties rocketmqProperties;
 
-    public RocketmqTopicCore(AdminProperties adminProperties) {
-        this.adminProperties = adminProperties;
+    public RocketmqTopicCore(RocketmqProperties rocketmqProperties) {
+        this.rocketmqProperties = rocketmqProperties;
     }
 
     @Override
-    public List<TopicProperties> getTopic() {
-        return null;
+    public List<TopicProperties> getTopics() {
+        List<TopicConfig> topicConfigList =
+            RocketmqUtils.getTopics(rocketmqProperties.getNamesrvAddr(), 
rocketmqProperties.getRequestTimeoutMillis());
+        List<TopicProperties> topicPropertiesList = new ArrayList<>();
+        for (TopicConfig topicConfig : topicConfigList) {
+            TopicProperties topicProperties = new TopicProperties();
+            topicProperties.setRocketmqTopicConfig(topicConfig);
+            topicPropertiesList.add(topicProperties);
+        }
+        return topicPropertiesList;
     }

Review Comment:
   You implemented these three methods twice. If your implementation in the 
`common` module is generalizable between `core` and `console`, it's a good idea 
to standardize the usage in `core` and `console`, or leave to-do comments.



-- 
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