How HBase major compaction works

Compaction is the process in which HBase combines small files (HStoreFiles) into bigger ones.

Its of two types

Minor : When it take FEW number of files which are placed together and make them one.

Major : When it takes all the files in region and make them one.

This post covers the major compaction.

If you want to read about minor compaction , please read other post. How HBase minor compaction works . I suggest you to read that first.

The following properties effect major compaction

hbase.hregion.majorcompaction

The time (in miliseconds) between 'major' compactions of all HStoreFiles in a region. Default: 1 day. Set to 0 to disable automated major compactions.

    Default: 86400000

hbase.server.compactchecker.interval.multiplier This property affects decision to get the number that determines how often (time interval) we scan to see if compaction is necessary.

The interval between checks is hbase.server.compactchecker.interval.multiplier multiplied by hbase.server.thread.wakefrequency.
hbase.server.thread.wakefrequency

Time to sleep in between searches for work (in milliseconds). Used as sleep interval by service threads such as log roller.

Default: 10000

 

Quoting from ( Discussion specific stuff i have removed )

http://apache-hbase.679495.n3.nabble.com/Major-Compaction-Concerns-tp3642142p3645444.html

Major compactions are triggered by 3 methods: user issued, timed, and size-based. 

Even if we disable time based major compaction we can hit size-based compactions where your config is disabling time-based compactions.  Minor compactions are issued on a size-based threshold. 

The algorithm sees if sum(file[0:i] * ratio) > file[i+1] and includes file[0:i+1]   if so. 

This is a reverse iteration, so the highest 'i' value is used.  If all files match, then you can remove delete markers [which is the difference between a major and minor compaction].  Major compactions aren't a bad or time-intensive thing, it's just delete marker removal.

Minor compactions will usually pick up a couple of the smaller adjacent StoreFiles and rewrite them as one. Minors do not drop deletes or expired cells, only major compactions do this.

Now that you have read what major and minor compaction is , optimizing the above parameters based on cluster profile is necessary which we would see in other post.   

Happy Hadooping :)

How HBase minor compaction works

Compaction is the process in which HBase combines small files (HStoreFiles) into bigger ones.

Its of two types

Minor : When it take FEW number of files which are placed together and make them one.

Major : When it takes all the files in region and make them one.

This post covers the minor compaction.

If you want to read about major compaction , please read other post. How HBase major compaction works . I suggest you to read minor compaction first.

Lets see what decides the term FEW in minor compaction

The following properties effect minor compaction

 

hbase.hstore.compaction.min Minimum number of StoreFiles per Store to be selected for a compaction to occur (default 2).
hbase.hstore.compaction.max Maximum number of StoreFiles to compact per minor compaction (default 10).
hbase.hstore.compaction.min.size Any StoreFile smaller than this setting with automatically be a candidate for compaction.
hbase.hstore.compaction.max.size Any StoreFile larger than this setting with automatically be excluded from compaction
hbase.store.compaction.ratio Ratio used in compaction file selection algorithm

 

The file which would be used for minor compaction is decided based on following logic

Note the size of file

selects a file for compaction when the file size <= sum(smaller_files_size) * hbase.hstore.compaction.ratio.

Quoting example from official book

 

Consider following configuration settings

    hbase.store.compaction.ratio = 1.0f
    hbase.hstore.compaction.min = 3 (files)
    hbase.hstore.compaction.max = 5 (files)
    hbase.hstore.compaction.min.size = 10 (bytes)
    hbase.hstore.compaction.max.size = 1000 (bytes)

The following StoreFiles exist: 100, 50, 23, 12, and 12 bytes apiece (oldest to newest). With the above parameters, the files that would be selected for minor compaction are 23, 12, and 12.

Why?

Remember the logic

selects a file for compaction when the file size <= sum(smaller_files_size) * hbase.hstore.compaction.ratio.

    100 --> No, because sum(50, 23, 12, 12) * 1.0 = 97.
    50 --> No, because sum(23, 12, 12) * 1.0 = 47.
    23 --> Yes, because sum(12, 12) * 1.0 = 24.
    12 --> Yes, because the previous file has been included, and because this does not exceed the the max-file limit of 5
    12 --> Yes, because the previous file had been included, and because this does not exceed the the max-file limit of 5.

