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

[SCB-986] Cache instances result in CseDiscoveryClient #990

Merged
merged 5 commits into from Nov 19, 2018

Conversation

yangbor
Copy link
Member

@yangbor yangbor commented Nov 12, 2018

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

  • Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [SCB-XXX] Fixes bug in ApproximateQuantiles, where you replace SCB-XXX with the appropriate JIRA issue.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 86.66% when pulling 8045639 on yangbor:master into dd4554d on apache:master.


@Override
public int getOrder() {
return Integer.MAX_VALUE;
Copy link
Contributor

Choose a reason for hiding this comment

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

should give a change to filter List
so set order to be max int is not a good idea
we can set it to be: (int) Short.MAX_VALUE;


@Override
public DiscoveryTreeNode discovery(DiscoveryContext context, DiscoveryTreeNode parent) {
return createDiscoveryTreeNode(context, parent);
Copy link
Contributor

@wujimin wujimin Nov 12, 2018

Choose a reason for hiding this comment

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

there is no cache logic, because create new node each time,
take a look at: org.apache.servicecomb.loadbalance.filter.ServerDiscoveryFilter

@@ -75,5 +75,9 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>service-registry</artifactId>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

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

why need this new dependency?

Copy link
Member Author

Choose a reason for hiding this comment

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

The DiscoveryFilter interface is defined in this package

Copy link
Contributor

Choose a reason for hiding this comment

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

no , you add new core dependence

Copy link
Member Author

Choose a reason for hiding this comment

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

That's for Const.RESTFUL

List<ServiceInstance> instances = new ArrayList<>();
for (MicroserviceInstance instance : ((Map<String, MicroserviceInstance>) parent.data()).values()) {
for (String endpoint : instance.getEndpoints()) {
URIEndpointObject uri = new URIEndpointObject(endpoint);
Copy link
Contributor

Choose a reason for hiding this comment

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

zuul can not support highway
so we need to log and ignore highway endpoints

Map<String, MicroserviceInstance> servers = serversVersionedCache.data();
List<ServiceInstance> instances = new ArrayList<>(servers.size());
List<ServiceInstance> instances = null;
instances = serversVersionedCache.data();
Copy link
Contributor

Choose a reason for hiding this comment

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

merge line 93 and 94 to one line.

List<ServiceInstance> instances = null;
instances = serversVersionedCache.data();

//Map<String, MicroserviceInstance> servers = serversVersionedCache.data();
Copy link
Contributor

Choose a reason for hiding this comment

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

remote line from 96 to 104

@yangbor
Copy link
Member Author

yangbor commented Nov 13, 2018

@wujimin All are fixed, could you please check again?

protected DiscoveryTreeNode createDiscoveryTreeNode(DiscoveryContext context,
DiscoveryTreeNode parent) {
String serviceName = context.getInputParameters();
List<ServiceInstance> instances = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

not align?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will fix

@@ -44,24 +51,55 @@ public String description() {

@Override
public List<ServiceInstance> getInstances(final String serviceId) {
class InstanceDiscoveryFilter implements DiscoveryFilter {
Copy link
Contributor

Choose a reason for hiding this comment

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

put class InstanceDiscoveryFilter in "getInstances", make "getInstances" logic not clear

Copy link
Member Author

Choose a reason for hiding this comment

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

Will move to a separate class

}
return instances;

return serversVersionedCache.data();
Copy link
Contributor

Choose a reason for hiding this comment

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

what happened when serversVersionedCache is empty?

Copy link
Member Author

@yangbor yangbor Nov 14, 2018

Choose a reason for hiding this comment

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

It's OK for the versionedCache to be empty. As it will not be NULL. When there are associated filters and the children data is null, an Exception will be raised.

import java.util.List;
import java.util.Map;

import org.apache.servicecomb.core.Const;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove java-chassis-core dependency
define a new const "rest" or just hard code is enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@liubao68 liubao68 merged commit defbfa4 into apache:master Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants