Ver Fonte

ZOOKEEPER-2556: peerType not removed from static config file (Rakesh Kumar Singh via shralex).

Alexander Shraer há 8 anos atrás
pai
commit
bcb07a09b0

+ 1 - 0
src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java

@@ -480,6 +480,7 @@ public class QuorumPeerConfig {
                         || key.startsWith("group")
                         || key.startsWith("weight")
                         || key.startsWith("dynamicConfigFile")
+                        || key.startsWith("peerType")
                         || (eraseClientPortAddress
                             && (key.startsWith("clientPort")
                                 || key.startsWith("clientPortAddress")))) {

+ 20 - 11
src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerTestBase.java

@@ -79,7 +79,7 @@ public class QuorumPeerTestBase extends ZKTestCase implements Watcher {
         public MainThread(int myid, String quorumCfgSection, Integer secureClientPort, boolean writeDynamicConfigFile)
                 throws  IOException {
             this(myid, UNSET_STATIC_CLIENTPORT, JettyAdminServer.DEFAULT_PORT, secureClientPort,
-                    quorumCfgSection, null, writeDynamicConfigFile, null);
+                    quorumCfgSection, null, null, writeDynamicConfigFile, null);
         }
 
         public MainThread(int myid, String quorumCfgSection, boolean writeDynamicConfigFile)
@@ -89,43 +89,48 @@ public class QuorumPeerTestBase extends ZKTestCase implements Watcher {
 
         public MainThread(int myid, int clientPort, String quorumCfgSection)
                 throws IOException {
-            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null, true);
+            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null, null, true);
         }
 
         public MainThread(int myid, int clientPort, String quorumCfgSection, boolean writeDynamicConfigFile)
                 throws IOException {
-            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null, writeDynamicConfigFile);
+            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null, null, writeDynamicConfigFile);
+        }
+        
+        public MainThread(int myid, int clientPort, String quorumCfgSection, String peerType, boolean writeDynamicConfigFile)
+                throws IOException {
+            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null, peerType, writeDynamicConfigFile);
         }
 
         public MainThread(int myid, int clientPort, String quorumCfgSection, boolean writeDynamicConfigFile,
                           String version) throws IOException {
             this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, null,
-                    writeDynamicConfigFile, version);
+                    null, writeDynamicConfigFile, version);
         }
 
         public MainThread(int myid, int clientPort, String quorumCfgSection, String configs)
                 throws IOException {
-            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, configs, true);
+            this(myid, clientPort, JettyAdminServer.DEFAULT_PORT, quorumCfgSection, configs, null, true);
         }
 
         public MainThread(int myid, int clientPort, int adminServerPort, String quorumCfgSection,
                 String configs)  throws IOException {
-            this(myid, clientPort, adminServerPort, quorumCfgSection, configs, true);
+            this(myid, clientPort, adminServerPort, quorumCfgSection, configs, null, true);
         }
 
         public MainThread(int myid, int clientPort, int adminServerPort, String quorumCfgSection,
-                String configs, boolean writeDynamicConfigFile)
+                String configs, String peerType, boolean writeDynamicConfigFile)
                 throws IOException {
-            this(myid, clientPort, adminServerPort, quorumCfgSection, configs, writeDynamicConfigFile, null);
+            this(myid, clientPort, adminServerPort, quorumCfgSection, configs, peerType, writeDynamicConfigFile, null);
         }
 
         public MainThread(int myid, int clientPort, int adminServerPort, String quorumCfgSection,
-                          String configs, boolean writeDynamicConfigFile, String version) throws IOException {
-            this(myid, clientPort, adminServerPort, null, quorumCfgSection, configs, writeDynamicConfigFile, version);
+                          String configs, String peerType, boolean writeDynamicConfigFile, String version) throws IOException {
+            this(myid, clientPort, adminServerPort, null, quorumCfgSection, configs, peerType, writeDynamicConfigFile, version);
         }
 
         public MainThread(int myid, int clientPort, int adminServerPort, Integer secureClientPort,
-                          String quorumCfgSection, String configs, boolean writeDynamicConfigFile, String version)
+                          String quorumCfgSection, String configs, String peerType, boolean writeDynamicConfigFile, String version)
                 throws IOException {
             tmpDir = ClientBase.createTmpDir();
             LOG.info("id = " + myid + " tmpDir = " + tmpDir + " clientPort = "
@@ -162,6 +167,10 @@ public class QuorumPeerTestBase extends ZKTestCase implements Watcher {
             if (secureClientPort != null) {
                 fwriter.write("secureClientPort=" + secureClientPort + "\n");
             }
+            
+            if (peerType != null) {
+                fwriter.write("peerType=" + peerType + "\n");
+            }
 
             if (writeDynamicConfigFile) {
                 String dynamicConfigFilename = createDynamicFile(quorumCfgSection, version);

+ 4 - 2
src/java/test/org/apache/zookeeper/server/quorum/ReconfigLegacyTest.java

@@ -75,7 +75,7 @@ public class ReconfigLegacyTest extends QuorumPeerTestBase {
         // Start the servers with a static config file, without a dynamic
         // config file.
         for (int i = 0; i < SERVER_COUNT; i++) {
-            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection, false);
+            mt[i] = new MainThread(i, clientPorts[i], currentQuorumCfgSection, "participant", false);
             // check that a dynamic configuration file doesn't exist
             Assert.assertEquals( mt[i].getDynamicFiles().length, 0 );
             mt[i].start();
@@ -93,10 +93,12 @@ public class ReconfigLegacyTest extends QuorumPeerTestBase {
             ReconfigTest.testServerHasConfig(zk[i], allServers, null);
             // check that static config file doesn't include membership info
             // and has a pointer to the dynamic configuration file
+            // check that static config file doesn't include peerType info
             Properties cfg = readPropertiesFromFile(mt[i].confFile);
             for (int j = 0; j < SERVER_COUNT; j++) {
-                Assert.assertFalse(cfg.containsKey("server." + j));
+                Assert.assertFalse(cfg.containsKey("server." + j));                
             }
+            Assert.assertFalse(cfg.containsKey("peerType"));
             Assert.assertTrue(cfg.containsKey("dynamicConfigFile"));
             Assert.assertFalse(cfg.containsKey("clientPort"));