开发者

Problem with extending HBase Put

开发者 https://www.devze.com 2023-02-18 18:05 出处:网络
I have a problem while trying to extend HBase Put class. I have a code like this public class HBasePut extends Put {

I have a problem while trying to extend HBase Put class.

I have a code like this

public class HBasePut extends Put {  
    //here i define my own adds because i have only string "keys"  
    //so i dont have to use Bytes.toBytes() every time and so on 
}

But when testing these classes this code is OK:

Put p = new Put(Bytes.toBytes('row'));  
p.add(Bytes.toBytes('cf'), Bytes.toBytes('col'), Bytes.toBytes(1));
users.put(p);

But this one makes an exception after about 70 seconds of trying - RetriesExhaustedWithDetailsException

HBasePut p = new HBasePut('row');  
p.add('cf', 'col', 1);
users.put(p);

So I tried to iterate over exceptions in RetriesExh... It tells me there is one exception but it is null...

I was looking at the code of Put, HTable and HConnection but I couldn't find any dependencies on writing exactly the class Put in HBase so I don't know why my HBasePut is not working.

Is it possible to extend Put s开发者_StackOverflowomehow? Thank you


If you look into your regionserver logs you will see an exception like "Can't find class ... HBasePut". So, HBase obviously transports a Put instance from client to server, but the server is unaware of your subclass and cannot process it.

I suggest refraining from subclassing and instead suggest to code a custom Util class which provides a static "add" method taking the Put instance and Strings as args and importing this method with a static import.


As zillion1 said, just use a static method:

public static void add(Put put, String col, String qual, String data)
{
  put.add(col.getBytes(), qual.getBytes(), data.getBytes());
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号