zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivankelly <...@git.apache.org>
Subject [GitHub] zookeeper pull request #546: ZOOKEEPER-3066 Expose on JMX of Followers the i...
Date Wed, 20 Jun 2018 15:18:05 GMT
Github user ivankelly commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/546#discussion_r196823442
  
    --- Diff: src/java/test/org/apache/zookeeper/test/HierarchicalQuorumTest.java ---
    @@ -227,37 +227,73 @@ void startServers(boolean withObservers) throws Exception {
                 LOG.info(hp + " is accepting client connections");
             }
     
    +        final int numberOfPeers = 5;
    +
             // interesting to see what's there...
             JMXEnv.dump();
             // make sure we have these 5 servers listed
             Set<String> ensureNames = new LinkedHashSet<String>();
    -        for (int i = 1; i <= 5; i++) {
    +        for (int i = 1; i <= numberOfPeers; i++) {
                 ensureNames.add("InMemoryDataTree");
             }
    -        for (int i = 1; i <= 5; i++) {
    +        for (int i = 1; i <= numberOfPeers; i++) {
                 ensureNames.add("name0=ReplicatedServer_id" + i
                      + ",name1=replica." + i + ",name2=");
             }
    -        for (int i = 1; i <= 5; i++) {
    -            for (int j = 1; j <= 5; j++) {
    +        for (int i = 1; i <= numberOfPeers; i++) {
    +            for (int j = 1; j <= numberOfPeers; j++) {
                     ensureNames.add("name0=ReplicatedServer_id" + i
                          + ",name1=replica." + j);
                 }
             }
    -        for (int i = 1; i <= 5; i++) {
    +        for (int i = 1; i <= numberOfPeers; i++) {
                 ensureNames.add("name0=ReplicatedServer_id" + i);
             }
             JMXEnv.ensureAll(ensureNames.toArray(new String[ensureNames.size()]));
    -
    -        for (int i = 1; i <= 5; i++) {
    +        int countLeadersUsingLocalPeerBean = 0;
    +        for (int i = 1; i <= numberOfPeers; i++) {
    +            // LocalPeerBean
                 String bean = CommonNames.DOMAIN + ":name0=ReplicatedServer_id" + i
                         + ",name1=replica." + i;
                 JMXEnv.ensureBeanAttribute(bean, "ConfigVersion");
                 JMXEnv.ensureBeanAttribute(bean, "LearnerType");
                 JMXEnv.ensureBeanAttribute(bean, "ClientAddress");
                 JMXEnv.ensureBeanAttribute(bean, "ElectionAddress");
                 JMXEnv.ensureBeanAttribute(bean, "QuorumSystemInfo");
    +            boolean leader = (boolean) JMXEnv.ensureBeanAttribute(bean, "Leader");
    +            if (leader) {
    +                countLeadersUsingLocalPeerBean++;
    +            }
             }
    +        Assert.assertEquals(1, countLeadersUsingLocalPeerBean);
    +
    +
    +        int countLeadersUseRemotePeerBean = 0;
    --- End diff --
    
    Would be good to test that the jmx is correctly updated if the leader changes.


---

Mime
View raw message