zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [21/51] [partial] zookeeper git commit: ZOOKEEPER-3032: MAVEN MIGRATION - move java server, client
Date Fri, 05 Oct 2018 12:26:14 GMT
http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
deleted file mode 100644
index f4e8a5f..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerConfig.java
+++ /dev/null
@@ -1,825 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.StringReader;
-import java.io.Writer;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Map.Entry;
-
-import org.apache.yetus.audience.InterfaceAudience;
-import org.apache.zookeeper.common.StringUtils;
-import org.apache.zookeeper.common.ZKConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.apache.zookeeper.common.AtomicFileWritingIdiom;
-import org.apache.zookeeper.common.AtomicFileWritingIdiom.OutputStreamStatement;
-import org.apache.zookeeper.common.AtomicFileWritingIdiom.WriterStatement;
-import org.apache.zookeeper.common.PathUtils;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.quorum.QuorumPeer.LearnerType;
-import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
-import org.apache.zookeeper.server.quorum.auth.QuorumAuth;
-import org.apache.zookeeper.server.quorum.flexible.QuorumHierarchical;
-import org.apache.zookeeper.server.quorum.flexible.QuorumMaj;
-import org.apache.zookeeper.server.quorum.flexible.QuorumVerifier;
-import org.apache.zookeeper.server.util.VerifyingFileFactory;
-
-import static org.apache.zookeeper.common.NetUtils.formatInetAddr;
-import org.apache.zookeeper.metrics.impl.NullMetricsProvider;
-
-@InterfaceAudience.Public
-public class QuorumPeerConfig {
-    private static final Logger LOG = LoggerFactory.getLogger(QuorumPeerConfig.class);
-    private static final int UNSET_SERVERID = -1;
-    public static final String nextDynamicConfigFileSuffix = ".dynamic.next";
-
-    private static boolean standaloneEnabled = true;
-    private static boolean reconfigEnabled = false;
-
-    protected InetSocketAddress clientPortAddress;
-    protected InetSocketAddress secureClientPortAddress;
-    protected File dataDir;
-    protected File dataLogDir;
-    protected String dynamicConfigFileStr = null;
-    protected String configFileStr = null;
-    protected int tickTime = ZooKeeperServer.DEFAULT_TICK_TIME;
-    protected int maxClientCnxns = 60;
-    /** defaults to -1 if not set explicitly */
-    protected int minSessionTimeout = -1;
-    /** defaults to -1 if not set explicitly */
-    protected int maxSessionTimeout = -1;
-    protected String metricsProviderClassName = NullMetricsProvider.class.getName();
-    protected Properties metricsProviderConfiguration = new Properties();
-    protected boolean localSessionsEnabled = false;
-    protected boolean localSessionsUpgradingEnabled = false;
-
-    protected int initLimit;
-    protected int syncLimit;
-    protected int electionAlg = 3;
-    protected int electionPort = 2182;
-    protected boolean quorumListenOnAllIPs = false;
-
-    protected long serverId = UNSET_SERVERID;
-
-    protected QuorumVerifier quorumVerifier = null, lastSeenQuorumVerifier = null;
-    protected int snapRetainCount = 3;
-    protected int purgeInterval = 0;
-    protected boolean syncEnabled = true;
-
-    protected LearnerType peerType = LearnerType.PARTICIPANT;
-
-    /**
-     * Configurations for the quorumpeer-to-quorumpeer sasl authentication
-     */
-    protected boolean quorumServerRequireSasl = false;
-    protected boolean quorumLearnerRequireSasl = false;
-    protected boolean quorumEnableSasl = false;
-    protected String quorumServicePrincipal = QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL_DEFAULT_VALUE;
-    protected String quorumLearnerLoginContext = QuorumAuth.QUORUM_LEARNER_SASL_LOGIN_CONTEXT_DFAULT_VALUE;
-    protected String quorumServerLoginContext = QuorumAuth.QUORUM_SERVER_SASL_LOGIN_CONTEXT_DFAULT_VALUE;
-    protected int quorumCnxnThreadsSize;
-
-    /**
-     * Minimum snapshot retain count.
-     * @see org.apache.zookeeper.server.PurgeTxnLog#purge(File, File, int)
-     */
-    private final int MIN_SNAP_RETAIN_COUNT = 3;
-
-    @SuppressWarnings("serial")
-    public static class ConfigException extends Exception {
-        public ConfigException(String msg) {
-            super(msg);
-        }
-        public ConfigException(String msg, Exception e) {
-            super(msg, e);
-        }
-    }
-
-    /**
-     * Parse a ZooKeeper configuration file
-     * @param path the patch of the configuration file
-     * @throws ConfigException error processing configuration
-     */
-    public void parse(String path) throws ConfigException {
-        LOG.info("Reading configuration from: " + path);
-       
-        try {
-            File configFile = (new VerifyingFileFactory.Builder(LOG)
-                .warnForRelativePath()
-                .failForNonExistingPath()
-                .build()).create(path);
-                
-            Properties cfg = new Properties();
-            FileInputStream in = new FileInputStream(configFile);
-            try {
-                cfg.load(in);
-                configFileStr = path;
-            } finally {
-                in.close();
-            }
-            
-            parseProperties(cfg);
-        } catch (IOException e) {
-            throw new ConfigException("Error processing " + path, e);
-        } catch (IllegalArgumentException e) {
-            throw new ConfigException("Error processing " + path, e);
-        }   
-        
-        if (dynamicConfigFileStr!=null) {
-           try {           
-               Properties dynamicCfg = new Properties();
-               FileInputStream inConfig = new FileInputStream(dynamicConfigFileStr);
-               try {
-                   dynamicCfg.load(inConfig);
-                   if (dynamicCfg.getProperty("version") != null) {
-                       throw new ConfigException("dynamic file shouldn't have version inside");
-                   }
-
-                   String version = getVersionFromFilename(dynamicConfigFileStr);
-                   // If there isn't any version associated with the filename,
-                   // the default version is 0.
-                   if (version != null) {
-                       dynamicCfg.setProperty("version", version);
-                   }
-               } finally {
-                   inConfig.close();
-               }
-               setupQuorumPeerConfig(dynamicCfg, false);
-
-           } catch (IOException e) {
-               throw new ConfigException("Error processing " + dynamicConfigFileStr, e);
-           } catch (IllegalArgumentException e) {
-               throw new ConfigException("Error processing " + dynamicConfigFileStr, e);
-           }        
-           File nextDynamicConfigFile = new File(configFileStr + nextDynamicConfigFileSuffix);
-           if (nextDynamicConfigFile.exists()) {
-               try {           
-                   Properties dynamicConfigNextCfg = new Properties();
-                   FileInputStream inConfigNext = new FileInputStream(nextDynamicConfigFile);       
-                   try {
-                       dynamicConfigNextCfg.load(inConfigNext);
-                   } finally {
-                       inConfigNext.close();
-                   }
-                   boolean isHierarchical = false;
-                   for (Entry<Object, Object> entry : dynamicConfigNextCfg.entrySet()) {
-                       String key = entry.getKey().toString().trim();  
-                       if (key.startsWith("group") || key.startsWith("weight")) {
-                           isHierarchical = true;
-                           break;
-                       }
-                   }
-                   lastSeenQuorumVerifier = createQuorumVerifier(dynamicConfigNextCfg, isHierarchical);
-               } catch (IOException e) {
-                   LOG.warn("NextQuorumVerifier is initiated to null");
-               }
-           }
-        }
-    }
-
-    // This method gets the version from the end of dynamic file name.
-    // For example, "zoo.cfg.dynamic.0" returns initial version "0".
-    // "zoo.cfg.dynamic.1001" returns version of hex number "0x1001".
-    // If a dynamic file name doesn't have any version at the end of file,
-    // e.g. "zoo.cfg.dynamic", it returns null.
-    public static String getVersionFromFilename(String filename) {
-        int i = filename.lastIndexOf('.');
-        if(i < 0 || i >= filename.length())
-            return null;
-
-        String hexVersion = filename.substring(i + 1);
-        try {
-            long version = Long.parseLong(hexVersion, 16);
-            return Long.toHexString(version);
-        } catch (NumberFormatException e) {
-            return null;
-        }
-    }
-
-    /**
-     * Parse config from a Properties.
-     * @param zkProp Properties to parse from.
-     * @throws IOException
-     * @throws ConfigException
-     */
-    public void parseProperties(Properties zkProp)
-    throws IOException, ConfigException {
-        int clientPort = 0;
-        int secureClientPort = 0;
-        String clientPortAddress = null;
-        String secureClientPortAddress = null;
-        VerifyingFileFactory vff = new VerifyingFileFactory.Builder(LOG).warnForRelativePath().build();
-        for (Entry<Object, Object> entry : zkProp.entrySet()) {
-            String key = entry.getKey().toString().trim();
-            String value = entry.getValue().toString().trim();
-            if (key.equals("dataDir")) {
-                dataDir = vff.create(value);
-            } else if (key.equals("dataLogDir")) {
-                dataLogDir = vff.create(value);
-            } else if (key.equals("clientPort")) {
-                clientPort = Integer.parseInt(value);
-            } else if (key.equals("localSessionsEnabled")) {
-                localSessionsEnabled = Boolean.parseBoolean(value);
-            } else if (key.equals("localSessionsUpgradingEnabled")) {
-                localSessionsUpgradingEnabled = Boolean.parseBoolean(value);
-            } else if (key.equals("clientPortAddress")) {
-                clientPortAddress = value.trim();
-            } else if (key.equals("secureClientPort")) {
-                secureClientPort = Integer.parseInt(value);
-            } else if (key.equals("secureClientPortAddress")){
-                secureClientPortAddress = value.trim();
-            } else if (key.equals("tickTime")) {
-                tickTime = Integer.parseInt(value);
-            } else if (key.equals("maxClientCnxns")) {
-                maxClientCnxns = Integer.parseInt(value);
-            } else if (key.equals("minSessionTimeout")) {
-                minSessionTimeout = Integer.parseInt(value);
-            } else if (key.equals("maxSessionTimeout")) {
-                maxSessionTimeout = Integer.parseInt(value);
-            } else if (key.equals("initLimit")) {
-                initLimit = Integer.parseInt(value);
-            } else if (key.equals("syncLimit")) {
-                syncLimit = Integer.parseInt(value);
-            } else if (key.equals("electionAlg")) {
-                electionAlg = Integer.parseInt(value);
-                if (electionAlg != 1 && electionAlg != 2 && electionAlg != 3) {
-                    throw new ConfigException("Invalid electionAlg value. Only 1, 2, 3 are supported.");
-                }
-            } else if (key.equals("quorumListenOnAllIPs")) {
-                quorumListenOnAllIPs = Boolean.parseBoolean(value);
-            } else if (key.equals("peerType")) {
-                if (value.toLowerCase().equals("observer")) {
-                    peerType = LearnerType.OBSERVER;
-                } else if (value.toLowerCase().equals("participant")) {
-                    peerType = LearnerType.PARTICIPANT;
-                } else
-                {
-                    throw new ConfigException("Unrecognised peertype: " + value);
-                }
-            } else if (key.equals( "syncEnabled" )) {
-                syncEnabled = Boolean.parseBoolean(value);
-            } else if (key.equals("dynamicConfigFile")){
-                dynamicConfigFileStr = value;
-            } else if (key.equals("autopurge.snapRetainCount")) {
-                snapRetainCount = Integer.parseInt(value);
-            } else if (key.equals("autopurge.purgeInterval")) {
-                purgeInterval = Integer.parseInt(value);
-            } else if (key.equals("standaloneEnabled")) {
-                if (value.toLowerCase().equals("true")) {
-                    setStandaloneEnabled(true);
-                } else if (value.toLowerCase().equals("false")) {
-                    setStandaloneEnabled(false);
-                } else {
-                    throw new ConfigException("Invalid option " + value + " for standalone mode. Choose 'true' or 'false.'");
-                }
-            } else if (key.equals("reconfigEnabled")) {
-                if (value.toLowerCase().equals("true")) {
-                    setReconfigEnabled(true);
-                } else if (value.toLowerCase().equals("false")) {
-                    setReconfigEnabled(false);
-                } else {
-                    throw new ConfigException("Invalid option " + value + " for reconfigEnabled flag. Choose 'true' or 'false.'");
-                }
-            } else if ((key.startsWith("server.") || key.startsWith("group") || key.startsWith("weight")) && zkProp.containsKey("dynamicConfigFile")) {
-                throw new ConfigException("parameter: " + key + " must be in a separate dynamic config file");
-            } else if (key.equals(QuorumAuth.QUORUM_SASL_AUTH_ENABLED)) {
-                quorumEnableSasl = Boolean.parseBoolean(value);
-            } else if (key.equals(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED)) {
-                quorumServerRequireSasl = Boolean.parseBoolean(value);
-            } else if (key.equals(QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED)) {
-                quorumLearnerRequireSasl = Boolean.parseBoolean(value);
-            } else if (key.equals(QuorumAuth.QUORUM_LEARNER_SASL_LOGIN_CONTEXT)) {
-                quorumLearnerLoginContext = value;
-            } else if (key.equals(QuorumAuth.QUORUM_SERVER_SASL_LOGIN_CONTEXT)) {
-                quorumServerLoginContext = value;
-            } else if (key.equals(QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL)) {
-                quorumServicePrincipal = value;
-            } else if (key.equals("quorum.cnxn.threads.size")) {
-                quorumCnxnThreadsSize = Integer.parseInt(value);
-            } else if (key.equals("metricsProvider.className")) {
-                metricsProviderClassName = value;
-            } else if (key.startsWith("metricsProvider.")) {
-                String keyForMetricsProvider = key.substring(16);
-                metricsProviderConfiguration.put(keyForMetricsProvider, value);
-            } else {
-                System.setProperty("zookeeper." + key, value);
-            }
-        }
-
-        if (!quorumEnableSasl && quorumServerRequireSasl) {
-            throw new IllegalArgumentException(
-                    QuorumAuth.QUORUM_SASL_AUTH_ENABLED
-                            + " is disabled, so cannot enable "
-                            + QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED);
-        }
-        if (!quorumEnableSasl && quorumLearnerRequireSasl) {
-            throw new IllegalArgumentException(
-                    QuorumAuth.QUORUM_SASL_AUTH_ENABLED
-                            + " is disabled, so cannot enable "
-                            + QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED);
-        }
-        // If quorumpeer learner is not auth enabled then self won't be able to
-        // join quorum. So this condition is ensuring that the quorumpeer learner
-        // is also auth enabled while enabling quorum server require sasl.
-        if (!quorumLearnerRequireSasl && quorumServerRequireSasl) {
-            throw new IllegalArgumentException(
-                    QuorumAuth.QUORUM_LEARNER_SASL_AUTH_REQUIRED
-                            + " is disabled, so cannot enable "
-                            + QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED);
-        }
-
-        // Reset to MIN_SNAP_RETAIN_COUNT if invalid (less than 3)
-        // PurgeTxnLog.purge(File, File, int) will not allow to purge less
-        // than 3.
-        if (snapRetainCount < MIN_SNAP_RETAIN_COUNT) {
-            LOG.warn("Invalid autopurge.snapRetainCount: " + snapRetainCount
-                    + ". Defaulting to " + MIN_SNAP_RETAIN_COUNT);
-            snapRetainCount = MIN_SNAP_RETAIN_COUNT;
-        }
-
-        if (dataDir == null) {
-            throw new IllegalArgumentException("dataDir is not set");
-        }
-        if (dataLogDir == null) {
-            dataLogDir = dataDir;
-        }
-
-        if (clientPort == 0) {
-            LOG.info("clientPort is not set");
-            if (clientPortAddress != null) {
-                throw new IllegalArgumentException("clientPortAddress is set but clientPort is not set");
-            }
-        } else if (clientPortAddress != null) {
-            this.clientPortAddress = new InetSocketAddress(
-                    InetAddress.getByName(clientPortAddress), clientPort);
-            LOG.info("clientPortAddress is {}", formatInetAddr(this.clientPortAddress));
-        } else {
-            this.clientPortAddress = new InetSocketAddress(clientPort);
-            LOG.info("clientPortAddress is {}", formatInetAddr(this.clientPortAddress));
-        }
-
-        if (secureClientPort == 0) {
-            LOG.info("secureClientPort is not set");
-            if (secureClientPortAddress != null) {
-                throw new IllegalArgumentException("secureClientPortAddress is set but secureClientPort is not set");
-            }
-        } else if (secureClientPortAddress != null) {
-            this.secureClientPortAddress = new InetSocketAddress(
-                    InetAddress.getByName(secureClientPortAddress), secureClientPort);
-            LOG.info("secureClientPortAddress is {}", formatInetAddr(this.secureClientPortAddress));
-        } else {
-            this.secureClientPortAddress = new InetSocketAddress(secureClientPort);
-            LOG.info("secureClientPortAddress is {}", formatInetAddr(this.secureClientPortAddress));
-        }
-        if (this.secureClientPortAddress != null) {
-            configureSSLAuth();
-        }
-
-        if (tickTime == 0) {
-            throw new IllegalArgumentException("tickTime is not set");
-        }
-
-        minSessionTimeout = minSessionTimeout == -1 ? tickTime * 2 : minSessionTimeout;
-        maxSessionTimeout = maxSessionTimeout == -1 ? tickTime * 20 : maxSessionTimeout;
-
-        if (minSessionTimeout > maxSessionTimeout) {
-            throw new IllegalArgumentException(
-                    "minSessionTimeout must not be larger than maxSessionTimeout");
-        }
-
-        LOG.info("metricsProvider.className is {}", metricsProviderClassName);
-        try {
-            Class.forName(metricsProviderClassName, false, Thread.currentThread().getContextClassLoader());
-        } catch (ClassNotFoundException error) {
-            throw new IllegalArgumentException("metrics provider class was not found", error);
-        }
-
-        // backward compatibility - dynamic configuration in the same file as
-        // static configuration params see writeDynamicConfig()
-        if (dynamicConfigFileStr == null) {
-            setupQuorumPeerConfig(zkProp, true);
-            if (isDistributed() && isReconfigEnabled()) {
-                // we don't backup static config for standalone mode.
-                // we also don't backup if reconfig feature is disabled.
-                backupOldConfig();
-            }
-        }
-    }
-
-    /**
-     * Configure SSL authentication only if it is not configured.
-     * 
-     * @throws ConfigException
-     *             If authentication scheme is configured but authentication
-     *             provider is not configured.
-     */
-    private void configureSSLAuth() throws ConfigException {
-        String sslAuthProp = "zookeeper.authProvider." + System.getProperty(ZKConfig.SSL_AUTHPROVIDER, "x509");
-        if (System.getProperty(sslAuthProp) == null) {
-            if ("zookeeper.authProvider.x509".equals(sslAuthProp)) {
-                System.setProperty("zookeeper.authProvider.x509",
-                        "org.apache.zookeeper.server.auth.X509AuthenticationProvider");
-            } else {
-                throw new ConfigException("No auth provider configured for the SSL authentication scheme '"
-                        + System.getProperty(ZKConfig.SSL_AUTHPROVIDER) + "'.");
-            }
-        }
-    }
-
-    /**
-     * Backward compatibility -- It would backup static config file on bootup
-     * if users write dynamic configuration in "zoo.cfg".
-     */
-    private void backupOldConfig() throws IOException {
-        new AtomicFileWritingIdiom(new File(configFileStr + ".bak"), new OutputStreamStatement() {
-            @Override
-            public void write(OutputStream output) throws IOException {
-                InputStream input = null;
-                try {
-                    input = new FileInputStream(new File(configFileStr));
-                    byte[] buf = new byte[1024];
-                    int bytesRead;
-                    while ((bytesRead = input.read(buf)) > 0) {
-                        output.write(buf, 0, bytesRead);
-                    }
-                } finally {
-                    if( input != null) {
-                        input.close();
-                    }
-                }
-            }
-        });
-    }
-
-    /**
-     * Writes dynamic configuration file
-     */
-    public static void writeDynamicConfig(final String dynamicConfigFilename,
-                                          final QuorumVerifier qv,
-                                          final boolean needKeepVersion)
-            throws IOException {
-
-        new AtomicFileWritingIdiom(new File(dynamicConfigFilename), new WriterStatement() {
-            @Override
-            public void write(Writer out) throws IOException {
-                Properties cfg = new Properties();
-                cfg.load( new StringReader(
-                        qv.toString()));
-
-                List<String> servers = new ArrayList<String>();
-                for (Entry<Object, Object> entry : cfg.entrySet()) {
-                    String key = entry.getKey().toString().trim();
-                    if ( !needKeepVersion && key.startsWith("version"))
-                        continue;
-
-                    String value = entry.getValue().toString().trim();
-                    servers.add(key
-                            .concat("=")
-                            .concat(value));
-                }
-
-                Collections.sort(servers);
-                out.write(StringUtils.joinStrings(servers, "\n"));
-            }
-        });
-    }
-
-    /**
-     * Edit static config file.
-     * If there are quorum information in static file, e.g. "server.X", "group",
-     * it will remove them.
-     * If it needs to erase client port information left by the old config,
-     * "eraseClientPortAddress" should be set true.
-     * It should also updates dynamic file pointer on reconfig.
-     */
-    public static void editStaticConfig(final String configFileStr,
-                                        final String dynamicFileStr,
-                                        final boolean eraseClientPortAddress)
-            throws IOException {
-        // Some tests may not have a static config file.
-        if (configFileStr == null)
-            return;
-
-        File configFile = (new VerifyingFileFactory.Builder(LOG)
-                .warnForRelativePath()
-                .failForNonExistingPath()
-                .build()).create(configFileStr);
-
-        final File dynamicFile = (new VerifyingFileFactory.Builder(LOG)
-                .warnForRelativePath()
-                .failForNonExistingPath()
-                .build()).create(dynamicFileStr);
-        
-        final Properties cfg = new Properties();
-        FileInputStream in = new FileInputStream(configFile);
-        try {
-            cfg.load(in);
-        } finally {
-            in.close();
-        }
-
-        new AtomicFileWritingIdiom(new File(configFileStr), new WriterStatement() {
-            @Override
-            public void write(Writer out) throws IOException {
-                for (Entry<Object, Object> entry : cfg.entrySet()) {
-                    String key = entry.getKey().toString().trim();
-
-                    if (key.startsWith("server.")
-                        || key.startsWith("group")
-                        || key.startsWith("weight")
-                        || key.startsWith("dynamicConfigFile")
-                        || key.startsWith("peerType")
-                        || (eraseClientPortAddress
-                            && (key.startsWith("clientPort")
-                                || key.startsWith("clientPortAddress")))) {
-                        // not writing them back to static file
-                        continue;
-                    }
-
-                    String value = entry.getValue().toString().trim();
-                    out.write(key.concat("=").concat(value).concat("\n"));
-                }
-
-                // updates the dynamic file pointer
-                String dynamicConfigFilePath = PathUtils.normalizeFileSystemPath(dynamicFile.getCanonicalPath());
-                out.write("dynamicConfigFile="
-                         .concat(dynamicConfigFilePath)
-                         .concat("\n"));
-            }
-        });
-    }
-
-
-    public static void deleteFile(String filename){
-       if (filename == null) return;
-       File f = new File(filename);
-       if (f.exists()) {
-           try{ 
-               f.delete();
-           } catch (Exception e) {
-               LOG.warn("deleting " + filename + " failed");
-           }
-       }                   
-    }
-    
-    
-    private static QuorumVerifier createQuorumVerifier(Properties dynamicConfigProp, boolean isHierarchical) throws ConfigException{
-       if(isHierarchical){
-            return new QuorumHierarchical(dynamicConfigProp);
-        } else {
-           /*
-             * The default QuorumVerifier is QuorumMaj
-             */        
-            //LOG.info("Defaulting to majority quorums");
-            return new QuorumMaj(dynamicConfigProp);            
-        }          
-    }
-
-    void setupQuorumPeerConfig(Properties prop, boolean configBackwardCompatibilityMode)
-            throws IOException, ConfigException {
-        quorumVerifier = parseDynamicConfig(prop, electionAlg, true, configBackwardCompatibilityMode);
-        setupMyId();
-        setupClientPort();
-        setupPeerType();
-        checkValidity();
-    }
-
-    /**
-     * Parse dynamic configuration file and return
-     * quorumVerifier for new configuration.
-     * @param dynamicConfigProp Properties to parse from.
-     * @throws IOException
-     * @throws ConfigException
-     */
-    public static QuorumVerifier parseDynamicConfig(Properties dynamicConfigProp, int eAlg, boolean warnings,
-	   boolean configBackwardCompatibilityMode) throws IOException, ConfigException {
-       boolean isHierarchical = false;
-        for (Entry<Object, Object> entry : dynamicConfigProp.entrySet()) {
-            String key = entry.getKey().toString().trim();                    
-            if (key.startsWith("group") || key.startsWith("weight")) {
-               isHierarchical = true;
-            } else if (!configBackwardCompatibilityMode && !key.startsWith("server.") && !key.equals("version")){ 
-               LOG.info(dynamicConfigProp.toString());
-               throw new ConfigException("Unrecognised parameter: " + key);                
-            }
-        }
-        
-        QuorumVerifier qv = createQuorumVerifier(dynamicConfigProp, isHierarchical);
-               
-        int numParticipators = qv.getVotingMembers().size();
-        int numObservers = qv.getObservingMembers().size();
-        if (numParticipators == 0) {
-            if (!standaloneEnabled) {
-                throw new IllegalArgumentException("standaloneEnabled = false then " +
-                        "number of participants should be >0");
-            }
-            if (numObservers > 0) {
-                throw new IllegalArgumentException("Observers w/o participants is an invalid configuration");
-            }
-        } else if (numParticipators == 1 && standaloneEnabled) {
-            // HBase currently adds a single server line to the config, for
-            // b/w compatibility reasons we need to keep this here. If standaloneEnabled
-            // is true, the QuorumPeerMain script will create a standalone server instead
-            // of a quorum configuration
-            LOG.error("Invalid configuration, only one server specified (ignoring)");
-            if (numObservers > 0) {
-                throw new IllegalArgumentException("Observers w/o quorum is an invalid configuration");
-            }
-        } else {
-            if (warnings) {
-                if (numParticipators <= 2) {
-                    LOG.warn("No server failure will be tolerated. " +
-                        "You need at least 3 servers.");
-                } else if (numParticipators % 2 == 0) {
-                    LOG.warn("Non-optimial configuration, consider an odd number of servers.");
-                }
-            }
-
-            for (QuorumServer s : qv.getVotingMembers().values()) {
-                if (s.electionAddr == null)
-                    throw new IllegalArgumentException(
-                            "Missing election port for server: " + s.id);
-            }
-        }
-        return qv;
-    }
-
-    private void setupMyId() throws IOException {
-        File myIdFile = new File(dataDir, "myid");
-        // standalone server doesn't need myid file.
-        if (!myIdFile.isFile()) {
-            return;
-        }
-        BufferedReader br = new BufferedReader(new FileReader(myIdFile));
-        String myIdString;
-        try {
-            myIdString = br.readLine();
-        } finally {
-            br.close();
-        }
-        try {
-            serverId = Long.parseLong(myIdString);
-            MDC.put("myid", myIdString);
-        } catch (NumberFormatException e) {
-            throw new IllegalArgumentException("serverid " + myIdString
-                    + " is not a number");
-        }
-    }
-
-    private void setupClientPort() throws ConfigException {
-        if (serverId == UNSET_SERVERID) {
-            return;
-        }
-        QuorumServer qs = quorumVerifier.getAllMembers().get(serverId);
-        if (clientPortAddress != null && qs != null && qs.clientAddr != null) {
-            if ((!clientPortAddress.getAddress().isAnyLocalAddress()
-                    && !clientPortAddress.equals(qs.clientAddr)) ||
-                    (clientPortAddress.getAddress().isAnyLocalAddress()
-                            && clientPortAddress.getPort() != qs.clientAddr.getPort()))
-                throw new ConfigException("client address for this server (id = " + serverId +
-                        ") in static config file is " + clientPortAddress +
-                        " is different from client address found in dynamic file: " + qs.clientAddr);
-        }
-        if (qs != null && qs.clientAddr != null) clientPortAddress = qs.clientAddr;
-        if (qs != null && qs.clientAddr == null) {
-            qs.clientAddr = clientPortAddress;
-            qs.isClientAddrFromStatic = true;
-        }
-    }
-
-    private void setupPeerType() {
-        // Warn about inconsistent peer type
-        LearnerType roleByServersList = quorumVerifier.getObservingMembers().containsKey(serverId) ? LearnerType.OBSERVER
-                : LearnerType.PARTICIPANT;
-        if (roleByServersList != peerType) {
-            LOG.warn("Peer type from servers list (" + roleByServersList
-                    + ") doesn't match peerType (" + peerType
-                    + "). Defaulting to servers list.");
-
-            peerType = roleByServersList;
-        }
-    }
-
-    public void checkValidity() throws IOException, ConfigException{
-        if (isDistributed()) {
-            if (initLimit == 0) {
-                throw new IllegalArgumentException("initLimit is not set");
-            }
-            if (syncLimit == 0) {
-                throw new IllegalArgumentException("syncLimit is not set");
-            }
-            if (serverId == UNSET_SERVERID) {
-                throw new IllegalArgumentException("myid file is missing");
-            }
-       }
-    }
-
-    public InetSocketAddress getClientPortAddress() { return clientPortAddress; }
-    public InetSocketAddress getSecureClientPortAddress() { return secureClientPortAddress; }
-    public File getDataDir() { return dataDir; }
-    public File getDataLogDir() { return dataLogDir; }
-    public int getTickTime() { return tickTime; }
-    public int getMaxClientCnxns() { return maxClientCnxns; }
-    public int getMinSessionTimeout() { return minSessionTimeout; }
-    public int getMaxSessionTimeout() { return maxSessionTimeout; }
-    public String getMetricsProviderClassName() { return metricsProviderClassName; }
-    public Properties getMetricsProviderConfiguration() { return metricsProviderConfiguration; }
-    public boolean areLocalSessionsEnabled() { return localSessionsEnabled; }
-    public boolean isLocalSessionsUpgradingEnabled() {
-        return localSessionsUpgradingEnabled;
-    }
-
-    public int getInitLimit() { return initLimit; }
-    public int getSyncLimit() { return syncLimit; }
-    public int getElectionAlg() { return electionAlg; }
-    public int getElectionPort() { return electionPort; }
-
-    public int getSnapRetainCount() {
-        return snapRetainCount;
-    }
-
-    public int getPurgeInterval() {
-        return purgeInterval;
-    }
-    
-    public boolean getSyncEnabled() {
-        return syncEnabled;
-    }
-
-    public QuorumVerifier getQuorumVerifier() {
-        return quorumVerifier;
-    }
-    
-    public QuorumVerifier getLastSeenQuorumVerifier() {   
-        return lastSeenQuorumVerifier;
-    }
-
-    public Map<Long,QuorumServer> getServers() {
-        // returns all configuration servers -- participants and observers
-        return Collections.unmodifiableMap(quorumVerifier.getAllMembers());
-    }
-
-    public long getServerId() { return serverId; }
-
-    public boolean isDistributed() {
-        return quorumVerifier!=null && (!standaloneEnabled || quorumVerifier.getVotingMembers().size() > 1);
-    }
-
-    public LearnerType getPeerType() {
-        return peerType;
-    }
-
-    public String getConfigFilename(){
-        return configFileStr;
-    }
-    
-    public Boolean getQuorumListenOnAllIPs() {
-        return quorumListenOnAllIPs;
-    }
- 
-    public static boolean isStandaloneEnabled() {
-	return standaloneEnabled;
-    }
-    
-    public static void setStandaloneEnabled(boolean enabled) {
-        standaloneEnabled = enabled;
-    }
-
-    public static boolean isReconfigEnabled() { return reconfigEnabled; }
-
-    public static void setReconfigEnabled(boolean enabled) {
-        reconfigEnabled = enabled;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java
deleted file mode 100644
index 11b5c0b..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumPeerMain.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zookeeper.server.quorum;
-
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.management.JMException;
-import javax.security.sasl.SaslException;
-
-import org.apache.yetus.audience.InterfaceAudience;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.zookeeper.jmx.ManagedUtil;
-import org.apache.zookeeper.metrics.MetricsProvider;
-import org.apache.zookeeper.metrics.MetricsProviderLifeCycleException;
-import org.apache.zookeeper.metrics.impl.MetricsProviderBootstrap;
-import org.apache.zookeeper.server.ExitCode;
-import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.ZKDatabase;
-import org.apache.zookeeper.server.DatadirCleanupManager;
-import org.apache.zookeeper.server.ZooKeeperServerMain;
-import org.apache.zookeeper.server.admin.AdminServer.AdminServerException;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog.DatadirException;
-import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException;
-
-/**
- *
- * <h2>Configuration file</h2>
- *
- * When the main() method of this class is used to start the program, the first
- * argument is used as a path to the config file, which will be used to obtain
- * configuration information. This file is a Properties file, so keys and
- * values are separated by equals (=) and the key/value pairs are separated
- * by new lines. The following is a general summary of keys used in the
- * configuration file. For full details on this see the documentation in
- * docs/index.html
- * <ol>
- * <li>dataDir - The directory where the ZooKeeper data is stored.</li>
- * <li>dataLogDir - The directory where the ZooKeeper transaction log is stored.</li>
- * <li>clientPort - The port used to communicate with clients.</li>
- * <li>tickTime - The duration of a tick in milliseconds. This is the basic
- * unit of time in ZooKeeper.</li>
- * <li>initLimit - The maximum number of ticks that a follower will wait to
- * initially synchronize with a leader.</li>
- * <li>syncLimit - The maximum number of ticks that a follower will wait for a
- * message (including heartbeats) from the leader.</li>
- * <li>server.<i>id</i> - This is the host:port[:port] that the server with the
- * given id will use for the quorum protocol.</li>
- * </ol>
- * In addition to the config file. There is a file in the data directory called
- * "myid" that contains the server id as an ASCII decimal value.
- *
- */
-@InterfaceAudience.Public
-public class QuorumPeerMain {
-    private static final Logger LOG = LoggerFactory.getLogger(QuorumPeerMain.class);
-
-    private static final String USAGE = "Usage: QuorumPeerMain configfile";
-
-    protected QuorumPeer quorumPeer;
-
-    /**
-     * To start the replicated server specify the configuration file name on
-     * the command line.
-     * @param args path to the configfile
-     */
-    public static void main(String[] args) {
-        QuorumPeerMain main = new QuorumPeerMain();
-        try {
-            main.initializeAndRun(args);
-        } catch (IllegalArgumentException e) {
-            LOG.error("Invalid arguments, exiting abnormally", e);
-            LOG.info(USAGE);
-            System.err.println(USAGE);
-            System.exit(ExitCode.INVALID_INVOCATION.getValue());
-        } catch (ConfigException e) {
-            LOG.error("Invalid config, exiting abnormally", e);
-            System.err.println("Invalid config, exiting abnormally");
-            System.exit(ExitCode.INVALID_INVOCATION.getValue());
-        } catch (DatadirException e) {
-            LOG.error("Unable to access datadir, exiting abnormally", e);
-            System.err.println("Unable to access datadir, exiting abnormally");
-            System.exit(ExitCode.UNABLE_TO_ACCESS_DATADIR.getValue());
-        } catch (AdminServerException e) {
-            LOG.error("Unable to start AdminServer, exiting abnormally", e);
-            System.err.println("Unable to start AdminServer, exiting abnormally");
-            System.exit(ExitCode.ERROR_STARTING_ADMIN_SERVER.getValue());
-        } catch (Exception e) {
-            LOG.error("Unexpected exception, exiting abnormally", e);
-            System.exit(ExitCode.UNEXPECTED_ERROR.getValue());
-        }
-        LOG.info("Exiting normally");
-        System.exit(ExitCode.EXECUTION_FINISHED.getValue());
-    }
-
-    protected void initializeAndRun(String[] args)
-        throws ConfigException, IOException, AdminServerException
-    {
-        QuorumPeerConfig config = new QuorumPeerConfig();
-        if (args.length == 1) {
-            config.parse(args[0]);
-        }
-
-        // Start and schedule the the purge task
-        DatadirCleanupManager purgeMgr = new DatadirCleanupManager(config
-                .getDataDir(), config.getDataLogDir(), config
-                .getSnapRetainCount(), config.getPurgeInterval());
-        purgeMgr.start();
-
-        if (args.length == 1 && config.isDistributed()) {
-            runFromConfig(config);
-        } else {
-            LOG.warn("Either no config or no quorum defined in config, running "
-                    + " in standalone mode");
-            // there is only server in the quorum -- run as standalone
-            ZooKeeperServerMain.main(args);
-        }
-    }
-
-    public void runFromConfig(QuorumPeerConfig config)
-            throws IOException, AdminServerException
-    {
-      try {
-          ManagedUtil.registerLog4jMBeans();
-      } catch (JMException e) {
-          LOG.warn("Unable to register log4j JMX control", e);
-      }
-
-      LOG.info("Starting quorum peer");
-      MetricsProvider metricsProvider;
-      try {
-        metricsProvider = MetricsProviderBootstrap
-                      .startMetricsProvider(config.getMetricsProviderClassName(),
-                                            config.getMetricsProviderConfiguration());
-      } catch (MetricsProviderLifeCycleException error) {
-        throw new IOException("Cannot boot MetricsProvider " + config.getMetricsProviderClassName(),
-                      error);
-      }
-      try {
-
-          ServerCnxnFactory cnxnFactory = null;
-          ServerCnxnFactory secureCnxnFactory = null;
-
-          if (config.getClientPortAddress() != null) {
-              cnxnFactory = ServerCnxnFactory.createFactory();
-              cnxnFactory.configure(config.getClientPortAddress(),
-                      config.getMaxClientCnxns(),
-                      false);
-          }
-
-          if (config.getSecureClientPortAddress() != null) {
-              secureCnxnFactory = ServerCnxnFactory.createFactory();
-              secureCnxnFactory.configure(config.getSecureClientPortAddress(),
-                      config.getMaxClientCnxns(),
-                      true);
-          }
-
-          quorumPeer = getQuorumPeer();
-          quorumPeer.setRootMetricsContext(metricsProvider.getRootContext());
-          quorumPeer.setTxnFactory(new FileTxnSnapLog(
-                      config.getDataLogDir(),
-                      config.getDataDir()));
-          quorumPeer.enableLocalSessions(config.areLocalSessionsEnabled());
-          quorumPeer.enableLocalSessionsUpgrading(
-              config.isLocalSessionsUpgradingEnabled());
-          //quorumPeer.setQuorumPeers(config.getAllMembers());
-          quorumPeer.setElectionType(config.getElectionAlg());
-          quorumPeer.setMyid(config.getServerId());
-          quorumPeer.setTickTime(config.getTickTime());
-          quorumPeer.setMinSessionTimeout(config.getMinSessionTimeout());
-          quorumPeer.setMaxSessionTimeout(config.getMaxSessionTimeout());
-          quorumPeer.setInitLimit(config.getInitLimit());
-          quorumPeer.setSyncLimit(config.getSyncLimit());
-          quorumPeer.setConfigFileName(config.getConfigFilename());
-          quorumPeer.setZKDatabase(new ZKDatabase(quorumPeer.getTxnFactory()));
-          quorumPeer.setQuorumVerifier(config.getQuorumVerifier(), false);
-          if (config.getLastSeenQuorumVerifier()!=null) {
-              quorumPeer.setLastSeenQuorumVerifier(config.getLastSeenQuorumVerifier(), false);
-          }
-          quorumPeer.initConfigInZKDatabase();
-          quorumPeer.setCnxnFactory(cnxnFactory);
-          quorumPeer.setSecureCnxnFactory(secureCnxnFactory);
-          quorumPeer.setLearnerType(config.getPeerType());
-          quorumPeer.setSyncEnabled(config.getSyncEnabled());
-          quorumPeer.setQuorumListenOnAllIPs(config.getQuorumListenOnAllIPs());
-
-          // sets quorum sasl authentication configurations
-          quorumPeer.setQuorumSaslEnabled(config.quorumEnableSasl);
-          if(quorumPeer.isQuorumSaslAuthEnabled()){
-              quorumPeer.setQuorumServerSaslRequired(config.quorumServerRequireSasl);
-              quorumPeer.setQuorumLearnerSaslRequired(config.quorumLearnerRequireSasl);
-              quorumPeer.setQuorumServicePrincipal(config.quorumServicePrincipal);
-              quorumPeer.setQuorumServerLoginContext(config.quorumServerLoginContext);
-              quorumPeer.setQuorumLearnerLoginContext(config.quorumLearnerLoginContext);
-          }
-          quorumPeer.setQuorumCnxnThreadsSize(config.quorumCnxnThreadsSize);
-          quorumPeer.initialize();
-          
-          quorumPeer.start();
-          quorumPeer.join();
-      } catch (InterruptedException e) {
-          // warn, but generally this is ok
-          LOG.warn("Quorum Peer interrupted", e);
-      } finally {
-          if (metricsProvider != null) {
-              try {
-                  metricsProvider.stop();
-              } catch (Throwable error) {
-                  LOG.warn("Error while stopping metrics", error);
-              }
-          }
-      }
-    }
-
-    // @VisibleForTesting
-    protected QuorumPeer getQuorumPeer() throws SaslException {
-        return new QuorumPeer();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/QuorumStats.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumStats.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumStats.java
deleted file mode 100644
index b6c62e4..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumStats.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-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 OBSERVING_STATE = "observing";
-        public String[] getQuorumPeers();
-        public String getServerState();
-    }
-    
-    protected QuorumStats(Provider provider) {
-        this.provider = provider;
-    }
-    
-    public String getServerState(){
-        return provider.getServerState();
-    }
-    
-    public String[] getQuorumPeers(){
-        return provider.getQuorumPeers();
-    }
-
-    @Override
-    public String toString(){
-        StringBuilder sb=new StringBuilder(super.toString());
-        String state=getServerState();
-        if(state.equals(Provider.LEADING_STATE)){
-            sb.append("Followers:");
-            for(String f: getQuorumPeers()){
-                sb.append(" ").append(f);
-            }
-            sb.append("\n");            
-        }else if(state.equals(Provider.FOLLOWING_STATE) 
-                || state.equals(Provider.OBSERVING_STATE)){
-            sb.append("Leader: ");
-            String[] ldr=getQuorumPeers();
-            if(ldr.length>0)
-                sb.append(ldr[0]);
-            else
-                sb.append("not connected");
-            sb.append("\n");
-        }
-        return sb.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/QuorumZooKeeperServer.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/QuorumZooKeeperServer.java b/src/java/main/org/apache/zookeeper/server/quorum/QuorumZooKeeperServer.java
deleted file mode 100644
index f6e4f11..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/QuorumZooKeeperServer.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.zookeeper.server.quorum;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.ByteBuffer;
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.MultiTransactionRecord;
-import org.apache.zookeeper.Op;
-import org.apache.zookeeper.ZooDefs.OpCode;
-import org.apache.zookeeper.proto.CreateRequest;
-import org.apache.zookeeper.server.ByteBufferInputStream;
-import org.apache.zookeeper.server.Request;
-import org.apache.zookeeper.server.ZKDatabase;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
-
-/**
- * Abstract base class for all ZooKeeperServers that participate in
- * a quorum.
- */
-public abstract class QuorumZooKeeperServer extends ZooKeeperServer {
-
-    public final QuorumPeer self;
-    protected UpgradeableSessionTracker upgradeableSessionTracker;
-
-    protected QuorumZooKeeperServer(FileTxnSnapLog logFactory, int tickTime,
-            int minSessionTimeout, int maxSessionTimeout,
-            ZKDatabase zkDb, QuorumPeer self)
-    {
-        super(logFactory, tickTime, minSessionTimeout, maxSessionTimeout, zkDb);
-        this.self = self;
-    }
-
-    @Override
-    protected void startSessionTracker() {
-        upgradeableSessionTracker = (UpgradeableSessionTracker) sessionTracker;
-        upgradeableSessionTracker.start();
-    }
-
-    public Request checkUpgradeSession(Request request)
-            throws IOException, KeeperException {
-        // If this is a request for a local session and it is to
-        // create an ephemeral node, then upgrade the session and return
-        // a new session request for the leader.
-        // This is called by the request processor thread (either follower
-        // or observer request processor), which is unique to a learner.
-        // So will not be called concurrently by two threads.
-        if ((request.type != OpCode.create && request.type != OpCode.create2 && request.type != OpCode.multi) ||
-            !upgradeableSessionTracker.isLocalSession(request.sessionId)) {
-            return null;
-        }
-
-        if (OpCode.multi == request.type) {
-            MultiTransactionRecord multiTransactionRecord = new MultiTransactionRecord();
-            request.request.rewind();
-            ByteBufferInputStream.byteBuffer2Record(request.request, multiTransactionRecord);
-            request.request.rewind();
-            boolean containsEphemeralCreate = false;
-            for (Op op : multiTransactionRecord) {
-                if (op.getType() == OpCode.create || op.getType() == OpCode.create2) {
-                    CreateRequest createRequest = (CreateRequest)op.toRequestRecord();
-                    CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags());
-                    if (createMode.isEphemeral()) {
-                        containsEphemeralCreate = true;
-                        break;
-                    }
-                }
-            }
-            if (!containsEphemeralCreate) {
-                return null;
-            }
-        } else {
-            CreateRequest createRequest = new CreateRequest();
-            request.request.rewind();
-            ByteBufferInputStream.byteBuffer2Record(request.request, createRequest);
-            request.request.rewind();
-            CreateMode createMode = CreateMode.fromFlag(createRequest.getFlags());
-            if (!createMode.isEphemeral()) {
-                return null;
-            }
-        }
-
-        // Uh oh.  We need to upgrade before we can proceed.
-        if (!self.isLocalSessionsUpgradingEnabled()) {
-            throw new KeeperException.EphemeralOnLocalSessionException();
-        }
-
-        return makeUpgradeRequest(request.sessionId);
-    }
-
-    private Request makeUpgradeRequest(long sessionId) {
-        // Make sure to atomically check local session status, upgrade
-        // session, and make the session creation request.  This is to
-        // avoid another thread upgrading the session in parallel.
-        synchronized (upgradeableSessionTracker) {
-            if (upgradeableSessionTracker.isLocalSession(sessionId)) {
-                int timeout = upgradeableSessionTracker.upgradeSession(sessionId);
-                ByteBuffer to = ByteBuffer.allocate(4);
-                to.putInt(timeout);
-                return new Request(
-                        null, sessionId, 0, OpCode.createSession, to, null);
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Implements the SessionUpgrader interface,
-     *
-     * @param sessionId
-     */
-    public void upgrade(long sessionId) {
-        Request request = makeUpgradeRequest(sessionId);
-        if (request != null) {
-            LOG.info("Upgrading session 0x" + Long.toHexString(sessionId));
-            // This must be a global request
-            submitRequest(request);
-        }
-    }
-
-    @Override
-    protected void setLocalSessionFlag(Request si) {
-        // We need to set isLocalSession to tree for these type of request
-        // so that the request processor can process them correctly.
-        switch (si.type) {
-        case OpCode.createSession:
-            if (self.areLocalSessionsEnabled()) {
-                // All new sessions local by default.
-                si.setLocalSession(true);
-            }
-            break;
-        case OpCode.closeSession:
-            String reqType = "global";
-            if (upgradeableSessionTracker.isLocalSession(si.sessionId)) {
-                si.setLocalSession(true);
-                reqType = "local";
-            }
-            LOG.info("Submitting " + reqType + " closeSession request"
-                    + " for session 0x" + Long.toHexString(si.sessionId));
-            break;
-        default:
-            break;
-        }
-    }
-
-    @Override
-    public void dumpConf(PrintWriter pwriter) {
-        super.dumpConf(pwriter);
-
-        pwriter.print("initLimit=");
-        pwriter.println(self.getInitLimit());
-        pwriter.print("syncLimit=");
-        pwriter.println(self.getSyncLimit());
-        pwriter.print("electionAlg=");
-        pwriter.println(self.getElectionType());
-        pwriter.print("electionPort=");
-        pwriter.println(self.getElectionAddress().getPort());
-        pwriter.print("quorumPort=");
-        pwriter.println(self.getQuorumAddress().getPort());
-        pwriter.print("peerType=");
-        pwriter.println(self.getLearnerType().ordinal());
-        pwriter.println("membership: ");
-        pwriter.print(new String(self.getQuorumVerifier().toString().getBytes()));
-    }
-
-    @Override
-    protected void setState(State state) {
-        this.state = state;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyBean.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyBean.java b/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyBean.java
deleted file mode 100644
index a2b6fe3..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyBean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.ZooKeeperServerBean;
-
-/**
- * ReadOnly MX Bean interface, implemented by ReadOnlyBean
- *
- */
-public class ReadOnlyBean extends ZooKeeperServerBean {
-
-    public ReadOnlyBean(ZooKeeperServer zks) {
-        super(zks);
-    }
-
-    public String getName() {
-        return "ReadOnlyServer";
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyRequestProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyRequestProcessor.java b/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyRequestProcessor.java
deleted file mode 100644
index c62eb42..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyRequestProcessor.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import java.io.IOException;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import org.apache.zookeeper.KeeperException.Code;
-import org.apache.zookeeper.ZooDefs.OpCode;
-import org.apache.zookeeper.proto.ReplyHeader;
-import org.apache.zookeeper.server.Request;
-import org.apache.zookeeper.server.RequestProcessor;
-import org.apache.zookeeper.server.ZooKeeperCriticalThread;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.ZooTrace;
-import org.apache.zookeeper.server.quorum.Leader.XidRolloverException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This processor is at the beginning of the ReadOnlyZooKeeperServer's
- * processors chain. All it does is, it passes read-only operations (e.g.
- * OpCode.getData, OpCode.exists) through to the next processor, but drops
- * state-changing operations (e.g. OpCode.create, OpCode.setData).
- */
-public class ReadOnlyRequestProcessor extends ZooKeeperCriticalThread implements
-        RequestProcessor {
-
-    private static final Logger LOG = LoggerFactory.getLogger(ReadOnlyRequestProcessor.class);
-
-    private final LinkedBlockingQueue<Request> queuedRequests = new LinkedBlockingQueue<Request>();
-
-    private boolean finished = false;
-
-    private final RequestProcessor nextProcessor;
-
-    private final ZooKeeperServer zks;
-
-    public ReadOnlyRequestProcessor(ZooKeeperServer zks,
-            RequestProcessor nextProcessor) {
-        super("ReadOnlyRequestProcessor:" + zks.getServerId(), zks
-                .getZooKeeperServerListener());
-        this.zks = zks;
-        this.nextProcessor = nextProcessor;
-    }
-
-    public void run() {
-        try {
-            while (!finished) {
-                Request request = queuedRequests.take();
-
-                // log request
-                long traceMask = ZooTrace.CLIENT_REQUEST_TRACE_MASK;
-                if (request.type == OpCode.ping) {
-                    traceMask = ZooTrace.CLIENT_PING_TRACE_MASK;
-                }
-                if (LOG.isTraceEnabled()) {
-                    ZooTrace.logRequest(LOG, traceMask, 'R', request, "");
-                }
-                if (Request.requestOfDeath == request) {
-                    break;
-                }
-
-                // filter read requests
-                switch (request.type) {
-                case OpCode.sync:
-                case OpCode.create:
-                case OpCode.create2:
-                case OpCode.createTTL:
-                case OpCode.createContainer:
-                case OpCode.delete:
-                case OpCode.deleteContainer:
-                case OpCode.setData:
-                case OpCode.reconfig:
-                case OpCode.setACL:
-                case OpCode.multi:
-                case OpCode.check:
-                    ReplyHeader hdr = new ReplyHeader(request.cxid, zks.getZKDatabase()
-                            .getDataTreeLastProcessedZxid(), Code.NOTREADONLY.intValue());
-                    try {
-                        request.cnxn.sendResponse(hdr, null, null);
-                    } catch (IOException e) {
-                        LOG.error("IO exception while sending response", e);
-                    }
-                    continue;
-                }
-
-                // proceed to the next processor
-                if (nextProcessor != null) {
-                    nextProcessor.processRequest(request);
-                }
-            }
-        } catch (RequestProcessorException e) {
-            if (e.getCause() instanceof XidRolloverException) {
-                LOG.info(e.getCause().getMessage());
-            }
-            handleException(this.getName(), e);
-        } catch (Exception e) {
-            handleException(this.getName(), e);
-        }
-        LOG.info("ReadOnlyRequestProcessor exited loop!");
-    }
-
-    @Override
-    public void processRequest(Request request) {
-        if (!finished) {
-            queuedRequests.add(request);
-        }
-    }
-
-    @Override
-    public void shutdown() {
-        finished = true;
-        queuedRequests.clear();
-        queuedRequests.add(Request.requestOfDeath);
-        nextProcessor.shutdown();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyZooKeeperServer.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyZooKeeperServer.java b/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyZooKeeperServer.java
deleted file mode 100644
index 2ef8a5e..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/ReadOnlyZooKeeperServer.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import java.io.PrintWriter;
-
-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;
-import org.apache.zookeeper.server.ZKDatabase;
-import org.apache.zookeeper.server.ZooKeeperServer;
-import org.apache.zookeeper.server.ZooKeeperServerBean;
-import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
-
-/**
- * A ZooKeeperServer which comes into play when peer is partitioned from the
- * majority. Handles read-only clients, but drops connections from not-read-only
- * ones.
- * <p>
- * The very first processor in the chain of request processors is a
- * ReadOnlyRequestProcessor which drops state-changing requests.
- */
-public class ReadOnlyZooKeeperServer extends ZooKeeperServer {
-
-    protected final QuorumPeer self;
-    private volatile boolean shutdown = false;
-
-    ReadOnlyZooKeeperServer(FileTxnSnapLog logFactory, QuorumPeer self,
-                            ZKDatabase zkDb) {
-        super(logFactory, self.tickTime, self.minSessionTimeout,
-              self.maxSessionTimeout, zkDb);
-        this.self = self;
-    }
-
-    @Override
-    protected void setupRequestProcessors() {
-        RequestProcessor finalProcessor = new FinalRequestProcessor(this);
-        RequestProcessor prepProcessor = new PrepRequestProcessor(this, finalProcessor);
-        ((PrepRequestProcessor) prepProcessor).start();
-        firstProcessor = new ReadOnlyRequestProcessor(this, prepProcessor);
-        ((ReadOnlyRequestProcessor) firstProcessor).start();
-    }
-
-    @Override
-    public synchronized void startup() {
-        // check to avoid startup follows shutdown
-        if (shutdown) {
-            LOG.warn("Not starting Read-only server as startup follows shutdown!");
-            return;
-        }
-        registerJMX(new ReadOnlyBean(this), self.jmxLocalPeerBean);
-        super.startup();
-        self.setZooKeeperServer(this);
-        self.adminServer.setZooKeeperServer(this);
-        LOG.info("Read-only server started");
-    }
-
-    @Override
-    protected void registerJMX() {
-        // register with JMX
-        try {
-            jmxDataTreeBean = new DataTreeBean(getZKDatabase().getDataTree());
-            MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
-        } catch (Exception e) {
-            LOG.warn("Failed to register with JMX", e);
-            jmxDataTreeBean = null;
-        }
-    }
-
-    public void registerJMX(ZooKeeperServerBean serverBean, LocalPeerBean localPeerBean) {
-        // register with JMX
-        try {
-            jmxServerBean = serverBean;
-            MBeanRegistry.getInstance().register(serverBean, localPeerBean);
-        } catch (Exception e) {
-            LOG.warn("Failed to register with JMX", e);
-            jmxServerBean = null;
-        }
-    }
-
-    @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(ZooKeeperServer zks) {
-        // unregister from JMX
-        try {
-            if (jmxServerBean != null) {
-                MBeanRegistry.getInstance().unregister(jmxServerBean);
-            }
-        } catch (Exception e) {
-            LOG.warn("Failed to unregister with JMX", e);
-        }
-        jmxServerBean = null;
-    }
-
-    @Override
-    public String getState() {
-        return "read-only";
-    }
-
-    /**
-     * Returns the id of the associated QuorumPeer, which will do for a unique
-     * id of this server.
-     */
-    @Override
-    public long getServerId() {
-        return self.getId();
-    }
-
-    @Override
-    public synchronized void shutdown() {
-        if (!canShutdown()) {
-            LOG.debug("ZooKeeper server is not running, so not proceeding to shutdown!");
-            return;
-        }
-        shutdown = true;
-        unregisterJMX(this);
-
-        // set peer's server to null
-        self.setZooKeeperServer(null);
-        // clear all the connections
-        self.closeAllConnections();
-
-        self.adminServer.setZooKeeperServer(null);
-
-        // shutdown the server itself
-        super.shutdown();
-    }
-
-    @Override
-    public void dumpConf(PrintWriter pwriter) {
-        super.dumpConf(pwriter);
-
-        pwriter.print("initLimit=");
-        pwriter.println(self.getInitLimit());
-        pwriter.print("syncLimit=");
-        pwriter.println(self.getSyncLimit());
-        pwriter.print("electionAlg=");
-        pwriter.println(self.getElectionType());
-        pwriter.print("electionPort=");
-        pwriter.println(self.getElectionAddress().getPort());
-        pwriter.print("quorumPort=");
-        pwriter.println(self.getQuorumAddress().getPort());
-        pwriter.print("peerType=");
-        pwriter.println(self.getLearnerType().ordinal());
-    }
-
-    @Override
-    protected void setState(State state) {
-        this.state = state;
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java b/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java
deleted file mode 100644
index 285f11a..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerBean.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import org.apache.zookeeper.jmx.ZKMBeanInfo;
-
-/**
- * A remote peer bean only provides limited information about the remote peer,
- * and the peer cannot be managed remotely. 
- */
-public class RemotePeerBean implements RemotePeerMXBean,ZKMBeanInfo {
-    private QuorumPeer.QuorumServer peer;
-    private final QuorumPeer localPeer;
-
-    public RemotePeerBean(QuorumPeer localPeer, QuorumPeer.QuorumServer peer){
-        this.peer=peer;
-        this.localPeer = localPeer;
-    }
-
-    public void setQuorumServer(QuorumPeer.QuorumServer peer) {
-        this.peer = peer;
-    }
-
-    public String getName() {
-        return "replica."+peer.id;
-    }
-    public boolean isHidden() {
-        return false;
-    }
-
-    public String getQuorumAddress() {
-        return peer.addr.getHostString()+":"+peer.addr.getPort();
-    }
-
-    public String getElectionAddress() {
-        return peer.electionAddr.getHostString() + ":" + peer.electionAddr.getPort();
-    }
-
-    public String getClientAddress() {
-        if (null == peer.clientAddr) {
-            return "";
-        }
-        return peer.clientAddr.getHostString() + ":"
-                + peer.clientAddr.getPort();
-    }
-
-    public String getLearnerType() {
-        return peer.type.toString();
-    }
-
-    @Override
-    public boolean isLeader() {
-        return localPeer.isLeader(peer.getId());
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java b/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java
deleted file mode 100644
index cfeaa4b..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/RemotePeerMXBean.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-/**
- * A proxy for a remote quorum peer.
- */
-public interface RemotePeerMXBean {
-    /**
-     * @return name of the peer
-     */
-    public String getName();
-    /**
-     * @return IP address of the quorum peer 
-     */
-    public String getQuorumAddress();
-
-    /**
-     * @return the election address
-     */
-    public String getElectionAddress();
-
-    /**
-     * @return the client address
-     */
-    public String getClientAddress();
-
-    /**
-     * @return the learner type
-     */
-    public String getLearnerType();
-
-    /**
-     * @return true if the peer is the current leader
-     */
-    public boolean isLeader();
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/SendAckRequestProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/SendAckRequestProcessor.java b/src/java/main/org/apache/zookeeper/server/quorum/SendAckRequestProcessor.java
deleted file mode 100644
index 6985342..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/SendAckRequestProcessor.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import java.io.Flushable;
-import java.io.IOException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.zookeeper.ZooDefs.OpCode;
-import org.apache.zookeeper.server.Request;
-import org.apache.zookeeper.server.RequestProcessor;
-
-public class SendAckRequestProcessor implements RequestProcessor, Flushable {
-    private static final Logger LOG = LoggerFactory.getLogger(SendAckRequestProcessor.class);
-
-    Learner learner;
-
-    SendAckRequestProcessor(Learner peer) {
-        this.learner = peer;
-    }
-
-    public void processRequest(Request si) {
-        if(si.type != OpCode.sync){
-            QuorumPacket qp = new QuorumPacket(Leader.ACK, si.getHdr().getZxid(), null,
-                null);
-            try {
-                learner.writePacket(qp, false);
-            } catch (IOException e) {
-                LOG.warn("Closing connection to leader, exception during packet send", e);
-                try {
-                    if (!learner.sock.isClosed()) {
-                        learner.sock.close();
-                    }
-                } catch (IOException e1) {
-                    // Nothing to do, we are shutting things down, so an exception here is irrelevant
-                    LOG.debug("Ignoring error closing the connection", e1);
-                }
-            }
-        }
-    }
-
-    public void flush() throws IOException {
-        try {
-            learner.writePacket(null, true);
-        } catch(IOException e) {
-            LOG.warn("Closing connection to leader, exception during packet send", e);
-            try {
-                if (!learner.sock.isClosed()) {
-                    learner.sock.close();
-                }
-            } catch (IOException e1) {
-                    // Nothing to do, we are shutting things down, so an exception here is irrelevant
-                    LOG.debug("Ignoring error closing the connection", e1);
-            }
-        }
-    }
-
-    public void shutdown() {
-        // Nothing needed
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java b/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java
deleted file mode 100644
index 281c05b..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/ServerBean.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-import java.util.Date;
-
-import org.apache.zookeeper.jmx.ZKMBeanInfo;
-
-/**
- * An abstract base class for the leader and follower MBeans.
- */
-public abstract class ServerBean implements ServerMXBean, ZKMBeanInfo {
-    private final Date startTime=new Date();
-    
-    public boolean isHidden() {
-        return false;
-    }
-
-    public String getStartTime() {
-        return startTime.toString();
-    }
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java b/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java
deleted file mode 100644
index df52aea..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/ServerMXBean.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-/**
- * A quorum server MBean.
- */
-public interface ServerMXBean {
-    /**
-     * @return name of the server MBean
-     */
-    public String getName();
-    /**
-     * @return the start time the server 
-     */
-    public String getStartTime();
-}

http://git-wip-us.apache.org/repos/asf/zookeeper/blob/faa7cec7/src/java/main/org/apache/zookeeper/server/quorum/SnapshotThrottleException.java
----------------------------------------------------------------------
diff --git a/src/java/main/org/apache/zookeeper/server/quorum/SnapshotThrottleException.java b/src/java/main/org/apache/zookeeper/server/quorum/SnapshotThrottleException.java
deleted file mode 100644
index 77732f3..0000000
--- a/src/java/main/org/apache/zookeeper/server/quorum/SnapshotThrottleException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.server.quorum;
-
-/**
- * Thrown when a {@link Leader} has too many concurrent snapshots being sent
- * to observers.
- * 
- * @see LearnerSnapshotThrottler
- *
- */
-public class SnapshotThrottleException extends Exception {
-    private static final long serialVersionUID = 1L;
-
-    public SnapshotThrottleException(int concurrentSnapshotNumber, int throttleThreshold) {
-        super(getMessage(concurrentSnapshotNumber, throttleThreshold));
-    }
-
-    private static String getMessage(int concurrentSnapshotNumber, int throttleThreshold) {
-        return String.format("new snapshot would make %d concurrently in progress; " +
-                "maximum is %d", concurrentSnapshotNumber, throttleThreshold);
-    }
-}


Mime
View raw message