// Path: src/main/java/com/officedrop/redis/failover/HostConfiguration.java
// public class HostConfiguration {
// 
//     private final String host;
//     private final int port;
//     private final int timeout;
//     private final int database;
// 
//     public HostConfiguration(String host, int port) {
//         this( host, port, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_DATABASE );
//     }
// 
//     public HostConfiguration(String host, int port, int timeout) {
//         this( host, port, timeout, Protocol.DEFAULT_DATABASE );
//     }
// 
//     public HostConfiguration(String host, int port, int timeout, int database) {
// 
//         if ( host == null || host.trim().isEmpty() ) {
//             throw new IllegalArgumentException("'host' can not be null");
//         }
// 
//         this.port = port;
//         this.timeout = timeout;
//         this.host = host;
//         this.database = database;
//     }
// 
//     public int getPort() {
//         return port;
//     }
// 
//     public String getHost() {
//         return host;
//     }
// 
//     public int getTimeout() {
//         return this.timeout;
//     }
// 
//     public int getDatabase() {
//         return this.database;
//     }
// 
//     public String asHost() {
//         return String.format("%s:%s", this.getHost(), this.getPort());
//     }
// 
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) return true;
//         if (!(o instanceof HostConfiguration)) return false;
// 
//         HostConfiguration that = (HostConfiguration) o;
// 
//         if (port != that.port) return false;
//         if (database != that.database) return false;
//         if (!host.equals(that.host)) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = host.hashCode();
//         result = 31 * result + port;
//         return result;
//     }
// 
//     @Override
//     public String toString() {
//         return "HostConfiguration{" +
//                 "host='" + host + '\'' +
//                 ", port=" + port +
//                 ", timeout=" + timeout +
//                 '}';
//     }
// 
// }
// 
// Path: src/main/java/com/officedrop/redis/failover/utils/Action1.java
// public interface Action1<T> {
// 
//     public void apply(T parameter);
// 
// }


import com.officedrop.redis.failover.HostConfiguration;
import com.officedrop.redis.failover.utils.Action1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
    public void setAlwaysTimeout(boolean value) {
        this.alwaysTimeout = value;
    }

    public String getMasterHost() {
        return masterHost;
    }

    public void setMasterHost(final String masterHost) {
        this.masterHost = masterHost;
    }

    public String getMasterPort() {
        return masterPort;
    }

    public void setMasterPort(final String masterPort) {
        this.masterPort = masterPort;
    }

    public void setMasterPort(final int masterPort) {
        this.masterPort = String.valueOf(masterPort);
    }

    public void start() {

        this.running = true;

        log.info("started server - {}:{}", this.getAddress(), this.getPort());

// Path: src/main/java/com/officedrop/redis/failover/HostConfiguration.java
// public class HostConfiguration {
// 
//     private final String host;
//     private final int port;
//     private final int timeout;
//     private final int database;
// 
//     public HostConfiguration(String host, int port) {
//         this( host, port, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_DATABASE );
//     }
// 
//     public HostConfiguration(String host, int port, int timeout) {
//         this( host, port, timeout, Protocol.DEFAULT_DATABASE );
//     }
// 
//     public HostConfiguration(String host, int port, int timeout, int database) {
// 
//         if ( host == null || host.trim().isEmpty() ) {
//             throw new IllegalArgumentException("'host' can not be null");
//         }
// 
//         this.port = port;
//         this.timeout = timeout;
//         this.host = host;
//         this.database = database;
//     }
// 
//     public int getPort() {
//         return port;
//     }
// 
//     public String getHost() {
//         return host;
//     }
// 
//     public int getTimeout() {
//         return this.timeout;
//     }
// 
//     public int getDatabase() {
//         return this.database;
//     }
// 
//     public String asHost() {
//         return String.format("%s:%s", this.getHost(), this.getPort());
//     }
// 
// 
//     @Override
//     public boolean equals(final Object o) {
//         if (this == o) return true;
//         if (!(o instanceof HostConfiguration)) return false;
// 
//         HostConfiguration that = (HostConfiguration) o;
// 
//         if (port != that.port) return false;
//         if (database != that.database) return false;
//         if (!host.equals(that.host)) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = host.hashCode();
//         result = 31 * result + port;
//         return result;
//     }
// 
//     @Override
//     public String toString() {
//         return "HostConfiguration{" +
//                 "host='" + host + '\'' +
//                 ", port=" + port +
//                 ", timeout=" + timeout +
//                 '}';
//     }
// 
// }
// 
// Path: src/main/java/com/officedrop/redis/failover/utils/Action1.java
// public interface Action1<T> {
// 
//     public void apply(T parameter);
// 
// }


// Path: src/test/java/com/officedrop/redis/failover/redis/RedisServer.java
import com.officedrop.redis.failover.HostConfiguration;
import com.officedrop.redis.failover.utils.Action1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;

    public void setAlwaysTimeout(boolean value) {
        this.alwaysTimeout = value;
    }

    public String getMasterHost() {
        return masterHost;
    }

    public void setMasterHost(final String masterHost) {
        this.masterHost = masterHost;
    }

    public String getMasterPort() {
        return masterPort;
    }

    public void setMasterPort(final String masterPort) {
        this.masterPort = masterPort;
    }

    public void setMasterPort(final int masterPort) {
        this.masterPort = String.valueOf(masterPort);
    }

    public void start() {

        this.running = true;

        log.info("started server - {}:{}", this.getAddress(), this.getPort());

        Thread acceptor = new Thread(new Runnable() {