package mySQL;
import java.io.IOException;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTablePool;
public class HbaseClient {
/**
* @param args
* @throws IOException
* @throws MasterNotRunningException
*/
public static void main(String[] args) throws MasterNotRunningException, IOException {
HBaseConfiguration conf=new HBaseConfiguration();
conf.set("hbase.master","localhost");
HTablePool pool=new HTablePool(conf,10);
/* _hUtil=new HUtil();
_hUtil.setPool(pool);*/
HBaseAdmin admin=new HBaseAdmin(conf);
try {
admin.disableTable("test_simple-by_photoId");
admin.deleteTable("test_simple-by_photoId");
}
catch ( TableNotFoundException e) {
}
try {
admin.disableTable("test_simple");
admin.deleteTable("test_simple");
}
catch ( TableNotFoundException e) {
}
HTableDescriptor by_photoId_idx=new HTableDescriptor("test_simple-by_photoId");
by_photoId_idx.addFamily(new HColumnDescriptor("__idx__"));
by_photoId_idx.addFamily(new HColumnDescriptor("props"));
admin.createTable(by_photoId_idx);
HTableDescriptor test_simple=new HTableDescriptor("test_simple");
test_simple.addFamily(new HColumnDescriptor("props"));
admin.createTable(test_simple); System.out.println("Done......");
}
}
log4j:WARN No appenders could be found for logger (org.apache.hadoop.hbase.HBaseConfiguration).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/zookeeper/KeeperException
at org.apache.hadoop.hbase.client.HConnectionManager.getConnection(HConnectionManager.java:157)
at org.apache.hadoop.hbase.client.HBaseAdmin.<init>(HBaseAdmin.java:90)
at mySQL.HbaseClient.main(HbaseClient.java:28)
Caused by: java.lang.ClassNotFoundException: org.apache.zookeeper.KeeperException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 3 more