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

fix checkstyle check fail #680

Merged
merged 5 commits into from
Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Apache EventMesh (incubating)
# Apache EventMesh (incubating)
[![CI status](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/incubator-eventmesh/actions/workflows/ci.yml)
[![CodeCov](https://codecov.io/gh/apache/incubator-eventmesh/branch/develop/graph/badge.svg)](https://codecov.io/gh/apache/incubator-eventmesh)
[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/apache/incubator-eventmesh.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/incubator-eventmesh/context:java)
Expand All @@ -16,12 +16,14 @@ EventMesh(incubating) is a dynamic event-driven application runtime used to deco
**Multi-runtime:**
![architecture1](docs/images/eventmesh-arch3.png)


**Orchestration:**
![architecture1](docs/images/eventmesh-orchestration.png)

**Federation:**
![architecture1](docs/images/eventmesh-federation.png)


**Components:**

* **eventmesh-runtime** : an middleware to transmit events between event producers and consumers, support cloud native apps and microservices.
Expand Down Expand Up @@ -71,4 +73,4 @@ Mailing Lists:
| ---- | ---- |---- | ---- | ---- |
|Users |User support and questions mailing list| [Subscribe](mailto:users-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:users-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?users@eventmesh.apache.org)|
|Development |Development related discussions| [Subscribe](mailto:dev-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:dev-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?dev@eventmesh.apache.org)|
|Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:commits-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?commits@eventmesh.apache.org)|
|Commits |All commits to repositories| [Subscribe](mailto:commits-subscribe@eventmesh.incubator.apache.org) |[Unsubscribe](mailto:commits-unsubscribe@eventmesh.incubator.apache.org) |[Mail Archives](https://lists.apache.org/list.html?commits@eventmesh.apache.org)|
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ buildscript {
}

dependencies {
classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.7.1"
classpath "com.github.spotbugs.snom:spotbugs-gradle-plugin:5.0.3"
classpath "io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE"
classpath "com.github.jk1:gradle-license-report:1.17"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

package org.apache.eventmesh.admin.rocketmq.controller;

import org.apache.eventmesh.admin.rocketmq.handler.TopicsHandler;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.net.httpserver.HttpServer;

import org.apache.eventmesh.admin.rocketmq.handler.TopicsHandler;

public class AdminController {

private static final Logger logger = LoggerFactory.getLogger(AdminController.class);
Expand All @@ -34,9 +34,9 @@ public AdminController() {
}

public void run(HttpServer server) throws IOException {

server.createContext("/topicmanage", new TopicsHandler());

logger.info("EventMesh-Admin Controller server context created successfully");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,22 @@

package org.apache.eventmesh.admin.rocketmq.handler;

import org.apache.eventmesh.admin.rocketmq.request.TopicCreateRequest;
import org.apache.eventmesh.admin.rocketmq.response.TopicResponse;
import org.apache.eventmesh.admin.rocketmq.util.JsonUtils;
import org.apache.eventmesh.admin.rocketmq.util.NetUtils;
import org.apache.eventmesh.admin.rocketmq.util.RequestMapping;

import org.apache.commons.lang3.StringUtils;

import java.io.IOException;
import java.io.OutputStream;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;

import org.apache.eventmesh.admin.rocketmq.request.TopicCreateRequest;
import org.apache.eventmesh.admin.rocketmq.response.TopicResponse;
import org.apache.eventmesh.admin.rocketmq.util.JsonUtils;
import org.apache.eventmesh.admin.rocketmq.util.NetUtils;
import org.apache.eventmesh.admin.rocketmq.util.RequestMapping;

public class TopicsHandler implements HttpHandler {
private static final Logger logger = LoggerFactory.getLogger(TopicsHandler.class);

Expand All @@ -60,23 +59,23 @@ public void createTopicHandler(HttpExchange httpExchange) throws IOException {
try {
String params = NetUtils.parsePostBody(httpExchange);
TopicCreateRequest topicCreateRequest =
JsonUtils.toObject(params, TopicCreateRequest.class);
JsonUtils.toObject(params, TopicCreateRequest.class);
String topic = topicCreateRequest.getName();

if (StringUtils.isBlank(topic)) {
result = "Create topic failed. Parameter topic not found.";
logger.error(result);
out.write(result.getBytes());
return;
}

//TBD: A new rocketmq service will be implemented for creating topics
TopicResponse topicResponse = null;
if (topicResponse != null) {
logger.info("create a new topic: {}", topic);
logger.info("create a new topic: {}", topic);
httpExchange.getResponseHeaders().add("Content-Type", "appication/json");
httpExchange.sendResponseHeaders(200, 0);
result = JsonUtils.toJson(topicResponse);
result = JsonUtils.toJson(topicResponse);
logger.info(result);
out.write(result.getBytes());
return;
Expand All @@ -89,7 +88,7 @@ public void createTopicHandler(HttpExchange httpExchange) throws IOException {
}
} catch (Exception e) {
httpExchange.getResponseHeaders().add("Content-Type", "appication/json");
httpExchange.sendResponseHeaders(500, 0);
httpExchange.sendResponseHeaders(500, 0);
result = String.format("create topic failed! Server side error");
logger.error(result);
out.write(result.getBytes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class TopicResponse {

@JsonCreator
public TopicResponse(@JsonProperty("topic") String topic,
@JsonProperty("created_time") String createdTime) {
@JsonProperty("created_time") String createdTime) {
super();
this.topic = topic;
this.createdTime = createdTime;
Expand All @@ -51,12 +51,12 @@ public String getCreatedTime() {
@JsonProperty("created_time")
public void setCreatedTime(String createdTime) {
this.createdTime = createdTime;
}
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("TopicResponse {topic=" + this.topic + ",");
sb.append("TopicResponse {topic=" + this.topic + ",");
sb.append("created_time=" + this.createdTime + "}");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

public class JsonUtils {
public class JsonUtils {

private static ObjectMapper objectMapper;
private static ObjectMapper objectMapper;

static {
objectMapper = new ObjectMapper();
objectMapper = new ObjectMapper();
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}

public static <T> byte[] serialize(String topic, Class<T> data) throws JsonProcessingException {
Expand All @@ -47,7 +47,7 @@ public static String toJson(Object obj) throws JsonProcessingException {
if (obj == null) {
return null;
}
return objectMapper.writeValueAsString(obj);
return objectMapper.writeValueAsString(obj);
}

public static <T> T toObject(String json, Class<T> clazz) throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

package org.apache.eventmesh.admin.rocketmq.util;

import org.apache.http.Consts;

import java.io.IOException;
import java.io.InputStreamReader;

import org.apache.http.Consts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -30,14 +29,14 @@
public class NetUtils {

private static final Logger logger = LoggerFactory.getLogger(NetUtils.class);

public static String parsePostBody(HttpExchange exchange)
throws IOException {
StringBuilder body = new StringBuilder();
if ("post".equalsIgnoreCase(exchange.getRequestMethod())
|| "put".equalsIgnoreCase(exchange.getRequestMethod())) {
try (InputStreamReader reader =
new InputStreamReader(exchange.getRequestBody(), Consts.UTF_8)) {
|| "put".equalsIgnoreCase(exchange.getRequestMethod())) {
try (InputStreamReader reader =
new InputStreamReader(exchange.getRequestBody(), Consts.UTF_8)) {
char[] buffer = new char[256];
int read;
while ((read = reader.read(buffer)) != -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,37 @@

import com.sun.net.httpserver.HttpExchange;

public class RequestMapping {
public class RequestMapping {

public static boolean postMapping(String value, HttpExchange httpExchange) {
if ("post".equalsIgnoreCase(httpExchange.getRequestMethod())) {
public static boolean postMapping(String value, HttpExchange httpExchange) {
if ("post".equalsIgnoreCase(httpExchange.getRequestMethod())) {
String requestUri = httpExchange.getRequestURI().getPath();
UrlMappingPattern matcher = new UrlMappingPattern(value);
return matcher.matches(requestUri);
}
return false;
}

public static boolean getMapping(String value, HttpExchange httpExchange) {
if ("get".equalsIgnoreCase(httpExchange.getRequestMethod())) {
public static boolean getMapping(String value, HttpExchange httpExchange) {
if ("get".equalsIgnoreCase(httpExchange.getRequestMethod())) {
String requestUri = httpExchange.getRequestURI().getPath();
UrlMappingPattern matcher = new UrlMappingPattern(value);
return matcher.matches(requestUri);
}
return false;
}

public static boolean putMapping(String value, HttpExchange httpExchange) {
if ("put".equalsIgnoreCase(httpExchange.getRequestMethod())) {
public static boolean putMapping(String value, HttpExchange httpExchange) {
if ("put".equalsIgnoreCase(httpExchange.getRequestMethod())) {
String requestUri = httpExchange.getRequestURI().getPath();
UrlMappingPattern matcher = new UrlMappingPattern(value);
return matcher.matches(requestUri);
}
return false;
}

public static boolean deleteMapping(String value, HttpExchange httpExchange) {
if ("delete".equalsIgnoreCase(httpExchange.getRequestMethod())) {
public static boolean deleteMapping(String value, HttpExchange httpExchange) {
if ("delete".equalsIgnoreCase(httpExchange.getRequestMethod())) {
String requestUri = httpExchange.getRequestURI().getPath();
UrlMappingPattern matcher = new UrlMappingPattern(value);
return matcher.matches(requestUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class UrlMappingPattern {

private static final String URL_PARAMETER_REGEX = "\\{(\\w*?)\\}";

private static final String URL_PARAMETER_MATCH_REGEX =
"\\([%\\\\w-.\\\\~!\\$&'\\\\(\\\\)\\\\*\\\\+,;=:\\\\[\\\\]@]+?\\)";
private static final String URL_PARAMETER_MATCH_REGEX =
"\\([%\\\\w-.\\\\~!\\$&'\\\\(\\\\)\\\\*\\\\+,;=:\\\\[\\\\]@]+?\\)";

private static final Pattern URL_PARAMETER_PATTERN = Pattern.compile(URL_PARAMETER_REGEX);

Expand Down Expand Up @@ -74,8 +74,8 @@ public boolean matches(String url) {

public void compile() {
acquireParamNames();
String parsedPattern =
getUrlMappingPattern().replaceFirst(URL_FORMAT_REGEX, URL_FORMAT_MATCH_REGEX);
String parsedPattern =
getUrlMappingPattern().replaceFirst(URL_FORMAT_REGEX, URL_FORMAT_MATCH_REGEX);
parsedPattern = parsedPattern.replaceAll(URL_PARAMETER_REGEX, URL_PARAMETER_MATCH_REGEX);
this.compiledUrlMappingPattern = Pattern.compile(parsedPattern + URL_QUERY_STRING_REGEX);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, fin
public static ThreadPoolExecutor createThreadPoolExecutor(int core, int max, BlockingQueue<Runnable> blockingQueue,
final String threadName, final boolean isDaemon) {
return new ThreadPoolExecutor(core, max, 10 * 1000, TimeUnit.MILLISECONDS, blockingQueue,
new ThreadFactoryBuilder().setNameFormat(threadName).setDaemon(isDaemon).build()
new ThreadFactoryBuilder().setNameFormat(threadName).setDaemon(isDaemon).build()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

package org.apache.eventmesh.common.config;

import org.apache.commons.lang3.StringUtils;

import com.google.common.base.Preconditions;

import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.utils.IPUtils;

public class CommonConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@

package org.apache.eventmesh.common.config;

import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.ThreadPoolFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
Expand All @@ -31,6 +25,14 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Preconditions;

import org.apache.eventmesh.common.ThreadPoolFactory;

public class ConfigurationWrapper {

public Logger logger = LoggerFactory.getLogger(this.getClass());
Expand Down Expand Up @@ -64,8 +66,7 @@ public void run() {
private void load() {
try {
logger.info("loading config: {}", file);
properties.load(new BufferedReader(new FileReader(
new File(file))));
properties.load(new BufferedReader(new FileReader(new File(file))));
} catch (IOException e) {
logger.error("loading properties [{}] error", file, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package org.apache.eventmesh.common.loadbalance;

import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.RandomUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
* This selector use random strategy.
* Each selection will randomly give one from the given list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public AtomicInteger getCurrentWeight() {

@Override
public String toString() {
return "Wight{" +
"target=" + target +
", weight=" + weight +
", currentWeight=" + currentWeight +
'}';
return "Wight{"
+ "target=" + target
+ ", weight=" + weight
+ ", currentWeight=" + currentWeight
+ '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

package org.apache.eventmesh.common.loadbalance;

import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.eventmesh.common.exception.EventMeshException;

import java.util.List;
import org.apache.eventmesh.common.exception.EventMeshException;

/**
* This selector use the weighted random strategy to select from list.
Expand Down
Loading