Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #46] Refactor and split core module #47

Merged
merged 10 commits into from
Mar 2, 2024
18 changes: 17 additions & 1 deletion eventmesh-dashboard-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,30 @@
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.7.6</spring-boot.version>
</properties>

<dependencies>
<!-- Spring Boot Starter -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Utility -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.40</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.constant;
package org.apache.eventmesh.dashboard.common.constant;

public class ConfigConst {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.constant;
package org.apache.eventmesh.dashboard.common.constant;

public class NacosConst {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.dto;
package org.apache.eventmesh.dashboard.common.dto;

import static org.apache.eventmesh.dashboard.core.enums.Status.SUCCESS;

import org.apache.eventmesh.dashboard.core.enums.Status;
import org.apache.eventmesh.dashboard.core.exception.BaseException;
import org.apache.eventmesh.dashboard.common.enums.Status;
import org.apache.eventmesh.dashboard.common.exception.BaseException;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -59,28 +57,28 @@ public Result(T data, Integer pages) {
* The request is valid and the result is wrapped in {@link Result}.
*/
public static <T> Result<T> success() {
return new Result<>(new StatusMessage(SUCCESS));
return new Result<>(new StatusMessage(Status.SUCCESS));
}

public static <T> Result<T> success(Result<T> result) {
result.setMessage(new StatusMessage(SUCCESS));
result.setMessage(new StatusMessage(Status.SUCCESS));
return result;
}

public static <T> Result<T> success(T data) {
return new Result<>(data, null, new StatusMessage(SUCCESS));
return new Result<>(data, null, new StatusMessage(Status.SUCCESS));
}

/**
* The request is valid and the result is returned in {@link ResponseEntity}.
* Logic issues should use 422 Unprocessable Entity instead of 200 OK.
*/
public static <T> ResponseEntity<Result<T>> ok() {
return ResponseEntity.ok(new Result<>(new StatusMessage(SUCCESS)));
return ResponseEntity.ok(new Result<>(new StatusMessage(Status.SUCCESS)));
}

public static <T> ResponseEntity<Result<T>> ok(Result<T> result) {
result.setMessage(new StatusMessage(SUCCESS));
result.setMessage(new StatusMessage(Status.SUCCESS));
return ResponseEntity.ok(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.enums;
package org.apache.eventmesh.dashboard.common.enums;

import static org.apache.eventmesh.dashboard.core.constant.ConfigConst.COLON;
import static org.apache.eventmesh.dashboard.common.constant.ConfigConst.COLON;

import org.springframework.http.HttpStatus;

Expand Down Expand Up @@ -74,7 +74,7 @@ public enum Category {

SUCCESS("Successfully received and processed"),

SDK_CONFIG_ERR("The Meta SDK config in EventMeshAdmin application.yml error"),
SDK_CONFIG_ERR("Meta SDK config error"),

META_COM_ERR("Network communication to Meta error"),
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.exception;
package org.apache.eventmesh.dashboard.common.exception;

import static org.apache.eventmesh.dashboard.core.constant.ConfigConst.COLON;
import static org.apache.eventmesh.dashboard.common.constant.ConfigConst.COLON;

import org.apache.eventmesh.dashboard.core.enums.Status;
import org.apache.eventmesh.dashboard.core.util.ExceptionUtil;
import org.apache.eventmesh.dashboard.common.enums.Status;
import org.apache.eventmesh.dashboard.common.util.ExceptionUtil;

import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.exception;
package org.apache.eventmesh.dashboard.common.exception;

import org.apache.eventmesh.dashboard.core.enums.Status;
import org.apache.eventmesh.dashboard.common.enums.Status;

/**
* EventMeshAdmin Application side exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.exception;
package org.apache.eventmesh.dashboard.common.exception;

/**
* EventMesh Runtime side exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.exception;
package org.apache.eventmesh.dashboard.common.exception;

import org.apache.eventmesh.dashboard.core.enums.Status;
import org.apache.eventmesh.dashboard.common.enums.Status;

/**
* Meta side exception with EventMeshAdmin Application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.model;
package org.apache.eventmesh.dashboard.common.model;

public class ConnectionInfo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.model;
package org.apache.eventmesh.dashboard.common.model;

import lombok.Builder;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.model;
package org.apache.eventmesh.dashboard.common.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.util;
package org.apache.eventmesh.dashboard.common.util;

public class ExceptionUtil {

Expand Down
39 changes: 17 additions & 22 deletions eventmesh-dashboard-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,25 @@
</properties>

<dependencies>
<!-- springframework dependencies -->
<!-- EventMesh Dashboard modules -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.apache.eventmesh.dashboard.common</groupId>
<artifactId>eventmesh-dashboard-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<groupId>org.apache.eventmesh.dashboard.service</groupId>
<artifactId>eventmesh-dashboard-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<!-- ASP dependency -->

<!-- AOP -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>

<!-- swagger -->
<!-- Swagger -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
Expand All @@ -48,18 +49,6 @@
<version>1.7.0</version>
</dependency>

<!-- eventmesh.dashboard dependency -->
<dependency>
<groupId>org.apache.eventmesh.dashboard.common</groupId>
<artifactId>eventmesh-dashboard-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.eventmesh.dashboard.service</groupId>
<artifactId>eventmesh-dashboard-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>

<!-- Database -->
<dependency>
<groupId>com.alibaba</groupId>
Expand All @@ -77,7 +66,7 @@
</dependency>

<!-- health check client -->
<!-- Eventmesh SDK -->
<!-- EventMesh SDK -->
<dependency>
<groupId>org.apache.eventmesh</groupId>
<artifactId>eventmesh-sdk-java</artifactId>
Expand All @@ -100,6 +89,12 @@
</dependency>
<!-- health check client end -->

<!-- Unit Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!-- TODO: remove junit4 dependency -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class EventMeshDashboardApplication {
public static void main(String[] args) {
try {
SpringApplication.run(EventMeshDashboardApplication.class, args);
log.info("{} Successfully booted.", EventMeshDashboardApplication.class.getSimpleName());
log.info("{} Boot Successful!", EventMeshDashboardApplication.class.getSimpleName());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.controller;
package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.core.service.ConnectionService;
import org.apache.eventmesh.dashboard.service.meta.ConnectionCore;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -30,8 +29,10 @@
@RestController
public class ConnectionController {

@Autowired
ConnectionService connectionService;
/**
* TODO expose implement by FunctionManager
*/
ConnectionCore connectionCore;

/**
* Query Connection List
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.controller;
package org.apache.eventmesh.dashboard.console.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -24,8 +24,10 @@

@RestController
public class MetricsController {

@GetMapping("/druid/stat")
public Object druidStat() {
return DruidStatManagerFacade.getInstance().getDataSourceStatDataList();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
* limitations under the License.
*/

package org.apache.eventmesh.dashboard.core.controller;
package org.apache.eventmesh.dashboard.console.controller;

import org.apache.eventmesh.dashboard.core.dto.Result;
import org.apache.eventmesh.dashboard.core.model.SubscriptionInfo;
import org.apache.eventmesh.dashboard.core.service.SubscriptionService;
import org.apache.eventmesh.dashboard.common.dto.Result;
import org.apache.eventmesh.dashboard.common.model.SubscriptionInfo;
import org.apache.eventmesh.dashboard.service.meta.SubscriptionCore;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -33,8 +32,10 @@
@RequestMapping("/api/v1")
public class SubscriptionController {

@Autowired
SubscriptionService subscriptionService;
/**
* TODO expose implement by FunctionManager
*/
SubscriptionCore subscriptionCore;

// the subscription dataId naming pattern of EventMesh clients: ip-protocol
private static final String CLIENT_DATA_ID_PATTERN = "*.*.*.*-*";
Expand All @@ -48,7 +49,7 @@ public class SubscriptionController {
*/
@GetMapping("/subscription")
public Result<String> retrieveSubscription(@RequestParam("dataId") String dataId, @RequestParam("group") String group) {
return Result.success(subscriptionService.retrieveConfig(dataId, group));
return Result.success(subscriptionCore.retrieveConfig(dataId, group));
}

/**
Expand All @@ -66,7 +67,7 @@ public Result<List<SubscriptionInfo>> listSubscriptions(
@RequestParam(name = "size", defaultValue = "10") Integer size,
@RequestParam(name = "dataId", defaultValue = CLIENT_DATA_ID_PATTERN) String dataId,
@RequestParam(name = "group", defaultValue = "") String group) {
return Result.success(subscriptionService.retrieveConfigs(page, size, dataId, group));
return Result.success(subscriptionCore.retrieveConfigs(page, size, dataId, group));
}

}
Loading
Loading