// Path: src/main/java/hrider/actions/Action.java
// public abstract class Action<R> {
// 
//     /**
//      * Executes the action.
//      *
//      * @throws Exception Any error.
//      */
//     public abstract R run() throws Exception;
// 
//     /**
//      * The method is called when the error occurred.
//      *
//      * @param ex The error.
//      */
//     @SuppressWarnings("NoopMethodInAbstractClass")
//     public void onError(Exception ex) {
// 
//     }
// }
// 
// Path: src/main/java/hrider/actions/RunnableAction.java
// public class RunnableAction<R> implements Runnable {
// 
//     //region Constants
//     private final static Log logger = Log.getLogger(RunnableAction.class);
//     //endregion
// 
//     //region Variables
//     private String    name;
//     private Action<R> action;
//     private Thread    thread;
//     private boolean   isRunning;
//     private boolean   interrupted;
//     private R         result;
//     //endregion
// 
//     //region Constructor
//     public RunnableAction(String name, Action<R> action) {
//         this.name = name;
//         this.action = action;
//     }
//     //endregion
// 
//     //region Public Properties
//     public R getResult() {
//         return result;
//     }
// 
//     public boolean isCompleted() {
//         return !isRunning && !interrupted;
//     }
// 
//     public boolean isRunning() {
//         return isRunning;
//     }
//     //endregion
// 
//     //region Public Methods
//     public static <R> RunnableAction<R> run(String name, Action<R> action) {
//         RunnableAction<R> runnableAction = new RunnableAction<R>(name, action);
//         runnableAction.start();
// 
//         return runnableAction;
//     }
// 
//     public static <R> R runAndWait(String name, Action<R> action, long timeout) {
//         RunnableAction<R> runnableAction = new RunnableAction<R>(name, action);
//         runnableAction.start();
// 
//         runnableAction.waitOrAbort(timeout);
//         return runnableAction.result;
//     }
// 
//     public void start() {
//         if (this.thread == null) {
//             this.thread = new Thread(this);
//             this.thread.setName(this.name);
//             this.thread.setDaemon(true);
//             this.thread.start();
// 
//             this.isRunning = true;
// 
//             logger.info("Action '%s' started.", this.name);
//         }
//     }
// 
//     public void abort() {
//         if (this.isRunning) {
//             this.interrupted = true;
// 
//             this.thread.interrupt();
//             this.thread = null;
//         }
//     }
// 
//     public void waitUntil(long timeout) {
//         StopWatch stopWatch = new StopWatch();
//         stopWatch.start();
// 
//         long localTimeout = timeout / 10;
// 
//         while (this.isRunning) {
//             try {
//                 Thread.sleep(localTimeout);
// 
//                 if (stopWatch.getTime() > timeout) {
//                     break;
//                 }
//             }
//             catch (InterruptedException ignore) {
//             }
//         }
// 
//         stopWatch.stop();
//     }
// 
//     public void waitOrAbort(long timeout) {
//         waitUntil(timeout);
// 
//         if (this.isRunning) {
//             abort();
//         }
//     }
// 
//     @Override
//     public void run() {
//         try {
//             this.result = action.run();
//             this.isRunning = false;
// 
//             logger.info("Action '%s' completed.", this.name);
//         }
//         catch (Exception e) {
//             this.isRunning = false;
// 
//             if (this.interrupted) {
//                 logger.info("Action '%s' aborted.", this.name);
//             }
//             else {
//                 logger.info("Action '%s' failed.", this.name);
//                 this.action.onError(e);
//             }
//         }
//     }
//     //endregion
// }
// 
// Path: src/main/java/hrider/hbase/ConnectionManager.java
// public class ConnectionManager {
// 
//     private static Map<ConnectionDetails, Connection> connections;
// 
//     private ConnectionManager() {
//     }
// 
//     static {
//         connections = new HashMap<ConnectionDetails, Connection>();
//     }
// 
//     public static Connection create(ConnectionDetails details) throws IOException {
//         Connection connection = connections.get(details);
//         if (connection == null) {
//             connection = new Connection(details);
//             connections.put(details, connection);
//         }
//         return connection;
//     }
// 
//     public static void release(ConnectionDetails details) {
//         connections.remove(details);
//     }
// }


import hrider.actions.Action;
import hrider.actions.RunnableAction;
import hrider.hbase.ConnectionManager;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import java.io.IOException;
import java.io.Serializable;
                return true;
            }
        }, GlobalConfig.instance().getConnectionCheckTimeout());

        return result != null ? result : false;
    }

    public Configuration createConfig() {
        Configuration config = HBaseConfiguration.create();
        config.set("hbase.zookeeper.quorum", this.zookeeper.getHost());
        config.set("hbase.zookeeper.property.clientPort", this.zookeeper.getPort());
        config.set("hbase.client.retries.number", "3");
        config.set("hbase.rpc.timeout","900000");
        //config.set("zookeeper.znode.parent","/hbase-unsecure");

//        config.set("hbase.security.authentication", "kerberos");
//        config.set("hbase.rpc.engine", "org.apache.hadoop.hbase.ipc.SecureRpcEngine");

        return config;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ConnectionDetails) {
            ConnectionDetails details = (ConnectionDetails)obj;
            return this.zookeeper.equals(details.zookeeper);
        }
        return false;
    }

