hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ph...@apache.org
Subject svn commit: r734847 [2/2] - in /hadoop/zookeeper/trunk: ./ src/java/jmx/ src/java/main/org/apache/zookeeper/jmx/ src/java/main/org/apache/zookeeper/server/ src/java/main/org/apache/zookeeper/server/persistence/ src/java/main/org/apache/zookeeper/server...
Date Thu, 15 Jan 2009 22:57:23 GMT
Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Leader.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Leader.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Leader.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/Leader.java Thu Jan 15 14:57:14 2009
@@ -32,9 +32,8 @@
 import java.util.List;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
-import org.apache.log4j.Logger;
-
 import org.apache.jute.BinaryOutputArchive;
+import org.apache.log4j.Logger;
 import org.apache.zookeeper.server.FinalRequestProcessor;
 import org.apache.zookeeper.server.Request;
 import org.apache.zookeeper.server.RequestProcessor;
@@ -241,85 +240,91 @@
      * @throws InterruptedException
      */
     void lead() throws IOException, InterruptedException {
-        self.tick = 0;
-        zk.loadData();
-        zk.startup();
-        long epoch = self.getLastLoggedZxid() >> 32L;
-        epoch++;
-        zk.setZxid(epoch << 32L);
-        zk.dataTree.lastProcessedZxid = zk.getZxid();
-        lastProposed = zk.getZxid();
-        newLeaderProposal.packet = new QuorumPacket(NEWLEADER, zk.getZxid(),
-                null, null);
-        if ((newLeaderProposal.packet.getZxid() & 0xffffffffL) != 0) {
-            LOG.warn("NEWLEADER proposal has Zxid of "
-                    + newLeaderProposal.packet.getZxid());
-        }
-        outstandingProposals.add(newLeaderProposal);
-        
-        // Start thread that waits for connection requests from 
-        // new followers.
-        cnxAcceptor = new FollowerCnxAcceptor();
-        cnxAcceptor.start();
-        
-        // We have to get at least a majority of servers in sync with
-        // us. We do this by waiting for the NEWLEADER packet to get
-        // acknowledged
-        newLeaderProposal.ackCount++;
-        while (newLeaderProposal.ackCount <= self.quorumPeers.size() / 2) {
-            if (self.tick > self.initLimit) {
-                // Followers aren't syncing fast enough,
-                // renounce leadership!
-                shutdown("Waiting for " + (self.quorumPeers.size() / 2)
-                        + " followers, only synced with "
-                        + newLeaderProposal.ackCount);
-                if (followers.size() >= self.quorumPeers.size() / 2) {
-                    LOG.warn("Enough followers present. "+
-                            "Perhaps the initTicks need to be increased.");
-                }
-                return;
+        zk.registerJMX(new LeaderBean(this, zk), self.jmxLocalPeerBean);
+
+        try {
+            self.tick = 0;
+            zk.loadData();
+            zk.startup();
+            long epoch = self.getLastLoggedZxid() >> 32L;
+            epoch++;
+            zk.setZxid(epoch << 32L);
+            zk.dataTree.lastProcessedZxid = zk.getZxid();
+            lastProposed = zk.getZxid();
+            newLeaderProposal.packet = new QuorumPacket(NEWLEADER, zk.getZxid(),
+                    null, null);
+            if ((newLeaderProposal.packet.getZxid() & 0xffffffffL) != 0) {
+                LOG.warn("NEWLEADER proposal has Zxid of "
+                        + newLeaderProposal.packet.getZxid());
             }
-            Thread.sleep(self.tickTime);
-            self.tick++;
-        }
-        if (!System.getProperty("zookeeper.leaderServes", "yes").equals("no")) {
-            self.cnxnFactory.setZooKeeperServer(zk);
-        }
-        // Everything is a go, simply start counting the ticks
-        // WARNING: I couldn't find any wait statement on a synchronized
-        // block that would be notified by this notifyAll() call, so
-        // I commented it out
-        //synchronized (this) {
-        //    notifyAll();
-        //}
-        // We ping twice a tick, so we only update the tick every other
-        // iteration
-        boolean tickSkip = true;
-
-        while (true) {
-            Thread.sleep(self.tickTime / 2);
-            if (!tickSkip) {
+            outstandingProposals.add(newLeaderProposal);
+            
+            // Start thread that waits for connection requests from 
+            // new followers.
+            cnxAcceptor = new FollowerCnxAcceptor();
+            cnxAcceptor.start();
+            
+            // We have to get at least a majority of servers in sync with
+            // us. We do this by waiting for the NEWLEADER packet to get
+            // acknowledged
+            newLeaderProposal.ackCount++;
+            while (newLeaderProposal.ackCount <= self.quorumPeers.size() / 2) {
+                if (self.tick > self.initLimit) {
+                    // Followers aren't syncing fast enough,
+                    // renounce leadership!
+                    shutdown("Waiting for " + (self.quorumPeers.size() / 2)
+                            + " followers, only synced with "
+                            + newLeaderProposal.ackCount);
+                    if (followers.size() >= self.quorumPeers.size() / 2) {
+                        LOG.warn("Enough followers present. "+
+                                "Perhaps the initTicks need to be increased.");
+                    }
+                    return;
+                }
+                Thread.sleep(self.tickTime);
                 self.tick++;
             }
-            int syncedCount = 0;
-            // lock on the followers when we use it.
-            synchronized (followers) {
-                for (FollowerHandler f : followers) {
-                    if (f.synced()) {
-                        syncedCount++;
+            if (!System.getProperty("zookeeper.leaderServes", "yes").equals("no")) {
+                self.cnxnFactory.setZooKeeperServer(zk);
+            }
+            // Everything is a go, simply start counting the ticks
+            // WARNING: I couldn't find any wait statement on a synchronized
+            // block that would be notified by this notifyAll() call, so
+            // I commented it out
+            //synchronized (this) {
+            //    notifyAll();
+            //}
+            // We ping twice a tick, so we only update the tick every other
+            // iteration
+            boolean tickSkip = true;
+    
+            while (true) {
+                Thread.sleep(self.tickTime / 2);
+                if (!tickSkip) {
+                    self.tick++;
+                }
+                int syncedCount = 0;
+                // lock on the followers when we use it.
+                synchronized (followers) {
+                    for (FollowerHandler f : followers) {
+                        if (f.synced()) {
+                            syncedCount++;
+                        }
+                        f.ping();
                     }
-                    f.ping();
                 }
+                if (!tickSkip && syncedCount < self.quorumPeers.size() / 2) {
+                    // Lost quorum, shutdown
+                    shutdown("Only " + syncedCount + " followers, need "
+                            + (self.quorumPeers.size() / 2));
+                    // make sure the order is the same!
+                    // the leader goes to looking
+                    return;
+                }
+                tickSkip = !tickSkip;
             }
-            if (!tickSkip && syncedCount < self.quorumPeers.size() / 2) {
-                // Lost quorum, shutdown
-                shutdown("Only " + syncedCount + " followers, need "
-                        + (self.quorumPeers.size() / 2));
-                // make sure the order is the same!
-                // the leader goes to looking
-                return;
-            }
-            tickSkip = !tickSkip;
+        } finally {
+            zk.unregisterJMX(this);
         }
     }
 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderBean.java Thu Jan 15 14:57:14 2009
@@ -16,14 +16,38 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
+
+import org.apache.zookeeper.server.ZooKeeperServerBean;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.apache.zookeeper.server.quorum.FollowerHandler;
+import org.apache.zookeeper.server.quorum.Leader;
 
 /**
  * Leader MBean interface implementation.
  */
-public class LeaderBean extends ServerBean implements LeaderMXBean {
-
+public class LeaderBean extends ZooKeeperServerBean implements LeaderMXBean {
+    private final Leader leader;
+    
+    public LeaderBean(Leader leader, ZooKeeperServer zks) {
+        super(zks);
+        this.leader = leader;
+    }
+    
     public String getName() {
         return "Leader";
     }
+
+    public String getCurrentZxid() {
+        return "0x" + Long.toHexString(zks.getZxid());
+    }
+    
+    public String followerInfo() {
+        StringBuffer sb = new StringBuffer();
+        for (FollowerHandler handler : leader.followers) {
+            sb.append(handler.toString()).append("\n");
+        }
+        return sb.toString();
+    }
+
 }

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderElectionBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderElectionBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderElectionBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionBean.java Thu Jan 15 14:57:14 2009
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
 import java.util.Date;
 
@@ -25,8 +25,8 @@
 /**
  * Leader election MBean interface implementation
  */
-public class LeaderElectionBean implements LeaderElectionMXBean,ZKMBeanInfo {
-    private final Date startTime=new Date();
+public class LeaderElectionBean implements LeaderElectionMXBean, ZKMBeanInfo {
+    private final Date startTime = new Date();
 
     public String getName() {
         return "LeaderElection";
@@ -39,5 +39,4 @@
     public String getStartTime() {
         return startTime.toString();
     }
-
 }

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionMXBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderElectionMXBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionMXBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionMXBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderElectionMXBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderElectionMXBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionMXBean.java Thu Jan 15 14:57:14 2009
@@ -16,17 +16,14 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
+
 
 /**
  * Leader election protocol MBean. 
  */
 public interface LeaderElectionMXBean {
     /**
-     * @return leader election instance name
-     */
-    public String getName();
-    /**
      * 
      * @return the time when the leader election started
      */

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionMXBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderElectionMXBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderMXBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderMXBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderMXBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderMXBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderMXBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LeaderMXBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderMXBean.java Thu Jan 15 14:57:14 2009
@@ -16,11 +16,21 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
+
+import org.apache.zookeeper.server.ZooKeeperServerMXBean;
 
 /**
  * Leader MBean.
  */
-public interface LeaderMXBean extends ServerMXBean {
+public interface LeaderMXBean extends ZooKeeperServerMXBean {
+    /**
+     * Current zxid of cluster.
+     */
+    public String getCurrentZxid();
 
+    /**
+     * @return information on current followers
+     */
+    public String followerInfo();
 }

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderMXBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderMXBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java Thu Jan 15 14:57:14 2009
@@ -20,6 +20,8 @@
 
 import java.io.IOException;
 
+import org.apache.zookeeper.jmx.MBeanRegistry;
+import org.apache.zookeeper.server.DataTreeBean;
 import org.apache.zookeeper.server.FinalRequestProcessor;
 import org.apache.zookeeper.server.PrepRequestProcessor;
 import org.apache.zookeeper.server.RequestProcessor;
@@ -85,4 +87,55 @@
     public void setZxid(long zxid) {
         hzxid = zxid;
     }
+
+    @Override
+    protected void registerJMX() {
+        // register with JMX
+        try {
+            jmxDataTreeBean = new DataTreeBean(dataTree);
+            MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
+        } catch (Exception e) {
+            LOG.warn("Failed to register with JMX", e);
+        }
+    }
+
+    public void registerJMX(LeaderBean leaderBean,
+            LocalPeerBean localPeerBean)
+    {
+        // register with JMX
+        try {
+            MBeanRegistry.getInstance().unregister(self.jmxLeaderElectionBean);
+            self.jmxLeaderElectionBean = null;
+
+            jmxServerBean = leaderBean;
+            MBeanRegistry.getInstance().register(leaderBean, localPeerBean);
+        } catch (Exception e) {
+            LOG.warn("Failed to register with JMX", e);
+        }
+    }
+
+    @Override
+    protected void unregisterJMX() {
+        // unregister from JMX
+        try {
+            if (jmxDataTreeBean != null) {
+                MBeanRegistry.getInstance().unregister(jmxDataTreeBean);
+            }
+        } catch (Exception e) {
+            LOG.warn("Failed to unregister with JMX", e);
+        }
+        jmxDataTreeBean = null;
+    }
+
+    protected void unregisterJMX(Leader leader) {
+        // unregister from JMX
+        try {
+            if (jmxServerBean != null) {
+                MBeanRegistry.getInstance().unregister(jmxServerBean);
+            }
+        } catch (Exception e) {
+            LOG.warn("Failed to unregister with JMX", e);
+        }
+        jmxServerBean = null;
+    }
 }

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LocalPeerBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LocalPeerBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LocalPeerBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerBean.java Thu Jan 15 14:57:14 2009
@@ -16,38 +16,53 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
-import org.apache.zookeeper.jmx.server.ZooKeeperServerBean;
-import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 
 /**
  * Implementation of the local peer MBean interface.
  */
-public class LocalPeerBean extends ZooKeeperServerBean implements LocalPeerMXBean {
-
-    private QuorumPeer peer;
+public class LocalPeerBean extends ServerBean implements LocalPeerMXBean {
+    private final QuorumPeer peer;
     
-    public LocalPeerBean(QuorumPeer peer){
-        this.peer=peer;
+    public LocalPeerBean(QuorumPeer peer) {
+        this.peer = peer;
     }
 
     public String getName() {
-        return "replica."+peer.getId();
+        return "replica." + peer.getId();
     }
 
     public boolean isHidden() {
         return false;
     }
 
+    public int getTickTime() {
+        return peer.getTickTime();
+    }
+    
+    public int getInitLimit() {
+        return peer.getInitLimit();
+    }
+    
+    public int getSyncLimit() {
+        return peer.getSyncLimit();
+    }
+    
+    public int getTick() {
+        return peer.getTick();
+    }
+    
+    public String getState() {
+        return peer.getState().toString();
+    }
+    
     public String getQuorumAddress() {
-        return peer.getQuorumAddress().getHostName()+":"+
-            peer.getQuorumAddress().getPort();
+        return peer.getQuorumAddress().toString();
     }
-
-    @Override
-    public ZooKeeperServer getZooKeeperServer() {
-        return peer.getActiveServer();
+    
+    public int getElectionType() {
+        return peer.getElectionType();
     }
 }

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerMXBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LocalPeerMXBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerMXBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerMXBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LocalPeerMXBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/LocalPeerMXBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerMXBean.java Thu Jan 15 14:57:14 2009
@@ -16,19 +16,49 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
-import org.apache.zookeeper.jmx.server.ZooKeeperServerMXBean;
 
 /**
  * A local zookeeper server MBean interface. Unlike the remote peer, the local
  * peer provides complete state/statistics at runtime and can be managed (just 
  * like a standalone zookeeper server).
  */
-public interface LocalPeerMXBean extends ZooKeeperServerMXBean{
+public interface LocalPeerMXBean extends ServerMXBean {
+    
     /**
-     * @return the IP address used for running quorum protocols and data 
-     * replication
+     * @return the number of milliseconds of each tick
+     */
+    public int getTickTime();
+    
+    /**
+     * @return the number of ticks that the initial sync phase can take
+     */
+    public int getInitLimit();
+    
+    /**
+     * @return the number of ticks that can pass between sending a request
+     * and getting a acknowledgment
+     */
+    public int getSyncLimit();
+    
+    /**
+     * @return the current tick
+     */
+    public int getTick();
+    
+    /**
+     * @return the current server state
+     */
+    public String getState();
+    
+    /**
+     * @return the quorum address
      */
     public String getQuorumAddress();
+    
+    /**
+     * @return the election type
+     */
+    public int getElectionType();
 }

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerMXBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LocalPeerMXBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ProposalRequestProcessor.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ProposalRequestProcessor.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ProposalRequestProcessor.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ProposalRequestProcessor.java Thu Jan 15 14:57:14 2009
@@ -18,7 +18,6 @@
 
 package org.apache.zookeeper.server.quorum;
 
-import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.server.Request;
 import org.apache.zookeeper.server.RequestProcessor;
 import org.apache.zookeeper.server.SyncRequestProcessor;

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/QuorumBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/QuorumBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/QuorumBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumBean.java Thu Jan 15 14:57:14 2009
@@ -16,21 +16,22 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
 import org.apache.zookeeper.jmx.ZKMBeanInfo;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 
-public class QuorumBean implements QuorumMXBean,ZKMBeanInfo {
-
-    private QuorumPeer peer;
+public class QuorumBean implements QuorumMXBean, ZKMBeanInfo {
+    private final QuorumPeer peer;
+    private final String name;
     
     public QuorumBean(QuorumPeer peer){
-        this.peer=peer;
+        this.peer = peer;
+        name = "ReplicatedServer_id" + peer.getMyid();
     }
     
     public String getName() {
-        return "ReplicatedServer";
+        return name;
     }
     
     public boolean isHidden() {
@@ -40,5 +41,4 @@
     public int getQuorumSize() {
         return peer.getQuorumSize();
     }
-
 }

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumMXBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/QuorumMXBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumMXBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumMXBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/QuorumMXBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/QuorumMXBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumMXBean.java Thu Jan 15 14:57:14 2009
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
 /**
  * An MBean representing a zookeeper cluster nodes (aka quorum peers)
@@ -26,6 +26,7 @@
      * @return the name of the quorum
      */
     public String getName();
+    
     /**
      * @return configured number of peers in the quorum
      */

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumMXBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumMXBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeer.java Thu Jan 15 14:57:14 2009
@@ -28,20 +28,13 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.jute.BinaryInputArchive;
-import org.apache.jute.InputArchive;
 import org.apache.log4j.Logger;
+import org.apache.zookeeper.jmx.MBeanRegistry;
+import org.apache.zookeeper.jmx.ZKMBeanInfo;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
 
-import static org.apache.zookeeper.server.quorum.QuorumPeerConfig.getElectionAlg;
-import static org.apache.zookeeper.server.quorum.QuorumPeerConfig.getInitLimit;
-import static org.apache.zookeeper.server.quorum.QuorumPeerConfig.getServerId;
-import static org.apache.zookeeper.server.quorum.QuorumPeerConfig.getServers;
-import static org.apache.zookeeper.server.quorum.QuorumPeerConfig.getSyncLimit;
-import static org.apache.zookeeper.server.quorum.QuorumPeerConfig.getTickTime;
-
 /**
  * This class manages the quorum protocol. There are three states this server
  * can be in:
@@ -72,6 +65,10 @@
 public class QuorumPeer extends Thread implements QuorumStats.Provider {
     private static final Logger LOG = Logger.getLogger(QuorumPeer.class);
 
+    QuorumBean jmxQuorumBean;
+    LocalPeerBean jmxLocalPeerBean;
+    LeaderElectionBean jmxLeaderElectionBean;
+
     /**
      * Create an instance of a quorum peer
      */
@@ -151,7 +148,7 @@
 
     /**
      * The number of ticks that can pass between sending a request and getting
-     * an acknowledgement
+     * an acknowledgment
      */
     int syncLimit;
 
@@ -255,17 +252,18 @@
     NIOServerCnxn.Factory cnxnFactory;
     private FileTxnSnapLog logFactory = null;
 
+    private final QuorumStats quorumStats;
     
     public QuorumPeer() {
         super("QuorumPeer");
-        QuorumStats.getInstance().setStatsProvider(this);
+        quorumStats = new QuorumStats(this);
     }
     
     public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
             File dataLogDir, int electionType,
             long myid, int tickTime, int initLimit, int syncLimit,
             NIOServerCnxn.Factory cnxnFactory) throws IOException {
-        super("QuorumPeer");
+        this();
         this.cnxnFactory = cnxnFactory;
         this.quorumPeers = quorumPeers;
         this.electionType = electionType;
@@ -274,7 +272,10 @@
         this.initLimit = initLimit;
         this.syncLimit = syncLimit;        
         this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
-        QuorumStats.getInstance().setStatsProvider(this);
+    }
+    
+    QuorumStats quorumStats() {
+        return quorumStats;
     }
     
     @Override
@@ -318,9 +319,12 @@
      */
     public QuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir,
             File logDir, int clientPort, int electionAlg,
-            long myid, int tickTime, int initLimit, int syncLimit) throws IOException {
+            long myid, int tickTime, int initLimit, int syncLimit)
+        throws IOException
+    {
         this(quorumPeers, snapDir, logDir, electionAlg,
-                myid,tickTime, initLimit,syncLimit,new NIOServerCnxn.Factory(clientPort));
+                myid,tickTime, initLimit,syncLimit,
+                new NIOServerCnxn.Factory(clientPort));
     }
     
     public long getLastLoggedZxid(){
@@ -362,6 +366,14 @@
     }
 
     protected Election makeLEStrategy(){
+        LOG.debug("Running leader election protocol...");
+        try {
+            jmxLeaderElectionBean = new LeaderElectionBean();
+            MBeanRegistry.getInstance().register(jmxLeaderElectionBean, jmxLocalPeerBean);        
+        } catch (Exception e) {
+            LOG.warn("Failed to register with JMX", e);
+        }
+
         if(electionAlg==null)
             return new LeaderElection(this);
         return electionAlg;
@@ -387,52 +399,79 @@
     public void run() {
         setName("QuorumPeer:" + cnxnFactory.getLocalAddress());
 
-        /*
-         * Main loop
-         */
-        while (running) {
-            switch (getPeerState()) {
-            case LOOKING:
-                try {
-                    LOG.info("LOOKING");
-                    setCurrentVote(makeLEStrategy().lookForLeader());
-                } catch (Exception e) {
-                    LOG.warn("Unexpected exception",e);
-                    setPeerState(ServerState.LOOKING);
-                }
-                break;
-            case FOLLOWING:
-                try {
-                    LOG.info("FOLLOWING");
-                    setFollower(makeFollower(logFactory));
-                    follower.followLeader();
-                } catch (Exception e) {
-                    LOG.warn("Unexpected exception",e);
-                } finally {
-                    follower.shutdown();
-                    setFollower(null);
-                    setPeerState(ServerState.LOOKING);
+        LOG.debug("Starting quorum peer");
+        try {
+            jmxQuorumBean = new QuorumBean(this);
+            MBeanRegistry.getInstance().register(jmxQuorumBean, null);
+            for(QuorumServer s: quorumPeers.values()){
+                ZKMBeanInfo p;
+                if (getId() == s.id) {
+                    p = jmxLocalPeerBean = new LocalPeerBean(this);
+                } else {
+                    p = new RemotePeerBean(s);
                 }
-                break;
-            case LEADING:
-                LOG.info("LEADING");
-                try {
-                    setLeader(makeLeader(logFactory));
-                    leader.lead();
-                    setLeader(null);
-                } catch (Exception e) {
-                    LOG.warn("Unexpected exception",e);
-                } finally {
-                    if (leader != null) {
-                        leader.shutdown("Forcing shutdown");
+                MBeanRegistry.getInstance().register(p, jmxQuorumBean);
+            }
+        } catch (Exception e) {
+            LOG.warn("Failed to register with JMX", e);
+        }
+
+        try {
+            /*
+             * Main loop
+             */
+            while (running) {
+                switch (getPeerState()) {
+                case LOOKING:
+                    try {
+                        LOG.info("LOOKING");
+                        setCurrentVote(makeLEStrategy().lookForLeader());
+                    } catch (Exception e) {
+                        LOG.warn("Unexpected exception",e);
+                        setPeerState(ServerState.LOOKING);
+                    }
+                    break;
+                case FOLLOWING:
+                    try {
+                        LOG.info("FOLLOWING");
+                        setFollower(makeFollower(logFactory));
+                        follower.followLeader();
+                    } catch (Exception e) {
+                        LOG.warn("Unexpected exception",e);
+                    } finally {
+                        follower.shutdown();
+                        setFollower(null);
+                        setPeerState(ServerState.LOOKING);
+                    }
+                    break;
+                case LEADING:
+                    LOG.info("LEADING");
+                    try {
+                        setLeader(makeLeader(logFactory));
+                        leader.lead();
                         setLeader(null);
+                    } catch (Exception e) {
+                        LOG.warn("Unexpected exception",e);
+                    } finally {
+                        if (leader != null) {
+                            leader.shutdown("Forcing shutdown");
+                            setLeader(null);
+                        }
+                        setPeerState(ServerState.LOOKING);
                     }
-                    setPeerState(ServerState.LOOKING);
+                    break;
                 }
-                break;
             }
+        } finally {
+            LOG.warn("QuorumPeer main thread exited");
+            try {
+                MBeanRegistry.getInstance().unregisterAll();
+            } catch (Exception e) {
+                LOG.warn("Failed to unregister with JMX", e);
+            }
+            jmxQuorumBean = null;
+            jmxLocalPeerBean = null;
         }
-        LOG.warn("QuorumPeer main thread exited");
     }
 
     public void shutdown() {
@@ -524,6 +563,13 @@
     }
 
     /**
+     * Get the current tick
+     */
+    public int getTick() {
+        return tick;
+    }
+    
+    /**
      * Get an instance of LeaderElection
      */
         

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java Thu Jan 15 14:57:14 2009
@@ -22,7 +22,10 @@
 import java.io.File;
 import java.io.IOException;
 
+import javax.management.JMException;
+
 import org.apache.log4j.Logger;
+import org.apache.zookeeper.jmx.ManagedUtil;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ServerConfig;
 import org.apache.zookeeper.server.ZooKeeperServerMain;
@@ -74,6 +77,12 @@
             System.exit(2);
         }
         if (!QuorumPeerConfig.isStandalone()) {
+            try {
+                ManagedUtil.registerLog4jMBeans();
+            } catch (JMException e) {
+                LOG.warn("Unable to register log4j JMX control", e);
+            }
+
             runPeer(new QuorumPeer.Factory() {
                 public QuorumPeer create(NIOServerCnxn.Factory cnxnFactory) throws IOException {
                     QuorumPeer peer = new QuorumPeer();
@@ -102,7 +111,6 @@
     
     public static void runPeer(QuorumPeer.Factory qpFactory) {
         try {
-            QuorumStats.registerAsConcrete();
             QuorumPeer self = qpFactory.create(qpFactory.createConnectionFactory());
             self.start();
             self.join();

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumStats.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumStats.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumStats.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumStats.java Thu Jan 15 14:57:14 2009
@@ -18,43 +18,29 @@
 
 package org.apache.zookeeper.server.quorum;
 
-import org.apache.zookeeper.server.ServerStats;
-
-public class QuorumStats extends ServerStats {
+public class QuorumStats {
+    private final Provider provider;
     
     public interface Provider {
-        static public final String UNKNOWN_STATE="unknown";
-        static public final String LOOKING_STATE="leaderelection";
-        static public final String LEADING_STATE="leading";
-        static public final String FOLLOWING_STATE="following";
+        static public final String UNKNOWN_STATE = "unknown";
+        static public final String LOOKING_STATE = "leaderelection";
+        static public final String LEADING_STATE = "leading";
+        static public final String FOLLOWING_STATE = "following";
         
         public String[] getQuorumPeers();
         public String getServerState();
     }
-    private Provider qprovider=null;
     
-    static public QuorumStats getInstance(){
-        ServerStats i=ServerStats.getInstance();
-        assert i==null || i instanceof QuorumStats;
-        return (QuorumStats)i;
-    }
-    static public void registerAsConcrete(){
-        assert getInstance()==null;
-        setInstance(new QuorumStats());
+    protected QuorumStats(Provider provider) {
+        this.provider = provider;
     }
-    protected QuorumStats(){}
     
-    public void setStatsProvider(Provider newProvider){
-        qprovider=newProvider;
-    }
-    
-    @Override
     public String getServerState(){
-        return (qprovider!=null)?qprovider.getServerState():Provider.UNKNOWN_STATE;
+        return provider.getServerState();
     }
     
     public String[] getQuorumPeers(){
-        return (qprovider!=null)?qprovider.getQuorumPeers():new String[0];
+        return provider.getQuorumPeers();
     }
 
     @Override

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/RemotePeerBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/RemotePeerBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/RemotePeerBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java Thu Jan 15 14:57:14 2009
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
 import org.apache.zookeeper.jmx.ZKMBeanInfo;
 import org.apache.zookeeper.server.quorum.QuorumPeer;

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/RemotePeerMXBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/RemotePeerMXBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/RemotePeerMXBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java Thu Jan 15 14:57:14 2009
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
 /**
  * A proxy for a remote quorum peer.

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/ServerBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/ServerBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/ServerBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java Thu Jan 15 14:57:14 2009
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
 import java.util.Date;
 

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java (from r734276, hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/ServerMXBean.java)
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java?p2=hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java&p1=hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/ServerMXBean.java&r1=734276&r2=734847&rev=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/jmx/org/apache/zookeeper/jmx/server/quorum/ServerMXBean.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java Thu Jan 15 14:57:14 2009
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.zookeeper.jmx.server.quorum;
+package org.apache.zookeeper.server.quorum;
 
 /**
  * A quorum server MBean.

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/CRCTest.java Thu Jan 15 14:57:14 2009
@@ -51,11 +51,9 @@
     @Override
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
-        ServerStats.registerAsConcrete();
     }
     @Override
     protected void tearDown() throws Exception {
-        ServerStats.unregister();
         LOG.info("FINISHED " + getName());
     }
     

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/InvalidSnapshotTest.java Thu Jan 15 14:57:14 2009
@@ -21,6 +21,8 @@
 import java.io.File;
 import java.io.RandomAccessFile;
 
+import junit.framework.TestCase;
+
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.WatchedEvent;
@@ -29,8 +31,6 @@
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.test.ClientBase;
 
-import junit.framework.TestCase;
-
 /**
  * this test checks that the server works 
  * even if the last snapshot is invalidated
@@ -43,17 +43,6 @@
     ZooKeeperServer zks = null;
     private static final int CONNECTION_TIMEOUT = 3000;
     
-    @Override
-    protected void setUp() throws Exception {
-        ServerStats.registerAsConcrete();
-    }
-    
-    @Override
-    protected void tearDown() throws Exception {
-        ServerStats.unregister();
-    }
-    
-   
     /**
      * this test does the main work of testing 
      * an invalid snapshot

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ACLTest.java Thu Jan 15 14:57:14 2009
@@ -18,26 +18,25 @@
 
 package org.apache.zookeeper.test;
 
+import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
+
 import java.io.File;
 import java.util.ArrayList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import junit.framework.TestCase;
-import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
+
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
+import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Id;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.server.DataTree;
 import org.apache.zookeeper.server.NIOServerCnxn;
-import org.apache.zookeeper.server.ServerStats;
 import org.apache.zookeeper.server.SyncRequestProcessor;
 import org.apache.zookeeper.server.ZooKeeperServer;
 
@@ -50,11 +49,9 @@
     @Override
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
-        ServerStats.registerAsConcrete();
     }
     @Override
     protected void tearDown() throws Exception {
-        ServerStats.unregister();
         LOG.info("FINISHED " + getName());
     }
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/ClientBase.java Thu Jan 15 14:57:14 2009
@@ -39,7 +39,6 @@
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.server.NIOServerCnxn;
-import org.apache.zookeeper.server.ServerStats;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.persistence.FileTxnLog;
 
@@ -288,8 +287,6 @@
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
 
-        ServerStats.registerAsConcrete();
-
         tmpDir = createTmpDir(BASETEST);
         
         setupTestEnv();
@@ -322,8 +319,6 @@
             recursiveDelete(tmpDir);
         }
 
-        ServerStats.unregister();
-
         LOG.info("FINISHED " + getName());
     }
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/FLETest.java Thu Jan 15 14:57:14 2009
@@ -25,18 +25,14 @@
 import java.util.HashSet;
 import java.util.Random;
 
+import junit.framework.TestCase;
+
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.server.quorum.FastLeaderElection;
-import org.apache.zookeeper.server.quorum.QuorumCnxManager;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
-import org.apache.zookeeper.server.quorum.QuorumStats;
 import org.apache.zookeeper.server.quorum.Vote;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
-
-import junit.framework.TestCase;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 public class FLETest extends TestCase {
@@ -93,7 +89,6 @@
         successCount = 0;
         finalObj = new Object();
         
-        QuorumStats.registerAsConcrete();
         LOG.info("SetUp " + getName());
     }
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/LETest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/LETest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/LETest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/LETest.java Thu Jan 15 14:57:14 2009
@@ -21,18 +21,16 @@
 import java.io.File;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
-import java.util.Random;
 import java.util.HashMap;
+import java.util.Random;
+
+import junit.framework.TestCase;
 
-import org.apache.log4j.Logger;
 import org.apache.zookeeper.server.quorum.LeaderElection;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
-import org.apache.zookeeper.server.quorum.QuorumStats;
 import org.apache.zookeeper.server.quorum.Vote;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 
-import junit.framework.TestCase;
-
 public class LETest extends TestCase {
     volatile Vote votes[];
     volatile boolean leaderDies;
@@ -92,7 +90,6 @@
         File tmpdir[] = new File[count];
         int port[] = new int[count];
         votes = new Vote[count];
-        QuorumStats.registerAsConcrete();
         for(int i = 0; i < count; i++) {
             peers.put(Long.valueOf(i), new QuorumServer(i, new InetSocketAddress("127.0.0.1", baseport+100+i)));
             tmpdir[i] = File.createTempFile("letest", "test");

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java Thu Jan 15 14:57:14 2009
@@ -26,7 +26,6 @@
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
-import org.apache.zookeeper.server.quorum.QuorumStats;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 import org.junit.After;
 import org.junit.Before;
@@ -61,7 +60,6 @@
         LOG.info("Setup finished");
     }
     void startServers() throws IOException, InterruptedException {
-        QuorumStats.registerAsConcrete();
         int tickTime = 2000;
         int initLimit = 3;
         int syncLimit = 3;
@@ -123,7 +121,6 @@
             LOG.info(hp + " is no longer accepting client connections");
         }
 
-        QuorumStats.unregister();
         LOG.info("FINISHED " + getName());
     }
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RecoveryTest.java Thu Jan 15 14:57:14 2009
@@ -35,7 +35,6 @@
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.server.NIOServerCnxn;
-import org.apache.zookeeper.server.ServerStats;
 import org.apache.zookeeper.server.SyncRequestProcessor;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.junit.Test;
@@ -50,11 +49,9 @@
     @Override
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
-        ServerStats.registerAsConcrete();
     }
     @Override
     protected void tearDown() throws Exception {
-        ServerStats.unregister();
         LOG.info("FINISHED " + getName());
     }
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/RepeatStartupTest.java Thu Jan 15 14:57:14 2009
@@ -18,8 +18,6 @@
 
 package org.apache.zookeeper.test;
 
-import java.io.IOException;
-
 import junit.framework.TestCase;
 
 import org.apache.zookeeper.CreateMode;
@@ -27,7 +25,6 @@
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.server.NIOServerCnxn;
 import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.quorum.QuorumPeer;
 
 /**
  * this test fails quorum peers 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java Thu Jan 15 14:57:14 2009
@@ -30,13 +30,12 @@
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.server.NIOServerCnxn;
-import org.apache.zookeeper.server.ServerStats;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.junit.Test;
 
@@ -52,8 +51,6 @@
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
 
-        ServerStats.registerAsConcrete();
-
         File tmpDir = ClientBase.createTmpDir();
 
         ClientBase.setupTestEnv();
@@ -74,7 +71,6 @@
                    ClientBase.waitForServerDown(HOSTPORT,
                                                 CONNECTION_TIMEOUT));
 
-        ServerStats.unregister();
         LOG.info("FINISHED " + getName());
     }
 

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SledgeHammer.java Thu Jan 15 14:57:14 2009
@@ -22,13 +22,13 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.WatchedEvent;
 
 public class SledgeHammer extends Thread implements Watcher {
     ZooKeeper zk;

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/UpgradeTest.java Thu Jan 15 14:57:14 2009
@@ -36,7 +36,6 @@
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.server.NIOServerCnxn;
-import org.apache.zookeeper.server.ServerStats;
 import org.apache.zookeeper.server.SyncRequestProcessor;
 import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.upgrade.UpgradeMain;
@@ -52,11 +51,9 @@
     @Override
     protected void setUp() throws Exception {
         LOG.info("STARTING " + getName());
-        ServerStats.registerAsConcrete();
     }
     @Override
     protected void tearDown() throws Exception {
-        ServerStats.unregister();
         LOG.info("FINISHED " + getName());
     }
     

Modified: hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java?rev=734847&r1=734846&r2=734847&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java (original)
+++ hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/WatcherTest.java Thu Jan 15 14:57:14 2009
@@ -29,8 +29,6 @@
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.TestableZooKeeper;
 import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.AsyncCallback.StatCallback;
 import org.apache.zookeeper.AsyncCallback.VoidCallback;



Mime
View raw message