public CConfiguration read ( Type type , String namespace ) throws IOException { String tableName = getTableName ( namespace ) ; CConfiguration conf = null ; HTable table = null ; try { table = new HTable ( hbaseConf , tableName ) ; Get get = new Get ( Bytes . toBytes ( type . name ( ) ) ) ; get . addFamily ( FAMILY ) ; Result result = table . get ( get ) ; int propertyCnt = 0 ; if ( result != null && ! result . isEmpty ( ) ) { conf = CConfiguration . create ( ) ; conf . clear ( ) ; Map < byte [ ] , byte [ ] > kvs = result . getFamilyMap ( FAMILY ) ; for ( Map . Entry < byte [ ] , byte [ ] > e : kvs . entrySet ( ) ) { conf . set ( Bytes . toString ( e . getKey ( ) ) , Bytes . toString ( e . getValue ( ) ) ) ; propertyCnt ++ ; } } LOG . info ( "Read " + propertyCnt + " properties from configuration table = " + tableName + ", row = " + type . name ( ) ) ; } catch ( TableNotFoundException e ) { // it's expected that this may occur when tables are created before Tigon has started LOG . warn ( "Configuration table " + tableName + " does not yet exist." ) ; } finally { if ( table != null ) { try { table . close ( ) ; } catch ( IOException ioe ) { LOG . error ( "Error closing HTable for " + tableName , ioe ) ; } } } return conf ; }
Reads the given configuration type from the HBase table looking for the HBase table name under the given namespace .