// Path: src/main/java/hrider/actions/Action.java
// public abstract class Action<R> {
// 
//     /**
//      * Executes the action.
//      *
//      * @throws Exception Any error.
//      */
//     public abstract R run() throws Exception;
// 
//     /**
//      * The method is called when the error occurred.
//      *
//      * @param ex The error.
//      */
//     @SuppressWarnings("NoopMethodInAbstractClass")
//     public void onError(Exception ex) {
// 
//     }
// }
// 
// Path: src/main/java/hrider/actions/RunnableAction.java
// public class RunnableAction<R> implements Runnable {
// 
//     //region Constants
//     private final static Log logger = Log.getLogger(RunnableAction.class);
//     //endregion
// 
//     //region Variables
//     private String    name;
//     private Action<R> action;
//     private Thread    thread;
//     private boolean   isRunning;
//     private boolean   interrupted;
//     private R         result;
//     //endregion
// 
//     //region Constructor
//     public RunnableAction(String name, Action<R> action) {
//         this.name = name;
//         this.action = action;
//     }
//     //endregion
// 
//     //region Public Properties
//     public R getResult() {
//         return result;
//     }
// 
//     public boolean isCompleted() {
//         return !isRunning && !interrupted;
//     }
// 
//     public boolean isRunning() {
//         return isRunning;
//     }
//     //endregion
// 
//     //region Public Methods
//     public static <R> RunnableAction<R> run(String name, Action<R> action) {
//         RunnableAction<R> runnableAction = new RunnableAction<R>(name, action);
//         runnableAction.start();
// 
//         return runnableAction;
//     }
// 
//     public static <R> R runAndWait(String name, Action<R> action, long timeout) {
//         RunnableAction<R> runnableAction = new RunnableAction<R>(name, action);
//         runnableAction.start();
// 
//         runnableAction.waitOrAbort(timeout);
//         return runnableAction.result;
//     }
// 
//     public void start() {
//         if (this.thread == null) {
//             this.thread = new Thread(this);
//             this.thread.setName(this.name);
//             this.thread.setDaemon(true);
//             this.thread.start();
// 
//             this.isRunning = true;
// 
//             logger.info("Action '%s' started.", this.name);
//         }
//     }
// 
//     public void abort() {
//         if (this.isRunning) {
//             this.interrupted = true;
// 
//             this.thread.interrupt();
//             this.thread = null;
//         }
//     }
// 
//     public void waitUntil(long timeout) {
//         StopWatch stopWatch = new StopWatch();
//         stopWatch.start();
// 
//         long localTimeout = timeout / 10;
// 
//         while (this.isRunning) {
//             try {
//                 Thread.sleep(localTimeout);
// 
//                 if (stopWatch.getTime() > timeout) {
//                     break;
//                 }
//             }
//             catch (InterruptedException ignore) {
//             }
//         }
// 
//         stopWatch.stop();
//     }
// 
//     public void waitOrAbort(long timeout) {
//         waitUntil(timeout);
// 
//         if (this.isRunning) {
//             abort();
//         }
//     }
// 
//     @Override
//     public void run() {
//         try {
//             this.result = action.run();
//             this.isRunning = false;
// 
//             logger.info("Action '%s' completed.", this.name);
//         }
//         catch (Exception e) {
//             this.isRunning = false;
// 
//             if (this.interrupted) {
//                 logger.info("Action '%s' aborted.", this.name);
//             }
//             else {
//                 logger.info("Action '%s' failed.", this.name);
//                 this.action.onError(e);
//             }
//         }
//     }
//     //endregion
// }
// 
// Path: src/main/java/hrider/hbase/ConnectionManager.java
// public class ConnectionManager {
// 
//     private static Map<ConnectionDetails, Connection> connections;
// 
//     private ConnectionManager() {
//     }
// 
//     static {
//         connections = new HashMap<ConnectionDetails, Connection>();
//     }
// 
//     public static Connection create(ConnectionDetails details) throws IOException {
//         Connection connection = connections.get(details);
//         if (connection == null) {
//             connection = new Connection(details);
//             connections.put(details, connection);
//         }
//         return connection;
//     }
// 
//     public static void release(ConnectionDetails details) {
//         connections.remove(details);
//     }
// }


// Path: src/main/java/hrider/config/ConnectionDetails.java
import hrider.actions.Action;
import hrider.actions.RunnableAction;
import hrider.hbase.ConnectionManager;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import java.io.IOException;
import java.io.Serializable;

                return true;
            }
        }, GlobalConfig.instance().getConnectionCheckTimeout());

        return result != null ? result : false;
    }

    public Configuration createConfig() {
        Configuration config = HBaseConfiguration.create();
        config.set("hbase.zookeeper.quorum", this.zookeeper.getHost());
        config.set("hbase.zookeeper.property.clientPort", this.zookeeper.getPort());
        config.set("hbase.client.retries.number", "3");
        config.set("hbase.rpc.timeout","900000");
        //config.set("zookeeper.znode.parent","/hbase-unsecure");

//        config.set("hbase.security.authentication", "kerberos");
//        config.set("hbase.rpc.engine", "org.apache.hadoop.hbase.ipc.SecureRpcEngine");

        return config;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof ConnectionDetails) {
            ConnectionDetails details = (ConnectionDetails)obj;
            return this.zookeeper.equals(details.zookeeper);
        }
        return false;
    }

    @Override