Skip to content

Commit

Permalink
Merge branch 'apache:master' into developmentEM
Browse files Browse the repository at this point in the history
  • Loading branch information
devCod3r authored Aug 1, 2023
2 parents 77839f6 + a48410c commit d19baa5
Show file tree
Hide file tree
Showing 100 changed files with 1,925 additions and 2,363 deletions.
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ body:
options:
- label: Yes I am willing to submit a PR!

- type: checkboxes
attributes:
label: Code of Conduct
description: >
The Code of Conduct helps create a safe space for everyone. We require that everyone agrees to it..
options:
- label: I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) *

- type: markdown
attributes:
value: "Thanks for completing our form!"
10 changes: 9 additions & 1 deletion .github/ISSUE_TEMPLATE/documentation_related.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ body:
options:
- label: Yes I am willing to submit a PR!

- type: checkboxes
attributes:
label: Code of Conduct
description: >
The Code of Conduct helps create a safe space for everyone. We require that everyone agrees to it..
options:
- label: I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) *

- type: markdown
attributes:
value: "Thanks for completing our form!"
value: "Thanks for completing our form!"
9 changes: 8 additions & 1 deletion .github/ISSUE_TEMPLATE/enhancement_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ body:
options:
- label: Yes I am willing to submit a PR!

- type: checkboxes
attributes:
label: Code of Conduct
description: >
The Code of Conduct helps create a safe space for everyone. We require that everyone agrees to it..
options:
- label: I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) *
- type: markdown
attributes:
value: "Thanks for completing our form!"
value: "Thanks for completing our form!"
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ body:
options:
- label: Yes I am willing to submit a PR!

- type: checkboxes
attributes:
label: Code of Conduct
description: >
The Code of Conduct helps create a safe space for everyone. We require that everyone agrees to it..
options:
- label: I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) *

- type: markdown
attributes:
value: "Thanks for completing our form!"
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
import org.apache.eventmesh.common.protocol.http.common.EventMeshRetCode;
import org.apache.eventmesh.common.protocol.http.common.ProtocolKey;
import org.apache.eventmesh.common.protocol.http.common.RequestURI;
import org.apache.eventmesh.common.utils.IPUtils;
import org.apache.eventmesh.common.utils.JsonUtils;
import org.apache.eventmesh.common.utils.ThreadUtils;

import org.apache.commons.lang3.StringUtils;

import java.net.URI;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -194,20 +193,19 @@ public DefaultFullHttpResponse httpResponse() throws Exception {

public void buildSysHeaderForClient() {
// sys attributes
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.ENV, headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.ENV, "env"));
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.IDC, headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.IDC, "idc"));
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.IP, headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.IP, IPUtils.getLocalAddress()));
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.PID, headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.PID, ThreadUtils.getPID()));
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.SYS, headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.SYS, "1234"));
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.USERNAME, headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.USERNAME, "eventmesh"));
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.PASSWD, headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.PASSWD, "pass"));
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.PRODUCERGROUP,
headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.PRODUCERGROUP, "em-http-producer"));
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.CONSUMERGROUP,
headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.CONSUMERGROUP, "em-http-consumer"));
sysHeaderMap.put(ProtocolKey.PROTOCOL_TYPE, "http");
sysHeaderMap.put(ProtocolKey.PROTOCOL_DESC, "http");
sysHeaderMap.put(ProtocolKey.ClientInstanceKey.TOKEN, headerMap.getOrDefault(ProtocolKey.ClientInstanceKey.TOKEN, "token"));
EnumSet<ProtocolKey.ClientInstanceKey> clientInstanceKeys = EnumSet.allOf(ProtocolKey.ClientInstanceKey.class);
for (ProtocolKey.ClientInstanceKey clientInstanceKey : clientInstanceKeys) {
switch (clientInstanceKey) {
case BIZSEQNO:
case UNIQUEID:
break;
default:
sysHeaderMap.put(clientInstanceKey.getKey(),
headerMap.getOrDefault(clientInstanceKey.getKey(), clientInstanceKey.getValue()));
}
}
}

public void buildSysHeaderForCE() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

package org.apache.eventmesh.common.protocol.http.common;

import org.apache.eventmesh.common.utils.IPUtils;
import org.apache.eventmesh.common.utils.ThreadUtils;

