Search in sources :

Example 6 with KVSerializable

use of com.alibaba.jstorm.metric.KVSerializable in project jstorm by alibaba.

the class AbstractHBaseClient method getRow.

protected KVSerializable getRow(String tableName, Class clazz, byte[] key) {
    HTableInterface table = getHTableInterface(tableName);
    Get get = new Get(key);
    HTableInterface htable;
    try {
        htable = getHTableInterface(tableName);
        KVSerializable kvInst = (KVSerializable) clazz.getConstructors()[0].newInstance();
        Result result = htable.get(get);
        if (result != null) {
            kvInst.fromKV(key, result.getValue(CF, V_DATA));
            return kvInst;
        }
    } catch (Exception ex) {
        logger.error("Scan metric meta error, class:{}", clazz.getSimpleName(), ex);
    } finally {
        closeTable(table);
    }
    return null;
}
Also used : KVSerializable(com.alibaba.jstorm.metric.KVSerializable) Get(org.apache.hadoop.hbase.client.Get) HTableInterface(org.apache.hadoop.hbase.client.HTableInterface) IOException(java.io.IOException) Result(org.apache.hadoop.hbase.client.Result)

Aggregations

KVSerializable (com.alibaba.jstorm.metric.KVSerializable)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)3 TaskTrack (com.alibaba.jstorm.common.metric.TaskTrack)2 ResourceWorkerSlot (com.alibaba.jstorm.schedule.default_assign.ResourceWorkerSlot)2 Date (java.util.Date)2 HTableInterface (org.apache.hadoop.hbase.client.HTableInterface)2 MetricSnapshot (backtype.storm.generated.MetricSnapshot)1 MetricMeta (com.alibaba.jstorm.common.metric.MetricMeta)1 MetricType (com.alibaba.jstorm.metric.MetricType)1 Assignment (com.alibaba.jstorm.schedule.Assignment)1 Joiner (com.google.common.base.Joiner)1 IOException (java.io.IOException)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Get (org.apache.hadoop.hbase.client.Get)1 Put (org.apache.hadoop.hbase.client.Put)1 Result (org.apache.hadoop.hbase.client.Result)1