Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

[DPM] Add gRPC/MQ auto switch mechanism #742

Merged
merged 6 commits into from
Mar 5, 2022

Conversation

VanderChen
Copy link
Contributor

In this PR,

  1. gRPC/MQ path switch logic is added in PathManagerService
  2. a new cache is added, which stores the current chosen path for each VPC.

The gRPC only mode has passed the Jenkins test.

@xieus xieus added the enhancement New feature or request label Feb 6, 2022
@xieus xieus added this to the Version 1.1.2022.05.30 milestone Feb 6, 2022
Comment on lines 70 to 71
case "MIXED":
return choosePath(portEntity);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VanderChen The "Mixed" mode for me seems not a real MIXED mode, doesn't it? I think "AUTO" is better to describe this mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cj-chung Good suggestion. The mode name is changed to "AUTO".

Comment on lines 120 to 121
if (numberOfPorts > UPPER_VPC_SIZE) {
chosenPath = !USE_GRPC;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VanderChen Why the line#105 shows that using USE_GRPC when numberOfPorts > UPPER_VPC_SIZE, but the line#120 shows that using !USE_GRPC in the same condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cj-chung Line#105 initialize a topic for a new VPC, and line#120 handles the situation of path change. As designed in doc, a simplified algorithm is implemented here.

Comment on lines +85 to +92
AtomicInteger atomicNumberOfPorts = new AtomicInteger();
List<String> subnetIds;
subnetIds = vpcSubnetsCache.getVpcSubnets(vpcId).getSubnetIds();
subnetIds.stream().forEach(subnetId -> {
try {
InternalSubnetPorts internalSubnetPorts = subnetPortsCache.getSubnetPorts(subnetId);
atomicNumberOfPorts.addAndGet(internalSubnetPorts.getPorts().size());
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VanderChen Do we have a better way to retrieve the VPC size (total number of ports) instead of calculating the size on the fly. I am worry about the latency here if it's a very big VPC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cj-chung Another option is counting in VpcPathCache. When creating ports, the counter in the cache is incremented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VanderChen Please create an issue for this problem and link to this PR

Copy link
Contributor Author

@VanderChen VanderChen Feb 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cj-chung Issue #744 is created and it seems that I have no authority to link the issue.

Comment on lines 106 to 111
if (numberOfPorts > UPPER_VPC_SIZE) {
vpcPathCache.setPath(vpcId, USE_GRPC);
return !USE_GRPC;
} else {
vpcPathCache.setPath(vpcId, !USE_GRPC);
return USE_GRPC;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VanderChen line#107 (USE_GRPC) and line #108 is not match (return !USE_GRPC). Same as line#110 and line#111.

Copy link
Contributor Author

@VanderChen VanderChen Feb 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cj-chung I have fixed this and use USE_MQ to replace ! USE_GRPC for clearer expression.

Copy link
Contributor

@cj-chung cj-chung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xieus xieus merged commit 22a4c8b into futurewei-cloud:master Mar 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants