Skip to content

Commit

Permalink
[Issue #774] Optimize the object property description of eventmesh cl…
Browse files Browse the repository at this point in the history
…ient (#775)

* modify: add group field in UserAgent, delete ProducerGroup and ConsumerGroup field

* modify: fix checksyle error

* modify: fix checksyle error in ClientGroupWrapper.java

close #774
  • Loading branch information
lrhkobe authored Feb 22, 2022
1 parent 10a1004 commit 0bd8f57
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public class UserAgent {
private String username;
private String password;
private String idc;
private String producerGroup;
private String consumerGroup;
private String group;
private String purpose;
@Builder.Default
private int unack = 0;
Expand All @@ -46,8 +45,7 @@ public UserAgent() {
}

public UserAgent(String env, String subsystem, String path, int pid, String host, int port, String version,
String username, String password, String idc, String producerGroup, String consumerGroup,
String purpose, int unack) {
String username, String password, String idc, String group, String purpose, int unack) {
this.env = env;
this.subsystem = subsystem;
this.path = path;
Expand All @@ -58,17 +56,17 @@ public UserAgent(String env, String subsystem, String path, int pid, String host
this.username = username;
this.password = password;
this.idc = idc;
this.producerGroup = producerGroup;
this.consumerGroup = consumerGroup;
this.group = group;
this.purpose = purpose;
this.unack = unack;
}

@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', group='%s', path='%s', pid=%d, host='%s',"
+ " port=%d, version='%s', idc='%s', purpose='%s', unack='%d'}",
env, subsystem, group, path, pid, host, port, version, idc, purpose, unack);
}

@Override
Expand Down Expand Up @@ -99,6 +97,10 @@ public boolean equals(Object o) {
return false;
}

if (!Objects.equals(group, userAgent.group)) {
return false;
}


if (!Objects.equals(path, userAgent.path)) {
return false;
Expand Down Expand Up @@ -134,6 +136,7 @@ public boolean equals(Object o) {
@Override
public int hashCode() {
int result = subsystem != null ? subsystem.hashCode() : 0;
result = 31 * result + (group != null ? group.hashCode() : 0);
result = 31 * result + (path != null ? path.hashCode() : 0);
result = 31 * result + pid;
result = 31 * result + (host != null ? host.hashCode() : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public static UserAgent generateClient1() {
.host("127.0.0.1")
.password(generateRandomString(8))
.username("PU4283")
.producerGroup("EventmeshTest-ProducerGroup")
.consumerGroup("EventmeshTest-ConsumerGroup")
.group("EventmeshTestGroup")
.path("/data/app/umg_proxy")
.port(8362)
.subsystem("5023")
Expand All @@ -70,8 +69,7 @@ public static UserAgent generateClient2() {
.host("127.0.0.1")
.password(generateRandomString(8))
.username("PU4283")
.producerGroup("EventmeshTest-ProducerGroup")
.consumerGroup("EventmeshTest-ConsumerGroup")
.group("EventmeshTestGroup")
.path("/data/app/umg_proxy")
.port(9362)
.subsystem("5017")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void handle(HttpExchange httpExchange) throws IOException {
for (ClientGroupWrapper cgw : clientGroupMap.values()) {
Set<Session> listenSessionSet = cgw.getTopic2sessionInGroupMapping().get(topic);
if (listenSessionSet != null && listenSessionSet.size() > 0) {
result += String.format("group:%s", cgw.getConsumerGroup()) + newLine;
result += String.format("group:%s", cgw.getGroup()) + newLine;
for (Session session : listenSessionSet) {
UserAgent userAgent = session.getClient();
result += String.format("pid=%s | ip=%s | port=%s | path=%s | version=%s", userAgent.getPid(), userAgent
Expand Down
Loading

0 comments on commit 0bd8f57

Please sign in to comment.