You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hbase.apache.org by Vineet Mishra <cl...@gmail.com> on 2013/12/02 14:48:17 UTC

Hbase Region Size

Hi

Can Anyone tell me the Java API for getting the Region Size of a table!

Thanks!

Re: Hbase Region Size

Posted by Asaf Mesika <as...@gmail.com>.
In this method, you can get the region's Load per region:

    private Map<String, RegionLoad> getRegionsLoad() {
        try {
            Map<String, RegionLoad> regionsNameToLoad = new HashMap<String,
RegionLoad>();
            ClusterStatus clusterStatus = hAdmin.getClusterStatus();
            for (ServerName serverName : clusterStatus.getServers()) {
                HServerLoad load = clusterStatus.getLoad(serverName);
                Map<byte[], RegionLoad> regionsLoad = load.getRegionsLoad();
                for (Map.Entry<byte[], RegionLoad> entry :
regionsLoad.entrySet()) {
                    RegionLoad regionLoad = entry.getValue();
                    regionsNameToLoad.put(regionLoad.getNameAsString(),
regionLoad);
                }
            }
            return regionsNameToLoad;
        } catch (IOException e1) {
            throw new RuntimeException("Failed while fetching cluster load:
"+e1.getMessage(), e1);
        }
    }

Then you get use it by:

regionLoad.getStorefileSizeMB()

and there are other methds on RegionLoad.

Check it out.


Asaf


On Mon, Dec 2, 2013 at 3:48 PM, Vineet Mishra <cl...@gmail.com>wrote:

> Hi
>
> Can Anyone tell me the Java API for getting the Region Size of a table!
>
> Thanks!
>

Re: Hbase Region Size

Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Hi Vineet,

So to get the size you can get the list of stores for the region and call
getStoreSizeUncompressed on each store. I'm not 100% sure this method is
accessible from outside the class. If it's not accessible, might be good to
have an easy way to get this information.

you can take a look at ConstantSizeRegionSplitPolicy,java and Store.java to
see how it's done.

I will take a deeper look when I will get off the plane ;)

JM


2013/12/2 Jean-Marc Spaggiari <je...@spaggiari.org>

> Hum. I need to check but I'm not sure if HBase is doing the MAX_FILESIZE
> check against the compressed size of the region or against the uncompressed
> size. I will guess it's against the compress size. But I will doublecheck
> into the code to confirm.
>
> Are you looking for the compressed size? Or the "regular" size?
>
>
> 2013/12/2 Vineet Mishra <cl...@gmail.com>
>
>> Actually I am looking for the Size of the Region, and not for the whole
>> table. Although the Hbase internally do the Max file size check to split
>> the Region in a autonomous manner, hence there should be some way to get
>> it.
>>
>>
>> On Mon, Dec 2, 2013 at 7:51 PM, Jean-Marc Spaggiari <
>> jean-marc@spaggiari.org
>> > wrote:
>>
>> > Same for a single region. If it's compressed, you might want to look
>> into
>> > HDFS directly...
>> >
>> >
>> > 2013/12/2 Mike Axiak <mi...@axiak.net>
>> >
>> > > Are you looking to get the MAX_FILESIZE paramter? If so, there's
>> nothing
>> > in
>> > > the client, but HBaseAdmin has what you need [1].
>> > >
>> > >    HTableDescriptor myDescriptor =
>> > > hbaseAdmin.getDescriptor(Bytes.toBytes("my-table"));
>> > >    System.out.println("my-table has a max region size of " +
>> > > myDescriptor.getMaxFileSize());
>> > >
>> > >
>> > > 1:
>> > >
>> > >
>> >
>> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HBaseAdmin.html
>> > >
>> > >
>> > > On Mon, Dec 2, 2013 at 9:05 AM, Jean-Marc Spaggiari <
>> > > jean-marc@spaggiari.org
>> > > > wrote:
>> > >
>> > > > Hi Vineet,
>> > > >
>> > > > If you want the entire table size I don't think there is any API for
>> > > that.
>> > > > If you want the size of the table on the disk (compressed) they you
>> are
>> > > > better to use HDFS API.
>> > > >
>> > > > JM
>> > > >
>> > > >
>> > > > 2013/12/2 Vineet Mishra <cl...@gmail.com>
>> > > >
>> > > > > Hi
>> > > > >
>> > > > > Can Anyone tell me the Java API for getting the Region Size of a
>> > table!
>> > > > >
>> > > > > Thanks!
>> > > > >
>> > > >
>> > >
>> >
>>
>
>

Re: Hbase Region Size

Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Hum. I need to check but I'm not sure if HBase is doing the MAX_FILESIZE
check against the compressed size of the region or against the uncompressed
size. I will guess it's against the compress size. But I will doublecheck
into the code to confirm.

Are you looking for the compressed size? Or the "regular" size?


2013/12/2 Vineet Mishra <cl...@gmail.com>

