Search in sources :

Example 16 with HBaseAdmin

use of org.apache.hadoop.hbase.client.HBaseAdmin in project SpyGlass by ParallelAI.

the class HBaseTap method getHBaseAdmin.

protected HBaseAdmin getHBaseAdmin(JobConf conf) throws IOException {
    if (hBaseAdmin == null) {
        Configuration hbaseConf = HBaseConfiguration.create(conf);
        hBaseAdmin = new HBaseAdmin(hbaseConf);
    }
    return hBaseAdmin;
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration)

Example 17 with HBaseAdmin

use of org.apache.hadoop.hbase.client.HBaseAdmin in project Solbase by Photobucket.

the class SolbaseUtil method createTermVectorTable.

public static void createTermVectorTable(byte[][] splits) throws IOException {
    HTableDescriptor desc = new HTableDescriptor(SolbaseUtil.getTermVectorTableName());
    HColumnDescriptor column = new HColumnDescriptor(SolbaseUtil.termVectorDocColumnFamilyName);
    SolbaseUtil.setupHColumnDescriptor(column);
    desc.addFamily(column);
    HBaseAdmin admin;
    admin = new HBaseAdmin(SolbaseUtil.conf);
    admin.createTable(desc, splits);
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 18 with HBaseAdmin

use of org.apache.hadoop.hbase.client.HBaseAdmin in project Solbase by Photobucket.

the class SolbaseUtil method createDocTable.

public static void createDocTable(byte[][] splits) throws IOException {
    HTableDescriptor desc = new HTableDescriptor(SolbaseUtil.getDocTableName());
    HColumnDescriptor fieldColumn = new HColumnDescriptor(SolbaseUtil.fieldColumnFamilyName);
    SolbaseUtil.setupHColumnDescriptor(fieldColumn);
    desc.addFamily(fieldColumn);
    HColumnDescriptor allTermsColumn = new HColumnDescriptor(SolbaseUtil.allTermsColumnFamilyName);
    SolbaseUtil.setupHColumnDescriptor(allTermsColumn);
    desc.addFamily(allTermsColumn);
    HColumnDescriptor timestampColumn = new HColumnDescriptor(SolbaseUtil.timestampColumnFamilyName);
    SolbaseUtil.setupHColumnDescriptor(timestampColumn);
    desc.addFamily(timestampColumn);
    HBaseAdmin admin;
    admin = new HBaseAdmin(SolbaseUtil.conf);
    admin.createTable(desc, splits);
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 19 with HBaseAdmin

use of org.apache.hadoop.hbase.client.HBaseAdmin in project DataX by alibaba.

the class Hbase094xHelper method getTable.

/**
     * 每次都获取一个新的HTable  注意:HTable 本身是线程不安全的
     */
public static HTable getTable(com.alibaba.datax.common.util.Configuration configuration) {
    String hbaseConnConf = configuration.getString(Key.HBASE_CONFIG);
    String tableName = configuration.getString(Key.TABLE);
    HBaseAdmin admin = null;
    try {
        org.apache.hadoop.conf.Configuration hbaseConf = Hbase094xHelper.getHbaseConf(hbaseConnConf);
        HTable htable = new HTable(hbaseConf, tableName);
        admin = new HBaseAdmin(hbaseConf);
        checkHbaseTable(admin, htable);
        return htable;
    } catch (Exception e) {
        throw DataXException.asDataXException(Hbase094xReaderErrorCode.GET_HBASE_TABLE_ERROR, e);
    } finally {
        Hbase094xHelper.closeAdmin(admin);
    }
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) HTable(org.apache.hadoop.hbase.client.HTable) IOException(java.io.IOException) DataXException(com.alibaba.datax.common.exception.DataXException)

Example 20 with HBaseAdmin

use of org.apache.hadoop.hbase.client.HBaseAdmin in project DataX by alibaba.

the class HbaseUtil method initHtable.

/**
     * 每次都获取一个新的HTable  注意:HTable 本身是线程不安全的
     */
public static HTable initHtable(com.alibaba.datax.common.util.Configuration configuration) {
    String hbaseConnConf = configuration.getString(Key.HBASE_CONFIG);
    String tableName = configuration.getString(Key.TABLE);
    HBaseAdmin admin = null;
    try {
        org.apache.hadoop.conf.Configuration conf = HbaseUtil.getHbaseConf(hbaseConnConf);
        conf.set("hbase.meta.scanner.caching", META_SCANNER_CACHING);
        HTable htable = HTableManager.createHTable(conf, tableName);
        admin = HTableManager.createHBaseAdmin(conf);
        check(admin, htable);
        return htable;
    } catch (Exception e) {
        throw DataXException.asDataXException(HbaseReaderErrorCode.INIT_TABLE_ERROR, e);
    } finally {
        if (admin != null) {
            try {
                admin.close();
            } catch (IOException e) {
            // ignore it
            }
        }
    }
}
Also used : HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) IOException(java.io.IOException) HTable(org.apache.hadoop.hbase.client.HTable) IOException(java.io.IOException) DataXException(com.alibaba.datax.common.exception.DataXException)

Aggregations

HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)180 Test (org.junit.Test)93 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)76 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)72 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)70 Connection (java.sql.Connection)66 Properties (java.util.Properties)54 TableName (org.apache.hadoop.hbase.TableName)36 IOException (java.io.IOException)33 ResultSet (java.sql.ResultSet)27 BaseTest (org.apache.phoenix.query.BaseTest)27 HTable (org.apache.hadoop.hbase.client.HTable)26 SQLException (java.sql.SQLException)22 TestUtil.closeConnection (org.apache.phoenix.util.TestUtil.closeConnection)22 Put (org.apache.hadoop.hbase.client.Put)16 Configuration (org.apache.hadoop.conf.Configuration)13 HTableInterface (org.apache.hadoop.hbase.client.HTableInterface)13 PreparedStatement (java.sql.PreparedStatement)12 PhoenixIOException (org.apache.phoenix.exception.PhoenixIOException)12 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)9