// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
// 
// 	private static final String DEF_ZNODE = "/hbase";
// 
// 	private Configuration config;
// 	private HConnection conn;
// 
// 	public HBaseClientManager() {
// 		this.config = HBaseConfiguration.create();
// 	}
// 
// 	public HBaseClientManager(Configuration config) {
// 		this.config = config;
// 	}
// 
// 	public HBaseClientManager(String quorum, int port) {
// 		//默认为 : /hbase  EDH: /hyperbase1
// 		this(quorum, port, DEF_ZNODE);
// 	}
// 
// 
// 	public HBaseClientManager(String quorum, int port, String znode) {
// 		Configuration conf = HBaseConfiguration.create();
// 		conf.set("hbase.zookeeper.property.clientPort", port + "");
// 		conf.set("hbase.zookeeper.quorum", quorum);
// 		conf.set("zookeeper.znode.parent", znode);
// 		this.config = conf;
// 	}
// 
// 	public synchronized HConnection getConn() {
// 		if (null == conn) {
// 			try {
// 				this.conn = HConnectionManager.createConnection(config);
// 			} catch (Exception ex) {
// 				LOGGER.error("create conn err:", ex);
// 			}
// 		}
// 		return conn;
// 	}
// 
// 
// 	public void closeConn() {
// 		if (null != conn) {
// 			try {
// 				conn.close();
// 			} catch (Exception ex) {
// 				ex.printStackTrace();
// 			}
// 		}
// 	}
// 
// 	public void reloadConfig() {
// 		this.closeConn();
// 		this.getConn();
// 	}
// 
// 	public void setup() {
// 
// 	}
// 
// 	public Configuration getConfig() {
// 		return config;
// 	}
// 
// 	public void setConfig(Configuration config) {
// 		this.config = config;
// 		this.reloadConfig();
// 	}
// }
// 
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
// 
// 	void setup();
// 
// 	Configuration getConfig();
// 
// 	HConnection getConn();
// 
// 	void closeConn();
// }


import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
	 * delete a row identified by rowkey
	 *
	 * @param tableName
	 * @param rowKey
	 * @throws Exception
	 */
	public void deleteQualifier(String tableName, String rowKey, String family, String qualifier) throws Exception {
		HTableInterface htable = getTable(tableName);
		Delete delete = new Delete(Bytes.toBytes(rowKey));
		delete.deleteColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));
		htable.delete(delete);
	}

	/**
	 * return all row from a table
	 *
	 * @param table
	 * @throws Exception
	 */
	public static ResultScanner scanAll(HTableInterface table) throws Exception {
		Scan s = new Scan();
		ResultScanner rs = table.getScanner(s);
		return rs;
	}

	public static void main(String[] args) throws Exception {
		String quorum = "192.168.0.30,192.168.0.31,192.168.0.32";
		//quorum = "192.168.8.191,192.168.1.192,192.168.1.193";
		int port = 2181;
		String znode = "/hyperbase1";
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseClientManager.java
// public class HBaseClientManager implements HBaseConnPool {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(HBaseClientManager.class);
// 
// 	private static final String DEF_ZNODE = "/hbase";
// 
// 	private Configuration config;
// 	private HConnection conn;
// 
// 	public HBaseClientManager() {
// 		this.config = HBaseConfiguration.create();
// 	}
// 
// 	public HBaseClientManager(Configuration config) {
// 		this.config = config;
// 	}
// 
// 	public HBaseClientManager(String quorum, int port) {
// 		//默认为 : /hbase  EDH: /hyperbase1
// 		this(quorum, port, DEF_ZNODE);
// 	}
// 
// 
// 	public HBaseClientManager(String quorum, int port, String znode) {
// 		Configuration conf = HBaseConfiguration.create();
// 		conf.set("hbase.zookeeper.property.clientPort", port + "");
// 		conf.set("hbase.zookeeper.quorum", quorum);
// 		conf.set("zookeeper.znode.parent", znode);
// 		this.config = conf;
// 	}
// 
// 	public synchronized HConnection getConn() {
// 		if (null == conn) {
// 			try {
// 				this.conn = HConnectionManager.createConnection(config);
// 			} catch (Exception ex) {
// 				LOGGER.error("create conn err:", ex);
// 			}
// 		}
// 		return conn;
// 	}
// 
// 
// 	public void closeConn() {
// 		if (null != conn) {
// 			try {
// 				conn.close();
// 			} catch (Exception ex) {
// 				ex.printStackTrace();
// 			}
// 		}
// 	}
// 
// 	public void reloadConfig() {
// 		this.closeConn();
// 		this.getConn();
// 	}
// 
// 	public void setup() {
// 
// 	}
// 
// 	public Configuration getConfig() {
// 		return config;
// 	}
// 
// 	public void setConfig(Configuration config) {
// 		this.config = config;
// 		this.reloadConfig();
// 	}
// }
// 
// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/client/HBaseConnPool.java
// public interface HBaseConnPool {
// 
// 	void setup();
// 
// 	Configuration getConfig();
// 
// 	HConnection getConn();
// 
// 	void closeConn();
// }


// Path: hbase-tutorial/src/main/java/com/micmiu/bigdata/hbase/HBaseDMLHandler.java
import com.micmiu.bigdata.hbase.client.HBaseClientManager;
import com.micmiu.bigdata.hbase.client.HBaseConnPool;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.util.Bytes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;

	 * delete a row identified by rowkey
	 *
	 * @param tableName
	 * @param rowKey
	 * @throws Exception
	 */
	public void deleteQualifier(String tableName, String rowKey, String family, String qualifier) throws Exception {
		HTableInterface htable = getTable(tableName);
		Delete delete = new Delete(Bytes.toBytes(rowKey));
		delete.deleteColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));
		htable.delete(delete);
	}

	/**
	 * return all row from a table
	 *
	 * @param table
	 * @throws Exception
	 */
	public static ResultScanner scanAll(HTableInterface table) throws Exception {
		Scan s = new Scan();
		ResultScanner rs = table.getScanner(s);
		return rs;
	}

	public static void main(String[] args) throws Exception {
		String quorum = "192.168.0.30,192.168.0.31,192.168.0.32";
		//quorum = "192.168.8.191,192.168.1.192,192.168.1.193";
		int port = 2181;
		String znode = "/hyperbase1";
		HBaseConnPool connPool = new HBaseClientManager(quorum, port, znode);