conghuhu commented on code in PR #10543:
URL: https://github.com/apache/dubbo/pull/10543#discussion_r970378050
##########
dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscovery.java:
##########
@@ -206,28 +211,43 @@ public void
addServiceInstancesChangedListener(ServiceInstancesChangedListener l
}
private void watchEndpoints(ServiceInstancesChangedListener listener,
String serviceName) {
- Watch watch = kubernetesClient
- .endpoints()
- .inNamespace(namespace)
- .withName(serviceName)
- .watch(new Watcher<Endpoints>() {
- @Override
- public void eventReceived(Action action, Endpoints resource) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Endpoint Event. Event type: " +
action.name() +
- ". Current pod name: " + currentHostname);
+ SharedIndexInformer<Endpoints> endInformer = kubernetesClient
+ .endpoints()
+ .inNamespace(namespace)
+ .withName(serviceName)
+ .inform(new ResourceEventHandler<Endpoints>() {
+ @Override
+ public void onAdd(Endpoints endpoints) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Received Endpoint Event. Event type:
added. Current pod name: " + currentHostname +
+ ". Endpoints is: " + endpoints);
+ }
+
SERVICE_INSTANCE_MAP.put(getServiceCacheKey(serviceName),
toServiceInstance(endpoints, serviceName));
Review Comment:
I have removed useless SERVICE_INSTANCE_MAP. Pass serviceinstanceList which
converted by endpoints directly to notifyServiceChanged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]