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

Feature get subscribers #1297

Merged
merged 9 commits into from
Jun 17, 2019
Merged

Feature get subscribers #1297

merged 9 commits into from
Jun 17, 2019

Conversation

Nicholas2015
Copy link
Contributor

What is the purpose of the change
get the subscriber info by namespaceId、serviceName and aggregation

Brief changelog
Add an interface call in Pushservice to get subscription information from pushClient
Add aggregation judgment to control whether data is single-machine acquisition or cluster acquisition

Map<String, String> paramValues = new HashMap<>(128);
paramValues.put("serviceName",serviceName);
paramValues.put("namespaceId",namespaceId);
paramValues.put("aggregation",String.valueOf(!aggregation));
Copy link
Collaborator

Choose a reason for hiding this comment

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

不用取反,直接false就行

JSONObject result = new JSONObject();

try {
List<Subscriber> subscribers = subscribeManager.getSubscribers(serviceName,namespaceId,aggregation);
Copy link
Collaborator

Choose a reason for hiding this comment

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

代码没有格式化

String namespaceId = WebUtils.optional(request, CommonParams.NAMESPACE_ID,
Constants.DEFAULT_NAMESPACE_ID);
String serviceName = WebUtils.required(request, CommonParams.SERVICE_NAME);
boolean aggregation = Boolean.valueOf(WebUtils.required(request,"aggregation"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

改成可选,默认为true

// size = 1 means only myself in the list, we need at least one another server alive:
while (serverListManager.getHealthyServers().size() <= 1) {
Thread.sleep(1000L);
Loggers.EPHEMERAL.info("waiting server list init...");
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里不需要等待,小于等于1直接返回本机的订阅者就行

@Service
public class SubscribeManager {

private static final String DATA_ON_SYNC_URL = "/service/subscribers";
Copy link
Collaborator

Choose a reason for hiding this comment

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

常量名字换一下


/**
* @author Nicholas
*/
Copy link
Collaborator

@nkorange nkorange Jun 4, 2019

Choose a reason for hiding this comment

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

加上 @ since 1.0.1

for (Server server : serverListManager.getHealthyServers()) {

Map<String, String> paramValues = new HashMap<>(128);
paramValues.put("serviceName",serviceName);
Copy link
Collaborator

Choose a reason for hiding this comment

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

用常量替代

@nkorange
Copy link
Collaborator

nkorange commented Jun 5, 2019

Related issue is #494

@nkorange
Copy link
Collaborator

nkorange commented Jun 17, 2019

Nice work!

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.

3 participants