Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #3863]Rename EventmeshRebalanceImpl class name and EventmeshRebalanceImpl#caculateRedirectNum method name #3864

Merged
merged 2 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpExceptionHandler;
import org.apache.eventmesh.runtime.core.protocol.tcp.client.EventMeshTcpMessageDispatcher;
import org.apache.eventmesh.runtime.core.protocol.tcp.client.group.ClientSessionGroupMapping;
import org.apache.eventmesh.runtime.core.protocol.tcp.client.rebalance.EventMeshRebalanceImpl;
import org.apache.eventmesh.runtime.core.protocol.tcp.client.rebalance.EventMeshRebalanceService;
import org.apache.eventmesh.runtime.core.protocol.tcp.client.rebalance.EventmeshRebalanceImpl;
import org.apache.eventmesh.runtime.core.protocol.tcp.client.session.retry.EventMeshTcpRetryer;
import org.apache.eventmesh.runtime.metrics.tcp.EventMeshTcpMonitor;
import org.apache.eventmesh.runtime.registry.Registry;
Expand Down Expand Up @@ -234,7 +234,7 @@ public void init() throws Exception {

if (eventMeshTCPConfiguration.isEventMeshServerRegistryEnable()) {
eventMeshRebalanceService = new EventMeshRebalanceService(this,
new EventmeshRebalanceImpl(this));
new EventMeshRebalanceImpl(this));
eventMeshRebalanceService.init();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class EventmeshRebalanceImpl implements EventMeshRebalanceStrategy {
public class EventMeshRebalanceImpl implements EventMeshRebalanceStrategy {

private final EventMeshTCPServer eventMeshTCPServer;

public EventmeshRebalanceImpl(EventMeshTCPServer eventMeshTCPServer) {
public EventMeshRebalanceImpl(EventMeshTCPServer eventMeshTCPServer) {
this.eventMeshTCPServer = eventMeshTCPServer;
}

Expand Down Expand Up @@ -107,11 +107,10 @@ private Map<String, String> queryLocalEventMeshMap(String cluster) {
return localEventMeshMap;
}

private void doRebalanceByGroup(String cluster, String group, String purpose, Map<String,
String> eventMeshMap) throws Exception {
private void doRebalanceByGroup(String cluster, String group, String purpose, Map<String, String> eventMeshMap) throws Exception {
log.info("doRebalanceByGroup start, cluster:{}, group:{}, purpose:{}", cluster, group, purpose);

//query distribute data of loacl idc
//query distribute data of local idc
Map<String, Integer> clientDistributionMap = queryLocalEventMeshDistributeData(cluster, group, purpose,
eventMeshMap);
if (MapUtils.isEmpty(clientDistributionMap)) {
Expand All @@ -130,12 +129,12 @@ private void doRebalanceRedirect(String currEventMeshName, String group, String
return;
}

//caculate client num need to redirect in currEventMesh
int judge = caculateRedirectNum(currEventMeshName, group, purpose, clientDistributionMap);
//calculate client num need to redirect in currEventMesh
int judge = calculateRedirectNum(currEventMeshName, group, purpose, clientDistributionMap);

if (judge > 0) {

//select redirect target eventmesh lisg
//select redirect target eventmesh list
List<String> eventMeshRecommendResult = selectRedirectEventMesh(group, eventMeshMap, clientDistributionMap,
judge, currEventMeshName);
if (eventMeshRecommendResult == null || eventMeshRecommendResult.size() != judge) {
Expand Down Expand Up @@ -184,8 +183,7 @@ private List<String> selectRedirectEventMesh(String group, Map<String, String> e
group, judge, eventMeshName);
}

public int caculateRedirectNum(String eventMeshName, String group, String purpose,
Map<String, Integer> clientDistributionMap) throws Exception {
public int calculateRedirectNum(String eventMeshName, String group, String purpose, Map<String, Integer> clientDistributionMap) throws Exception {
int sum = 0;
for (Integer item : clientDistributionMap.values()) {
sum += item;
Expand Down
Loading