[ISSUE #670] fix checkstyle check fail (#680)

fix checkstyle check fail
This commit is contained in:
yangjun 2021-12-31 17:22:40 +08:00 committed by GitHub
parent 8f74fac6d3
commit e922d6b97a
367 changed files with 4732 additions and 4827 deletions

View File

@ -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)
@ -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.
@ -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)|

View File

@ -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"
}

View File

@ -34,9 +34,9 @@ public class AdminController {
}
public void run(HttpServer server) throws IOException {
server.createContext("/topicmanage", new TopicsHandler());
logger.info("EventMesh-Admin Controller server context created successfully");
}
}

View File

@ -60,23 +60,23 @@ public class TopicsHandler implements HttpHandler {
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;
@ -89,7 +89,7 @@ public class TopicsHandler implements HttpHandler {
}
} 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());

View File

@ -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;
@ -51,12 +51,12 @@ public class TopicResponse {
@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();
}

View File

@ -25,15 +25,15 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
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 {
@ -47,7 +47,7 @@ public class JsonUtils {
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 {

View File

@ -30,14 +30,14 @@ import com.sun.net.httpserver.HttpExchange;
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) {

View File

@ -19,10 +19,10 @@ package org.apache.eventmesh.admin.rocketmq.util;
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);
@ -30,8 +30,8 @@ public class RequestMapping {
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);
@ -39,8 +39,8 @@ public class RequestMapping {
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);
@ -48,8 +48,8 @@ public class RequestMapping {
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);

View File

@ -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);
@ -74,8 +74,8 @@ public class UrlMappingPattern {
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);
}

View File

@ -42,7 +42,7 @@ public class ThreadPoolFactory {
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()
);
}

View File

@ -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";

View File

@ -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;
@ -31,6 +29,11 @@ import java.util.Properties;
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());
@ -64,8 +67,7 @@ public class ConfigurationWrapper {
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);
}

View File

@ -19,11 +19,12 @@ package org.apache.eventmesh.common.loadbalance;
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

View File

@ -61,10 +61,10 @@ public class Weight<T> {
@Override
public String toString() {
return "Wight{" +
"target=" + target +
", weight=" + weight +
", currentWeight=" + currentWeight +
'}';
return "Wight{"
+ "target=" + target
+ ", weight=" + weight
+ ", currentWeight=" + currentWeight
+ '}';
}
}

View File

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

View File

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

View File

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

View File

@ -184,18 +184,18 @@ public class HttpCommand implements ProtocolTransportObject {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("httpCommand={")
.append(cmdType).append(",")
.append(httpMethod).append("/").append(httpVersion).append(",")
.append("requestCode=").append(requestCode).append(",")
.append("opaque=").append(opaque).append(",");
.append(cmdType).append(",")
.append(httpMethod).append("/").append(httpVersion).append(",")
.append("requestCode=").append(requestCode).append(",")
.append("opaque=").append(opaque).append(",");
if (cmdType == CmdType.RES) {
sb.append("cost=").append(resTime - reqTime).append(",");
}
sb.append("header=").append(header).append(",")
.append("body=").append(body)
.append("}");
.append("body=").append(body)
.append("}");
return sb.toString();
}
@ -203,17 +203,17 @@ public class HttpCommand implements ProtocolTransportObject {
public String abstractDesc() {
StringBuilder sb = new StringBuilder();
sb.append("httpCommand={")
.append(cmdType).append(",")
.append(httpMethod).append("/").append(httpVersion).append(",")
.append("requestCode=").append(requestCode).append(",")
.append("opaque=").append(opaque).append(",");
.append(cmdType).append(",")
.append(httpMethod).append("/").append(httpVersion).append(",")
.append("requestCode=").append(requestCode).append(",")
.append("opaque=").append(opaque).append(",");
if (cmdType == CmdType.RES) {
sb.append("cost=").append(resTime - reqTime).append(",");
}
sb.append("header=").append(header).append(",")
.append("bodySize=").append(body.toString().length()).append("}");
.append("bodySize=").append(body.toString().length()).append("}");
return sb.toString();
}
@ -221,9 +221,9 @@ public class HttpCommand implements ProtocolTransportObject {
public String simpleDesc() {
StringBuilder sb = new StringBuilder();
sb.append("httpCommand={")
.append(cmdType).append(",")
.append(httpMethod).append("/").append(httpVersion).append(",")
.append("requestCode=").append(requestCode).append("}");
.append(cmdType).append(",")
.append(httpMethod).append("/").append(httpVersion).append(",")
.append("requestCode=").append(requestCode).append("}");
return sb.toString();
}
@ -233,7 +233,7 @@ public class HttpCommand implements ProtocolTransportObject {
return null;
}
DefaultFullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
Unpooled.wrappedBuffer(JsonUtils.serialize(this.getBody()).getBytes(Constants.DEFAULT_CHARSET)));
Unpooled.wrappedBuffer(JsonUtils.serialize(this.getBody()).getBytes(Constants.DEFAULT_CHARSET)));
HttpHeaders headers = response.headers();
headers.add(HttpHeaderNames.CONTENT_TYPE, "text/plain; charset=" + Constants.DEFAULT_CHARSET);
headers.add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());

View File

