Skip to content

Commit

Permalink
[ISSUE #670] fix checkstyle check fail (#680)
Browse files Browse the repository at this point in the history
fix checkstyle check fail
  • Loading branch information
jonyangx authored Dec 31, 2021
1 parent 8f74fac commit e922d6b
Show file tree
Hide file tree
Showing 367 changed files with 4,740 additions and 4,835 deletions.
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 @@ -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 @@ -60,23 +60,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 +89,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 @@ -30,14 +30,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,10 +17,11 @@

package org.apache.eventmesh.common.config;

import com.google.common.base.Preconditions;
import org.apache.eventmesh.common.utils.IPUtils;

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

import com.google.common.base.Preconditions;

public class CommonConfiguration {
public String eventMeshEnv = "P";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

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 org.apache.commons.lang3.StringUtils;

import java.io.BufferedReader;
import java.io.File;
Expand All @@ -31,6 +29,11 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

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

import com.google.common.base.Preconditions;

public class ConfigurationWrapper {

public Logger logger = LoggerFactory.getLogger(this.getClass());
Expand Down Expand Up @@ -64,8 +67,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 @@ -19,11 +19,12 @@

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

import java.util.List;

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

/**
* 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,9 +17,10 @@

package org.apache.eventmesh.common.loadbalance;

import org.apache.eventmesh.common.exception.EventMeshException;

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

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
package org.apache.eventmesh.common.loadbalance;

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

import java.util.List;

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

/**
* This selector use the weighted round robin strategy to select from list.
* If the weight is greater, the probability of being selected is larger.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public void setMode(SubscriptionMode mode) {

@Override
public String toString() {
return "SubscriptionItem{" +
"topic=" + topic +
", mode=" + mode +
", type=" + type +
'}';
return "SubscriptionItem{"
+ "topic=" + topic
+ ", mode=" + mode
+ ", type=" + type
+ '}';
}
}

Expand Down
Loading

0 comments on commit e922d6b

Please sign in to comment.