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#5863]add nacos client batchRegitserInstance request #8675

Conversation

chenhao26-nineteen
Copy link
Collaborator

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

for #5863 nacos client support batchRegister request

Brief changelog

XX

Verifying this change

XXXX

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean package apache-rat:check findbugs:findbugs -Dmaven.test.skip=true to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.

@markguy
Copy link

markguy commented Jul 3, 2022 via email

@codecov-commenter
Copy link

Codecov Report

Merging #8675 (1288888) into develop (6fe84f4) will increase coverage by 0.00%.
The diff coverage is 42.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop    #8675   +/-   ##
==========================================
  Coverage      41.59%   41.59%           
- Complexity      4480     4489    +9     
==========================================
  Files            884      885    +1     
  Lines          32245    32291   +46     
  Branches        3733     3738    +5     
==========================================
+ Hits           13411    13433   +22     
- Misses         17479    17503   +24     
  Partials        1355     1355           
Impacted Files Coverage Δ
...om/alibaba/nacos/api/naming/utils/NamingUtils.java 20.00% <0.00%> (-5.72%) ⬇️
...libaba/nacos/client/naming/NacosNamingService.java 86.09% <0.00%> (-1.75%) ⬇️
...lient/naming/remote/NamingClientProxyDelegate.java 84.12% <0.00%> (-10.52%) ⬇️
...ent/naming/remote/gprc/redo/RedoScheduledTask.java 73.13% <0.00%> (-4.65%) ⬇️
...naming/remote/gprc/redo/data/InstanceRedoData.java 100.00% <ø> (ø)
...ient/naming/remote/http/NamingHttpClientProxy.java 80.00% <0.00%> (-0.37%) ⬇️
...vice/impl/EphemeralClientOperationServiceImpl.java 68.42% <0.00%> (ø)
...g/remote/gprc/redo/data/BatchInstanceRedoData.java 87.50% <87.50%> (ø)
...ient/naming/remote/gprc/NamingGrpcClientProxy.java 82.35% <100.00%> (+1.30%) ⬆️
...naming/remote/gprc/redo/NamingGrpcRedoService.java 94.00% <100.00%> (+0.38%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6fe84f4...1288888. Read the comment docs.

for (int i = 0; i < newInstanceList.size(); i++) {
Instance instance = newInstanceList.get(i);
checkInstanceIsLegal(instance);
for (int j = i + 1; j < newInstanceList.size(); j++) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why not use set?

get

CopyOnWriteArrayList<Instance> newInstanceList = new CopyOnWriteArrayList<>(instances);
for (int i = 0; i < newInstanceList.size(); i++) {
Instance instance = newInstanceList.get(i);
checkInstanceIsLegal(instance);
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we check all instance is same ephemeral?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

should we check all instance is same ephemeral?

Yes, I adjusted it

NAMING_LOGGER.warn("batchRegisterInstance instances is Empty:{}", instances);
grpcClientProxy.batchRegisterService(serviceName, groupName, instances);
}
getExecuteClientProxy(instances.get(0)).batchRegisterService(serviceName, groupName, instances);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ArrayIndexOutOf if instances is empty.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't get the logic for double call batchRegisterService for different proxy.
The batch feature only add for grpc I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't get the logic for double call batchRegisterService for different proxy. The batch feature only add for grpc I think.

In order to adapt to the Nacos call style, I have modified it to grpc call

@@ -75,6 +76,12 @@ private void redoForInstance(InstanceRedoData redoData) throws NacosException {
if (isClientDisabled()) {
return;
}
if (redoData instanceof BatchInstanceRedoData) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

abstract line from 79 to 85 into other method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

abstract line from 79 to 85 into other method.

i abstract it

public static void checkInstanceIsEphemeral(Instance instance) throws NacosException {
if (!instance.isEphemeral()) {
throw new NacosException(NacosException.INVALID_PARAM,
String.format("Batch registration does not allow non-temporary instance registration , Instance:%s", instance));
Copy link
Collaborator

Choose a reason for hiding this comment

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

non-temporary -> non-ephemeral or persistent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

persistent

rigorous

@@ -487,7 +492,7 @@ public String callServer(String api, Map<String, String> params, Map<String, Str
HttpRestResult<String> restResult = nacosRestTemplate
.exchangeForm(url, header, Query.newInstance().initParams(params), body, method, String.class);
end = System.currentTimeMillis();

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why remove indent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why remove indent?

I have revised it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature type/feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants