Commit 95ceacfc authored by 赵禹光's avatar 赵禹光 Committed by 吴晟
Browse files

Fix the zookeeper plugin has many nodes in the cluster case (#3372)

* Fix the zookeeper plugin has many nodes in the cluster case

* support version
parent 8bf7e346
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import org.apache.zookeeper.proto.RequestHeader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
@@ -82,9 +84,14 @@ public class ClientCnxnInterceptor implements InstanceMethodsAroundInterceptor,
            field.setAccessible(true);
            @SuppressWarnings("unchecked")
            List<InetSocketAddress> serverAddresses = (List<InetSocketAddress>) field.get(hostProvider);
            StringBuilder peer = new StringBuilder();
            List<String> addresses = new ArrayList<String>();
            for (InetSocketAddress address : serverAddresses) {
                peer.append(address.getHostName()).append(":").append(address.getPort()).append(";");
                addresses.add(address.getHostName() + ":" + address.getPort());
            }
            Collections.sort(addresses);
            StringBuilder peer = new StringBuilder();
            for (String address : addresses) {
                peer.append(address).append(";");
            }
            objInst.setSkyWalkingDynamicField(peer.toString());
        } catch (NoSuchFieldException e) {
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@
* Service Discovery
  * [Netflix Eureka](https://github.com/Netflix/eureka)
* Distributed Coordination
  * [Zookeeper](https://github.com/apache/zookeeper) 3.4.x (Optional² & Except 3.4.4)
  * [Zookeeper](https://github.com/apache/zookeeper) 3.4.0+ (Optional² & Except 3.4.4)
* Spring Ecosystem
  * Spring Bean annotations(@Bean, @Service, @Component, @Repository) 3.x and 4.x (Optional²)
  * Spring Core Async SuccessCallback/FailureCallback/ListenableFutureCallback 4.x