Search in sources :

Example 1 with HBaseStore

use of com.nearinfinity.honeycomb.hbase.HBaseStore in project honeycomb by altamiracorp.

the class BulkLoadMapper method setup.

@Override
protected void setup(Context context) throws IOException {
    Configuration conf = context.getConfiguration();
    char separator = conf.get(SEPARATOR, " ").charAt(0);
    columns = conf.getStrings(SQL_COLUMNS);
    String sqlTable = conf.get(SQL_TABLE);
    String hbaseTable = conf.get(ConfigConstants.TABLE_NAME);
    String columnFamily = conf.get(ConfigConstants.COLUMN_FAMILY);
    // Check that necessary configuration variables are set
    checkNotNull(conf.get(HConstants.ZOOKEEPER_QUORUM), HConstants.ZOOKEEPER_QUORUM + NOT_SET_ERROR);
    checkNotNull(sqlTable, SQL_TABLE + NOT_SET_ERROR);
    checkNotNull(columns, SQL_COLUMNS + NOT_SET_ERROR);
    checkNotNull(hbaseTable, ConfigConstants.TABLE_NAME + NOT_SET_ERROR);
    checkNotNull(columnFamily, ConfigConstants.COLUMN_FAMILY + NOT_SET_ERROR);
    LOG.info("Zookeeper: " + conf.get(HConstants.ZOOKEEPER_QUORUM));
    LOG.info("SQL Table: " + sqlTable);
    LOG.info("HBase Table: " + hbaseTable);
    LOG.info("HBase Column Family: " + columnFamily);
    LOG.info("Input separator: '" + separator + "'");
    final HTablePool pool = new HTablePool(conf, 1);
    HBaseMetadata metadata = new HBaseMetadata(new PoolHTableProvider(hbaseTable, pool));
    metadata.setColumnFamily(columnFamily);
    HBaseStore store = new HBaseStore(metadata, null, new MetadataCache(metadata));
    tableId = store.getTableId(sqlTable);
    schema = store.getSchema(sqlTable);
    mutationFactory = new MutationFactory(store);
    mutationFactory.setColumnFamily(columnFamily);
    rowParser = new RowParser(schema, columns, separator);
    checkSqlColumnsMatch(sqlTable);
}
Also used : HTablePool(org.apache.hadoop.hbase.client.HTablePool) Configuration(org.apache.hadoop.conf.Configuration) HBaseStore(com.nearinfinity.honeycomb.hbase.HBaseStore) HBaseMetadata(com.nearinfinity.honeycomb.hbase.HBaseMetadata) MetadataCache(com.nearinfinity.honeycomb.hbase.MetadataCache) MutationFactory(com.nearinfinity.honeycomb.hbase.MutationFactory)

Aggregations

HBaseMetadata (com.nearinfinity.honeycomb.hbase.HBaseMetadata)1 HBaseStore (com.nearinfinity.honeycomb.hbase.HBaseStore)1 MetadataCache (com.nearinfinity.honeycomb.hbase.MetadataCache)1 MutationFactory (com.nearinfinity.honeycomb.hbase.MutationFactory)1 Configuration (org.apache.hadoop.conf.Configuration)1 HTablePool (org.apache.hadoop.hbase.client.HTablePool)1