> Actually I am looking for the Size of the Region, and not for the whole
> table. Although the Hbase internally do the Max file size check to split
> the Region in a autonomous manner, hence there should be some way to get
> it.
>
>
> On Mon, Dec 2, 2013 at 7:51 PM, Jean-Marc Spaggiari <
> jean-marc@spaggiari.org
> > wrote:
>
> > Same for a single region. If it's compressed, you might want to look into
> > HDFS directly...
> >
> >
> > 2013/12/2 Mike Axiak <mi...@axiak.net>
> >
> > > Are you looking to get the MAX_FILESIZE paramter? If so, there's
> nothing
> > in
> > > the client, but HBaseAdmin has what you need [1].
> > >
> > >    HTableDescriptor myDescriptor =
> > > hbaseAdmin.getDescriptor(Bytes.toBytes("my-table"));
> > >    System.out.println("my-table has a max region size of " +
> > > myDescriptor.getMaxFileSize());
> > >
> > >
> > > 1:
> > >
> > >
> >
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HBaseAdmin.html
> > >
> > >
> > > On Mon, Dec 2, 2013 at 9:05 AM, Jean-Marc Spaggiari <
> > > jean-marc@spaggiari.org
> > > > wrote:
> > >
> > > > Hi Vineet,
> > > >
> > > > If you want the entire table size I don't think there is any API for
> > > that.
> > > > If you want the size of the table on the disk (compressed) they you
> are
> > > > better to use HDFS API.
> > > >
> > > > JM
> > > >
> > > >
> > > > 2013/12/2 Vineet Mishra <cl...@gmail.com>
> > > >
> > > > > Hi
> > > > >
> > > > > Can Anyone tell me the Java API for getting the Region Size of a
> > table!
> > > > >
> > > > > Thanks!
> > > > >
> > > >
> > >
> >
>

Re: Hbase Region Size

Posted by Vineet Mishra <cl...@gmail.com>.
Actually I am looking for the Size of the Region, and not for the whole
table. Although the Hbase internally do the Max file size check to split
the Region in a autonomous manner, hence there should be some way to get it.


On Mon, Dec 2, 2013 at 7:51 PM, Jean-Marc Spaggiari <jean-marc@spaggiari.org
> wrote:

> Same for a single region. If it's compressed, you might want to look into
> HDFS directly...
>
>
> 2013/12/2 Mike Axiak <mi...@axiak.net>
>
> > Are you looking to get the MAX_FILESIZE paramter? If so, there's nothing
> in
> > the client, but HBaseAdmin has what you need [1].
> >
> >    HTableDescriptor myDescriptor =
> > hbaseAdmin.getDescriptor(Bytes.toBytes("my-table"));
> >    System.out.println("my-table has a max region size of " +
> > myDescriptor.getMaxFileSize());
> >
> >
> > 1:
> >
> >
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HBaseAdmin.html
> >
> >
> > On Mon, Dec 2, 2013 at 9:05 AM, Jean-Marc Spaggiari <
> > jean-marc@spaggiari.org
> > > wrote:
> >
> > > Hi Vineet,
> > >
> > > If you want the entire table size I don't think there is any API for
> > that.
> > > If you want the size of the table on the disk (compressed) they you are
> > > better to use HDFS API.
> > >
> > > JM
> > >
> > >
> > > 2013/12/2 Vineet Mishra <cl...@gmail.com>
> > >
> > > > Hi
> > > >
> > > > Can Anyone tell me the Java API for getting the Region Size of a
> table!
> > > >
> > > > Thanks!
> > > >
> > >
> >
>

Re: Hbase Region Size

Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Same for a single region. If it's compressed, you might want to look into
HDFS directly...


2013/12/2 Mike Axiak <mi...@axiak.net>

> Are you looking to get the MAX_FILESIZE paramter? If so, there's nothing in
> the client, but HBaseAdmin has what you need [1].
>
>    HTableDescriptor myDescriptor =
> hbaseAdmin.getDescriptor(Bytes.toBytes("my-table"));
>    System.out.println("my-table has a max region size of " +
> myDescriptor.getMaxFileSize());
>
>
> 1:
>
> http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HBaseAdmin.html
>
>
> On Mon, Dec 2, 2013 at 9:05 AM, Jean-Marc Spaggiari <
> jean-marc@spaggiari.org
> > wrote:
>
> > Hi Vineet,
> >
> > If you want the entire table size I don't think there is any API for
> that.
> > If you want the size of the table on the disk (compressed) they you are
> > better to use HDFS API.
> >
> > JM
> >
> >
> > 2013/12/2 Vineet Mishra <cl...@gmail.com>
> >
> > > Hi
> > >
> > > Can Anyone tell me the Java API for getting the Region Size of a table!
> > >
> > > Thanks!
> > >
> >
>

Re: Hbase Region Size

Posted by Mike Axiak <mi...@axiak.net>.
Are you looking to get the MAX_FILESIZE paramter? If so, there's nothing in
the client, but HBaseAdmin has what you need [1].

   HTableDescriptor myDescriptor =
hbaseAdmin.getDescriptor(Bytes.toBytes("my-table"));
   System.out.println("my-table has a max region size of " +
myDescriptor.getMaxFileSize());


1:
http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/HBaseAdmin.html


On Mon, Dec 2, 2013 at 9:05 AM, Jean-Marc Spaggiari <jean-marc@spaggiari.org
> wrote:

> Hi Vineet,
>
> If you want the entire table size I don't think there is any API for that.
> If you want the size of the table on the disk (compressed) they you are
> better to use HDFS API.
>
> JM
>
>
> 2013/12/2 Vineet Mishra <cl...@gmail.com>
>
> > Hi
> >
> > Can Anyone tell me the Java API for getting the Region Size of a table!
> >
> > Thanks!
> >
>

Re: Hbase Region Size

Posted by Jean-Marc Spaggiari <je...@spaggiari.org>.
Hi Vineet,

If you want the entire table size I don't think there is any API for that.
If you want the size of the table on the disk (compressed) they you are
better to use HDFS API.

JM


2013/12/2 Vineet Mishra <cl...@gmail.com>

> Hi
>
> Can Anyone tell me the Java API for getting the Region Size of a table!
>
> Thanks!
>