@ -18,11 +18,11 @@
package org.apache.eventmesh.common.protocol.http.body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
public class BaseResponseBody extends Body {
private Integer retCode;

View File

@ -18,8 +18,6 @@
package org.apache.eventmesh.common.protocol.http.body;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.body.client.HeartbeatRequestBody;
import org.apache.eventmesh.common.protocol.http.body.client.RegRequestBody;
import org.apache.eventmesh.common.protocol.http.body.client.SubscribeRequestBody;
@ -32,6 +30,8 @@ import org.apache.eventmesh.common.protocol.http.body.message.SendMessageBatchV2
import org.apache.eventmesh.common.protocol.http.body.message.SendMessageRequestBody;
import org.apache.eventmesh.common.protocol.http.common.RequestCode;
import java.util.Map;
public abstract class Body {
public abstract Map<String, Object> toMap();

View File

@ -30,9 +30,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
public class HeartbeatRequestBody extends Body {
public static final String CLIENTTYPE = "clientType";
public static final String CLIENTTYPE = "clientType";
public static final String HEARTBEATENTITIES = "heartbeatEntities";
public static final String CONSUMERGROUP = "consumerGroup";
public static final String CONSUMERGROUP = "consumerGroup";
private String consumerGroup;
@ -69,9 +69,9 @@ public class HeartbeatRequestBody extends Body {
body.setClientType(MapUtils.getString(bodyParam, CLIENTTYPE));
body.setConsumerGroup(MapUtils.getString(bodyParam, CONSUMERGROUP));
body.setHeartbeatEntities(JsonUtils
.deserialize(MapUtils.getString(bodyParam, HEARTBEATENTITIES),
new TypeReference<List<HeartbeatEntity>>() {
}));
.deserialize(MapUtils.getString(bodyParam, HEARTBEATENTITIES),
new TypeReference<List<HeartbeatEntity>>() {
}));
return body;
}
@ -94,10 +94,10 @@ public class HeartbeatRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("heartbeatEntity={")
.append("topic=").append(topic).append(",")
.append("serviceId=").append(serviceId).append(",")
.append("instanceId=").append(instanceId).append(",")
.append("url=").append(url).append("}");
.append("topic=").append(topic).append(",")
.append("serviceId=").append(serviceId).append(",")
.append("instanceId=").append(instanceId).append(",")
.append("url=").append(url).append("}");
return sb.toString();
}
}
@ -106,8 +106,8 @@ public class HeartbeatRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("heartbeatRequestBody={")
.append("consumerGroup=").append(consumerGroup).append(",")
.append("clientType=").append(clientType).append("}");
.append("consumerGroup=").append(consumerGroup).append(",")
.append("clientType=").append(clientType).append("}");
return sb.toString();
}
}

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class HeartbeatResponseBody extends Body {
//return code

View File

@ -72,8 +72,8 @@ public class RegRequestBody extends Body {
body.setClientType(MapUtils.getString(bodyParam, CLIENTTYPE));
body.setEndPoint(MapUtils.getString(bodyParam, ENDPOINT));
body.setTopics(JsonUtils.deserialize(MapUtils.getString(bodyParam, TOPICS),
new TypeReference<List<SubscriptionItem>>() {
}));
new TypeReference<List<SubscriptionItem>>() {
}));
return body;
}
@ -89,9 +89,9 @@ public class RegRequestBody extends Body {
@Override
public String toString() {
return "regRequestBody{"
+ "clientType='" + clientType + '\''
+ ", endPoint='" + endPoint + '\''
+ ", topics=" + topics
+ '}';
+ "clientType='" + clientType + '\''
+ ", endPoint='" + endPoint + '\''
+ ", topics=" + topics
+ '}';
}
}

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class RegResponseBody extends Body {
private Integer retCode;
private String retMsg;

View File

@ -71,8 +71,8 @@ public class SubscribeRequestBody extends Body {
SubscribeRequestBody body = new SubscribeRequestBody();
body.setUrl(MapUtils.getString(bodyParam, URL));
body.setTopics(JsonUtils.deserialize(MapUtils.getString(bodyParam, TOPIC),
new TypeReference<List<SubscriptionItem>>() {
}));
new TypeReference<List<SubscriptionItem>>() {
}));
body.setConsumerGroup(MapUtils.getString(bodyParam, CONSUMERGROUP));
return body;
}
@ -89,9 +89,9 @@ public class SubscribeRequestBody extends Body {
@Override
public String toString() {
return "subscribeBody{"
+ "consumerGroup='" + consumerGroup + '\''
+ ", url='" + url + '\''
+ ", topics=" + topics
+ '}';
+ "consumerGroup='" + consumerGroup + '\''
+ ", url='" + url + '\''
+ ", topics=" + topics
+ '}';
}
}

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class SubscribeResponseBody extends Body {
private Integer retCode;
private String retMsg;

View File

@ -58,8 +58,8 @@ public class UnRegRequestBody extends Body {
UnRegRequestBody body = new UnRegRequestBody();
body.setClientType(MapUtils.getString(bodyParam, CLIENTTYPE));
body.setTopics(JsonUtils.deserialize(MapUtils.getString(bodyParam, TOPICS),
new TypeReference<List<UnRegTopicEntity>>() {
}));
new TypeReference<List<UnRegTopicEntity>>() {
}));
return body;
}
@ -75,9 +75,9 @@ public class UnRegRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("regRequestBody={")
.append("clientType=").append(clientType)
.append("topics=").append(topics)
.append("}");
.append("clientType=").append(clientType)
.append("topics=").append(topics)
.append("}");
return sb.toString();
}
@ -90,9 +90,9 @@ public class UnRegRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("unRegTopicEntity={")
.append("topic=").append(topic).append(",")
.append("serviceId=").append(serviceId).append(",")
.append("instanceId=").append(instanceId).append("}");
.append("topic=").append(topic).append(",")
.append("serviceId=").append(serviceId).append(",")
.append("instanceId=").append(instanceId).append("}");
return sb.toString();
}
}

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class UnRegResponseBody extends Body {
private Integer retCode;
private String retMsg;

View File

@ -70,8 +70,8 @@ public class UnSubscribeRequestBody extends Body {
UnSubscribeRequestBody body = new UnSubscribeRequestBody();
body.setUrl(MapUtils.getString(bodyParam, URL));
body.setTopics(JsonUtils
.deserialize(MapUtils.getString(bodyParam, TOPIC), new TypeReference<List<String>>() {
}));
.deserialize(MapUtils.getString(bodyParam, TOPIC), new TypeReference<List<String>>() {
}));
body.setConsumerGroup(MapUtils.getString(bodyParam, CONSUMERGROUP));
return body;
}
@ -88,9 +88,9 @@ public class UnSubscribeRequestBody extends Body {
@Override
public String toString() {
return "unSubscribeRequestBody{"
+ "consumerGroup='" + consumerGroup + '\''
+ ", url='" + url + '\''
+ ", topics=" + topics
+ '}';
+ "consumerGroup='" + consumerGroup + '\''
+ ", url='" + url + '\''
+ ", topics=" + topics
+ '}';
}
}

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class UnSubscribeResponseBody extends Body {
private Integer retCode;

View File

@ -30,11 +30,11 @@ import com.fasterxml.jackson.core.type.TypeReference;
public class PushMessageRequestBody extends Body {
public static final String RANDOMNO = "randomNo";
public static final String TOPIC = "topic";
public static final String BIZSEQNO = "bizseqno";
public static final String UNIQUEID = "uniqueId";
public static final String CONTENT = "content";
public static final String RANDOMNO = "randomNo";
public static final String TOPIC = "topic";
public static final String BIZSEQNO = "bizseqno";
public static final String UNIQUEID = "uniqueId";
public static final String CONTENT = "content";
public static final String EXTFIELDS = "extFields";
private String randomNo;
@ -108,8 +108,8 @@ public class PushMessageRequestBody extends Body {
if (StringUtils.isNotBlank(extFields)) {
pushMessageRequestBody.setExtFields(
JsonUtils.deserialize(extFields, new TypeReference<HashMap<String, String>>() {
}));
JsonUtils.deserialize(extFields, new TypeReference<HashMap<String, String>>() {
}));
}
return pushMessageRequestBody;
}
@ -131,12 +131,12 @@ public class PushMessageRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("pushMessageRequestBody={")
.append("randomNo=").append(randomNo).append(",")
.append("topic=").append(topic).append(",")
.append("bizSeqNo=").append(bizSeqNo).append(",")
.append("uniqueId=").append(uniqueId).append(",")
.append("content=").append(content).append(",")
.append("extFields=").append(extFields).append("}");
.append("randomNo=").append(randomNo).append(",")
.append("topic=").append(topic).append(",")
.append("bizSeqNo=").append(bizSeqNo).append(",")
.append("uniqueId=").append(uniqueId).append(",")
.append("content=").append(content).append(",")
.append("extFields=").append(extFields).append("}");
return sb.toString();
}
}

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class PushMessageResponseBody extends Body {
private Integer retCode;

View File

@ -30,11 +30,11 @@ import com.fasterxml.jackson.core.type.TypeReference;
public class ReplyMessageRequestBody extends Body {
public static final String ORIGTOPIC = "origtopic";
public static final String BIZSEQNO = "bizseqno";
public static final String UNIQUEID = "uniqueid";
public static final String CONTENT = "content";
public static final String EXTFIELDS = "extFields";
public static final String ORIGTOPIC = "origtopic";
public static final String BIZSEQNO = "bizseqno";
public static final String UNIQUEID = "uniqueid";
public static final String CONTENT = "content";
public static final String EXTFIELDS = "extFields";
public static final String PRODUCERGROUP = "producergroup";
private String bizSeqNo;
@ -106,8 +106,8 @@ public class ReplyMessageRequestBody extends Body {
String extFields = MapUtils.getString(bodyParam, EXTFIELDS);
if (StringUtils.isNotBlank(extFields)) {
body.setExtFields(
JsonUtils.deserialize(extFields, new TypeReference<HashMap<String, String>>() {
}));
JsonUtils.deserialize(extFields, new TypeReference<HashMap<String, String>>() {
}));
}
body.setProducerGroup(MapUtils.getString(bodyParam, PRODUCERGROUP));
return body;
@ -117,12 +117,12 @@ public class ReplyMessageRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("replyMessageRequestBody={")
.append("bizSeqNo=").append(bizSeqNo).append(",")
.append("uniqueId=").append(uniqueId).append(",")
.append("origTopic=").append(origTopic).append(",")
.append("content=").append(content).append(",")
.append("producerGroup=").append(producerGroup).append(",")
.append("extFields=").append(extFields).append("}");
.append("bizSeqNo=").append(bizSeqNo).append(",")
.append("uniqueId=").append(uniqueId).append(",")
.append("origTopic=").append(origTopic).append(",")
.append("content=").append(content).append(",")
.append("producerGroup=").append(producerGroup).append(",")
.append("extFields=").append(extFields).append("}");
return sb.toString();
}

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class ReplyMessageResponseBody extends Body {
//return code

View File

@ -31,9 +31,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
public class SendMessageBatchRequestBody extends Body {
public static final String BATCHID = "batchId";
public static final String CONTENTS = "contents";
public static final String SIZE = "size";
public static final String BATCHID = "batchId";
public static final String CONTENTS = "contents";
public static final String SIZE = "size";
public static final String PRODUCERGROUP = "producerGroup";
private String batchId;
@ -83,10 +83,10 @@ public class SendMessageBatchRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("sendMessageBatchRequestBody={")
.append("batchId=").append(batchId).append(",")
.append("size=").append(size).append(",")
.append("producerGroup=").append(producerGroup).append(",")
.append("contents=").append(JsonUtils.serialize(contents)).append("}");
.append("batchId=").append(batchId).append(",")
.append("size=").append(size).append(",")
.append("producerGroup=").append(producerGroup).append(",")
.append("contents=").append(JsonUtils.serialize(contents)).append("}");
return sb.toString();
}
@ -101,29 +101,29 @@ public class SendMessageBatchRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("batchMessageEntity={")
.append("bizSeqNo=").append(bizSeqNo).append(",")
.append("topic=").append(topic).append(",")
.append("msg=").append(msg).append(",")
.append("ttl=").append(ttl).append(",")
.append("tag=").append(tag).append("}");
.append("bizSeqNo=").append(bizSeqNo).append(",")
.append("topic=").append(topic).append(",")
.append("msg=").append(msg).append(",")
.append("ttl=").append(ttl).append(",")
.append("tag=").append(tag).append("}");
return sb.toString();
}
}
public static SendMessageBatchRequestBody buildBody(final Map<String, Object> bodyParam) {
String batchId = MapUtils.getString(bodyParam,
BATCHID);
BATCHID);
String size = StringUtils.isBlank(MapUtils.getString(bodyParam,
SIZE)) ? "1" : MapUtils.getString(bodyParam,
SIZE);
SIZE)) ? "1" : MapUtils.getString(bodyParam,
SIZE);
String contents = MapUtils.getString(bodyParam,
CONTENTS, null);
CONTENTS, null);
SendMessageBatchRequestBody body = new SendMessageBatchRequestBody();
body.setBatchId(batchId);
if (StringUtils.isNotBlank(contents)) {
body.setContents(
JsonUtils.deserialize(contents, new TypeReference<List<BatchMessageEntity>>() {
}));
JsonUtils.deserialize(contents, new TypeReference<List<BatchMessageEntity>>() {
}));
}
body.setSize(size);
body.setProducerGroup(MapUtils.getString(bodyParam, PRODUCERGROUP));

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class SendMessageBatchResponseBody extends Body {
//return code

View File

@ -17,11 +17,12 @@
package org.apache.eventmesh.common.protocol.http.body.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.commons.collections4.MapUtils;
import org.apache.eventmesh.common.protocol.http.body.Body;
import java.util.HashMap;
import java.util.Map;
public class SendMessageBatchV2RequestBody extends Body {

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.body.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.body.Body;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.HashMap;
import java.util.Map;
public class SendMessageBatchV2ResponseBody extends Body {
//return code

View File

@ -30,13 +30,13 @@ import com.fasterxml.jackson.core.type.TypeReference;
public class SendMessageRequestBody extends Body {
public static final String TOPIC = "topic";
public static final String BIZSEQNO = "bizseqno";
public static final String UNIQUEID = "uniqueid";
public static final String CONTENT = "content";
public static final String TTL = "ttl";
public static final String TAG = "tag";
public static final String EXTFIELDS = "extFields";
public static final String TOPIC = "topic";
public static final String BIZSEQNO = "bizseqno";
public static final String UNIQUEID = "uniqueid";
public static final String CONTENT = "content";
public static final String TTL = "ttl";
public static final String TAG = "tag";
public static final String EXTFIELDS = "extFields";
public static final String PRODUCERGROUP = "producergroup";
private String topic;
@ -130,8 +130,8 @@ public class SendMessageRequestBody extends Body {
String extFields = MapUtils.getString(bodyParam, EXTFIELDS);
if (StringUtils.isNotBlank(extFields)) {
body.setExtFields(
JsonUtils.deserialize(extFields, new TypeReference<HashMap<String, String>>() {
}));
JsonUtils.deserialize(extFields, new TypeReference<HashMap<String, String>>() {
}));
}
body.setProducerGroup(MapUtils.getString(bodyParam, PRODUCERGROUP));
return body;
@ -155,14 +155,14 @@ public class SendMessageRequestBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("sendMessageRequestBody={")
.append("topic=").append(topic).append(",")
.append("bizSeqNo=").append(bizSeqNo).append(",")
.append("uniqueId=").append(uniqueId).append(",")
.append("content=").append(content).append(",")
.append("ttl=").append(ttl).append(",")
.append("tag=").append(tag).append(",")
.append("producerGroup=").append(producerGroup).append(",")
.append("extFields=").append(extFields).append("}");
.append("topic=").append(topic).append(",")
.append("bizSeqNo=").append(bizSeqNo).append(",")
.append("uniqueId=").append(uniqueId).append(",")
.append("content=").append(content).append(",")
.append("ttl=").append(ttl).append(",")
.append("tag=").append(tag).append(",")
.append("producerGroup=").append(producerGroup).append(",")
.append("extFields=").append(extFields).append("}");
return sb.toString();
}

View File

@ -73,9 +73,9 @@ public class SendMessageResponseBody extends Body {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("sendMessageResponseBody={")
.append("retCode=").append(retCode).append(",")
.append("retMsg=").append(retMsg).append(",")
.append("resTime=").append(DateFormatUtils.format(resTime, Constants.DATE_FORMAT)).append("}");
.append("retCode=").append(retCode).append(",")
.append("retMsg=").append(retMsg).append(",")
.append("resTime=").append(DateFormatUtils.format(resTime, Constants.DATE_FORMAT)).append("}");
return sb.toString();
}
@ -91,8 +91,8 @@ public class SendMessageResponseBody extends Body {
@Data
@Builder
public static class ReplyMessage {
public String topic;
public String body;
public String topic;
public String body;
public Map<String, String> properties;
}
}

View File

@ -17,11 +17,12 @@
package org.apache.eventmesh.common.protocol.http.header;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.commons.collections4.MapUtils;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import java.util.HashMap;
import java.util.Map;
public class BaseRequestHeader extends Header {
private String code;

View File

@ -18,11 +18,11 @@
package org.apache.eventmesh.common.protocol.http.header;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
public class BaseResponseHeader extends Header {
private String code;

View File

@ -18,8 +18,6 @@
package org.apache.eventmesh.common.protocol.http.header;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.RequestCode;
import org.apache.eventmesh.common.protocol.http.header.client.HeartbeatRequestHeader;
import org.apache.eventmesh.common.protocol.http.header.client.RegRequestHeader;
@ -32,6 +30,8 @@ import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatch
import org.apache.eventmesh.common.protocol.http.header.message.SendMessageBatchV2RequestHeader;
import org.apache.eventmesh.common.protocol.http.header.message.SendMessageRequestHeader;
import java.util.Map;
public abstract class Header {
public abstract Map<String, Object> toMap();

View File

@ -17,16 +17,17 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
public class HeartbeatRequestHeader extends Header {
//request code

View File

@ -18,12 +18,12 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class HeartbeatResponseHeader extends Header {
private int code;

View File

@ -17,13 +17,14 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;

View File

@ -18,12 +18,12 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class RegResponseHeader extends Header {
//response code, as same as the request code

View File

@ -17,13 +17,14 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;

View File

@ -17,12 +17,12 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class SubscribeResponseHeader extends Header {
private int code;

View File

@ -17,16 +17,17 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
public class UnRegRequestHeader extends Header {
//request code

View File

@ -18,12 +18,12 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class UnRegResponseHeader extends Header {
private int code;

View File

@ -17,13 +17,14 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;

View File

@ -17,12 +17,12 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class UnSubscribeResponseHeader extends Header {
private int code;

View File

@ -18,15 +18,16 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.collections4.MapUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import java.util.HashMap;
import java.util.Map;
public class PushMessageRequestHeader extends Header {
//request code

View File

@ -17,13 +17,14 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;

View File

@ -18,12 +18,12 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class ReplyMessageResponseHeader extends Header {
//response code, as same as the request code

View File

@ -18,13 +18,14 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;

View File

@ -18,12 +18,12 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class SendMessageBatchResponseHeader extends Header {
//response code, as same as the request code

View File

@ -17,13 +17,14 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;

View File

@ -17,12 +17,12 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class SendMessageBatchV2ResponseHeader extends Header {
//response code, as same as the request code

View File

@ -17,13 +17,14 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;

View File

@ -18,12 +18,12 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import java.util.HashMap;
import java.util.Map;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import java.util.HashMap;
import java.util.Map;
public class SendMessageResponseHeader extends Header {
//response code, as same as the request code

View File

@ -29,7 +29,8 @@
// private long lastUpdateTimestamp;
// private int protocolNumber;
//
// public EventMeshClientInfo(String clientId, String consumerGroup, String endpoint, String language, long version, DataVersion dataVersion, long lastUpdateTimestamp, int protocolNumber) {
// public EventMeshClientInfo(String clientId, String consumerGroup, String endpoint, String language, long version,
// DataVersion dataVersion, long lastUpdateTimestamp, int protocolNumber) {
// this.clientId = clientId;
// this.endpoint = endpoint;
// this.language = language;
@ -106,6 +107,8 @@
//
// @Override
// public String toString() {
// return "ClientId [clientId=" + clientId + ", consumerGroup=" + consumerGroup + ", endpoint=" + endpoint + ", language=" + language + ", version=" + version + ", dataVersion=" + dataVersion + ", lastUpdateTimestamp=" + lastUpdateTimestamp + "]";
// return "ClientId [clientId=" + clientId + ", consumerGroup=" + consumerGroup + ", endpoint=" + endpoint
// + ", language=" + language + ", version=" + version + ", dataVersion=" + dataVersion
// + ", lastUpdateTimestamp=" + lastUpdateTimestamp + "]";
// }
//}

View File

@ -29,7 +29,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
public class EventMeshMessage {
private String topic;
private String topic;
private Map<String, String> properties = new ConcurrentHashMap<>();
private String body;
private String body;
}

View File

@ -25,10 +25,10 @@ import lombok.Data;
@Data
public class Header {
private Command cmd;
private int code;
private String desc;
private String seq;
private Command cmd;
private int code;
private String desc;
private String seq;
private Map<String, Object> properties = new HashMap<>();
public Header() {
@ -72,4 +72,8 @@ public class Header {
return property.toString();
}
public Command getCommand() {
return this.cmd;
}
}

View File

@ -60,10 +60,12 @@ public class HeartBeatInfo {
@Override
public String toString() {
return "HeartBeatInfo{" +
"serviceId='" + serviceId + '\'' +
", instanceId='" + instanceId + '\'' +
", topicList=" + topicList +
'}';
return "HeartBeatInfo{"
+ "serviceId='" + serviceId
+ '\''
+ ", instanceId='" + instanceId
+ '\''
+ ", topicList=" + topicList
+ '}';
}
}

View File

@ -17,12 +17,14 @@
package org.apache.eventmesh.common.protocol.tcp;
import org.apache.eventmesh.common.protocol.ProtocolTransportObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor

View File

@ -47,9 +47,10 @@ public class RedirectInfo {
@Override
public String toString() {
return "RedirectInfo{" +
"ip='" + ip + '\'' +
", port=" + port +
'}';
return "RedirectInfo{"
+ "ip='" + ip
+ '\''
+ ", port=" + port
+ '}';
}
}

View File

@ -40,8 +40,8 @@ public class RegisterInfo {
@Override
public String toString() {
return "RegisterInfo{" +
"topicList=" + topicList +
'}';
return "RegisterInfo{"
+ "topicList=" + topicList
+ '}';
}
}

View File

@ -43,8 +43,8 @@ public class Subscription {
@Override
public String toString() {
return "Subscription{" +
"topicList=" + topicList +
'}';
return "Subscription{"
+ "topicList=" + topicList
+ '}';
}
}

View File

@ -60,10 +60,12 @@ public class UnRegisterInfo {
@Override
public String toString() {
return "UnRegisterInfo{" +
"serviceId='" + serviceId + '\'' +
", instanceId='" + instanceId + '\'' +
", topicList=" + topicList +
'}';
return "UnRegisterInfo{"
+ "serviceId='" + serviceId
+ '\''
+ ", instanceId='" + instanceId
+ '\''
+ ", topicList=" + topicList
+ '}';
}
}

View File

@ -17,11 +17,11 @@
package org.apache.eventmesh.common.protocol.tcp;
import java.util.Objects;
import lombok.Builder;
import lombok.Data;
import java.util.Objects;
@Data
@Builder
public class UserAgent {
@ -29,9 +29,9 @@ public class UserAgent {
private String env;
private String subsystem;
private String path;
private int pid;
private int pid;
private String host;
private int port;
private int port;
private String version;
private String username;
private String password;
@ -40,7 +40,7 @@ public class UserAgent {
private String consumerGroup;
private String purpose;
@Builder.Default
private int unack = 0;
private int unack = 0;
public UserAgent() {
}
@ -67,28 +67,67 @@ public class UserAgent {
@Override
public String toString() {
return String.format(
"UserAgent{env='%s', subsystem='%s', path='%s', pid=%d, host='%s', port=%d, version='%s', idc='%s', purpose='%s', unack='%d'}",
env, subsystem, path, pid, host, port, version, idc, purpose, unack);
"UserAgent{env='%s', subsystem='%s', path='%s', pid=%d, host='%s', port=%d, version='%s', idc='%s', purpose='%s', unack='%d'}",
env, subsystem, path, pid, host, port, version, idc, purpose, unack);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UserAgent userAgent = (UserAgent) o;
if (pid != userAgent.pid) return false;
if (port != userAgent.port) return false;
if (unack != userAgent.unack) return false;
if (!Objects.equals(subsystem, userAgent.subsystem)) return false;
if (!Objects.equals(path, userAgent.path)) return false;
if (!Objects.equals(host, userAgent.host)) return false;
if (!Objects.equals(purpose, userAgent.purpose)) return false;
if (!Objects.equals(version, userAgent.version)) return false;
if (!Objects.equals(username, userAgent.username)) return false;
if (!Objects.equals(password, userAgent.password)) return false;
if (!Objects.equals(env, userAgent.env)) return false;
if (pid != userAgent.pid) {
return false;
}
if (port != userAgent.port) {
return false;
}
if (unack != userAgent.unack) {
return false;
}
if (!Objects.equals(subsystem, userAgent.subsystem)) {
return false;
}
if (!Objects.equals(path, userAgent.path)) {
return false;
}
if (!Objects.equals(host, userAgent.host)) {
return false;
}
if (!Objects.equals(purpose, userAgent.purpose)) {
return false;
}
if (!Objects.equals(version, userAgent.version)) {
return false;
}
if (!Objects.equals(username, userAgent.username)) {
return false;
}
if (!Objects.equals(password, userAgent.password)) {
return false;
}
if (!Objects.equals(env, userAgent.env)) {
return false;
}
return Objects.equals(idc, userAgent.idc);
}

View File

@ -34,6 +34,11 @@ import java.util.Arrays;
import java.util.List;
import java.util.TimeZone;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.ReplayingDecoder;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
@ -41,24 +46,20 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.netty.handler.codec.ReplayingDecoder;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Codec {
private static final int FRAME_MAX_LENGTH = 1024 * 1024 * 4;
private static final Charset DEFAULT_CHARSET = Charset.forName(Constants.DEFAULT_CHARSET);
private static final int FRAME_MAX_LENGTH = 1024 * 1024 * 4;
private static final Charset DEFAULT_CHARSET = Charset.forName(Constants.DEFAULT_CHARSET);
private static final byte[] CONSTANT_MAGIC_FLAG = serializeBytes("EventMesh");
private static final byte[] VERSION = serializeBytes("0000");
private static final byte[] VERSION = serializeBytes("0000");
// todo: move to constants
public static String CLOUD_EVENTS_PROTOCOL_NAME = "cloudevents";
public static String EM_MESSAGE_PROTOCOL_NAME = "eventmeshmessage";
public static String EM_MESSAGE_PROTOCOL_NAME = "eventmeshmessage";
public static String OPEN_MESSAGE_PROTOCOL_NAME = "openmessage";
// todo: use json util
@ -178,8 +179,8 @@ public class Codec {
private void validateFlag(byte[] flagBytes, byte[] versionBytes, ChannelHandlerContext ctx) {
if (!Arrays.equals(flagBytes, CONSTANT_MAGIC_FLAG) || !Arrays.equals(versionBytes, VERSION)) {
String errorMsg = String.format(
"invalid magic flag or version|flag=%s|version=%s|remoteAddress=%s",
deserializeBytes(flagBytes), deserializeBytes(versionBytes), ctx.channel().remoteAddress());
"invalid magic flag or version|flag=%s|version=%s|remoteAddress=%s",
deserializeBytes(flagBytes), deserializeBytes(versionBytes), ctx.channel().remoteAddress());
throw new IllegalArgumentException(errorMsg);
}
}

View File

@ -36,8 +36,9 @@ public class IPUtils {
// if the progress works under docker environment
// return the host ip about this docker located from environment value
String dockerHostIp = System.getenv("docker_host_ip");
if (dockerHostIp != null && !"".equals(dockerHostIp))
if (dockerHostIp != null && !"".equals(dockerHostIp)) {
return dockerHostIp;
}
//priority of networkInterface when generating client ip
String priority = System.getProperty("networkInterface.priority", "eth0<eth1<bond1");
@ -56,10 +57,7 @@ public class IPUtils {
continue;
} else if (preferNetworkInterface == null) {
preferNetworkInterface = networkInterface;
}
//get the networkInterface that has higher priority
else if (preferList.indexOf(networkInterface.getName())
} else if (preferList.indexOf(networkInterface.getName()) //get the networkInterface that has higher priority
> preferList.indexOf(preferNetworkInterface.getName())) {
preferNetworkInterface = networkInterface;
}

View File

@ -22,7 +22,7 @@ import org.apache.commons.text.RandomStringGenerator;
public class RandomStringUtils {
private static final RandomStringGenerator RANDOM_NUM_GENERATOR = new RandomStringGenerator.Builder()
.withinRange('0', '9').build();
.withinRange('0', '9').build();
public static String generateNum(int length) {
return RANDOM_NUM_GENERATOR.generate(length);

View File

@ -68,7 +68,7 @@ public class EventMeshMessageTest {
prop.put("key1", "value1");
prop.put("key2", "value2");
return EventMeshMessage.builder()
.prop(prop)
.build();
.prop(prop)
.build();
}
}

View File

@ -17,17 +17,17 @@
package org.apache.eventmesh.common.loadbalance;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class RandomLoadBalanceSelectorTest {
private RandomLoadBalanceSelector<String> randomLoadBalanceSelector;

View File

@ -17,10 +17,8 @@
package org.apache.eventmesh.common.loadbalance;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.summingInt;
import java.lang.reflect.Field;
import java.util.ArrayList;
@ -29,8 +27,10 @@ import java.util.Map;
import java.util.function.Function;
import java.util.stream.IntStream;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.summingInt;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WeightRandomLoadBalanceSelectorTest {

View File

@ -17,17 +17,17 @@
package org.apache.eventmesh.common.loadbalance;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class WeightRoundRobinLoadBalanceSelectorTest {
private Logger logger = LoggerFactory.getLogger(WeightRoundRobinLoadBalanceSelectorTest.class);

View File

@ -17,12 +17,13 @@
package org.apache.eventmesh.common.protocol.http.body;
import static org.hamcrest.CoreMatchers.is;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
public class BaseResponseBodyTest {
@Test

View File

@ -18,14 +18,15 @@
package org.apache.eventmesh.common.protocol.http.header;
import static org.hamcrest.CoreMatchers.is;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import org.junit.Assert;
import org.junit.Test;
public class BaseRequestHeaderTest {

View File

@ -17,12 +17,13 @@
package org.apache.eventmesh.common.protocol.http.header;
import static org.hamcrest.CoreMatchers.is;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
public class BaseResponseHeaderTest {
@Test

View File

@ -19,6 +19,7 @@ package org.apache.eventmesh.common.protocol.http.header.client;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.junit.Assert;
public class AbstractRequestHeaderTest {

View File

@ -17,11 +17,12 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import static org.hamcrest.CoreMatchers.is;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.header.Header;
import org.junit.Assert;
import static org.hamcrest.CoreMatchers.is;
import org.junit.Assert;
public class AbstractResponseHeaderTest {

View File

@ -18,10 +18,10 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.junit.Test;
import java.util.HashMap;
import org.junit.Test;
public class HeartbeatRequestHeaderTest extends AbstractRequestHeaderTest {
@Test

View File

@ -17,12 +17,8 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
public class HeartbeatResponseHeaderTest extends AbstractResponseHeaderTest {
@Test

View File

@ -17,10 +17,10 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.junit.Test;
import java.util.HashMap;
import org.junit.Test;
public class RegRequestHeaderTest extends AbstractRequestHeaderTest {
@Test

View File

@ -17,10 +17,10 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.junit.Test;
import java.util.HashMap;
import org.junit.Test;
public class SubscribeRequestHeaderTest extends AbstractRequestHeaderTest {
@Test

View File

@ -18,10 +18,10 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.junit.Test;
import java.util.HashMap;
import org.junit.Test;
public class UnRegRequestHeaderTest extends AbstractRequestHeaderTest {
@Test

View File

@ -17,10 +17,10 @@
package org.apache.eventmesh.common.protocol.http.header.client;
import org.junit.Test;
import java.util.HashMap;
import org.junit.Test;
public class UnSubscribeRequestHeaderTest extends AbstractRequestHeaderTest {
@Test

View File

@ -17,17 +17,18 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import static org.hamcrest.CoreMatchers.is;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class PushMessageRequestHeaderTest {

View File

@ -17,14 +17,15 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import static org.hamcrest.CoreMatchers.is;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
public class PushMessageResponseHeaderTest {
@Test

View File

@ -17,17 +17,18 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import static org.hamcrest.CoreMatchers.is;
import org.apache.eventmesh.common.Constants;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.ProtocolVersion;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class ReplyMessageRequestHeaderTest {

View File

@ -17,12 +17,13 @@
package org.apache.eventmesh.common.protocol.http.header.message;
import static org.hamcrest.CoreMatchers.is;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
public class ReplyMessageResponseHeaderTest {
@Test

View File

@ -17,19 +17,26 @@
package org.apache.eventmesh.common.protocol.tcp.codec;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
import org.apache.eventmesh.common.protocol.tcp.Command;
import org.apache.eventmesh.common.protocol.tcp.Header;
import org.apache.eventmesh.common.protocol.tcp.Package;
import java.util.ArrayList;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
public class CodecTest {
@Test
public void testCodec() throws Exception {
Package testP = new Package();
Header header = new Header();
header.setCmd(Command.HELLO_REQUEST);
Package testP = new Package(header);
testP.setBody(new Object());
Codec.Encoder ce = new Codec.Encoder();
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer();
ce.encode(null, testP, buf);
@ -37,7 +44,7 @@ public class CodecTest {
ArrayList<Object> result = new ArrayList<>();
cd.decode(null, buf, result);
Assert.assertNotNull(result.get(0));
Assert.assertEquals(result.get(0).toString(), testP.toString());
Assert.assertEquals(testP.getHeader(), ((Package) result.get(0)).getHeader());
}
}

View File

@ -49,7 +49,9 @@ public class ThreadUtilsTest {
try {
ThreadUtils.randomSleep(50);
} catch (Exception ignore) {
//ignore
}
sleepTime = System.currentTimeMillis() - startTime;
}
}

View File

@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
eventMesh.server.env=value1
eventMesh.server.idc=value2
eventMesh.sysid=3

View File

@ -17,5 +17,8 @@
package org.apache.eventmesh.api;
/**
* AbstractContext
*/
public interface AbstractContext {
}

View File

@ -19,6 +19,9 @@ package org.apache.eventmesh.api;
import io.cloudevents.CloudEvent;
/**
* RequestReplyCallback
*/
public interface RequestReplyCallback {
void onSuccess(CloudEvent event);

View File

@ -14,11 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.eventmesh.api.connector;
import org.apache.eventmesh.spi.EventMeshExtensionType;
import org.apache.eventmesh.spi.EventMeshSPI;
/**
* ConnectorResourceService
*/
@EventMeshSPI(isSingleton = true, eventMeshExtensionType = EventMeshExtensionType.CONNECTOR)
public interface ConnectorResourceService {
@ -30,7 +34,7 @@ public interface ConnectorResourceService {
void init() throws Exception;
/**
*Resource release in connector,such as,some public threadpool if exist
* Resource release in connector,such as,some public threadpool if exist
*
* @throws Exception
*/

Some files were not shown because too many files have changed in this diff Show More