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

Method name optimization #3104

Merged
merged 8 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -75,7 +75,7 @@ public interface ConsistencyService {
* @param listener callback of data change
* @throws NacosException nacos exception
*/
void unlisten(String key, RecordListener listener) throws NacosException;
void unListen(String key, RecordListener listener) throws NacosException;

/**
* Tell the status of this consistency service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public void listen(String key, RecordListener listener) throws NacosException {
}

@Override
public void unlisten(String key, RecordListener listener) throws NacosException {
mapConsistencyService(key).unlisten(key, listener);
public void unListen(String key, RecordListener listener) throws NacosException {
mapConsistencyService(key).unListen(key, listener);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public void listen(String key, RecordListener listener) throws NacosException {
}

@Override
public void unlisten(String key, RecordListener listener) throws NacosException {
public void unListen(String key, RecordListener listener) throws NacosException {
if (!listeners.containsKey(key)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void listen(String key, RecordListener listener) throws NacosException {
}

@Override
public void unlisten(String key, RecordListener listener) throws NacosException {
public void unListen(String key, RecordListener listener) throws NacosException {
raftCore.unlisten(key, listener);
}

Expand Down
10 changes: 5 additions & 5 deletions naming/src/main/java/com/alibaba/nacos/naming/core/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private List<Instance> updatedIps(Collection<Instance> newInstance, Collection<I

Map<String, Integer> intersectMap = new ConcurrentHashMap<>(newInstance.size() + oldInstance.size());
Map<String, Instance> instanceMap = new ConcurrentHashMap<>(newInstance.size());
Map<String, Instance> instanceMap1 = new ConcurrentHashMap<>(newInstance.size());
Map<String, Instance> instancesMap = new ConcurrentHashMap<>(newInstance.size());
Copy link
Collaborator

Choose a reason for hiding this comment

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

I read method again and I think we should change instanceMap to updatedInstancesMap
change instanceMap1 to newInstancesMap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I change


for (Instance instance : oldInstance) {
if (stringIpAddressMap.containsKey(instance.getIp() + ":" + instance.getPort())) {
Expand All @@ -329,8 +329,8 @@ private List<Instance> updatedIps(Collection<Instance> newInstance, Collection<I
intersectMap.put(instance.toString(), 1);
}
}
instanceMap1.put(instance.toString(), instance);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not change the Indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I change

instancesMap.put(instance.toString(), instance);

}

Expand All @@ -339,8 +339,8 @@ private List<Instance> updatedIps(Collection<Instance> newInstance, Collection<I
Integer value = entry.getValue();

if (value == 1) {
if (instanceMap1.containsKey(key)) {
instanceMap.put(key, instanceMap1.get(key));
if (instancesMap.containsKey(key)) {
instanceMap.put(key, instancesMap.get(key));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void onDelete(String key) throws Exception {

consistencyService.remove(KeyBuilder.buildInstanceListKey(namespace, name, false));

consistencyService.unlisten(KeyBuilder.buildServiceMetaKey(namespace, name), service);
consistencyService.unListen(KeyBuilder.buildServiceMetaKey(namespace, name), service);
Loggers.SRV_LOG.info("[DEAD-SERVICE] {}", service.toJson());
}

Expand Down