hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r748642 - in /hadoop/zookeeper/trunk: ./ src/java/main/org/apache/zookeeper/server/ src/java/main/org/apache/zookeeper/server/quorum/
Date Fri, 27 Feb 2009 19:00:14 GMT
Author: mahadev
Date: Fri Feb 27 19:00:08 2009
New Revision: 748642

URL: http://svn.apache.org/viewvc?rev=748642&view=rev
Log:
ZOOKEEPER-330. zookeeper standalone server does not startup with just a port and datadir.
(chris darroch and mahadev)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerConfig.java
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java
    hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=748642&r1=748641&r2=748642&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Fri Feb 27 19:00:08 2009
@@ -8,6 +8,9 @@
 
 BUGFIXES: 
   ZOOKEEPER-303. Bin scripts dont work on a Mac. (tom white via mahadev)
+  
+  ZOOKEEPER-330. zookeeper standalone server does not startup with just a port
+and datadir. (chris darroch and mahadev)
  
 IMPROVEMENTS:
   ZOOKEEPER-308. improve the atomic broadcast performance 3x. (breed via

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerConfig.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerConfig.java?rev=748642&r1=748641&r2=748642&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerConfig.java (original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerConfig.java Fri
Feb 27 19:00:08 2009
@@ -22,12 +22,15 @@
     private int clientPort;
     private String dataDir;
     private String dataLogDir;
+    private int tickTime;
     
-    protected ServerConfig(int port, String dataDir,String dataLogDir) {
+    protected ServerConfig(int port, String dataDir,String dataLogDir, int tickTime) {
         this.clientPort = port;
         this.dataDir = dataDir;
         this.dataLogDir=dataLogDir;
+        this.tickTime = tickTime;
     }
+    
     protected boolean isStandaloneServer(){
         return true;
     }
@@ -49,16 +52,27 @@
         return instance.isStandaloneServer();
     }
     
+    public static int getTickTime() {
+        assert instance != null;
+        return instance.tickTime;
+    }
+    
     protected static ServerConfig instance=null;
     
     public static void parse(String[] args) throws Exception {
         if(instance!=null)
             return;
-        if (args.length != 2) {
+        if (args.length < 2) {
             throw new IllegalArgumentException("Invalid usage.");
         }
+        int tickTime = ZooKeeperServer.DEFAULT_TICK_TIME;
+        if (args.length > 2) {
+            // the last parameter ticktime is optional
+            tickTime = Integer.parseInt(args[2]);
+        }
         try {
-              instance=new ServerConfig(Integer.parseInt(args[0]),args[1],args[1]);
+              instance=new ServerConfig(Integer.parseInt(args[0]),args[1],
+                      args[1], tickTime);
         } catch (NumberFormatException e) {
             throw new IllegalArgumentException(args[0] + " is not a valid port number");
         }

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java?rev=748642&r1=748641&r2=748642&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java
(original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java
Fri Feb 27 19:00:08 2009
@@ -93,7 +93,7 @@
         }
     }
 
-    private static final int DEFAULT_TICK_TIME = 3000;
+    public static final int DEFAULT_TICK_TIME = 3000;
     protected int tickTime = DEFAULT_TICK_TIME;
 
     public static final int commitLogCount = 500;

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java?rev=748642&r1=748641&r2=748642&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java
(original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java
Fri Feb 27 19:00:08 2009
@@ -34,7 +34,7 @@
 public class ZooKeeperServerMain {
 
     private static final Logger LOG = Logger.getLogger(ZooKeeperServerMain.class);
-    private static final String USAGE = "Usage: ZooKeeperServerMain port datadir";
+    private static final String USAGE = "Usage: ZooKeeperServerMain configfile | port datadir
[ticktime]";
     /*
      * Start up the ZooKeeper server.
      *
@@ -48,7 +48,11 @@
         }
 
         try {
-            QuorumPeerConfig.parse(args);
+            if (args.length == 1) {
+                QuorumPeerConfig.parse(args);
+            } else {
+                ServerConfig.parse(args);
+            }
         } catch(Exception e) {
             LOG.fatal("Error in config", e);
             LOG.info(USAGE);
@@ -67,7 +71,7 @@
                        File(ServerConfig.getDataLogDir()),
                         new File(ServerConfig.getDataDir()));
                zks.setTxnLogFactory(ftxn);
-               zks.setTickTime(QuorumPeerConfig.getTickTime());
+               zks.setTickTime(ServerConfig.getTickTime());
                return zks;
             }
         });

Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java?rev=748642&r1=748641&r2=748642&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
(original)
+++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
Fri Feb 27 19:00:08 2009
@@ -30,6 +30,7 @@
 import org.apache.log4j.Logger;
 
 import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 
 public class QuorumPeerConfig extends ServerConfig {
@@ -43,8 +44,8 @@
     private HashMap<Long,QuorumServer> servers = null;
     private long serverId;
 
-    private QuorumPeerConfig(int port, String dataDir, String dataLogDir) {
-        super(port, dataDir, dataLogDir);
+    private QuorumPeerConfig(int port, String dataDir, String dataLogDir, int tickTime) {
+        super(port, dataDir, dataLogDir, tickTime);
     }
 
     public static void parse(String[] args) throws Exception {
@@ -137,8 +138,7 @@
             throw new IllegalArgumentException("syncLimit is not set");
         }
         QuorumPeerConfig conf = new QuorumPeerConfig(clientPort, dataDir,
-                dataLogDir);
-        conf.tickTime = tickTime;
+                dataLogDir, tickTime);
         conf.initLimit = initLimit;
         conf.syncLimit = syncLimit;
         conf.electionAlg = electionAlg;



Mime
View raw message