public class ProtocolKey {

public static final String REQUEST_CODE = "code";
Expand All @@ -32,22 +35,39 @@ public class ProtocolKey {

public static final String CONTENT_TYPE = "contenttype";

public static class ClientInstanceKey {
public enum ClientInstanceKey {

////////////////////////////////////Protocol layer requester description///////////
public static final String ENV = "env";
public static final String IDC = "idc";
public static final String SYS = "sys";
public static final String PID = "pid";
public static final String IP = "ip";
public static final String USERNAME = "username";
public static final String PASSWD = "passwd";
public static final String BIZSEQNO = "bizseqno";
public static final String UNIQUEID = "uniqueid";
public static final String PRODUCERGROUP = "producergroup";
public static final String CONSUMERGROUP = "consumergroup";

public static final String TOKEN = "token";
ENV("env", "env"),
IDC("idc", "idc"),
SYS("sys", "1234"),
PID("pid", ThreadUtils.getPID()),
IP("ip", IPUtils.getLocalAddress()),
USERNAME("username", "eventmesh"),
PASSWD("passwd", "pass"),
BIZSEQNO("bizseqno", "bizseqno"),
UNIQUEID("uniqueid", "uniqueid"),
PRODUCERGROUP("producergroup", "em-http-producer"),
CONSUMERGROUP("consumergroup", "em-http-consumer"),

TOKEN("token", "token");

private final String key;

private final Object value;

public String getKey() {
return key;
}

public Object getValue() {
return value;
}

ClientInstanceKey(String key, Object value) {
this.key = key;
this.value = value;
}
}


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

package org.apache.eventmesh.common.protocol.http.header.client;

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.eventmesh.common.utils.HttpConvertsUtils;

import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class HeartbeatRequestHeader extends Header {

//request code
Expand Down Expand Up @@ -62,133 +65,16 @@ public class HeartbeatRequestHeader extends Header {
//PASSWD of the requester
private String passwd = "user@123";

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getLanguage() {
return language;
}

public void setLanguage(String language) {
this.language = language;
}

public ProtocolVersion getVersion() {
return version;
}

public void setVersion(ProtocolVersion version) {
this.version = version;
}

public String getEnv() {
return env;
}

public void setEnv(String env) {
this.env = env;
}

public String getIdc() {
return idc;
}

public void setIdc(String idc) {
this.idc = idc;
}

public String getSys() {
return sys;
}

public void setSys(String sys) {
this.sys = sys;
}

public String getPid() {
return pid;
}

public void setPid(String pid) {
this.pid = pid;
}

public String getIp() {
return ip;
}

public void setIp(String ip) {
this.ip = ip;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPasswd() {
return passwd;
}

public void setPasswd(String passwd) {
this.passwd = passwd;
}

@Override
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<String, Object>();
map.put(ProtocolKey.REQUEST_CODE, code);
map.put(ProtocolKey.LANGUAGE, language);
map.put(ProtocolKey.VERSION, version);
map.put(ProtocolKey.ClientInstanceKey.ENV, env);
map.put(ProtocolKey.ClientInstanceKey.IDC, idc);
map.put(ProtocolKey.ClientInstanceKey.SYS, sys);
map.put(ProtocolKey.ClientInstanceKey.PID, pid);
map.put(ProtocolKey.ClientInstanceKey.IP, ip);
map.put(ProtocolKey.ClientInstanceKey.USERNAME, username);
map.put(ProtocolKey.ClientInstanceKey.PASSWD, passwd);
return map;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("heartbeatRequestHeader={")
.append("code=").append(code).append(",")
.append("language=").append(language).append(",")
.append("version=").append(version).append(",")
.append("env=").append(env).append(",")
.append("idc=").append(idc).append(",")
.append("sys=").append(sys).append(",")
.append("pid=").append(pid).append(",")
.append("ip=").append(ip).append(",")
.append("username=").append(username).append(",")
.append("passwd=").append(passwd).append("}");
return sb.toString();
HttpConvertsUtils httpConvertsUtils = new HttpConvertsUtils();
ProtocolKey protocolKey = new ProtocolKey();
return httpConvertsUtils.httpMapConverts(this, protocolKey);
}

public static HeartbeatRequestHeader buildHeader(Map<String, Object> headerParam) {
HttpConvertsUtils httpConvertsUtils = new HttpConvertsUtils();
HeartbeatRequestHeader header = new HeartbeatRequestHeader();
header.setCode(MapUtils.getString(headerParam, ProtocolKey.REQUEST_CODE));
header.setVersion(ProtocolVersion.get(MapUtils.getString(headerParam, ProtocolKey.VERSION)));
String lan = StringUtils.isBlank(MapUtils.getString(headerParam, ProtocolKey.LANGUAGE))
? Constants.LANGUAGE_JAVA : MapUtils.getString(headerParam, ProtocolKey.LANGUAGE);
header.setLanguage(lan);
header.setEnv(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.ENV));
header.setIdc(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.IDC));
header.setSys(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.SYS));
header.setPid(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.PID));
header.setIp(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.IP));
header.setUsername(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.USERNAME));
header.setPasswd(MapUtils.getString(headerParam, ProtocolKey.ClientInstanceKey.PASSWD));
return header;
return (HeartbeatRequestHeader) httpConvertsUtils.httpHeaderConverts(header, headerParam);
}
}
Loading

0 comments on commit d19baa5

Please sign in to comment.