Hope this helps in understanding HBase minor compaction

Hadoop Hadooping :)

HBase Default Configuration list

HBase Default Configuration list

The page below explains the default property files of HBase , what are there purpose.

The documentation says its build from source , so it should be always latest.

http://hbase.apache.org/book/config.files.html

I know you are source control guy , always want to see trunk data.

So here is that direct link

http://svn.apache.org/repos/asf/hbase/trunk/hbase-common/src/main/resources/hbase-default.xml

Oozie data load assurance

While using Oozie workflows to import data to Cluster for load assurance we should make sure that workflow is importing data to cluster regularly.

For File based loads

After each workflow run use

boolean fs:dirSize(String path)

To see that workflow has imported something or not ?

If not shoot an email using Email action and logging them.

For Sqoop based loads

Since Sqoop based loads don't support counters yet ( Oozie 3.2)

See OOZIE-1012 Sqoop jobs are unable to utilize Hadoop Counters

Use the following to find if something new has been created or not

Get list of all files in Sqoop import directory. Check for the files with creation stamp greater than start of oozie job. And then see its size

Corresponding methods are

FileStatus stat = fileSys.getFileStatus(file1);
long ctime1 = stat.getCreationTime();

You can also count number of records imported and match with source using sqoop eval

If Sqoop job is importing files to new directory every time then using simple logic like dirSize is also enough.

Further logging them to some central database for tracking daily loads :)

------

Was it helpful ? You know better way ?

Share your thoughts below in comments , Thanks for reading

Import Hadoop Code to Eclipse

Setting up eclipse for Hadoop development is bit time consuming with no clear instructions available online

Just trying to share what i know :)

You should do it on some Linux machine ideally. I used Windows just to show the steps (PS : Ubuntu i still love you )

Also read the Building.txt in the source code to know more about what all you need to build.

Here we go :)

Download m2e plugin in eclipse

Download m2e subversive connector

You should also have

SVN kit 1.3.5

Native Java HL 1.6

While this import is being done if eclipse asks you to allow him to download something , let him :) , Keep eclipse happy :)

Open Eclipse

Click Import

Maven > Import existing project from SVN

image

 

Select SCM type as SVN from drop menu ( If you don't have this then you need to install connector as told above)

URL as

http://svn.apache.org/repos/asf/hadoop/common/trunk/

 

image

Click next

Choose destination directory ( Optional )

Hit the import button and relax for some time :)

After some time you would see this

image

 

Click Next

 

image

Done

After this eclipse will take some time to build your workspace , resolve dependencies all that magical maven stuff :) The guy who wrote maven was wonderful :)

A long list of Hadoop projects will get fit into Eclipse project list on left :)

Do a quick refresh , That’s it you are ready to play with Hadoop code.

From time to time do a update of the project so that you are always updated with line of fire Trunk code :)  and know what those awesome people in apache are doing.

Was it helpful ? You know better way ?

Share your thoughts below in comments , Thanks for reading

There are 2 problems at this moment , but right now i don't have time to check them. Just writing them for my reference

1) Some build issues and Java compatibility.

2) Code is not showing up as java packages but as folders

Update on Issues above , This problem is that eclipse is not able to detect that particular project as Java project. I saw the issue with pom.xml artifact jdk.tools:jdk.tools:jar:1.6 is missing. So fixing this should resolve , so both 1) and 2) are related  :)

Ubuntu repository no address associated with hostname

While I setup this new machine I often got error while doing update

no address associated with hostname

Workaround

System Settings >Network > Wired> Options > IP 4 Settings

Choose Method
Automatic DHCP address only
DNS servers 8.8.8.8

We are using Google DNS server :)

You can read more about this message here
http://ubuntuforums.org/showthread.php?t=1475399&page=2