You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Kyle Lin <ky...@gmail.com> on 2013/01/23 09:18:27 UTC
How to get coprocessor list by client API
Hi, Everyone
I need to know What coprocessors registered in a HTable. But, in Class
HTableDescriptor, I can only find
*addCoprocessor<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)>
*, *hasCoprocessor<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)>
* ..etc. How can I use Client API to get the coprocessor information just
like Typing "describe table_name" in HBase Shell as follows?
hbase(main):002:0> describe 'table21'
DESCRIPTION
ENABLED
{NAME => 'table21', *coprocessor$1 =>
'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
*
* .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf', DATA_BLOCK_ENCODING =>
'NONE', BLOOMFILTER
=> 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
'NONE', MIN_VERSIONS =>
'0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE =>
'65536', IN_MEMORY =>
'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0210 seconds
Kyle
Re: How to get coprocessor list by client API
Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Hi Kyle,
I this it's possible. I have already done that between 0.94.1 and 0.94.3.
JM
2013/1/29, Kyle Lin <ky...@gmail.com>:
> Hello JM
>
> If I import 0.94.4 jar file on Client side for calling getCoprocessors
> to get list from server of old version(0.94.0), Is it possible?
>
> Kyle
>
> 2013/1/28 Jean-Marc Spaggiari <je...@spaggiari.org>
>
>> Hi Kyle,
>>
>> If you are not running a production cluster, you might think about
>> getting the last 0.94.4 source code, apply HBASE-7654 and deploy it.
>> That way you can use getCoprocessors which will send you the list you
>> the list you are looking for...
>>
>> JM
>>
>> 2013/1/28, Kyle Lin <ky...@gmail.com>:
>> > Hi JM
>> >
>> > I saw the source code of hasCoprocessor, and notice this CONTANT.
>> > Thanks for your hint.
>> >
>> > Kyle
>> >
>> > 2013/1/24 Jean-Marc Spaggiari <je...@spaggiari.org>
>> >
>> >> Hi Kyle,
>> >>
>> >> This will give you all the attributs of the table, not just the
>> >> coprocessors, so don't forget to parse they key using
>> >> CP_HTD_ATTR_KEY_PATTERN ...
>> >>
>> >> I will add in my ToDo to add a List<> getCoprocessors() method in
>> >> HTableInterface or HTableDescriptor...
>> >>
>> >> JM
>> >>
>> >> 2013/1/23, Kyle Lin <ky...@gmail.com>:
>> >> > Hello JM
>> >> >
>> >> > It really works! Thanks a lot.
>> >> >
>> >> > Hello Jack
>> >> >
>> >> > For each table, it needs to use htable.getTableDescriptor().
>> >> >
>> >> > hbaseAdmin.getTableDescriptor only gets -ROOT- and .META.
>> >> >
>> >> > So I use the code as follows,
>> >> >
>> >> > HTable htable = new HTable(config, tableName);
>> >> > HTableDescriptor htableDesc = *htable.getTableDescriptor()*;
>> >> > Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
>> >> > htableDesc.getValues();
>> >> > Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets =
>> >> > maps.entrySet();
>> >> > for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable>
>> entrySet
>> >> > :
>> >> > sets) {
>> >> > String stringKey = Bytes.toString(entrySet.getKey().get());
>> >> > String stringValue = Bytes.toString(entrySet.getValue().get());
>> >> > System.out.println("key:" + stringKey + ", value:" + stringValue);
>> >> > }
>> >> > htable.close();
>> >> >
>> >> > Kyle
>> >> >
>> >> > 2013/1/24 jack <ky...@yahoo.com.tw>
>> >> >
>> >> >> Hi, Kyle
>> >> >>
>> >> >> Configuration config = HBaseConfiguration.create();
>> >> >> config.set("hbase.zookeeper.quorum", "host3");
>> >> >> config.set("hbase.zookeeper.property.clientPort", "2181");
>> >> >>
>> >> >> config.set("fs.default.name", "hdfs://host3:9000");
>> >> >> config.set("mapred.job.tracker", "hdfs://host3:9001");
>> >> >>
>> >> >> HBaseAdmin hbaseAdmin = new HBaseAdmin(config);
>> >> >>
>> >> >> HTableDescriptor htableDescriptor =
>> >> >> hbaseAdmin.getTableDescriptor(Bytes.toBytes("table21"));
>> >> >>
>> >> >> Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
>> >> >> htableDescriptor.getValues();
>> >> >> Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>>
>> >> >> sets
>> >> =
>> >> >> maps.entrySet();
>> >> >> Iterator<Entry<ImmutableBytesWritable,
>> >> >> ImmutableBytesWritable>>
>> >> >> it
>> >> >> = sets.iterator();
>> >> >> while(it.hasNext()){
>> >> >> Entry<ImmutableBytesWritable,
>> >> >> ImmutableBytesWritable>
>> >> >> keys = it.next();
>> >> >> ImmutableBytesWritable ibwKey = keys.getKey();
>> >> >> ImmutableBytesWritable ibwValue = keys.getValue();
>> >> >> String stringKey = Bytes.toString(ibwKey.get());
>> >> >> String stringValue =
>> >> >> Bytes.toString(ibwValue.get());
>> >> >> System.out.println(stringKey + " " +
>> >> >> stringValue);
>> >> >> }
>> >> >> hbaseAdmin.close();
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> ________________________________
>> >> >> 寄件者: Kyle Lin <ky...@gmail.com>
>> >> >> 收件者: user@hbase.apache.org
>> >> >> 寄件日期: 2013/1/23 (週三) 4:18 PM
>> >> >> 主旨: How to get coprocessor list by client API
>> >> >>
>> >> >> Hi, Everyone
>> >> >>
>> >> >> I need to know What coprocessors registered in a HTable. But,
>> >> >> in
>> >> >> Class
>> >> >> HTableDescriptor, I can only find
>> >> >> *addCoprocessor<
>> >> >>
>> >>
>> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)
>> >> >> >
>> >> >> *, *hasCoprocessor<
>> >> >>
>> >>
>> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)
>> >> >> >
>> >> >> * ..etc. How can I use Client API to get the coprocessor
>> >> >> information
>> >> just
>> >> >> like Typing "describe table_name" in HBase Shell as follows?
>> >> >>
>> >> >>
>> >> >> hbase(main):002:0> describe 'table21'
>> >> >> DESCRIPTION
>> >> >> ENABLED
>> >> >> {NAME => 'table21', *coprocessor$1 =>
>> >> >> 'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
>> >> >> *
>> >> >> * .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf',
>> >> >> DATA_BLOCK_ENCODING
>> >> >> =>
>> >> >> 'NONE', BLOOMFILTER
>> >> >> => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION
>> >> >> =>
>> >> >> 'NONE', MIN_VERSIONS =>
>> >> >> '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false',
>> >> >> BLOCKSIZE
>> >> >> =>
>> >> >> '65536', IN_MEMORY =>
>> >> >> 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
>> >> >>
>> >> >> 1 row(s) in 0.0210 seconds
>> >> >>
>> >> >> Kyle
>> >> >>
>> >> >
>> >>
>> >
>>
>
Re: How to get coprocessor list by client API
Posted by Kyle Lin <ky...@gmail.com>.
Hello JM
If I import 0.94.4 jar file on Client side for calling getCoprocessors
to get list from server of old version(0.94.0), Is it possible?
Kyle
2013/1/28 Jean-Marc Spaggiari <je...@spaggiari.org>
> Hi Kyle,
>
> If you are not running a production cluster, you might think about
> getting the last 0.94.4 source code, apply HBASE-7654 and deploy it.
> That way you can use getCoprocessors which will send you the list you
> the list you are looking for...
>
> JM
>
> 2013/1/28, Kyle Lin <ky...@gmail.com>:
> > Hi JM
> >
> > I saw the source code of hasCoprocessor, and notice this CONTANT.
> > Thanks for your hint.
> >
> > Kyle
> >
> > 2013/1/24 Jean-Marc Spaggiari <je...@spaggiari.org>
> >
> >> Hi Kyle,
> >>
> >> This will give you all the attributs of the table, not just the
> >> coprocessors, so don't forget to parse they key using
> >> CP_HTD_ATTR_KEY_PATTERN ...
> >>
> >> I will add in my ToDo to add a List<> getCoprocessors() method in
> >> HTableInterface or HTableDescriptor...
> >>
> >> JM
> >>
> >> 2013/1/23, Kyle Lin <ky...@gmail.com>:
> >> > Hello JM
> >> >
> >> > It really works! Thanks a lot.
> >> >
> >> > Hello Jack
> >> >
> >> > For each table, it needs to use htable.getTableDescriptor().
> >> >
> >> > hbaseAdmin.getTableDescriptor only gets -ROOT- and .META.
> >> >
> >> > So I use the code as follows,
> >> >
> >> > HTable htable = new HTable(config, tableName);
> >> > HTableDescriptor htableDesc = *htable.getTableDescriptor()*;
> >> > Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
> >> > htableDesc.getValues();
> >> > Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets =
> >> > maps.entrySet();
> >> > for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable>
> entrySet
> >> > :
> >> > sets) {
> >> > String stringKey = Bytes.toString(entrySet.getKey().get());
> >> > String stringValue = Bytes.toString(entrySet.getValue().get());
> >> > System.out.println("key:" + stringKey + ", value:" + stringValue);
> >> > }
> >> > htable.close();
> >> >
> >> > Kyle
> >> >
> >> > 2013/1/24 jack <ky...@yahoo.com.tw>
> >> >
> >> >> Hi, Kyle
> >> >>
> >> >> Configuration config = HBaseConfiguration.create();
> >> >> config.set("hbase.zookeeper.quorum", "host3");
> >> >> config.set("hbase.zookeeper.property.clientPort", "2181");
> >> >>
> >> >> config.set("fs.default.name", "hdfs://host3:9000");
> >> >> config.set("mapred.job.tracker", "hdfs://host3:9001");
> >> >>
> >> >> HBaseAdmin hbaseAdmin = new HBaseAdmin(config);
> >> >>
> >> >> HTableDescriptor htableDescriptor =
> >> >> hbaseAdmin.getTableDescriptor(Bytes.toBytes("table21"));
> >> >>
> >> >> Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
> >> >> htableDescriptor.getValues();
> >> >> Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>>
> >> >> sets
> >> =
> >> >> maps.entrySet();
> >> >> Iterator<Entry<ImmutableBytesWritable,
> >> >> ImmutableBytesWritable>>
> >> >> it
> >> >> = sets.iterator();
> >> >> while(it.hasNext()){
> >> >> Entry<ImmutableBytesWritable, ImmutableBytesWritable>
> >> >> keys = it.next();
> >> >> ImmutableBytesWritable ibwKey = keys.getKey();
> >> >> ImmutableBytesWritable ibwValue = keys.getValue();
> >> >> String stringKey = Bytes.toString(ibwKey.get());
> >> >> String stringValue = Bytes.toString(ibwValue.get());
> >> >> System.out.println(stringKey + " " + stringValue);
> >> >> }
> >> >> hbaseAdmin.close();
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> ________________________________
> >> >> 寄件者: Kyle Lin <ky...@gmail.com>
> >> >> 收件者: user@hbase.apache.org
> >> >> 寄件日期: 2013/1/23 (週三) 4:18 PM
> >> >> 主旨: How to get coprocessor list by client API
> >> >>
> >> >> Hi, Everyone
> >> >>
> >> >> I need to know What coprocessors registered in a HTable. But, in
> >> >> Class
> >> >> HTableDescriptor, I can only find
> >> >> *addCoprocessor<
> >> >>
> >>
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)
> >> >> >
> >> >> *, *hasCoprocessor<
> >> >>
> >>
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)
> >> >> >
> >> >> * ..etc. How can I use Client API to get the coprocessor information
> >> just
> >> >> like Typing "describe table_name" in HBase Shell as follows?
> >> >>
> >> >>
> >> >> hbase(main):002:0> describe 'table21'
> >> >> DESCRIPTION
> >> >> ENABLED
> >> >> {NAME => 'table21', *coprocessor$1 =>
> >> >> 'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
> >> >> *
> >> >> * .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf',
> >> >> DATA_BLOCK_ENCODING
> >> >> =>
> >> >> 'NONE', BLOOMFILTER
> >> >> => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
> >> >> 'NONE', MIN_VERSIONS =>
> >> >> '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE
> >> >> =>
> >> >> '65536', IN_MEMORY =>
> >> >> 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
> >> >>
> >> >> 1 row(s) in 0.0210 seconds
> >> >>
> >> >> Kyle
> >> >>
> >> >
> >>
> >
>
Re: How to get coprocessor list by client API
Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Hi Kyle,
If you are not running a production cluster, you might think about
getting the last 0.94.4 source code, apply HBASE-7654 and deploy it.
That way you can use getCoprocessors which will send you the list you
the list you are looking for...
JM
2013/1/28, Kyle Lin <ky...@gmail.com>:
> Hi JM
>
> I saw the source code of hasCoprocessor, and notice this CONTANT.
> Thanks for your hint.
>
> Kyle
>
> 2013/1/24 Jean-Marc Spaggiari <je...@spaggiari.org>
>
>> Hi Kyle,
>>
>> This will give you all the attributs of the table, not just the
>> coprocessors, so don't forget to parse they key using
>> CP_HTD_ATTR_KEY_PATTERN ...
>>
>> I will add in my ToDo to add a List<> getCoprocessors() method in
>> HTableInterface or HTableDescriptor...
>>
>> JM
>>
>> 2013/1/23, Kyle Lin <ky...@gmail.com>:
>> > Hello JM
>> >
>> > It really works! Thanks a lot.
>> >
>> > Hello Jack
>> >
>> > For each table, it needs to use htable.getTableDescriptor().
>> >
>> > hbaseAdmin.getTableDescriptor only gets -ROOT- and .META.
>> >
>> > So I use the code as follows,
>> >
>> > HTable htable = new HTable(config, tableName);
>> > HTableDescriptor htableDesc = *htable.getTableDescriptor()*;
>> > Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
>> > htableDesc.getValues();
>> > Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets =
>> > maps.entrySet();
>> > for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> entrySet
>> > :
>> > sets) {
>> > String stringKey = Bytes.toString(entrySet.getKey().get());
>> > String stringValue = Bytes.toString(entrySet.getValue().get());
>> > System.out.println("key:" + stringKey + ", value:" + stringValue);
>> > }
>> > htable.close();
>> >
>> > Kyle
>> >
>> > 2013/1/24 jack <ky...@yahoo.com.tw>
>> >
>> >> Hi, Kyle
>> >>
>> >> Configuration config = HBaseConfiguration.create();
>> >> config.set("hbase.zookeeper.quorum", "host3");
>> >> config.set("hbase.zookeeper.property.clientPort", "2181");
>> >>
>> >> config.set("fs.default.name", "hdfs://host3:9000");
>> >> config.set("mapred.job.tracker", "hdfs://host3:9001");
>> >>
>> >> HBaseAdmin hbaseAdmin = new HBaseAdmin(config);
>> >>
>> >> HTableDescriptor htableDescriptor =
>> >> hbaseAdmin.getTableDescriptor(Bytes.toBytes("table21"));
>> >>
>> >> Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
>> >> htableDescriptor.getValues();
>> >> Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>>
>> >> sets
>> =
>> >> maps.entrySet();
>> >> Iterator<Entry<ImmutableBytesWritable,
>> >> ImmutableBytesWritable>>
>> >> it
>> >> = sets.iterator();
>> >> while(it.hasNext()){
>> >> Entry<ImmutableBytesWritable, ImmutableBytesWritable>
>> >> keys = it.next();
>> >> ImmutableBytesWritable ibwKey = keys.getKey();
>> >> ImmutableBytesWritable ibwValue = keys.getValue();
>> >> String stringKey = Bytes.toString(ibwKey.get());
>> >> String stringValue = Bytes.toString(ibwValue.get());
>> >> System.out.println(stringKey + " " + stringValue);
>> >> }
>> >> hbaseAdmin.close();
>> >>
>> >>
>> >>
>> >>
>> >> ________________________________
>> >> 寄件者: Kyle Lin <ky...@gmail.com>
>> >> 收件者: user@hbase.apache.org
>> >> 寄件日期: 2013/1/23 (週三) 4:18 PM
>> >> 主旨: How to get coprocessor list by client API
>> >>
>> >> Hi, Everyone
>> >>
>> >> I need to know What coprocessors registered in a HTable. But, in
>> >> Class
>> >> HTableDescriptor, I can only find
>> >> *addCoprocessor<
>> >>
>> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)
>> >> >
>> >> *, *hasCoprocessor<
>> >>
>> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)
>> >> >
>> >> * ..etc. How can I use Client API to get the coprocessor information
>> just
>> >> like Typing "describe table_name" in HBase Shell as follows?
>> >>
>> >>
>> >> hbase(main):002:0> describe 'table21'
>> >> DESCRIPTION
>> >> ENABLED
>> >> {NAME => 'table21', *coprocessor$1 =>
>> >> 'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
>> >> *
>> >> * .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf',
>> >> DATA_BLOCK_ENCODING
>> >> =>
>> >> 'NONE', BLOOMFILTER
>> >> => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
>> >> 'NONE', MIN_VERSIONS =>
>> >> '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE
>> >> =>
>> >> '65536', IN_MEMORY =>
>> >> 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
>> >>
>> >> 1 row(s) in 0.0210 seconds
>> >>
>> >> Kyle
>> >>
>> >
>>
>
Re: How to get coprocessor list by client API
Posted by Kyle Lin <ky...@gmail.com>.
Hi JM
I saw the source code of hasCoprocessor, and notice this CONTANT.
Thanks for your hint.
Kyle
2013/1/24 Jean-Marc Spaggiari <je...@spaggiari.org>
> Hi Kyle,
>
> This will give you all the attributs of the table, not just the
> coprocessors, so don't forget to parse they key using
> CP_HTD_ATTR_KEY_PATTERN ...
>
> I will add in my ToDo to add a List<> getCoprocessors() method in
> HTableInterface or HTableDescriptor...
>
> JM
>
> 2013/1/23, Kyle Lin <ky...@gmail.com>:
> > Hello JM
> >
> > It really works! Thanks a lot.
> >
> > Hello Jack
> >
> > For each table, it needs to use htable.getTableDescriptor().
> >
> > hbaseAdmin.getTableDescriptor only gets -ROOT- and .META.
> >
> > So I use the code as follows,
> >
> > HTable htable = new HTable(config, tableName);
> > HTableDescriptor htableDesc = *htable.getTableDescriptor()*;
> > Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
> > htableDesc.getValues();
> > Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets =
> > maps.entrySet();
> > for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> entrySet :
> > sets) {
> > String stringKey = Bytes.toString(entrySet.getKey().get());
> > String stringValue = Bytes.toString(entrySet.getValue().get());
> > System.out.println("key:" + stringKey + ", value:" + stringValue);
> > }
> > htable.close();
> >
> > Kyle
> >
> > 2013/1/24 jack <ky...@yahoo.com.tw>
> >
> >> Hi, Kyle
> >>
> >> Configuration config = HBaseConfiguration.create();
> >> config.set("hbase.zookeeper.quorum", "host3");
> >> config.set("hbase.zookeeper.property.clientPort", "2181");
> >>
> >> config.set("fs.default.name", "hdfs://host3:9000");
> >> config.set("mapred.job.tracker", "hdfs://host3:9001");
> >>
> >> HBaseAdmin hbaseAdmin = new HBaseAdmin(config);
> >>
> >> HTableDescriptor htableDescriptor =
> >> hbaseAdmin.getTableDescriptor(Bytes.toBytes("table21"));
> >>
> >> Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
> >> htableDescriptor.getValues();
> >> Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets
> =
> >> maps.entrySet();
> >> Iterator<Entry<ImmutableBytesWritable, ImmutableBytesWritable>>
> >> it
> >> = sets.iterator();
> >> while(it.hasNext()){
> >> Entry<ImmutableBytesWritable, ImmutableBytesWritable>
> >> keys = it.next();
> >> ImmutableBytesWritable ibwKey = keys.getKey();
> >> ImmutableBytesWritable ibwValue = keys.getValue();
> >> String stringKey = Bytes.toString(ibwKey.get());
> >> String stringValue = Bytes.toString(ibwValue.get());
> >> System.out.println(stringKey + " " + stringValue);
> >> }
> >> hbaseAdmin.close();
> >>
> >>
> >>
> >>
> >> ________________________________
> >> 寄件者: Kyle Lin <ky...@gmail.com>
> >> 收件者: user@hbase.apache.org
> >> 寄件日期: 2013/1/23 (週三) 4:18 PM
> >> 主旨: How to get coprocessor list by client API
> >>
> >> Hi, Everyone
> >>
> >> I need to know What coprocessors registered in a HTable. But, in
> >> Class
> >> HTableDescriptor, I can only find
> >> *addCoprocessor<
> >>
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)
> >> >
> >> *, *hasCoprocessor<
> >>
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)
> >> >
> >> * ..etc. How can I use Client API to get the coprocessor information
> just
> >> like Typing "describe table_name" in HBase Shell as follows?
> >>
> >>
> >> hbase(main):002:0> describe 'table21'
> >> DESCRIPTION
> >> ENABLED
> >> {NAME => 'table21', *coprocessor$1 =>
> >> 'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
> >> *
> >> * .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf', DATA_BLOCK_ENCODING
> >> =>
> >> 'NONE', BLOOMFILTER
> >> => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
> >> 'NONE', MIN_VERSIONS =>
> >> '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE =>
> >> '65536', IN_MEMORY =>
> >> 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
> >>
> >> 1 row(s) in 0.0210 seconds
> >>
> >> Kyle
> >>
> >
>
Re: How to get coprocessor list by client API
Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Hi Kyle,
This will give you all the attributs of the table, not just the
coprocessors, so don't forget to parse they key using
CP_HTD_ATTR_KEY_PATTERN ...
I will add in my ToDo to add a List<> getCoprocessors() method in
HTableInterface or HTableDescriptor...
JM
2013/1/23, Kyle Lin <ky...@gmail.com>:
> Hello JM
>
> It really works! Thanks a lot.
>
> Hello Jack
>
> For each table, it needs to use htable.getTableDescriptor().
>
> hbaseAdmin.getTableDescriptor only gets -ROOT- and .META.
>
> So I use the code as follows,
>
> HTable htable = new HTable(config, tableName);
> HTableDescriptor htableDesc = *htable.getTableDescriptor()*;
> Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
> htableDesc.getValues();
> Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets =
> maps.entrySet();
> for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> entrySet :
> sets) {
> String stringKey = Bytes.toString(entrySet.getKey().get());
> String stringValue = Bytes.toString(entrySet.getValue().get());
> System.out.println("key:" + stringKey + ", value:" + stringValue);
> }
> htable.close();
>
> Kyle
>
> 2013/1/24 jack <ky...@yahoo.com.tw>
>
>> Hi, Kyle
>>
>> Configuration config = HBaseConfiguration.create();
>> config.set("hbase.zookeeper.quorum", "host3");
>> config.set("hbase.zookeeper.property.clientPort", "2181");
>>
>> config.set("fs.default.name", "hdfs://host3:9000");
>> config.set("mapred.job.tracker", "hdfs://host3:9001");
>>
>> HBaseAdmin hbaseAdmin = new HBaseAdmin(config);
>>
>> HTableDescriptor htableDescriptor =
>> hbaseAdmin.getTableDescriptor(Bytes.toBytes("table21"));
>>
>> Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
>> htableDescriptor.getValues();
>> Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets =
>> maps.entrySet();
>> Iterator<Entry<ImmutableBytesWritable, ImmutableBytesWritable>>
>> it
>> = sets.iterator();
>> while(it.hasNext()){
>> Entry<ImmutableBytesWritable, ImmutableBytesWritable>
>> keys = it.next();
>> ImmutableBytesWritable ibwKey = keys.getKey();
>> ImmutableBytesWritable ibwValue = keys.getValue();
>> String stringKey = Bytes.toString(ibwKey.get());
>> String stringValue = Bytes.toString(ibwValue.get());
>> System.out.println(stringKey + " " + stringValue);
>> }
>> hbaseAdmin.close();
>>
>>
>>
>>
>> ________________________________
>> 寄件者: Kyle Lin <ky...@gmail.com>
>> 收件者: user@hbase.apache.org
>> 寄件日期: 2013/1/23 (週三) 4:18 PM
>> 主旨: How to get coprocessor list by client API
>>
>> Hi, Everyone
>>
>> I need to know What coprocessors registered in a HTable. But, in
>> Class
>> HTableDescriptor, I can only find
>> *addCoprocessor<
>> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)
>> >
>> *, *hasCoprocessor<
>> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)
>> >
>> * ..etc. How can I use Client API to get the coprocessor information just
>> like Typing "describe table_name" in HBase Shell as follows?
>>
>>
>> hbase(main):002:0> describe 'table21'
>> DESCRIPTION
>> ENABLED
>> {NAME => 'table21', *coprocessor$1 =>
>> 'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
>> *
>> * .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf', DATA_BLOCK_ENCODING
>> =>
>> 'NONE', BLOOMFILTER
>> => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
>> 'NONE', MIN_VERSIONS =>
>> '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE =>
>> '65536', IN_MEMORY =>
>> 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
>>
>> 1 row(s) in 0.0210 seconds
>>
>> Kyle
>>
>
Re: How to get coprocessor list by client API
Posted by Kyle Lin <ky...@gmail.com>.
Hello JM
It really works! Thanks a lot.
Hello Jack
For each table, it needs to use htable.getTableDescriptor().
hbaseAdmin.getTableDescriptor only gets -ROOT- and .META.
So I use the code as follows,
HTable htable = new HTable(config, tableName);
HTableDescriptor htableDesc = *htable.getTableDescriptor()*;
Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
htableDesc.getValues();
Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets =
maps.entrySet();
for (Map.Entry<ImmutableBytesWritable, ImmutableBytesWritable> entrySet :
sets) {
String stringKey = Bytes.toString(entrySet.getKey().get());
String stringValue = Bytes.toString(entrySet.getValue().get());
System.out.println("key:" + stringKey + ", value:" + stringValue);
}
htable.close();
Kyle
2013/1/24 jack <ky...@yahoo.com.tw>
> Hi, Kyle
>
> Configuration config = HBaseConfiguration.create();
> config.set("hbase.zookeeper.quorum", "host3");
> config.set("hbase.zookeeper.property.clientPort", "2181");
>
> config.set("fs.default.name", "hdfs://host3:9000");
> config.set("mapred.job.tracker", "hdfs://host3:9001");
>
> HBaseAdmin hbaseAdmin = new HBaseAdmin(config);
>
> HTableDescriptor htableDescriptor =
> hbaseAdmin.getTableDescriptor(Bytes.toBytes("table21"));
>
> Map<ImmutableBytesWritable, ImmutableBytesWritable> maps =
> htableDescriptor.getValues();
> Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets =
> maps.entrySet();
> Iterator<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> it
> = sets.iterator();
> while(it.hasNext()){
> Entry<ImmutableBytesWritable, ImmutableBytesWritable>
> keys = it.next();
> ImmutableBytesWritable ibwKey = keys.getKey();
> ImmutableBytesWritable ibwValue = keys.getValue();
> String stringKey = Bytes.toString(ibwKey.get());
> String stringValue = Bytes.toString(ibwValue.get());
> System.out.println(stringKey + " " + stringValue);
> }
> hbaseAdmin.close();
>
>
>
>
> ________________________________
> 寄件者: Kyle Lin <ky...@gmail.com>
> 收件者: user@hbase.apache.org
> 寄件日期: 2013/1/23 (週三) 4:18 PM
> 主旨: How to get coprocessor list by client API
>
> Hi, Everyone
>
> I need to know What coprocessors registered in a HTable. But, in Class
> HTableDescriptor, I can only find
> *addCoprocessor<
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)
> >
> *, *hasCoprocessor<
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)
> >
> * ..etc. How can I use Client API to get the coprocessor information just
> like Typing "describe table_name" in HBase Shell as follows?
>
>
> hbase(main):002:0> describe 'table21'
> DESCRIPTION
> ENABLED
> {NAME => 'table21', *coprocessor$1 =>
> 'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
> *
> * .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf', DATA_BLOCK_ENCODING =>
> 'NONE', BLOOMFILTER
> => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
> 'NONE', MIN_VERSIONS =>
> '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE =>
> '65536', IN_MEMORY =>
> 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
>
> 1 row(s) in 0.0210 seconds
>
> Kyle
>
RE: How to get coprocessor list by client API
Posted by jack <ky...@yahoo.com.tw>.
Hi, Kyle
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "host3");
config.set("hbase.zookeeper.property.clientPort", "2181");
config.set("fs.default.name", "hdfs://host3:9000");
config.set("mapred.job.tracker", "hdfs://host3:9001");
HBaseAdmin hbaseAdmin = new HBaseAdmin(config);
HTableDescriptor htableDescriptor = hbaseAdmin.getTableDescriptor(Bytes.toBytes("table21"));
Map<ImmutableBytesWritable, ImmutableBytesWritable> maps = htableDescriptor.getValues();
Set<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> sets = maps.entrySet();
Iterator<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> it = sets.iterator();
while(it.hasNext()){
Entry<ImmutableBytesWritable, ImmutableBytesWritable> keys = it.next();
ImmutableBytesWritable ibwKey = keys.getKey();
ImmutableBytesWritable ibwValue = keys.getValue();
String stringKey = Bytes.toString(ibwKey.get());
String stringValue = Bytes.toString(ibwValue.get());
System.out.println(stringKey + " " + stringValue);
}
hbaseAdmin.close();
________________________________
寄件者: Kyle Lin <ky...@gmail.com>
收件者: user@hbase.apache.org
寄件日期: 2013/1/23 (週三) 4:18 PM
主旨: How to get coprocessor list by client API
Hi, Everyone
I need to know What coprocessors registered in a HTable. But, in Class
HTableDescriptor, I can only find
*addCoprocessor<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)>
*, *hasCoprocessor<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)>
* ..etc. How can I use Client API to get the coprocessor information just
like Typing "describe table_name" in HBase Shell as follows?
hbase(main):002:0> describe 'table21'
DESCRIPTION
ENABLED
{NAME => 'table21', *coprocessor$1 =>
'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
*
* .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf', DATA_BLOCK_ENCODING =>
'NONE', BLOOMFILTER
=> 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
'NONE', MIN_VERSIONS =>
'0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE =>
'65536', IN_MEMORY =>
'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
1 row(s) in 0.0210 seconds
Kyle
Re: How to get coprocessor list by client API
Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Hi Kyle,
You might want to take a look at HTable.getTableDescriptor().getValues().
In the HTableDescriptor class, you have hasCoprocessor(className).
This method is looping over the values and is comparing the entries
with the CP_HTD_ATTR_KEY_PATTERN constant to figure if it's a
coprocessor or not. Simply do something similar in your code and you
might be able to get the list of coprocessors.
Also, I think this method should already be there in the
HTableInterface... Can you please open a JIRA and request for it?
Thanks,
JM
2013/1/23, Kyle Lin <ky...@gmail.com>:
> Hi, Everyone
>
> I need to know What coprocessors registered in a HTable. But, in Class
> HTableDescriptor, I can only find
> *addCoprocessor<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#addCoprocessor(java.lang.String)>
> *,
> *hasCoprocessor<http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/HTableDescriptor.html#hasCoprocessor(java.lang.String)>
> * ..etc. How can I use Client API to get the coprocessor information just
> like Typing "describe table_name" in HBase Shell as follows?
>
>
> hbase(main):002:0> describe 'table21'
> DESCRIPTION
> ENABLED
> {NAME => 'table21', *coprocessor$1 =>
> 'hdfs://host3:9000/sumCoprocessor.jar|idv.jack.endpoint true
> *
> * .SumDataEndpoint||'*, FAMILIES => [{NAME => 'cf', DATA_BLOCK_ENCODING =>
> 'NONE', BLOOMFILTER
> => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION =>
> 'NONE', MIN_VERSIONS =>
> '0', TTL => '2147483647', KEEP_DELETED_CELLS => 'false', BLOCKSIZE =>
> '65536', IN_MEMORY =>
> 'false', ENCODE_ON_DISK => 'true', BLOCKCACHE => 'true'}]}
>
> 1 row(s) in 0.0210 seconds
>
> Kyle
>