chickenlj commented on code in PR #10543:
URL: https://github.com/apache/dubbo/pull/10543#discussion_r963355099


##########
dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscovery.java:
##########
@@ -168,23 +167,23 @@ public void doUnregister(ServiceInstance serviceInstance) 
throws RuntimeExceptio
     @Override
     public Set<String> getServices() {
         return kubernetesClient
-            .services()
-            .inNamespace(namespace)
-            .list()
-            .getItems()
-            .stream()
-            .map(service -> service.getMetadata().getName())
-            .collect(Collectors.toSet());
+                .services()
+                .inNamespace(namespace)
+                .list()
+                .getItems()
+                .stream()
+                .map(service -> service.getMetadata().getName())
+                .collect(Collectors.toSet());
     }
 
     @Override
     public List<ServiceInstance> getInstances(String serviceName) throws 
NullPointerException {
         Endpoints endpoints =
-            kubernetesClient
-                .endpoints()
-                .inNamespace(namespace)
-                .withName(serviceName)
-                .get();
+                kubernetesClient
+                        .endpoints()
+                        .inNamespace(namespace)
+                        .withName(serviceName)
+                        .get();

Review Comment:
   This step seems to still needs to interact with api-server directly on every 
event. 
   
   Is it possible for us to use the informer cache directly on each event 
notification? Introducing Informer guarantees that all events will be received 
even on connection loss but the cache hasn't been fully used. 



##########
dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesMeshEnvListener.java:
##########
@@ -134,42 +139,48 @@ private void subscribeDr(String appName) {
 
         try {
             Watch watch = kubernetesClient
-                .customResource(
-                    MeshConstant.getDrDefinition())
-                .watch(namespace, appName, null, new 
ListOptionsBuilder().build(), new Watcher<String>() {
-                    @Override
-                    public void eventReceived(Action action, String resource) {
-                        logger.info("Received VS Rule notification. AppName: " 
+ appName + " Action:" + action + " Resource:" + resource);
+                    .genericKubernetesResources(
+                            MeshConstant.getDrDefinition())
+                    .inNamespace(namespace)
+                    .withName(appName)
+                    .watch(new Watcher<GenericKubernetesResource>() {
+                        @Override
+                        public void eventReceived(Action action, 
GenericKubernetesResource resource) {
+                            if (logger.isInfoEnabled()) {
+                                logger.info("Received VS Rule notification. 
AppName: " + appName + " Action:" + action + " Resource:" + resource);
+                            }
 
-                        if (action == Action.ADDED || action == 
Action.MODIFIED) {
-                            Map drRuleMap = new Gson().fromJson(resource, 
Map.class);
-                            String drRule = new Yaml(new 
SafeConstructor()).dump(drRuleMap);
+                            if (action == Action.ADDED || action == 
Action.MODIFIED) {
+                                Map drRuleMap = new 
Gson().fromJson(resource.getMetadata().getName(), Map.class);

Review Comment:
   'drRuleMap' seems to be a rule but `resource.getMetadata().getName()` seems 
to be only a name.



-- 
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]

Reply via email to