Hi, I am trying use Java with installed HBase 2.0.0.
I see, Java for HBase has much more possibilities,like creating tables (must not using shell)
I can find many examples, but all are old (for example using HBaseAdmin)

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.ConnectionUtils;
import org.apache.hadoop.hbase.client.HBaseAdmin;

public class Example {
public static void mk() throws IOException {
                Configuration configuration = HBaseConfiguration.create();
                configuration.set("hbase.zookeeper.quorum", "127.0.0.1");
                configuration.set("hbase.zookeeper.property.clientPort", 
"2181");
                final TableName tableName = TableName.valueOf("testEclipse");
                final HTableDescriptor desc = new HTableDescriptor(tableName);
                desc.addFamily(new HColumnDescriptor("Id"));
                desc.addFamily(new HColumnDescriptor("Name"));
                System.out.println( "Connecting..." );
                HBaseAdmin hbase_admin = new HBaseAdmin( configuration );
                System.out.println( "Creating Table..." );
                hbase_admin.createTable( desc );
                System.out.println("Done!");
        }

   public static void main(String[] args) throws IOException {
      mk();
   }
}

HTableDescriptor and HColumnDescriptor are deprecated,
but more important, that HBaseAdmin not works with configuration parameter, but with interface ClusterConnection.
One implementation of ClusterConnection is ConnectionImplementation,
but I can't write
HBaseAdmin hbase_admin = new HBaseAdmin(new ConnectionImplementation());
nor
org.apache.hadoop.hbase.client.ConnectionImplementation

Where can I find newer examples for version 2.0.0?
In
https://github.com/apache/hbase/tree/master/hbase-client/src/test/java/org/apache/hadoop/hbase
in master branch?
or version is differ than 2.0? Maybe on other branch will for version 2.0?
I see there is Admin admin = new HBaseAdmin(mockConnection)
Admin, not HBaseAdmin.

Thanks in advance!

@Previous post: I am going "mvn package"

Reply via email to